Skip to content
Snippets Groups Projects
Commit b6d4aea0 authored by actb's avatar actb
Browse files

aiAreaOpen

parent 8b7c8e45
No related branches found
No related tags found
No related merge requests found
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;
bw=bwareaopen(bw,area);
return;
end
maskRadius=0.5*min_radius_pixels;
maskRadius=max(maskRadius,[1,1,1]);
ee=HIP.MakeEllipsoidMask(maskRadius);
bwSeeds=imerode(bw,ee);
bw=imreconstruct(bwSeeds,bw);
...@@ -88,7 +88,7 @@ end ...@@ -88,7 +88,7 @@ end
% of those pixels will be discarded in resolving the underlying cells. % of those pixels will be discarded in resolving the underlying cells.
% allocateShake (below) assigns each discarded pixel to it's closest % allocateShake (below) assigns each discarded pixel to it's closest
% touching segmentation using a morphological region fill % touching segmentation using a morphological region fill
bw=bwareaopen(bw,min_area_pixels); bw=Segment.aiAreaOpen(bw,min_radius_pixels);
bw2=bw; bw2=bw;
bPhaseReduce=segParams.isPhase || segParams.bCytoplasmic; bPhaseReduce=segParams.isPhase || segParams.bCytoplasmic;
% if prod(size(im))>1e9 % if prod(size(im))>1e9
......
...@@ -6,7 +6,6 @@ if bPhaseReduce ...@@ -6,7 +6,6 @@ if bPhaseReduce
return; return;
end end
minKernelArea=ceil(0.25*min_area_pixels); %
if is3D(bw) if is3D(bw)
se=strel('sphere',1); se=strel('sphere',1);
else else
...@@ -14,11 +13,11 @@ else ...@@ -14,11 +13,11 @@ else
end end
% %
bwOut=bw; bwOut=bw;
nIter=100; %10*max(min_radius_pixels); nIter=100; %10*max(min_radius_pixels);
for nDilate=1:nIter for nDilate=1:nIter
bwKernels=bwOut&~bwLog; bwKernels=bwOut&~bwLog;
bwKernels=bwareaopen(bwKernels,minKernelArea); bwKernels=Segment.aiAreaOpen(bwKernels,0.5*min_radius_pixels);
L=bwlabeln(bwKernels); L=bwlabeln(bwKernels);
CC=bwconncomp(bwOut); CC=bwconncomp(bwOut);
workingL=double(labelmatrix(CC)); workingL=double(labelmatrix(CC));
......
...@@ -14,10 +14,10 @@ end ...@@ -14,10 +14,10 @@ end
if sensitivity>1 && round(sensitivity)==sensitivity if sensitivity>1 && round(sensitivity)==sensitivity
lm=multithresh(imLog,sensitivity) lm=multithresh(imLog,sensitivity)
bwLog=logical(imLog>lm(end)); bwLog=logical(imLog>lm(end));
bwLog=bwareaopen(bwLog,4*min_area_pixels); bwLog=Segment.aiAreaOpen(bwLog,2*min_radius_pixels);
lm=multithresh(im,sensitivity) lm=multithresh(im,sensitivity)
bw=logical(im>lm(end)); bw=logical(im>lm(end));
bw=bwareaopen(bw,min_area_pixels); bw=Segment.aiAreaOpen(bw,min_radius_pixels);
return; return;
end end
...@@ -25,12 +25,12 @@ if is3D(im) ...@@ -25,12 +25,12 @@ if is3D(im)
nsz=2*floor(size(im)/16)+1; nsz=2*floor(size(im)/16)+1;
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian'); T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T); bwLog=imbinarize(imLog,T);
bwLog=bwareaopen(bwLog,4*min_area_pixels); bwLog=Segment.aiAreaOpen(bwLog,2*min_radius_pixels);
nsz=4*floor(size(im)/16)+1; nsz=4*floor(size(im)/16)+1;
T=adaptthresh(im,sensitivity,'NeighborhoodSize',nsz,'statistic','gaussian'); T=adaptthresh(im,sensitivity,'NeighborhoodSize',nsz,'statistic','gaussian');
bw=imbinarize(im,T); bw=imbinarize(im,T);
bw=bwareaopen(bw,min_area_pixels); bw=Segment.aiAreaOpen(bw,min_radius_pixels);
return; return;
end end
...@@ -38,7 +38,7 @@ end ...@@ -38,7 +38,7 @@ end
nsz=4*floor(size(im)/16)+1; nsz=4*floor(size(im)/16)+1;
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian'); T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T); bwLog=imbinarize(imLog,T);
bwLog=bwareaopen(bwLog,4*min_area_pixels); bwLog=Segment.aiAreaOpen(bwLog,2*min_radius_pixels);
if segParams.isPhase if segParams.isPhase
[bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,... [bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
...@@ -49,7 +49,7 @@ else ...@@ -49,7 +49,7 @@ else
T=adaptthresh(im,sensitivity,'NeighborhoodSize',4*floor(size(im)/16)+1,'statistic','gaussian'); T=adaptthresh(im,sensitivity,'NeighborhoodSize',4*floor(size(im)/16)+1,'statistic','gaussian');
bw=imbinarize(im,T); bw=imbinarize(im,T);
end end
bw=bwareaopen(bw,min_area_pixels); bw=Segment.aiAreaOpen(bw,min_radius_pixels);
4; 4;
function [bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,... function [bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment