資源簡(jiǎn)介
KSVD OMP處理圖像的程序,有效果演示
代碼片段和文件信息
function?I?=?displayDictionaryElementsAsImage(D?numRows?numColsXYsortVarFlag)
%?function?I?=?displayDictionaryElementsAsImage(D?numRows?numCols?XY)
%?displays?the?dictionary?atoms?as?blocks.?For?activation?the?dictionary?D
%?should?be?given?as?also?the?number?of?rows?(numRows)?and?columns
%?(numCols)?for?the?atoms?to?be?displayed.?X?and?Y?are?the?dimensions?of
%?each?atom.
borderSize?=?1;
columnScanFlag?=?1;
strechEachVecFlag?=?1;
showImFlag?=?1;
if?(length(who(‘X‘))==0)
????X?=?8;
????Y?=?8;
end
if?(length(who(‘sortVarFlag‘))==0)
????sortVarFlag?=?1;
end
numElems?=?size(D2);
if?(length(who(‘numRows‘))==0)
????numRows?=?floor(sqrt(numElems));
????numCols?=?numRows;
end
if?(length(who(‘strechEachVecFlag‘))==0)?
????strechEachVecFlag?=?0;
end
if?(length(who(‘showImFlag‘))==0)?
????showImFlag?=?1;
end
%%%?sort?the?elements?if?necessary.
%%%?construct?the?image?to?display?(I)
sizeForEachImage?=?sqrt(size(D1))+borderSize;
I?=?zeros(sizeForEachImage*numRows+borderSizesizeForEachImage*numCols+borderSize3);
%%%?fill?all?this?image?in?blue
I(::1)?=?0;%min(min(D));
I(::2)?=?0;?%min(min(D));
I(::3)?=?1;?%max(max(D));
%%%?now?fill?the?image?squares?with?the?elements?(in?row?scan?or?column
%%%?scan).
if?(strechEachVecFlag)
????for?counter?=?1:size(D2)
????????D(:counter)?=?D(:counter)-min(D(:counter));
????????if?(max(D(:counter)))
????????????D(:counter)?=?D(:counter)./max(D(:counter));
????????end
????end
end
if?(sortVarFlag)
????vars?=?var(D);
????[Vindices]?=?sort(vars‘);
????indices?=?fliplr(indices);
????D?=?[D(:1:sortVarFlag-1)D(:indices+sortVarFlag-1)];
????signs?=?sign(D(1:));
????signs(find(signs==0))?=?1;
????D?=?D.*repmat(signssize(D1)1);
????D?=?D(:1:numRows*numCols);
end
counter=1;
for?j?=?1:numRows
????for?i?=?1:numCols
%?????????if?(strechEachVecFlag)
%?????????????D(:counter)?=?D(:counter)-min(D(:counter));
%?????????????D(:counter)?=?D(:counter)./max(D(:counter));
%?????????end
%?????????if?(columnScanFlag==1)
%?????????????I(borderSize+(i-1)*sizeForEachImage+1:i*sizeForEachImageborderSize+(j-1)*sizeForEachImage+1:j*sizeForEachImage1)=reshape(D(:counter)88);
%?????????????I(borderSize+(i-1)*sizeForEachImage+1:i*sizeForEachImageborderSize+(j-1)*sizeForEachImage+1:j*sizeForEachImage2)=reshape(D(:counter)88);
%?????????????I(borderSize+(i-1)*sizeForEachImage+1:i*sizeForEachImageborderSize+(j-1)*sizeForEachImage+1:j*sizeForEachImage3)=reshape(D(:counter)88);
%?????????else
????????????%?Go?in?Column?Scan:
????????????I(borderSize+(j-1)*sizeForEachImage+1:j*sizeForEachImageborderSize+(i-1)*sizeForEachImage+1:i*sizeForEachImage1)=reshape(D(:counter)XY);
????????????I(borderSize+(j-1)*sizeForEachImage+1:j*sizeForEachImageborderSize+(i-1)*sizeForEachImage+1:i*sizeForEachImage2)=reshape(D(:counter)XY);
????????????I(borderSize+(j-1)*sizeForEachImage+1:j*sizeForEachImageborderSize+(i-1)*sizeFor
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????194172??2014-06-04?15:02??KSVD-OMP\Dictionary_peppers_sample5.mat
?????文件???????3224??2007-01-25?08:39??KSVD-OMP\displayDictionaryElementsAsImage.m
?????文件???????1357??2014-05-28?19:53??KSVD-OMP\KSVD.m
?????文件????????954??2014-05-22?00:00??KSVD-OMP\OMP.m
?????文件???????1083??2006-12-11?15:08??KSVD-OMP\OMPerr.m
?????目錄??????????0??2014-06-08?16:49??KSVD-OMP
?????文件?????185727??2014-06-02?21:26??KSVD-OMP\picturesample\barbara.png
?????文件??????34985??2014-06-03?10:20??KSVD-OMP\picturesample\house.png
?????文件?????719641??2014-05-12?23:44??KSVD-OMP\picturesample\lena.jpg
?????文件??????40181??2014-06-03?10:10??KSVD-OMP\picturesample\peppers256.png
?????目錄??????????0??2014-06-03?20:04??KSVD-OMP\picturesample
-----------?---------??----------?-----??----
??????????????1181324????????????????????11
評(píng)論
共有 條評(píng)論