⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 estimateshape.html

📁 显著区域检测。求的图像中感兴趣区域的位置
💻 HTML
📖 第 1 页 / 共 2 页
字号:
0065 0066 <span class="comment">% need to go deeper into the maps?</span>0067 <span class="keyword">if</span> ((mx &gt; 0) &amp; ~strcmp(params.shapeMode,<span class="string">'shapeSM'</span>))0068   0069   <span class="comment">% find the biggest contributing conspicuity map</span>0070   CMidx = CMidx(<a href="randInt.html" class="code" title="function r = randInt(arg,varargin)">randInt</a>(length(CMidx)));0071   tmp = cat(1,saliencyData(CMidx).FM(:));0072   tmp = cat(3,tmp.data);0073   [mx,FMidx] = max(tmp(winner(1),winner(2),:));0074   0075   <span class="comment">% found our winning conspicuity map</span>0076   winMap(end+1) = saliencyData(CMidx).CM;0077   winPos{end+1} = winner;0078   0079   <span class="comment">% need to go deeper?</span>0080   <span class="keyword">if</span> ((mx &gt; 0) &amp; ~strcmp(params.shapeMode,<span class="string">'shapeCM'</span>))0081     0082     <span class="comment">% our next bet are the feature maps that contribute</span>0083     <span class="comment">% to the wining conspicuity map</span>0084     FMidx = FMidx(<a href="randInt.html" class="code" title="function r = randInt(arg,varargin)">randInt</a>(length(FMidx)));0085     winMap(end+1) = saliencyData(CMidx).FM(FMidx);0086     winPos{end+1} = winner;0087     0088     <span class="comment">% need to go deeper still?</span>0089     <span class="keyword">if</span> (strcmp(params.shapeMode,<span class="string">'shapePyr'</span>))0090       0091       <span class="comment">% now we compare the contributing center and surround maps</span>0092       cen = saliencyData(CMidx).csLevels(FMidx).centerLevel;0093       sur = saliencyData(CMidx).csLevels(FMidx).surroundLevel;0094       [pyrIdx,tmp] = ind2sub(size(saliencyData(CMidx).FM),FMidx);0095       cenMap = saliencyData(CMidx).pyr(pyrIdx).levels(cen);0096       surMap = saliencyData(CMidx).pyr(pyrIdx).levels(sur);0097       0098       <span class="comment">% extract the values of the cen and sur maps at the winner location</span>0099       wCM = size(saliencyData(CMidx).CM.data,2);0100       cenWin = round(winner/wCM * size(cenMap.data,2));0101       surWin = round(winner/wCM * size(surMap.data,2));0102       cenWin = max(min(cenWin,size(cenMap.data)),[1 1]);0103       surWin = max(min(surWin,size(surMap.data)),[1 1]);0104       cenVal = cenMap.data(cenWin(1),cenWin(2));0105       surVal = surMap.data(surWin(1),surWin(2));0106       0107       <span class="comment">% compare center and surround and store the winner</span>0108       <span class="keyword">if</span> (abs(cenVal) &gt; abs(surVal) &amp; (min(size(cenMap.data)) &gt; 7))0109         winMap(end+1) = cenMap;0110         winVal = cenVal;0111         winPos{end+1} = cenWin;0112       <span class="keyword">else</span>0113         winMap(end+1) = surMap;0114         winVal = surVal;0115         winPos{end+1} = surWin;0116       <span class="keyword">end</span>0117       0118       <span class="comment">% renormalize the cen or sur map values for better segmentation</span>0119       winMap(end).data = (1 - abs(winMap(end).data - winVal) / winVal).^2;0120     <span class="keyword">end</span>    0121   <span class="keyword">end</span>0122 <span class="keyword">end</span>0123 0124 <span class="comment">% now we have extracted all the maps we need</span>0125 <a href="debugMsg.html" class="code" title="function debugMsg(message,varargin)">debugMsg</a>(winMap(end).label)0126 <a href="debugMsg.html" class="code" title="function debugMsg(message,varargin)">debugMsg</a>(sprintf(<span class="string">'Value at winning location: %g'</span>,<span class="keyword">...</span>0127          winMap(end).data(winPos{end}(1),winPos{end}(2))));0128 gotMap = 0;0129 0130 <span class="comment">% let's see who behaves nicely for segmentation</span>0131 <span class="keyword">for</span> idx = length(winMap):-1:10132   <span class="keyword">switch</span> params.segmentComputeType0133     <span class="keyword">case</span> <span class="string">'Fast'</span>0134       binMap = <a href="fastSegmentMap.html" class="code" title="function resultMap = fastSegmentMap(map,seedPoint,varargin)">fastSegmentMap</a>(winMap(idx),winPos{idx});0135     <span class="keyword">case</span> <span class="string">'LTU'</span>0136       binMap = <a href="LTUsegmentMap.html" class="code" title="function [resultMap,segMaps] = LTUsegmentMap(map,seedPoint,varargin)">LTUsegmentMap</a>(winMap(idx),winPos{idx});0137     <span class="keyword">otherwise</span>0138       <a href="fatal.html" class="code" title="function fatal(message)">fatal</a>([<span class="string">'Unknown segmentComputeType: '</span> params.segmentComputeType]);0139   <span class="keyword">end</span>0140     0141   <span class="comment">% check that we actually segmented something, but not too big (&lt; 10%)</span>0142   areaRatio = sum(binMap.data(:)) / prod(size(binMap.data));0143   <span class="keyword">if</span> ((areaRatio &gt; 0) &amp; (areaRatio &lt; 0.1))0144     0145     <span class="comment">% this guy looks good - let's keep him!</span>0146     shapeData.winningMap = winMap(idx);0147     shapeData.winner = winPos{idx};0148 0149     <span class="comment">% for the IOR mask, we don't want to smooth the shape</span>0150     shapeData.iorMask = binMap;0151     shapeData.iorMask.data = imdilate(shapeData.iorMask.data,strel(<span class="string">'disk'</span>,2));0152     shapeData.iorMask.label = <span class="string">'IOR mask'</span>;0153     0154     <span class="comment">% for the binary map, erode the shape a bit</span>0155     binMap.label = <span class="string">'binary shape map'</span>;0156     se = [[0 0 1 0 0];[0 1 1 1 0];[1 1 1 1 1];[0 1 1 1 0];[0 0 1 0 0]];0157     tmp = imclose(imopen(binMap.data,se),se);0158     newMap = [];0159     <span class="keyword">if</span> (tmp(winPos{idx}(1),winPos{idx}(2)) &gt; 0)0160       <span class="keyword">if</span> (sum(tmp(:)) &gt; 0)0161         newMap = tmp;0162       <span class="keyword">end</span>0163     <span class="keyword">else</span>0164       se = [[0 1 0];[1 1 1];[0 1 0]];0165       tmp = imclose(imopen(binMap.data,se),se);0166       <span class="keyword">if</span> ((tmp(winPos{idx}(1),winPos{idx}(2)) &gt; 0) &amp;&amp; (sum(tmp(:)) &gt; 0))0167         newMap = tmp;0168       <span class="keyword">end</span>0169     <span class="keyword">end</span>0170     <span class="keyword">if</span> ~isempty(newMap)0171       lab = bwlabel(newMap,4);0172       binMap.data = double(lab == lab(winPos{idx}(1),winPos{idx}(2)));0173     <span class="keyword">end</span>0174     shapeData.binaryMap = binMap;0175     gotMap = 1;0176     <span class="keyword">break</span>;0177   <span class="keyword">end</span>0178 <span class="keyword">end</span>0179 0180 <span class="comment">% huh - no success in segmentation? Just return empty then</span>0181 <span class="keyword">if</span> (~gotMap)0182   shapeData = [];0183   <span class="keyword">return</span>;0184 <span class="keyword">end</span>0185 0186 <span class="comment">% Hurray, we have a nicely segmented map - let's compute a few more things</span>0187 0188 <span class="comment">% The segmented map is just winning map * binary map</span>0189 shapeData.segmentedMap.origImage = shapeData.winningMap.origImage;0190 shapeData.segmentedMap.label = <span class="string">'segmented shape map'</span>;0191 shapeData.segmentedMap.data = shapeData.winningMap.data .* shapeData.binaryMap.data;0192 shapeData.segmentedMap.date = <a href="timeString.html" class="code" title="function s = timeString()">timeString</a>;0193 shapeData.segmentedMap.parameters = shapeData.winningMap.parameters;0194 0195 <span class="comment">% The shape map is a smoothed version of the binary map</span>0196 shapeData.shapeMap.origImage = shapeData.winningMap.origImage;0197 shapeData.shapeMap.label = [shapeData.binaryMap.label <span class="string">' - rescaled'</span>];0198 tmp = imresize(shapeData.binaryMap.data,<span class="keyword">...</span>0199                shapeData.shapeMap.origImage.size(1:2),<span class="string">'nearest'</span>);0200 kernel = <a href="gaussian.html" class="code" title="function kernel = gaussian(peak,sigma,maxhw,varargin)">gaussian</a>(0,15,15);0201 tmp = <a href="normalizeImage.html" class="code" title="function res = normalizeImage(img,varargin)">normalizeImage</a>(<a href="sepConv2PreserveEnergy.html" class="code" title="function result = sepConv2PreserveEnergy(filter1,filter2,data)">sepConv2PreserveEnergy</a>(kernel,kernel,tmp),[0,3]);0202 shapeData.shapeMap.data = <a href="clamp.html" class="code" title="function data = clamp(data,bottom,varargin)">clamp</a>(tmp,0,1);0203 0204 shapeData.shapeMap.date = <a href="timeString.html" class="code" title="function s = timeString()">timeString</a>;0205 shapeData.shapeMap.parameters = shapeData.winningMap.parameters;0206 0207 shapeData.date = <a href="timeString.html" class="code" title="function s = timeString()">timeString</a>;</pre></div><hr><address>Generated on Fri 07-Sep-2007 14:42:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -