Python skimage.restoration.denoise_tv_bregman() Examples
The following are 4
code examples of skimage.restoration.denoise_tv_bregman().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
skimage.restoration
, or try the search function
.
Example #1
Source File: operators.py From proxalgs with MIT License | 5 votes |
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)
Example #2
Source File: defenses.py From jpeg-defense with MIT License | 5 votes |
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)
Example #3
Source File: data_augmentation.py From Automated-Cardiac-Segmentation-and-Disease-Diagnosis with MIT License | 5 votes |
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
Example #4
Source File: pre.py From skan with BSD 3-Clause "New" or "Revised" License | 4 votes |
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