% Author: Dr. Joshua Morgan and Isabella Bagdasarian, TIME lab, UCR % Use gradient (via derivative5, Peter Kovesi) to find phalloidin edges and % threshold. Outputs an NxN double and NxN logical to be used for watershedding. %PARAMETERS % Pth - NxN image (normally already filtered) % Po- NxN filtered phalloidin image % Db4e- NxN logical % threshold- threshold parameter, single value % areaopen- smallest size to preserve when performing bwareaopen, % single value function [T, mask] = CytGradSeg(Pth, Po, Db4e, areaopen, threshold) %Use gradient to segment out cytosolic region [gx, gy] = derivative5(Pth, 'x','y'); G = gx.^2+gy.^2; G2 = adapthisteq(normalise(G),'NumTiles',[24 24],'NBins',1024); Pm = Po > threshold; Pmi = bwareaopen(Pm, areaopen); mask = imclose(Pmi,strel('disk',4)); T = graydist(G2,Db4e,'quasi'); T = normalise(T); T(~mask) = 1; T = imimposemin(T, Db4e); end