Commit 0da7f3ab authored by actb's avatar actb

msLoG, rd use aiAreaOpen

parent b660343f
function bw=aiAreaOpen(bw,min_radius_pixels)
if ~is3D(bw)
% 2d - use pi*r^2 approximation
radius=min_radius_pixels(1);
area = radius^2 * pi;
area=round(area);
bw=bwareaopen(bw,area);
return;
end
% if ~is3D(bw)
% % 2d - use pi*r^2 approximation
% radius=min_radius_pixels(1);
% area = radius^2 * pi;
% area=round(area);
% bw=bwareaopen(bw,area);
% return;
% end
maskRadius=0.5*min_radius_pixels;
maskRadius=max(maskRadius,[1,1,1]);
if ~is3D(bw)
maskRadius(3)=0;
end
ee=HIP.MakeEllipsoidMask(maskRadius);
bwSeeds=imerode(bw,ee);
bw=imreconstruct(bwSeeds,bw);
......@@ -10,6 +10,8 @@ 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(bw,min_radius_pixels);
% now, the boundary has been resent, label that and done
[L,num]=bwlabeln(bwBoundary);
return
......@@ -119,17 +119,6 @@ else
rp=[];
end
d=bwdist(~logical(L));
area_min=2*min_area_pixels;
if segParams.isPhase
dmin=min(min_radius_pixels)*1.5;
elseif segParams.bCytoplasmic
dmin=min(min_radius_pixels)/4;
area_min=min_area_pixels/2;
else
dmin=0.75*min(min_radius_pixels);
end
% final CC pass
if ~is3D(im)
bounds=bwboundaries(bwBoundary,'noholes');
......@@ -140,9 +129,6 @@ end
CC=bwconncomp(L);
for n=1:num
idx=CC.PixelIdxList{n};
if length(idx)<area_min && max(d(idx))<dmin
continue
end
if is3D(im)
newCell=Segment.frameSegment_create_3D(idx,size(bw),chan,t);
else
......
......@@ -30,8 +30,7 @@ if is3D(im)
return
end
if USE_CUDA
logRadius=min_radius_pixels.*(1/sqrt(3));
imLog=HIP.LoG(im,logRadius,[]);
imLog=msLog(im,min_radius_pixels);
else
% use difference of gaussian approximation
logRadius=min_radius_pixels;
......@@ -42,10 +41,7 @@ if is3D(im)
else
% 2D
if USE_CUDA
logRadius=(1/sqrt(2)).*min_radius_pixels;
logRadius(2)=logRadius(1);
logRadius(3)=0;
imLog=HIP.LoG(im,logRadius,[]);
imLog=msLog(im,[min_radius_pixels(1:2),0]);
else
if length(min_radius_pixels)>1
logRadius=0.5*min(min_radius_pixels(1:2));
......@@ -118,3 +114,25 @@ if length(size(im))==3
else
b3D=false;
end
function imLog=msLog(im,min_radius_pixels)
logScale=[0.25:0.25:2];
imLogCombined=[];
if length(min_radius_pixels)==3 && min_radius_pixels(3)>0
% 3d
logRadius=((1/sqrt(3)).*min_radius_pixels);
nDim=4;
else
% 2d
logRadius=((1/sqrt(2)).*min_radius_pixels);
nDim=3;
end
for i=1:length(logScale)
lrad=logScale(i).*logRadius;
imf=HIP.LoG(im,lrad,[]);
imLogCombined=cat(nDim,imLogCombined,imf);
end
imLog=max(imLogCombined,[],nDim);
4;
\ No newline at end of file
......@@ -34,21 +34,21 @@ if is3D(im)
return;
end
% else (not 3d)
nsz=4*floor(size(im)/16)+1;
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T);
bwLog=Segment.aiAreaOpen(bwLog,2*min_radius_pixels);
if segParams.isPhase
[bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
sensitivity,medianMask);
return;
else
% use 2x the default nhood size
T=adaptthresh(im,sensitivity,'NeighborhoodSize',4*floor(size(im)/16)+1,'statistic','gaussian');
bw=imbinarize(im,T);
end
% else (not 3d)
nsz=4*floor(size(im)/16)+1;
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T);
bwLog=Segment.aiAreaOpen(bwLog,min_radius_pixels);
% use 2x the default nhood size
T=adaptthresh(im,sensitivity,'NeighborhoodSize',4*floor(size(im)/16)+1,'statistic','gaussian');
bw=imbinarize(im,T);
bw=Segment.aiAreaOpen(bw,min_radius_pixels);
4;
......
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