コード例 #1
0
def background_subtraction_wavelet(img, holder, level=7, OFFSET=10):
    '''
    It might be radical but works in many cases in terms of segmentation.
    Use "background_subtraction_wavelet_hazen" for a proper implementation.
    '''
    img = wavelet_subtraction(img, level)
    return convert_positive(img, OFFSET)
コード例 #2
0
def background_subtraction_prcblock(img,
                                    holder,
                                    BLOCK=10,
                                    OPEN=3,
                                    PERCENTILE=0.1,
                                    OFFSET=50):
    img = median_filter(img, size=(5, 5))
    img = estimate_background_prc(img, BLOCK, PERCENTILE)
    img = convert_positive(img, OFFSET)
    return img
コード例 #3
0
def background_subtraction_wavelet_hazen(img,
                                         holder,
                                         THRES=100,
                                         ITER=5,
                                         WLEVEL=6,
                                         OFFSET=50):
    """Wavelet background subtraction for STORM.
    """
    back = wavelet_subtraction_hazen(img,
                                     ITER=ITER,
                                     THRES=THRES,
                                     WLEVEL=WLEVEL)
    img = img - back
    return convert_positive(img, OFFSET)
コード例 #4
0
def n4_illum_correction_downsample(img,
                                   holder,
                                   DOWN=2,
                                   RATIO=1.05,
                                   FILTERINGSIZE=50,
                                   OFFSET=10):
    """Faster but more insensitive to local illum bias.
    """
    fil = sitk.ShrinkImageFilter()
    cc = sitk.GetArrayFromImage(
        fil.Execute(sitk.GetImageFromArray(img), [DOWN, DOWN]))
    bw = adaptive_thresh(cc, RATIO=RATIO, FILTERINGSIZE=FILTERINGSIZE / DOWN)
    himg = homogenize_intensity_n4(cc, -bw)
    himg = cc - himg
    # himg[himg < 0] = 0
    bias = resize_img(himg, img.shape)
    img = img - bias
    return convert_positive(img, OFFSET)