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

reworked thresholdImages

parent 6d9ba833
Branches
No related tags found
No related merge requests found
...@@ -12,7 +12,6 @@ else ...@@ -12,7 +12,6 @@ else
end end
if is3D(im) 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);
...@@ -32,6 +31,19 @@ bwLog=imbinarize(imLog,T); ...@@ -32,6 +31,19 @@ bwLog=imbinarize(imLog,T);
bwLog=bwareaopen(bwLog,4*min_area_pixels); bwLog=bwareaopen(bwLog,4*min_area_pixels);
if segParams.isPhase 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
bw=bwareaopen(bw,min_area_pixels);
4;
function [bw,bwLog]=phaseThreshold(im,bwLog,min_radius_pixels,segParams,...
sensitivity,medianMask)
se=strel('disk',1); se=strel('disk',1);
se2=strel('disk',ceil(min_radius_pixels/2)); se2=strel('disk',ceil(min_radius_pixels/2));
if segParams.isPhase>0 if segParams.isPhase>0
...@@ -46,6 +58,11 @@ if segParams.isPhase ...@@ -46,6 +58,11 @@ if segParams.isPhase
bw=imclose(bw,se2); bw=imclose(bw,se2);
bw=imfill(bw,'holes'); bw=imfill(bw,'holes');
if true==segParams.wellRadius if true==segParams.wellRadius
[bw,bwLog]=thesholdMask(medianMask,bw,bwLog,se,se2);
end
function [bw,bwLog]=thesholdMask(medianMask,bw,bwLog,se,se2)
bwMask=imbinarize(medianMask,adaptthresh(medianMask,'statistic','gaussian')); bwMask=imbinarize(medianMask,adaptthresh(medianMask,'statistic','gaussian'));
bw=bw&~bwMask; bw=bw&~bwMask;
bwh=imfill(bw,'holes'); bwh=imfill(bw,'holes');
...@@ -61,15 +78,7 @@ if segParams.isPhase ...@@ -61,15 +78,7 @@ if segParams.isPhase
bw=imopen(bw,se); bw=imopen(bw,se);
bwLog=bwLog&~bwMask; bwLog=bwLog&~bwMask;
bwLog=imclose(bwLog,se2); bwLog=imclose(bwLog,se2);
end
bw=imfill(bw,'holes');
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
bw=bwareaopen(bw,min_area_pixels);
4;
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment