Commit a75aaa90 authored by ac 20's avatar ac 20

allocateShake: restore size kilt kernels, aiareaOpen speed

parent 003745f0
......@@ -16,4 +16,12 @@ if ~is3D(bw)
end
ee=HIP.MakeEllipsoidMask(maskRadius);
bwSeeds=imerode(bw,ee);
bw=imreconstruct(bwSeeds,bw);
% bw=imreconstruct(bwSeeds,bw);
% faster by 2x compared to imreconstruct...
idx=find(bwSeeds);
cc=bwconncomp(bw);
L=labelmatrix(cc);
idxIntersect=cellfun(@(x) intersect(x,idx),cc.PixelIdxList,'UniformOutput',false);
idxDelete=cellfun(@isempty,idxIntersect);
bw(vertcat(cc.PixelIdxList{idxDelete}))=0;
function [L,num,bwBoundary]=allocateShake(bw,bw2,min_radius_pixels,segParams)
bwBoundary=assignShake(bw,bw2,true);
bwReduce=Segment.aiAreaOpen(bwBoundary,min_radius_pixels);
% any components that were not big enough?
if find(bwBoundary & ~bwReduce,1,'first')
% "re-absorb" components too small to exist on their own
% allow disconnected components in case whole CC was removed
bwBoundary=assignShake(bwReduce,bw2,false);
bwBoundary=Segment.aiAreaOpen(bwBoundary,min_radius_pixels);
end
% now, the boundary has been resent, label that and done
[L,num]=bwlabeln(bwBoundary);
return
function bwBoundary=assignShake(bw,bw2,bNoDisconnected)
d=bwdist(bw);
L=watershed(d);
L(~bw2)=0;
bwBoundary=logical(L); % cell image with boundaries set to 0
% don't allow disconnected components
[LX,nx]=bwlabeln(bwBoundary);
idx=unique(LX(bw));
% the boundary image, remove the connected components not from bw (e.g.
% bw2 only)
bwBoundary=bwBoundary&ismember(LX,idx);
bwBoundary=Segment.aiAreaOpen(bwBoundary,min_radius_pixels);
if bNoDisconnected
[LX,nx]=bwlabeln(bwBoundary);
idx=unique(LX(bw));
% the boundary image, remove the connected components not from bw (e.g.
% bw2 only)
bwBoundary=bwBoundary&ismember(LX,idx);
end
% now, the boundary has been resent, label that and done
[L,num]=bwlabeln(bwBoundary);
return
......@@ -24,6 +24,13 @@ for i=1:length(names)
segParams=setfield(segParams,names{i},fv);
end
end
% convert to row vectors for easier readability
if isfield(segParams,'minimumRadius_um')
segParams.minimumRadius_um=segParams.minimumRadius_um(:)';
end
if isfield(segParams,'NLM')
segParams.NLM=segParams.NLM(:)';
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment