資源簡介
顯著性檢測代碼,顯著性檢測效果不錯
代碼片段和文件信息
function?Saliency_Absorb_MC
%%
clear;?????tic;
addpath(?‘./SubCode/‘?);
Salmap?=?‘./map/‘;
mkdir(?Salmap?);
imgpath?=?‘./img/‘;
ImgEnum=dir([imgpath?‘*.jpg‘]);???ImgNum=length(ImgEnum);
for?i=?1?:ImgNum
????i
????imname?=?[?imgpath?ImgEnum(i).name?];
????Img?=?double(?imread(?imname?)?);
????[?heightwidth?]?=?size(Img(::1));
????PixNum?=?height*width;????
????ImgVecR?=?reshape(?Img(::1)‘?PixNum?1);
????ImgVecG?=?reshape(?Img(::2)‘?PixNum?1);
????ImgVecB?=?reshape(?Img(::3)‘?PixNum?1);
????%?m?is?the?compactness?parameter?k?is?the?super-pixel?number?in?SLIC?algorithm
????m?=?20;??????k?=?500;??
????ImgAttr=[?height?width?k?m?PixNum?];
????%?obtain?superpixel?from?SLIC?algorithm:?LabelLine?is?the?super-pixel?label?vector?of?the?image
????%?Sup1?Sup2?Sup3?are?the?mean?L?a?b?colour?value?of?each?superpixel
????%??k?is?the?number?of?the?super-pixel.
????[?LabelLine?Sup1?Sup2?Sup3?k?]?=?SLIC(?ImgVecR?ImgVecG?ImgVecB?ImgAttr?);
????Label=reshape(LabelLinewidthheight);
????Label?=?Label‘;?????%?the?superpixle?label
????
????[?ConPix?ConPixDouble?]?=?find_connect_superpixel_DoubleIn_Opposite(?Label?k?height?width?);
????%?count?the?number?of?the?edge?in?the?graph?
????NumInit=0;
????for?j=1:k
????????for?z=j+1:k
????????????if?ConPixDouble(jz)>0
????????????????NumInit=NumInit+1;
????????????end
????????end
????end
????Dcol=zeros(NumInit3);
????%?calculate?the?edge?weight
????mm=1;
????for?j=1:k-1
????????for?z=j+1:k
????????????if?ConPixDouble(jz)>0
????????????????DcolTem?=?sqrt(?(?Sup1(j)-Sup1(z)?).^2?+?(?Sup2(j)-Sup2(z)?).^2?+?(?Sup3(j)-?Sup3(z)?).^2?);
????????????????Dcol(mm?1:?3?)=[jzDcolTem?];
????????????????mm=mm+1;
????????????end
????????end
????end
????
????DcolNor?=?normalize(?Dcol(:3)?);
????weight?=?exp(?-10*DcolNor?)?+?.00001;
????WconFirst?=?sparse(?[Dcol(:1);Dcol(:2)]?[Dcol(:2);Dcol(:1)]?[weightweight]k?k?);
????WconFirst?=?full(WconFirst?)??+?eye(k);???%?the?affinity?matrix?of?the?graph?model
????
????Discard?=?sum(WconFirst2);
????DiscardPos?=?find(?Discard?1.1?);????%?to?discard?the?outlier
????LenDiscardPos?=?length(DiscardPos);
????
????EdgSup?=?Find_Edge_Superpixels(?Label?k??height?width??WconFirst?ConPix?);????
????for?j=1:LenDiscardPos
????????EdgSup(?DiscardPos(j)?)?=?2;
????end
????
????NumIn?=?k?-?length(?find(?EdgSup?==?2?)?);????
????NumEdg?=?length(?find(?EdgSup==1?)?);
????EdgWcon?=?zeros(?k?NumEdg?);
????mm=1;
????for?j=1:k
????????if?EdgSup(j)==1
????????????EdgWcon(:mm)?=?WconFirst(:j);
????????????mm?=?mm?+?1;
????????end
????end
????alph?=?1;??W=zeros(kk);
????%%%%%%%%%%%%?absorb?MC
????if?NumIn?==?k
????????baseEdg?=?sum(?EdgWcon?2?)?;
????????D?=?diag(?Discard?+?baseEdg?);
????????Wcon?=??D?\?WconFirst;
????????I?=?eye(?NumIn?);
????????N?=?(?I?-?alph*?Wcon??);
????????y?=?ones(?NumIn?1?);
????????Sal?=?N?\?y;
????????Sal?=?normalize(Sal);
????else
????????baseEdg
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????15742??2007-06-13?17:00??code_absorb_MC\img\0_1_1339.jpg
?????文件??????42274??2007-06-13?17:00??code_absorb_MC\img\0_1_1427.jpg
?????文件??????22666??2014-04-25?16:58??code_absorb_MC\img\1.jpg
?????文件??????22771??2014-04-25?16:58??code_absorb_MC\img\2.jpg
????..A.SH.?????19968??2014-07-28?08:53??code_absorb_MC\img\Thumbs.db
?????文件???????9363??2014-07-28?08:57??code_absorb_MC\map\0_1_1339.png
?????文件??????18407??2014-07-28?08:57??code_absorb_MC\map\0_1_1427.png
?????文件??????10337??2014-07-28?08:57??code_absorb_MC\map\1.png
?????文件??????10679??2014-07-28?08:57??code_absorb_MC\map\2.png
????..A.SH.?????13824??2014-07-28?08:57??code_absorb_MC\map\Thumbs.db
?????文件???????1346??2013-10-02?12:01??code_absorb_MC\read_me.txt
?????文件???????6879??2014-07-28?08:56??code_absorb_MC\Saliency_Absorb_MC.m
?????文件???????2333??2013-10-02?10:32??code_absorb_MC\SubCode\find_connect_superpixel_DoubleIn_Opposite.m
?????文件???????1376??2013-10-02?10:40??code_absorb_MC\SubCode\Find_Edge_Superpixels.m
?????文件???????2368??2013-10-02?11:40??code_absorb_MC\SubCode\normalize.m
?????文件??????32892??2013-04-05?18:32??code_absorb_MC\SubCode\SLIC.cpp
?????文件??????20480??2013-04-05?18:32??code_absorb_MC\SubCode\SLIC.mexw32
?????文件??????32768??2013-04-06?11:48??code_absorb_MC\SubCode\SLIC.mexw64
?????文件????????568??2013-04-05?20:06??code_absorb_MC\SubCode\sup2pixel.cpp
?????文件???????7680??2013-04-05?20:17??code_absorb_MC\SubCode\sup2pixel.mexw32
?????文件???????7168??2013-04-06?11:48??code_absorb_MC\SubCode\sup2pixel.mexw64
?????目錄??????????0??2014-07-28?08:53??code_absorb_MC\img
?????目錄??????????0??2014-07-28?08:57??code_absorb_MC\map
?????目錄??????????0??2014-07-27?10:08??code_absorb_MC\SubCode
?????目錄??????????0??2014-07-28?08:52??code_absorb_MC
-----------?---------??----------?-----??----
???????????????301889????????????????????25
評論
共有 條評論