當前位置: 首頁>>代碼示例>>Python>>正文


Python restoration.denoise_tv_bregman方法代碼示例

本文整理匯總了Python中skimage.restoration.denoise_tv_bregman方法的典型用法代碼示例。如果您正苦於以下問題:Python restoration.denoise_tv_bregman方法的具體用法?Python restoration.denoise_tv_bregman怎麽用?Python restoration.denoise_tv_bregman使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在skimage.restoration的用法示例。


在下文中一共展示了restoration.denoise_tv_bregman方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tvd

# 需要導入模塊: from skimage import restoration [as 別名]
# 或者: from skimage.restoration import denoise_tv_bregman [as 別名]
def tvd(x0, rho, gamma):
    """
    Proximal operator for the total variation denoising penalty

    Requires scikit-image be installed

    Parameters
    ----------
    x0 : array_like
        The starting or initial point used in the proximal update step

    rho : float
        Momentum parameter for the proximal step (larger value -> stays closer to x0)

    gamma : float
        A constant that weights how strongly to enforce the constraint

    Returns
    -------
    theta : array_like
        The parameter vector found after running the proximal update step

    Raises
    ------
    ImportError
        If scikit-image fails to be imported
    """
    try:
        from skimage.restoration import denoise_tv_bregman
    except ImportError:
        print('Error: scikit-image not found. TVD will not work.')
        return x0

    return denoise_tv_bregman(x0, rho / gamma) 
開發者ID:ganguli-lab,項目名稱:proxalgs,代碼行數:36,代碼來源:operators.py

示例2: denoise_tv_bregman

# 需要導入模塊: from skimage import restoration [as 別名]
# 或者: from skimage.restoration import denoise_tv_bregman [as 別名]
def denoise_tv_bregman(img_arr, weight=30):
    denoised = _denoise_tv_bregman(img_arr, weight=weight) * 255.
    return np.array(denoised, dtype=img_arr.dtype) 
開發者ID:poloclub,項目名稱:jpeg-defense,代碼行數:5,代碼來源:defenses.py

示例3: denoise_img_vol

# 需要導入模塊: from skimage import restoration [as 別名]
# 或者: from skimage.restoration import denoise_tv_bregman [as 別名]
def denoise_img_vol(image_vol, weight=.01):
    denoised_img = slicewise_bilateral_filter(image_vol)
    # denoised_img = denoise_tv_chambolle(image_vol, weight=weight, eps=0.0002, n_iter_max=200, multichannel=False)
    # denoised_img = denoise_tv_bregman(image_vol, weight=1./weight, max_iter=100, eps=0.001, isotropic=True)
    # print (np.linalg.norm(denoised_img-image_vol))
    return denoised_img 
開發者ID:mahendrakhened,項目名稱:Automated-Cardiac-Segmentation-and-Disease-Diagnosis,代碼行數:8,代碼來源:data_augmentation.py

示例4: threshold

# 需要導入模塊: from skimage import restoration [as 別名]
# 或者: from skimage.restoration import denoise_tv_bregman [as 別名]
def threshold(image, *, sigma=0., radius=0, offset=0.,
              method='sauvola', smooth_method='Gaussian'):
    """Use scikit-image filters to "intelligently" threshold an image.

    Parameters
    ----------
    image : array, shape (M, N, ...[, 3])
        Input image, conformant with scikit-image data type
        specification [1]_.
    sigma : float, optional
        If positive, use Gaussian filtering to smooth the image before
        thresholding.
    radius : int, optional
        If given, use local median thresholding instead of global.
    offset : float, optional
        If given, reduce the threshold by this amount. Higher values
        result in fewer pixels above the threshold.
    method: {'sauvola', 'niblack', 'median'}
        Which method to use for thresholding. Sauvola is 100x faster, but
        median might be more accurate.
    smooth_method: {'Gaussian', 'TV'}
        Which method to use for smoothing. Choose from Gaussian smoothing
        and total variation denoising.

    Returns
    -------
    thresholded : image of bool, same shape as `image`
        The thresholded image.

    References
    ----------
    .. [1] http://scikit-image.org/docs/dev/user_guide/data_types.html
    """
    if sigma > 0:
        if smooth_method.lower() == 'gaussian':
            image = filters.gaussian(image, sigma=sigma)
        elif smooth_method.lower() == 'tv':
            image = restoration.denoise_tv_bregman(image, weight=sigma)
    if radius == 0:
        t = filters.threshold_otsu(image) + offset
    else:
        if method == 'median':
            footprint = hyperball(image.ndim, radius=radius)
            t = ndi.median_filter(image, footprint=footprint) + offset
        elif method == 'sauvola':
            w = 2 * radius + 1
            t = threshold_sauvola(image, window_size=w, k=offset)
        elif method == 'niblack':
            w = 2 * radius + 1
            t = threshold_niblack(image, window_size=w, k=offset)
        else:
            raise ValueError('Unknown method %s. Valid methods are median,'
                             'niblack, and sauvola.' % method)
    thresholded = image > t
    return thresholded 
開發者ID:jni,項目名稱:skan,代碼行數:57,代碼來源:pre.py


注:本文中的skimage.restoration.denoise_tv_bregman方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。