Skip to content
Snippets Groups Projects
Commit 51d8218b authored by ac 20's avatar ac 20
Browse files

perftune segReduce use bwconncomp

parent 326e6d7e
Branches
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ end
override=fscanf(fid,'%s');
fclose(fid);
override=strrep(override,'\','\\');
override=jsondecode(override);
leverFile=fullfile(override.ROOT,[CONSTANTS.imageData.DatasetName '.h5']);
if exist(leverFile,'file')
......
......@@ -19,24 +19,19 @@ nIter=100; %10*max(min_radius_pixels);
for nDilate=1:nIter
bwKernels=bwOut&~bwLog;
bwKernels=bwareaopen(bwKernels,minKernelArea);
% if isempty(find(bwKernels, 1))
% break;
% end
%
L=bwlabeln(bwKernels);
workingL=bwlabeln(bwOut);
CC=bwconncomp(bwOut);
workingL=double(labelmatrix(CC));
% 3 things can happen: (0) CC s (1) CC disappears (2) CC splits
idxWL=find(workingL);
idxWL=vertcat(CC.PixelIdxList{:});
map=unique([workingL(idxWL),L(idxWL)],'rows');
map(map(:,2)==0,:)=[];
% h=histogram(map(:,1),[0.5:max(map(:,1))+0.5]);
% mapCounts=h.Values;
mapCounts=hist(map(:,1),[1:max(map(:,1))])';
idxChange=find(mapCounts>1);
for i=1:length(idxChange)
% copy over new objects to bwOut
idxMap=find(map(:,1)==idxChange(i),1,'first');
idx=find(workingL==map(idxMap,1));
idx=CC.PixelIdxList{map(idxMap,1)};
bwOut(idx)=logical(L(idx));
end
......@@ -47,14 +42,9 @@ for nDilate=1:nIter
bwLog=imdilate(bwLog,se);
end
4;
function bwReduce=phaseReduce(bw,bwLog,min_radius_pixels)
% min_radius_pixels=min_radius_pixels(1);
% se=strel('disk',ceil(min_radius_pixels/2));
% bwLogHoles=imclose(bwLog,se);
bwLogHoles=bwLog;
bwLogHoles=imfill(bwLogHoles,'holes')&~bwLogHoles;
bwReduce=bw&bwLogHoles;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment