本文整理汇总了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)
示例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)
示例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