How to use the skimage.filters.gaussian function in skimage

To help you get started, we’ve selected a few skimage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samocooper / nuclitrack / nuclitrack / nuclitrack_tools / segmentimages.py View on Github external
if 8 > val >= 4:
        k = morphology.octagon(val//2 + 1, val//2 + 1)

        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)

        im = morphology.erosion(im, k)
        im = morphology.erosion(im, k)

        im = morphology.dilation(im, k)
        im = morphology.dilation(im, k)

    if val >= 8:
        k = morphology.octagon(val // 4 + 1, val // 4 + 1)

        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)

        im = morphology.erosion(im, k)
        im = morphology.erosion(im, k)
        im = morphology.erosion(im, k)
        im = morphology.erosion(im, k)

        im = morphology.dilation(im, k)
        im = morphology.dilation(im, k)
        im = morphology.dilation(im, k)
        im = morphology.dilation(im, k)

    return im
github samocooper / nuclitrack / nuclitrack / nuclitrack_tools / segmentimages.py View on Github external
if 4 > val > 0:

        k = morphology.octagon(val, val)

        im = filters.gaussian(im, val)

        im = morphology.erosion(im, k)

        im = morphology.dilation(im, k)

    if 8 > val >= 4:
        k = morphology.octagon(val//2 + 1, val//2 + 1)

        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)

        im = morphology.erosion(im, k)
        im = morphology.erosion(im, k)

        im = morphology.dilation(im, k)
        im = morphology.dilation(im, k)

    if val >= 8:
        k = morphology.octagon(val // 4 + 1, val // 4 + 1)

        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)
        im = filters.gaussian(im, val)

        im = morphology.erosion(im, k)
github prip-lab / MSU-LatentAFIS / extraction / get_maps.py View on Github external
def smooth_dir_map(dir_map, sigma=2.0, mask=None):

    cos2Theta = np.cos(dir_map * 2)
    sin2Theta = np.sin(dir_map * 2)
    if mask is not None:
        assert (dir_map.shape[0] == mask.shape[0])
        assert (dir_map.shape[1] == mask.shape[1])
        cos2Theta[mask == 0] = 0
        sin2Theta[mask == 0] = 0

    cos2Theta = gaussian(cos2Theta, sigma, multichannel=False, mode='reflect')
    sin2Theta = gaussian(sin2Theta, sigma, multichannel=False, mode='reflect')

    dir_map = np.arctan2(sin2Theta, cos2Theta) * 0.5

    return dir_map
github DerThorsten / nifty / docs / python / html / _downloads / plot_agglomerative_clustering.py View on Github external
# load some image
img = skimage.data.coins()




# slic superpixels
overseg = skimage.segmentation.slic(img, n_segments=2000,
    compactness=0.1, sigma=1)
 
# make the Region adjacency graph (RAG)
rag = nifty.graph.rag.gridRag(overseg)


# compute edge strength
smoothed = skimage.filters.gaussian(img, 2.5)
edgeStrength = skimage.filters.sobel(smoothed)


# accumulate the mean edge value
# along the superpixel boundaries
# length of each boundary and 
print(edgeStrength.shape, overseg.shape)
edge_features, node_features = nifty.graph.rag.accumulateMeanAndLength(
    rag, edgeStrength, [512,512],0)
meanEdgeStrength = edge_features[:,0]
edgeSizes = edge_features[:,1]
nodeSizes = node_features[:,1]


# cluster-policy  
clusterPolicy = nifty.graph.agglo.edgeWeightedClusterPolicy(
github neuropoly / spinalcordtoolbox / scripts / msct_register.py View on Github external
# below: only for debugging purpose
                    # coord_src2d_scaleX = np.copy(coord_src2d)  # need to use np.copy to avoid copying pointer
                    # coord_src2d_scaleX[:, 0] = (coord_src2d[:, 0] - mean_src) * Sx + mean_dest
                    # coord_init_pix_scaleY = np.copy(coord_init_pix)  # need to use np.copy to avoid copying pointer
                    # coord_init_pix_scaleY[:, 0] = (coord_init_pix[:, 0] - mean_src ) * Sx + mean_dest
                    range_x = range(ix * ny, ix * ny + nx)
                    coord_init_pix_scaleY[range_x, 1] = (coord_init_pix[range_x, 1] - mean_src_y) * Sy + mean_dest_y
                    coord_init_pix_scaleYinv[range_x, 1] = (coord_init_pix[range_x, 1] - mean_dest_y) / float(Sy) + mean_src_y
            # apply transformation to image
            col_scaleYinv = np.reshape(coord_init_pix_scaleYinv[:, 1], [nx, ny])
            src2d_scaleXY = warp(src2d, np.array([row_scaleXinv, col_scaleYinv]), order=1)
            # regularize Y warping fields
            from skimage.filters import gaussian
            col_scaleY = np.reshape(coord_init_pix_scaleY[:, 1], [nx, ny])
            col_scaleYsmooth = gaussian(col_scaleY, smoothWarpXY)
            col_scaleYinvsmooth = gaussian(col_scaleYinv, smoothWarpXY)
            # apply smoothed transformation to image
            src2d_scaleXYsmooth = warp(src2d, np.array([row_scaleXinv, col_scaleYinvsmooth]), order=1)
            # reshape warping field as 1d
            coord_init_pix_scaleY[:, 1] = col_scaleYsmooth.ravel()
            coord_init_pix_scaleYinv[:, 1] = col_scaleYinvsmooth.ravel()
            # display
            if verbose == 2:
                # FIG 1
                plt.figure(figsize=(15, 3))
                # plot #1
                ax = plt.subplot(141)
                plt.imshow(np.swapaxes(src2d, 1, 0), cmap=plt.cm.gray, interpolation='none')
                plt.hold(True)  # add other layer
                plt.imshow(np.swapaxes(dest2d, 1, 0), cmap=plt.cm.copper, interpolation='none', alpha=0.5)
                plt.title('src')
                plt.xlabel('x')
github insarlab / MintPy / pysar / filter_spatial.py View on Github external
if   filtType == "sobel":       filt_data = sobel(data)
    elif filtType == "roberts":     filt_data = roberts(data)
    elif filtType == "canny":       filt_data = canny(data)
    elif filtType == "lowpass_avg":
        from scipy import ndimage
        p=int(par)
        kernel = np.ones((p,p),np.float32)/(p*p)
        filt_data = ndimage.convolve(data, kernel)
    elif filtType == "highpass_avg":
        from scipy import ndimage
        p=int(par)
        kernel = np.ones((p,p),np.float32)/(p*p)
        lp_data = ndimage.convolve(data, kernel)
        filt_data = data - lp_data
    elif filtType == "lowpass_gaussian":
        filt_data = gaussian(data, sigma=float(par))
    elif filtType == "highpass_gaussian":
        lp_data   = gaussian(data, sigma=float(par))
        filt_data = data - lp_data

    #elif filtType ==  "gradient":
       
    return filt_data
github TenteEEEE / quiche_pantie_patch / src / bra.py View on Github external
panties = list([panties[args.num - 1]])

for fname in panties:
    pantie = io.imread('./dream/' + fname)
    print('Process: ' + fname)

    # crop center texture
    center_texture = pantie[20:140, -170:-15]
    center_texture = skt.resize(center_texture, (np.int(center_texture.shape[0] * 1.6), np.int(center_texture.shape[1] * 1.6)), anti_aliasing=True, mode='reflect')
    [hr, hc, hd] = center_texture.shape

    # make seamless design
    design = rgb2gray(center_texture[:, :, :3])[::-1, ::-1]
    design = (design - np.min(design)) / (np.max(design) - np.min(design))
    edge = 30
    design_seamless = gaussian(design, sigma=3)
    design_seamless[edge:-edge, edge:-edge] = design[edge:-edge, edge:-edge]
    y = np.arange(-hr / 2, hr / 2, dtype=np.int16)
    x = np.arange(-hc / 2, hc / 2, dtype=np.int16)
    design_seamless = (design_seamless[y, :])[:, x]  # rearrange pixels
    design_seamless = np.tile(design_seamless, (3, 3))

    # paste center texture
    posx = 20
    posy = 230
    padx = c - hc - posx
    pady = r - hr - posy
    center_texture = (np.pad(center_texture, [(posy, pady), (posx, padx), (0, 0)], mode='constant'))
    center_texture[:, :, 3] = bra_center[:, :, 0] / 255.0

    # base color painting and shading seamless design
    front = pantie[20:100, 30:80, :]
github nipy / dipy / 1.0.0 / _downloads / e4914788c2109e833aacd5a405a6b8f2 / register_binary_fuzzy.py View on Github external
"""


def draw_ellipse(img, center, axis):
    rr, cc = draw.ellipse(center[0], center[1], axis[0], axis[1],
                          shape=img.shape)
    img[rr, cc] = 1
    return img


img_ref = np.zeros((64, 64))
img_ref = draw_ellipse(img_ref, (25, 15), (10, 5))
img_ref = draw_ellipse(img_ref, (20, 45), (15, 10))
img_ref = draw_ellipse(img_ref, (50, 40), (7, 15))

img_in = filters.gaussian(img_ref, sigma=3)

"""
Let's define a small visualization function.
"""


def show_images(img_ref, img_warp, fig_name):
    fig, axarr = plt.subplots(ncols=2, figsize=(12, 5))
    axarr[0].set_title('warped image & reference contour')
    axarr[0].imshow(img_warp)
    axarr[0].contour(img_ref, colors='r')
    ssd = np.sum((img_warp - img_ref) ** 2)
    axarr[1].set_title('difference, SSD=%.02f' % ssd)
    im = axarr[1].imshow(img_warp - img_ref)
    plt.colorbar(im)
    fig.tight_layout()
github BPHO-Salk / PSSR / utils / utils.py View on Github external
def _my_noise(x, gauss_sigma:uniform=0.01, pscale:uniform=10):
    xn = x.numpy()
    xorig_max = xn.max()

    xn = random_noise(xn, mode='salt', amount=0.005)
    xn = random_noise(xn, mode='pepper', amount=0.005)
    lvar = filters.gaussian(x, sigma=5) + 1e-10
    xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
    #xn = np.random.poisson(xn*pscale)/pscale
    #xn += np.random.normal(0, gauss_sigma*xn.std(), size=x.shape)
    x = x.new(xn)
    new_max = xn.max()
    if new_max > 0:
        xn /= new_max
    xn *= xorig_max
    return x
github wolny / pytorch-3dunet / augment / transforms.py View on Github external
def blur_boundary(boundary, sigma):
    boundary = gaussian(boundary, sigma=sigma)
    boundary[boundary >= 0.5] = 1
    boundary[boundary < 0.5] = 0
    return boundary