def test_addm(): f = to_uint8([255, 255, 0, 10, 0, 255, 250]) g = to_uint8([0, 40, 80, 140, 250, 10, 30]) y = addm(f, g) for fi, gi, yi in zip(f, g, y): assert yi >= fi assert yi >= gi
def test_addm(): f = to_uint8([255, 255, 0, 10, 0, 255, 250]) g = to_uint8([ 0, 40, 80, 140, 250, 10, 30]) y = addm(f,g) for fi,gi,yi in zip(f,g,y): assert yi >= fi assert yi >= gi
def roysam_watershed(dna,thresh=None,blur_factor=3): ''' Run watershed on mixed gradient & intensity image as suggested by Lin et al. -Input dna: DNA image thresh: Gray value threshold (default: computed using Murphy's RC) blur_factor: Blur factor (default: 3) REFERENCE Gang Lin, Umesh Adiga, Kathy Olson, John F. Guzowski, Carol A. Barnes, and Badrinath Roysam "A Hybrid 3-D Watershed Algorithm Incorporating Gradient Cues & Object Models for Automatic Segmentation of Nuclei in Confocal Image Stacks" Vol. 56A, No. 1, pp. 23-36 Cytometry Part A, November 2003. ''' if thresh is None: thresh = 'murphy_rc' M = (ndimage.gaussian_filter(dna,4) > thresholding.threshold(dna,thresh)) G = pymorph.gradm(dna) D = ndimage.distance_transform_edt(M) D *= np.exp(1-G/float(G.max())) T = ndimage.gaussian_filter(D.max() - D,blur_factor) if T.max() < 256: T = pymorph.to_uint8(T) else: T = pymorph.to_uint8(T*(256.0/T.max())) T *= M R = pymorph.regmin(T) R *= M R,N = ndimage.label(R) R[(R==0)&(M==0)] = N+1 W,WL = mahotas.cwatershed(T,R,return_lines=True) W *= M return W,WL
def gray16_to8(im): i = 0.00390625 * im return pymorph.to_uint8(i)
def gray12_to8(im): i = 0.062271062 * im return pymorph.to_uint8(i)
def gray16_to8(im): i=0.00390625*im return pymorph.to_uint8(i)
def gray12_to8(im): i=0.062271062*im return pymorph.to_uint8(i)