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

updated threshold and segreduce for phase

parent 73e8d894
Branches
No related tags found
No related merge requests found
......@@ -51,6 +51,8 @@ function bwReduce=phaseReduce(bw,bwLog,min_radius_pixels)
bwLogHoles=bwLog;
bwLogHoles=imfill(bwLogHoles,'holes')&~bwLogHoles;
bwReduce=bw&bwLogHoles;
bwReduce=imfill(bwReduce,'holes');
bwReduce=Segment.aiAreaOpen(bwReduce,min_radius_pixels);
[L,num]=bwlabeln(bw);
for n=1:num
idx=find(L==n);
......
......@@ -21,17 +21,14 @@ if sensitivity>1 && round(sensitivity)==sensitivity
return;
end
if segParams.isPhase
[bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
sensitivity,medianMask);
return;
end
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);
else
if is3D(im)
% lower density (generally?) use smaller radius
nsz=2*floor(size(im)/16)+1;
......@@ -40,13 +37,17 @@ else
end
T=adaptthresh(im,sensitivity,'NeighborhoodSize',nsz,'statistic','gaussian');
bw=imbinarize(im,T);
end
bwLog=Segment.aiAreaOpen(bwLog,2*min_radius_pixels);
bw=Segment.aiAreaOpen(bw,min_radius_pixels);
4;
function [bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
sensitivity,medianMask)
se=strel('disk',1);
se2=strel('disk',ceil(min_radius_pixels/2));
rClose=max(1,ceil(min_radius_pixels/2));
se2=strel('disk',rClose);
if segParams.isPhase>0
T=adaptthresh(im,sensitivity,'foregroundpolarity','dark','statistic','gaussian');
else
......@@ -56,15 +57,24 @@ bw=imbinarize(im,T);
if segParams.isPhase>0
bw=imcomplement(bw);
end
bw=imclose(bw,se2);
bw=imfill(bw,'holes');
if true==segParams.wellRadius
[bw,bwLog]=thesholdMask(medianMask,bw,bwLog,se,se2);
[bw,bwLog]=thresholdMask(medianMask,bw,bwLog,se,se2);
end
% fill in holes
bwh=imclose(bw,se2);
bwh=imfill(bwh,'holes')&~bwh;
bw=bw|bwh;
bw=imfill(bw,'holes');
function [bw,bwLog]=thresholdMask(medianMask,bw,bwLog,se,se2)
imf=stdfilt(medianMask,true(5));
bwMask=imbinarize(imf);
bwMask=imclose(bwMask,true(10));
bwMask=imopen(bwMask,true(5));
function [bw,bwLog]=thesholdMask(medianMask,bw,bwLog,se,se2)
bwMask=imbinarize(medianMask,adaptthresh(medianMask,'statistic','gaussian'));
bw=bw&~bwMask;
bwh=imfill(bw,'holes');
nrep=0;
......@@ -78,7 +88,6 @@ end
bw=imfill(bw,'holes');
bw=imopen(bw,se);
bwLog=bwLog&~bwMask;
bwLog=imclose(bwLog,se2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment