Bases: object
Linear Position-Invariant Filter (2-dimensional)
Parameters : | impulse_response : callable f(r, c, **filter_params)
|
---|
Examples
Gaussian filter:
>>> def filt_func(r, c):
... return np.exp(-np.hypot(r, c)/1)
>>> filter = LPIFilter2D(filt_func)
skimage.filter.canny(image[, sigma, ...]) | Edge filter an image using the Canny algorithm. |
skimage.filter.denoise_bilateral | Denoise image using bilateral filter. |
skimage.filter.denoise_tv_bregman | Perform total-variation denoising using split-Bregman optimization. |
skimage.filter.denoise_tv_chambolle(im[, ...]) | Perform total-variation denoising on 2D and 3D images. |
skimage.filter.hprewitt(image[, mask]) | Find the horizontal edges of an image using the Prewitt transform. |
skimage.filter.hscharr(image[, mask]) | Find the horizontal edges of an image using the Scharr transform. |
skimage.filter.hsobel(image[, mask]) | Find the horizontal edges of an image using the Sobel transform. |
skimage.filter.inverse(data[, ...]) | Apply the filter in reverse to the given data. |
skimage.filter.median_filter(image[, ...]) | Masked median filter with octagon shape. |
skimage.filter.prewitt(image[, mask]) | Find the edge magnitude using the Prewitt transform. |
skimage.filter.rank_order(image) | Return an image of the same shape where each pixel is the index of the pixel value in the ascending order of the unique values of image, aka the rank-order value. |
skimage.filter.scharr(image[, mask]) | Find the edge magnitude using the Scharr transform. |
skimage.filter.sobel(image[, mask]) | Find the edge magnitude using the Sobel transform. |
skimage.filter.threshold_adaptive(image, ...) | Applies an adaptive threshold to an array. |
skimage.filter.threshold_otsu(image[, nbins]) | Return threshold value based on Otsu’s method. |
skimage.filter.tv_denoise(*args, **kwargs) | Perform total-variation denoising on 2D and 3D images. |
skimage.filter.vprewitt(image[, mask]) | Find the vertical edges of an image using the Prewitt transform. |
skimage.filter.vscharr(image[, mask]) | Find the vertical edges of an image using the Scharr transform. |
skimage.filter.vsobel(image[, mask]) | Find the vertical edges of an image using the Sobel transform. |
skimage.filter.wiener(data[, ...]) | Minimum Mean Square Error (Wiener) inverse filter. |
Edge filter an image using the Canny algorithm.
Parameters : | image : array_like, dtype=float
sigma : float
low_threshold : float
high_threshold : float
mask : array, dtype=bool, optional
|
---|---|
Returns : | output : array (image)
|
See also
skimage.sobel
Notes
The steps of the algorithm are as follows:
References
Canny, J., A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986
William Green’ Canny tutorial http://dasl.mem.drexel.edu/alumni/bGreen/www.pages.drexel.edu/_weg22/can_tut.html
Examples
>>> from skimage import filter
>>> # Generate noisy image of a square
>>> im = np.zeros((256, 256))
>>> im[64:-64, 64:-64] = 1
>>> im += 0.2*np.random.random(im.shape)
>>> # First trial with the Canny filter, with the default smoothing
>>> edges1 = filter.canny(im)
>>> # Increase the smoothing for better results
>>> edges2 = filter.canny(im, sigma=3)
Denoise image using bilateral filter.
This is an edge-preserving and noise reducing denoising filter. It averages pixels based on their spatial closeness and radiometric similarity.
Spatial closeness is measured by the gaussian function of the euclidian distance between two pixels and a certain standard deviation (sigma_spatial).
Radiometric similarity is measured by the gaussian function of the euclidian distance between two color values and a certain standard deviation (sigma_range).
Parameters : | image : ndarray
win_size : int
sigma_range : float
sigma_spatial : float
bins : int
mode : string
cval : string
|
---|---|
Returns : | denoised : ndarray
|
References
[R67] | http://users.soe.ucsc.edu/~manduchi/Papers/ICCV98.pdf |
Perform total-variation denoising using split-Bregman optimization.
Total-variation denoising (also know as total-variation regularization) tries to find an image with less total-variation under the constraint of being similar to the input image, which is controlled by the regularization parameter.
Parameters : | image : ndarray
weight : float, optional
eps : float, optional
max_iter: int, optional :
|
---|---|
Returns : | u : ndarray
|
References
[R68] | http://en.wikipedia.org/wiki/Total_variation_denoising |
[R69] | Tom Goldstein and Stanley Osher, “The Split Bregman Method For L1 Regularized Problems”, ftp://ftp.math.ucla.edu/pub/camreport/cam08-29.pdf |
[R70] | Pascal Getreuer, “Rudin–Osher–Fatemi Total Variation Denoising using Split Bregman” in Image Processing On Line on 2012–05–19, http://www.ipol.im/pub/art/2012/g-tvd/article_lr.pdf |
Perform total-variation denoising on 2D and 3D images.
Parameters : | im : ndarray (2d or 3d) of ints, uints or floats
weight : float, optional
eps : float, optional
n_iter_max : int, optional
multichannel : bool, optional
|
---|---|
Returns : | out : ndarray
|
Notes
Make sure to set the multichannel parameter appropriately for color images.
The principle of total variation denoising is explained in http://en.wikipedia.org/wiki/Total_variation_denoising
The principle of total variation denoising is to minimize the total variation of the image, which can be roughly described as the integral of the norm of the image gradient. Total variation denoising tends to produce “cartoon-like” images, that is, piecewise-constant images.
This code is an implementation of the algorithm of Rudin, Fatemi and Osher that was proposed by Chambolle in [R71].
References
[R71] | (1, 2) A. Chambolle, An algorithm for total variation minimization and applications, Journal of Mathematical Imaging and Vision, Springer, 2004, 20, 89-97. |
Examples
2D example on Lena image:
>>> from skimage import color, data
>>> lena = color.rgb2gray(data.lena())
>>> lena += 0.5 * lena.std() * np.random.randn(*lena.shape)
>>> denoised_lena = denoise_tv(lena, weight=60)
3D example on synthetic data:
>>> x, y, z = np.ogrid[0:40, 0:40, 0:40]
>>> mask = (x - 22)**2 + (y - 20)**2 + (z - 17)**2 < 8**2
>>> mask = mask.astype(np.float)
>>> mask += 0.2*np.random.randn(*mask.shape)
>>> res = denoise_tv(mask, weight=100)
Find the horizontal edges of an image using the Prewitt transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
We use the following kernel and return the absolute value of the result at each point:
1 1 1
0 0 0
-1 -1 -1
Find the horizontal edges of an image using the Scharr transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
We use the following kernel and return the absolute value of the result at each point:
3 10 3
0 0 0
-3 -10 -3
References
[R72] | D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives. |
Find the horizontal edges of an image using the Sobel transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
We use the following kernel and return the absolute value of the result at each point:
1 2 1
0 0 0
-1 -2 -1
Apply the filter in reverse to the given data.
Parameters : | data : (M,N) ndarray
impulse_response : callable f(r, c, **filter_params)
filter_params : dict
max_gain : float
|
---|
Masked median filter with octagon shape.
Parameters : | image : (M,N) ndarray, dtype uint8
radius : {int, 2}, optional
mask : (M,N) ndarray, dtype uint8, optional
percent : {int, 50}, optional
|
---|---|
Returns : | out : (M,N) ndarray, dtype uint8
|
Find the edge magnitude using the Prewitt transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
Return the square root of the sum of squares of the horizontal and vertical Prewitt transforms.
Return an image of the same shape where each pixel is the index of the pixel value in the ascending order of the unique values of image, aka the rank-order value.
Parameters : | image: ndarray : |
---|---|
Returns : | labels: ndarray of type np.uint32, of shape image.shape :
original_values: 1-d ndarray :
|
Examples
>>> a = np.array([[1, 4, 5], [4, 4, 1], [5, 1, 1]])
>>> a
array([[1, 4, 5],
[4, 4, 1],
[5, 1, 1]])
>>> rank_order(a)
(array([[0, 1, 2],
[1, 1, 0],
[2, 0, 0]], dtype=uint32), array([1, 4, 5]))
>>> b = np.array([-1., 2.5, 3.1, 2.5])
>>> rank_order(b)
(array([0, 1, 2, 1], dtype=uint32), array([-1. , 2.5, 3.1]))
Find the edge magnitude using the Scharr transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
Take the square root of the sum of the squares of the horizontal and vertical Scharrs to get a magnitude that’s somewhat insensitive to direction.
References
[R73] | D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives. |
Find the edge magnitude using the Sobel transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
Take the square root of the sum of the squares of the horizontal and vertical Sobels to get a magnitude that’s somewhat insensitive to direction.
Note that scipy.ndimage.sobel returns a directional Sobel which has to be further processed to perform edge detection.
Applies an adaptive threshold to an array.
Also known as local or dynamic thresholding where the threshold value is the weighted mean for the local neighborhood of a pixel subtracted by a constant. Alternatively the threshold can be determined dynamically by a a given function using the ‘generic’ method.
Parameters : | image : (N, M) ndarray
block_size : int
method : {‘generic’, ‘gaussian’, ‘mean’, ‘median’}, optional
offset : float, optional
mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional
param : {int, function}, optional
|
---|---|
Returns : | threshold : (N, M) ndarray
|
References
Examples
>>> from skimage.data import camera
>>> image = camera()
>>> binary_image1 = threshold_adaptive(image, 15, 'mean')
>>> func = lambda arr: arr.mean()
>>> binary_image2 = threshold_adaptive(image, 15, 'generic', param=func)
Return threshold value based on Otsu’s method.
Parameters : | image : array
nbins : int
|
---|---|
Returns : | threshold : float
|
References
[R74] | Wikipedia, http://en.wikipedia.org/wiki/Otsu’s_Method |
Examples
>>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_otsu(image)
>>> binary = image > thresh
Perform total-variation denoising on 2D and 3D images.
Parameters : | im : ndarray (2d or 3d) of ints, uints or floats
weight : float, optional
eps : float, optional
n_iter_max : int, optional
multichannel : bool, optional
|
---|---|
Returns : | out : ndarray
|
Notes
Make sure to set the multichannel parameter appropriately for color images.
The principle of total variation denoising is explained in http://en.wikipedia.org/wiki/Total_variation_denoising
The principle of total variation denoising is to minimize the total variation of the image, which can be roughly described as the integral of the norm of the image gradient. Total variation denoising tends to produce “cartoon-like” images, that is, piecewise-constant images.
This code is an implementation of the algorithm of Rudin, Fatemi and Osher that was proposed by Chambolle in [R75].
References
[R75] | (1, 2) A. Chambolle, An algorithm for total variation minimization and applications, Journal of Mathematical Imaging and Vision, Springer, 2004, 20, 89-97. |
Examples
2D example on Lena image:
>>> from skimage import color, data
>>> lena = color.rgb2gray(data.lena())
>>> lena += 0.5 * lena.std() * np.random.randn(*lena.shape)
>>> denoised_lena = denoise_tv(lena, weight=60)
3D example on synthetic data:
>>> x, y, z = np.ogrid[0:40, 0:40, 0:40]
>>> mask = (x - 22)**2 + (y - 20)**2 + (z - 17)**2 < 8**2
>>> mask = mask.astype(np.float)
>>> mask += 0.2*np.random.randn(*mask.shape)
>>> res = denoise_tv(mask, weight=100)
Find the vertical edges of an image using the Prewitt transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
We use the following kernel and return the absolute value of the result at each point:
1 0 -1
1 0 -1
1 0 -1
Find the vertical edges of an image using the Scharr transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
We use the following kernel and return the absolute value of the result at each point:
3 0 -3
10 0 -10
3 0 -3
References
[R76] | D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives. |
Find the vertical edges of an image using the Sobel transform.
Parameters : | image : 2-D array
mask : 2-D array, optional
|
---|---|
Returns : | output : ndarray
|
Notes
We use the following kernel and return the absolute value of the result at each point:
1 0 -1
2 0 -2
1 0 -1
Minimum Mean Square Error (Wiener) inverse filter.
Parameters : | data : (M,N) ndarray
K : float or (M,N) ndarray
impulse_response : callable f(r, c, **filter_params)
filter_params : dict
|
---|