Commit 8fbffa76 authored by actb's avatar actb

segReduce use foregound voxels instead of holes

parent a2abd217
......@@ -19,6 +19,7 @@ if isempty(im)
imLog=[];
return
end
imRaw=im;
im=denoise(im,segParams);
if 1==nargout
return
......@@ -31,12 +32,12 @@ if is3D(im)
end
if USE_CUDA
logRadius=min_radius_pixels.*(1/sqrt(3));
imLog=HIP.LoG(im,logRadius,[]);
imLog=HIP.LoG(imRaw,logRadius,[]);
else
% use difference of gaussian approximation
logRadius=min_radius_pixels;
imd1=imgaussfilt3(im,sqrt(2).*logRadius);
imd2=imgaussfilt3(im,logRadius./sqrt(2));
imd1=imgaussfilt3(imRaw,sqrt(2).*logRadius);
imd2=imgaussfilt3(imRaw,logRadius./sqrt(2));
imLog=imd1-imd2;
end
else
......@@ -45,16 +46,16 @@ else
logRadius=(1/sqrt(2)).*min_radius_pixels;
logRadius(2)=logRadius(1);
logRadius(3)=0;
imLog=HIP.LoG(im,logRadius,[]);
imLog=HIP.LoG(imRaw,logRadius,[]);
else
if length(min_radius_pixels)>1
logRadius=0.5*min(min_radius_pixels(1:2));
else
logRadius=0.5*min_radius_pixels ;
end
szFilter=round(size(im)/3);
szFilter=round(size(imRaw)/3);
h=fspecial('log',szFilter,logRadius);
imLog=imfilter(im,h,'replicate');
imLog=imfilter(imRaw,h,'replicate');
end
end
......
......@@ -20,13 +20,12 @@ else
end
for nDilate=1:2*min_radius_pixels
kernels=imfill(bwDilate,'holes')&~bwDilate;
kernels=kernels&bw;
kernels=bwareaopen(kernels,minKernelArea);
if isempty(find(kernels, 1))
bwKernels=bw&~bwDilate;
bwKernels=bwareaopen(bwKernels,minKernelArea);
if isempty(find(bwKernels, 1))
break;
end
L=bwlabeln(kernels);
L=bwlabeln(bwKernels);
qL=cat(nDimension+1,qL,L);
bwDilate=imdilate(bwDilate,se);
end
......
......@@ -4,15 +4,15 @@ function [bw,bwLog]=thresholdImagess(im,imLog,segParams, min_radius_pixels,min_a
imLog(imLog<0)=0;
imLog=mat2gray(imLog);
T=adaptthresh(imLog,0.5,'statistic','gaussian');
nsz=4*floor(size(im)/16)+1;
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T);
bwLog=bwareaopen(bwLog,4*min_area_pixels);
if is3D(im)
nsz=4*floor(size(im)/16)+1;
% nsz(3)=nsz(1);
T=adaptthresh(im,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
nsz=2*floor(size(im)/16)+1;
T=adaptthresh(im,0.4,'NeighborhoodSize',nsz,'statistic','gaussian');
bw=imbinarize(im,T);
return;
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