Commit cf18acf8 authored by ac32's avatar ac32

Merge branch 'fsIntensity' of git-bioimage.coe.drexel.edu:bioimage/leverjs into fsIntensity

parents 8391b202 44c3517d
......@@ -1299,9 +1299,9 @@ class LeverDB {
}
// set write ahead mode on the database -- makes concurrent access possible
setWAL(fnCallback) {
var sqlCmd = "PRAGMA journal_mode = WAL";
this._lDB.exec(sqlCmd,function(){
fnCallback();
var sqlCmd = "PRAGMA journal_mode = WAL;pragma journal mode";
this._lDB.all(sqlCmd,function(err,rows){
fnCallback();
});
}
......
......@@ -15,7 +15,13 @@ else
se=strel('disk',3);
end
imBG=imerode(im,se);
if isfield(segParams,'sensitivity')
sensitivity=segParams.sensitivity;
else
sensitivity=0.5;
end
T=adaptthresh(im,sensitivity,'NeighborhoodSize',4*floor(size(im)/16)+1,'statistic','gaussian');
T=imdilate(T,se);
for i=1:length(Cells)
if is3D(im)
verts=round(Cells(i).verts);
......@@ -26,8 +32,8 @@ for i=1:length(Cells)
idx=sub2ind(size(im),Cells(i).surface(:,2),Cells(i).surface(:,1));
end
idx(isnan(idx))=[];
imBGmu=mean(imBG(idx));
minFG=graythresh(im)*segParams.alpha(1);
imBGmu=median(imBG(idx));
minFG=max(T(idx));
imBGeff=1-imBGmu/minFG; %
imBGeff=min(imBGeff,1);
......
......@@ -70,13 +70,20 @@ end
[bw,bwLog]=Segment.thresholdImages(im,imLog,segParams, min_radius_pixels,min_area_pixels,...
medianMask);
if segParams.membraneChannel>0
bwMembrane=Segment.getMembrane(CONSTANTS,segParams.membraneChannel,t);
if ~isempty(bwMembrane)
bwLog=bwLog|bwMembrane;
end
end
% bw2 is all the pixels in our foreground image. after we mask, some
% of those pixels will be discarded in resolving the underlying cells.
% allocateShake (below) assigns each discarded pixel to it's closest
% touching segmentation using a morphological region fill
bw2=bw;
bw=Segment.segReduce(bw,bwLog,min_area_pixels,min_radius_pixels);
bw=Segment.segReduce(bw,bwLog,segParams,min_area_pixels,min_radius_pixels);
if ~segParams.isPhase
bw=bw|imfill(bw,'holes');
......
......@@ -2,19 +2,16 @@ function segParams=getDefaultSegParams()
segParams=[];
segParams.draw=false;
segParams.minimumRadius_um=[1.5,0.25,2.5];
segParams.channels=1; %[1CONSTANTS.imageData.NumberOfChannels];
segParams.channels=1;
segParams.membraneChannel=-1;
segParams.isPhase=false;
segParams.wellRadius=-1;
segParams.useCuda=true;
segParams.nCores=feature('numcores'); % for ensemble seg only
segParams.storeEnsemble=true;
segParams.alpha=1.0;
segParams.sensitivity=0.5;
segParams.denoise=true;
segParams.bCytoplasmic=false;
segParams.bCircular=false;
segParams.brightLevels=-1;
segParams.clonalMotionComp=false;
% advanced params
%
% NLM: h,search_window_radius,neighborhood_radius,high_pass_filter
segParams.NLM=[0.1,12,1,false];
......@@ -24,7 +24,6 @@ im=denoise(im,segParams);
if 1==nargout
return
end
if is3D(im)
% 3D
if 1==nargout
......@@ -106,7 +105,7 @@ else
imx=medfilt2(im)-imgaussfilt(im,szFilter(1:2));
end
end
imx=max(imx,0);
im=mat2gray(imx);
......
function bwMembrane=getMembrane(CONSTANTS,channel,t)
im = MicroscopeData.Reader('imageData',CONSTANTS.imageData, 'chanList',channel,...
'timeRange',[t t], 'outType','single','prompt',false);
if isempty(im) || all(im==0)
bwMembrane=[];
return;
end
imf=HIP.LoG(im,[3,3,0],[]);
imf(imf>0)=0;
imf=abs(imf);
bwMembrane=imbinarize(imf,adaptthresh(imf));
% bwMembrane=bwmorph(bwMembrane,'skel',Inf);
function bw=ljsThreshold(im,min_radius_pixels,min_area_pixels)
imOut=0*im;
for i=1:5
imf=HIP.Gaussian(im,[floor(size(im)/(128/2^(i)))+1,0],1,[]);
% imx=imf;
bw=(im - 1*(imf)>0);
imOut=imOut+bw;
end
se=strel('square',ceil(min_radius_pixels));
imo=imopen(imOut,se);
bw=logical(imo>0);
bw=bwareaopen(bw,min_area_pixels);
\ No newline at end of file
function bw=segReduce(bw,bwLog,min_area_pixels,min_radius_pixels)
function bw=segReduce(bw,bwLog,segParams,min_area_pixels,min_radius_pixels)
[origL,num]=bwlabeln(bw);
......@@ -8,9 +8,9 @@ qL=origL;
% nDimension is 2 for 2-D, 3 for 3-D used for concat'ing
nDimension=length(size(bw));
if is3D(bw)
minKernelArea=27;
minKernelArea=ceil(min_area_pixels/2); %
else
minKernelArea=9; %floor(min_area_pixels/4)+1;
minKernelArea=ceil(min_area_pixels/4); %
end
if is3D(bw)
......
function [bw,bwLog]=thresholdImagess(im,imLog,segParams, min_radius_pixels,min_area_pixels,...
function [bw,bwLog]=thresholdImages(im,imLog,segParams, min_radius_pixels,min_area_pixels,...
medianMask)
imLog(imLog<0)=0;
imLog=mat2gray(imLog);
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 isfield(segParams,'sensitivity')
sensitivity=segParams.sensitivity;
else
sensitivity=0.5;
end
if is3D(im)
nsz=2*floor(size(im)/16)+1;
T=adaptthresh(im,0.4,'NeighborhoodSize',nsz,'statistic','gaussian');
T=adaptthresh(imLog,0.5,'NeighborhoodSize',nsz,'statistic','gaussian');
bwLog=imbinarize(imLog,T);
bwLog=bwareaopen(bwLog,4*min_area_pixels);
T=adaptthresh(im,sensitivity,'NeighborhoodSize',nsz,'statistic','gaussian');
bw=imbinarize(im,T);
bw=bwareaopen(bw,min_area_pixels);
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=bwareaopen(bwLog,4*min_area_pixels);
if segParams.isPhase
se=strel('disk',1);
se2=strel('disk',ceil(min_radius_pixels/2));
T=adaptthresh(im,0.5,'foregroundpolarity','dark','statistic','gaussian');
se2=strel('disk',ceil(min_radius_pixels));
if segParams.isPhase>0
T=adaptthresh(im,sensitivity,'foregroundpolarity','dark','statistic','gaussian');
else
T=adaptthresh(im,sensitivity,'foregroundpolarity','bright','statistic','gaussian');
end
bw=imbinarize(im,T);
bw=imcomplement(bw);
if segParams.isPhase>0
bw=imcomplement(bw);
end
% bw=imopen(bw,se);
bw=imclose(bw,se2);
bw=imfill(bw,'holes');
if segParams.wellRadius
if true==segParams.wellRadius
bwMask=imbinarize(medianMask,adaptthresh(medianMask,'statistic','gaussian'));
seMask=strel('disk',ceil(2*min_radius_pixels));
bwMask=imdilate(bwMask,se2);
bw=bw&~bwMask;
bwMask=imdilate(bwMask,seMask);
bwLog=bwLog&~bwMask;
end
bw=imfill(bw,'holes');
else
% use 2x the default nhood size
T=adaptthresh(im,0.5,'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);
end
bw=bwareaopen(bw,min_area_pixels);
......
......@@ -4,14 +4,16 @@
"type" : "segment",
"description" : "texture w/ recurvise partition",
"params" : {
"note":" - channels: use e.g. [3,2,1]. the first channel should be the primary -- the remainder contribute edges",
"channels":"[1]",
"channels":"1",
"membraneChannel":"-1",
"note_1":" - minimumRadius_um: for ensemble, use [start,step,end] e.g. [2,0.1,4]",
"minimumRadius_um":"4",
"note_sensi":"sensitivity is on [0,1] 0 least fg, 1 most fg",
"sensitivity":0.5,
"useCuda":"true",
"denoise": "true",
"note_NLM":"non-local means params (denoise==true): [h,search window,neighborhood,high-pass filter]",
"NLM":"[0.1,6,3,0]",
"NLM":"[0.1,12,1,0]",
"isPhase":false,
"wellRadius":-1,
"note_2":" - bCytoplasmic to true for objects with fine processes to preserve",
......
This diff is collapsed.
This source diff could not be displayed because it is stored in LFS. You can view the blob instead.
No preview for this file type
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