PYME.recipes.skfilters module

Created on Fri Feb 20 17:11:05 2015

@author: david

class PYME.recipes.skfilters.SKF_copy_func(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.copy_func

Parameters:

f : function

Function to copy.

name : str, optional

Name of new function.

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_gabor(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.gabor

Parameters:

image : 2-D array

Input image.

frequency : float

Spatial frequency of the harmonic function. Specified in pixels.

theta : float, optional

Orientation in radians. If 0, the harmonic is in the x-direction.

bandwidth : float, optional

The bandwidth captured by the filter. For fixed bandwidth, sigma_x and sigma_y will decrease with increasing frequency. This value is ignored if sigma_x and sigma_y are set by the user.

sigma_x, sigma_y : float, optional

Standard deviation in x- and y-directions. These directions apply to the kernel before rotation. If theta = pi/2, then the kernel is rotated 90 degrees so that sigma_x controls the vertical direction.

n_stds : scalar, optional

The linear size of the kernel is n_stds (3 by default) standard deviations.

offset : float, optional

Phase offset of harmonic function in radians.

mode : {‘constant’, ‘nearest’, ‘reflect’, ‘mirror’, ‘wrap’}, optional

Mode used to convolve image with a kernel, passed to ndi.convolve

cval : scalar, optional

Value to fill past edges of input if mode of convolution is ‘constant’. The parameter is passed to ndi.convolve.

Returns:

real, imag : arrays

Filtered images using the real and imaginary parts of the Gabor filter kernel. Images are of the same dimensions as the input one.

References

[R1137]http://en.wikipedia.org/wiki/Gabor_filter
[R1138]http://mplab.ucsd.edu/tutorials/gabor.pdf

Examples

>>> from skimage.filters import gabor
>>> from skimage import data, io
>>> from matplotlib import pyplot as plt  
>>> image = data.coins()
>>> # detecting edges in a coin image
>>> filt_real, filt_imag = gabor(image, frequency=0.6)
>>> plt.figure()            
>>> io.imshow(filt_real)    
>>> io.show()               
>>> # less sensitivity to finer details with the lower frequency kernel
>>> filt_real, filt_imag = gabor(image, frequency=0.1)
>>> plt.figure()            
>>> io.imshow(filt_real)    
>>> io.show()               

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_gabor_kernel(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.gabor_kernel

Parameters:

frequency : float

Spatial frequency of the harmonic function. Specified in pixels.

theta : float, optional

Orientation in radians. If 0, the harmonic is in the x-direction.

bandwidth : float, optional

The bandwidth captured by the filter. For fixed bandwidth, sigma_x and sigma_y will decrease with increasing frequency. This value is ignored if sigma_x and sigma_y are set by the user.

sigma_x, sigma_y : float, optional

Standard deviation in x- and y-directions. These directions apply to the kernel before rotation. If theta = pi/2, then the kernel is rotated 90 degrees so that sigma_x controls the vertical direction.

n_stds : scalar, optional

The linear size of the kernel is n_stds (3 by default) standard deviations

offset : float, optional

Phase offset of harmonic function in radians.

Returns:

g : complex array

Complex filter kernel.

References

[R1139]http://en.wikipedia.org/wiki/Gabor_filter
[R1140]http://mplab.ucsd.edu/tutorials/gabor.pdf

Examples

>>> from skimage.filters import gabor_kernel
>>> from skimage import io
>>> from matplotlib import pyplot as plt  
>>> gk = gabor_kernel(frequency=0.2)
>>> plt.figure()        
>>> io.imshow(gk.real)  
>>> io.show()           
>>> # more ripples (equivalent to increasing the size of the
>>> # Gaussian spread)
>>> gk = gabor_kernel(frequency=0.2, bandwidth=0.1)
>>> plt.figure()        
>>> io.imshow(gk.real)  
>>> io.show()           

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_gaussian(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.gaussian

Parameters:

image : array-like

input image (grayscale or color) to filter.

sigma : scalar or sequence of scalars

standard deviation for Gaussian kernel. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.

output : array, optional

The output parameter passes an array in which to store the filter output.

mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional

The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’. Default is ‘nearest’.

cval : scalar, optional

Value to fill past edges of input if mode is ‘constant’. Default is 0.0

multichannel : bool, optional (default: None)

Whether the last axis of the image is to be interpreted as multiple channels. If True, each channel is filtered separately (channels are not mixed together). Only 3 channels are supported. If None, the function will attempt to guess this, and raise a warning if ambiguous, when the array has shape (M, N, 3).

Returns:

filtered_image : ndarray

the filtered array

Notes

This function is a wrapper around scipy.ndi.gaussian_filter().

Integer arrays are converted to float.

The multi-dimensional filter is implemented as a sequence of one-dimensional convolution filters. The intermediate arrays are stored in the same data type as the output. Therefore, for output types with a limited precision, the results may be imprecise because intermediate results may be stored with insufficient precision.

Examples

>>> a = np.zeros((3, 3))
>>> a[1, 1] = 1
>>> a
array([[ 0.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  0.]])
>>> gaussian(a, sigma=0.4)  # mild smoothing
array([[ 0.00163116,  0.03712502,  0.00163116],
       [ 0.03712502,  0.84496158,  0.03712502],
       [ 0.00163116,  0.03712502,  0.00163116]])
>>> gaussian(a, sigma=1)  # more smooting
array([[ 0.05855018,  0.09653293,  0.05855018],
       [ 0.09653293,  0.15915589,  0.09653293],
       [ 0.05855018,  0.09653293,  0.05855018]])
>>> # Several modes are possible for handling boundaries
>>> gaussian(a, sigma=1, mode='reflect')
array([[ 0.08767308,  0.12075024,  0.08767308],
       [ 0.12075024,  0.16630671,  0.12075024],
       [ 0.08767308,  0.12075024,  0.08767308]])
>>> # For RGB images, each is filtered separately
>>> from skimage.data import astronaut
>>> image = astronaut()
>>> filtered_img = gaussian(image, sigma=1, multichannel=True)

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_inverse(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.inverse

Parameters:

data : (M,N) ndarray

Input data.

impulse_response : callable f(r, c, **filter_params)

Impulse response of the filter. See LPIFilter2D.__init__.

filter_params : dict

Additional keyword parameters to the impulse_response function.

max_gain : float

Limit the filter gain. Often, the filter contains zeros, which would cause the inverse filter to have infinite gain. High gain causes amplification of artefacts, so a conservative limit is recommended.

Other Parameters:
 

predefined_filter : LPIFilter2D

If you need to apply the same filter multiple times over different images, construct the LPIFilter2D and specify it here.

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_laplace(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.laplace

Parameters:

image : ndarray

Image to process.

ksize : int, optional

Define the size of the discrete Laplacian operator such that it will have a size of (ksize,) * image.ndim.

mask : ndarray, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : ndarray

The Laplace edge map.

Notes

The Laplacian operator is generated using the function skimage.restoration.uft.laplacian().

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_median(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.median

Parameters:

image : 2-D array (uint8, uint16)

Input image.

selem : 2-D array

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : 2-D array (same dtype as input)

If None, a new array is allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : 2-D array (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filters.rank import median
>>> img = data.camera()
>>> med = median(img, disk(5))

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_prewitt(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.prewitt

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Prewitt edge map.

See also

sobel, scharr

Notes

Return the square root of the sum of squares of the horizontal and vertical Prewitt transforms. The edge magnitude depends slightly on edge directions, since the approximation of the gradient operator by the Prewitt operator is not completely rotation invariant. For a better rotation invariance, the Scharr operator should be used. The Sobel operator has a better rotation invariance than the Prewitt operator, but a worse rotation invariance than the Scharr operator.

Examples

>>> from skimage import data
>>> camera = data.camera()
>>> from skimage import filters
>>> edges = filters.prewitt(camera)

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_prewitt_h(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.prewitt_h

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Prewitt edge map.

Notes

We use the following kernel:

 1   1   1
 0   0   0
-1  -1  -1

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_prewitt_v(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.prewitt_v

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Prewitt edge map.

Notes

We use the following kernel:

1   0  -1
1   0  -1
1   0  -1

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_rank_order(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.rank_order

Parameters:

image: ndarray

Returns:

labels: ndarray of type np.uint32, of shape image.shape

New array where each pixel has the rank-order value of the corresponding pixel in image. Pixel values are between 0 and n - 1, where n is the number of distinct unique values in image.

original_values: 1-D ndarray

Unique original values of image

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]))

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_roberts(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.roberts

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Roberts’ Cross edge map.

See also

sobel, scharr, prewitt, feature.canny

Examples

>>> from skimage import data
>>> camera = data.camera()
>>> from skimage import filters
>>> edges = filters.roberts(camera)

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_roberts_neg_diag(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.roberts_neg_diag

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Robert’s edge map.

Notes

We use the following kernel:

 0   1
-1   0

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_roberts_pos_diag(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.roberts_pos_diag

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Robert’s edge map.

Notes

We use the following kernel:

1   0
0  -1

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_scharr(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.scharr

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Scharr edge map.

See also

sobel, prewitt, canny

Notes

Take the square root of the sum of the squares of the horizontal and vertical Scharrs to get a magnitude that is somewhat insensitive to direction. The Scharr operator has a better rotation invariance than other edge filters such as the Sobel or the Prewitt operators.

References

[R1141]D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives.
[R1142]http://en.wikipedia.org/wiki/Sobel_operator#Alternative_operators

Examples

>>> from skimage import data
>>> camera = data.camera()
>>> from skimage import filters
>>> edges = filters.scharr(camera)

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_scharr_h(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.scharr_h

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Scharr edge map.

Notes

We use the following kernel:

 3   10   3
 0    0   0
-3  -10  -3

References

[R1143]D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives.

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_scharr_v(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.scharr_v

Parameters:

image : 2-D array

Image to process

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Scharr edge map.

Notes

We use the following kernel:

 3   0   -3
10   0  -10
 3   0   -3

References

[R1144]D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives.

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_sobel(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.sobel

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Sobel edge map.

See also

scharr, prewitt, roberts, feature.canny

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.

The 3x3 convolution kernel used in the horizontal and vertical Sobels is an approximation of the gradient of the image (with some slight blurring since 9 pixels are used to compute the gradient at a given pixel). As an approximation of the gradient, the Sobel operator is not completely rotation-invariant. The Scharr operator should be used for a better rotation invariance.

Note that scipy.ndimage.sobel returns a directional Sobel which has to be further processed to perform edge detection.

Examples

>>> from skimage import data
>>> camera = data.camera()
>>> from skimage import filters
>>> edges = filters.sobel(camera)

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_sobel_h(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.sobel_h

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Sobel edge map.

Notes

We use the following kernel:

 1   2   1
 0   0   0
-1  -2  -1

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_sobel_v(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.sobel_v

Parameters:

image : 2-D array

Image to process.

mask : 2-D array, optional

An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns:

output : 2-D array

The Sobel edge map.

Notes

We use the following kernel:

1   0  -1
2   0  -2
1   0  -1

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_threshold_adaptive(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.threshold_adaptive

Parameters:

image : (N, M) ndarray

Input image.

block_size : int

Odd size of pixel neighborhood which is used to calculate the threshold value (e.g. 3, 5, 7, ..., 21, ...).

method : {‘generic’, ‘gaussian’, ‘mean’, ‘median’}, optional

Method used to determine adaptive threshold for local neighbourhood in weighted mean image.

  • ‘generic’: use custom function (see param parameter)
  • ‘gaussian’: apply gaussian filter (see param parameter for custom sigma value)
  • ‘mean’: apply arithmetic mean filter
  • ‘median’: apply median rank filter

By default the ‘gaussian’ method is used.

offset : float, optional

Constant subtracted from weighted mean of neighborhood to calculate the local threshold value. Default offset is 0.

mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional

The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’. Default is ‘reflect’.

param : {int, function}, optional

Either specify sigma for ‘gaussian’ method or function object for ‘generic’ method. This functions takes the flat array of local neighbourhood as a single argument and returns the calculated threshold for the centre pixel.

Returns:

threshold : (N, M) ndarray

Thresholded binary image

References

[R1145]http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=threshold#adaptivethreshold

Examples

>>> from skimage.data import camera
>>> image = camera()[:50, :50]
>>> binary_image1 = threshold_adaptive(image, 15, 'mean')
>>> func = lambda arr: arr.mean()
>>> binary_image2 = threshold_adaptive(image, 15, 'generic', param=func)

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_threshold_isodata(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.threshold_isodata

Parameters:

image : array

Input image.

nbins : int, optional

Number of bins used to calculate histogram. This value is ignored for integer arrays.

return_all: bool, optional

If False (default), return only the lowest threshold that satisfies the above equality. If True, return all valid thresholds.

Returns:

threshold : float or int or array

Threshold value(s).

References

[R1146]Ridler, TW & Calvard, S (1978), “Picture thresholding using an iterative selection method”
[R1147]IEEE Transactions on Systems, Man and Cybernetics 8: 630-632, http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4310039
[R1148]Sezgin M. and Sankur B. (2004) “Survey over Image Thresholding Techniques and Quantitative Performance Evaluation” Journal of Electronic Imaging, 13(1): 146-165, http://www.busim.ee.boun.edu.tr/~sankur/SankurFolder/Threshold_survey.pdf
[R1149]ImageJ AutoThresholder code, http://fiji.sc/wiki/index.php/Auto_Threshold

Examples

>>> from skimage.data import coins
>>> image = coins()
>>> thresh = threshold_isodata(image)
>>> binary = image > thresh

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_threshold_li(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.threshold_li

Parameters:

image : array

Input image.

Returns:

threshold : float

Upper threshold value. All pixels intensities more than this value are assumed to be foreground.

References

[R1150]Li C.H. and Lee C.K. (1993) “Minimum Cross Entropy Thresholding” Pattern Recognition, 26(4): 617-625
[R1151]Li C.H. and Tam P.K.S. (1998) “An Iterative Algorithm for Minimum Cross Entropy Thresholding” Pattern Recognition Letters, 18(8): 771-776
[R1152]Sezgin M. and Sankur B. (2004) “Survey over Image Thresholding Techniques and Quantitative Performance Evaluation” Journal of Electronic Imaging, 13(1): 146-165 http://citeseer.ist.psu.edu/sezgin04survey.html
[R1153]ImageJ AutoThresholder code, http://fiji.sc/wiki/index.php/Auto_Threshold

Examples

>>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_li(image)
>>> binary = image > thresh

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_threshold_otsu(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.threshold_otsu

Parameters:

image : array

Grayscale input image.

nbins : int, optional

Number of bins used to calculate histogram. This value is ignored for integer arrays.

Returns:

threshold : float

Upper threshold value. All pixels intensities that less or equal of this value assumed as foreground.

Notes

The input image must be grayscale.

References

[R1154]Wikipedia, http://en.wikipedia.org/wiki/Otsu’s_Method

Examples

>>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_otsu(image)
>>> binary = image <= thresh

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_threshold_yen(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.threshold_yen

Parameters:

image : array

Input image.

nbins : int, optional

Number of bins used to calculate histogram. This value is ignored for integer arrays.

Returns:

threshold : float

Upper threshold value. All pixels intensities that less or equal of this value assumed as foreground.

References

[R1155]Yen J.C., Chang F.J., and Chang S. (1995) “A New Criterion for Automatic Multilevel Thresholding” IEEE Trans. on Image Processing, 4(3): 370-378
[R1156]Sezgin M. and Sankur B. (2004) “Survey over Image Thresholding Techniques and Quantitative Performance Evaluation” Journal of Electronic Imaging, 13(1): 146-165, http://www.busim.ee.boun.edu.tr/~sankur/SankurFolder/Threshold_survey.pdf
[R1157]ImageJ AutoThresholder code, http://fiji.sc/wiki/index.php/Auto_Threshold

Examples

>>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_yen(image)
>>> binary = image <= thresh

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKF_wiener(parent=None, **kwargs)

Bases: PYME.recipes.skfilters.SKFilter

Autogenerated wrapper around skimage.filters.wiener

Parameters:

data : (M,N) ndarray

Input data.

K : float or (M,N) ndarray

Ratio between power spectrum of noise and undegraded image.

impulse_response : callable f(r, c, **filter_params)

Impulse response of the filter. See LPIFilter2D.__init__.

filter_params : dict

Additional keyword parameters to the impulse_response function.

Other Parameters:
 

predefined_filter : LPIFilter2D

If you need to apply the same filter multiple times over different images, construct the LPIFilter2D and specify it here.

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
class PYME.recipes.skfilters.SKFilter(parent=None, **kwargs)

Bases: PYME.recipes.base.Filter

Attributes

default_view
hide_in_overview
inputs
outputs
pipeline_view
pipeline_view_min

Methods

applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()
trait_items_event(event_trait,name,items_event)
trait_property_changed(...)
traits_init()
traits_inited([True])
applyFilter(data, chanNum, frNum, im)
completeMetadata(im)
kwargs()