skimage.exposure.adjust_gamma(image[, ...]) | Performs Gamma Correction on the input image. |
skimage.exposure.adjust_log(image[, gain, inv]) | Performs Logarithmic correction on the input image. |
skimage.exposure.adjust_sigmoid(image[, ...]) | Performs Sigmoid Correction on the input image. |
skimage.exposure.cumulative_distribution(image) | Return cumulative distribution function (cdf) for the given image. |
skimage.exposure.equalize_adapthist(image[, ...]) | Contrast Limited Adaptive Histogram Equalization. |
skimage.exposure.equalize_hist(image[, nbins]) | Return image after histogram equalization. |
skimage.exposure.histogram(image[, nbins]) | Return histogram of image. |
skimage.exposure.rescale_intensity(image[, ...]) | Return image after stretching or shrinking its intensity levels. |
Performs Gamma Correction on the input image.
Also known as Power Law Transform. This function transforms the input image pixelwise according to the equation O = I**gamma after scaling each pixel to the range 0 to 1.
Parameters: | image : ndarray
gamma : float
gain : float
|
---|---|
Returns: | out : ndarray
|
Notes
For gamma greater than 1, the histogram will shift towards left and the output image will be darker than the input image.
For gamma less than 1, the histogram will shift towards right and the output image will be brighter than the input image.
References
[R81] | http://en.wikipedia.org/wiki/Gamma_correction |
Performs Logarithmic correction on the input image.
This function transforms the input image pixelwise according to the equation O = gain*log(1 + I) after scaling each pixel to the range 0 to 1. For inverse logarithmic correction, the equation is O = gain*(2**I - 1).
Parameters: | image : ndarray
gain : float
inv : float
|
---|---|
Returns: | out : ndarray
|
References
[R82] | http://www.ece.ucsb.edu/Faculty/Manjunath/courses/ece178W03/EnhancePart1.pdf |
Performs Sigmoid Correction on the input image.
Also known as Contrast Adjustment. This function transforms the input image pixelwise according to the equation O = 1/(1 + exp*(gain*(cutoff - I))) after scaling each pixel to the range 0 to 1.
Parameters: | image : ndarray
cutoff : float
gain : float
inv : bool
|
---|---|
Returns: | out : ndarray
|
References
[R83] | Gustav J. Braun, “Image Lightness Rescaling Using Sigmoidal Contrast Enhancement Functions”, http://www.cis.rit.edu/fairchild/PDFs/PAP07.pdf |
Return cumulative distribution function (cdf) for the given image.
Parameters: | image : array
nbins : int
|
---|---|
Returns: | img_cdf : array
bin_centers : array
|
References
[R84] | http://en.wikipedia.org/wiki/Cumulative_distribution_function |
Contrast Limited Adaptive Histogram Equalization.
Parameters: | image : array-like
ntiles_x : int, optional
ntiles_y : int, optional
clip_limit : float: optional
nbins : int, optional
|
---|---|
Returns: | out : ndarray
|
Notes
The algorithm relies on an image whose rows and columns are even multiples of the number of tiles, so the extra rows and columns are left at their original values, thus preserving the input image shape.
For RGBA images, the original alpha channel is removed.
References
[R85] | http://tog.acm.org/resources/GraphicsGems/gems.html#gemsvi |
[R86] | https://en.wikipedia.org/wiki/CLAHE#CLAHE |
Return image after histogram equalization.
Parameters: | image : array
nbins : int
|
---|---|
Returns: | out : float array
|
Notes
This function is adapted from [R87] with the author’s permission.
References
[R87] | (1, 2) http://www.janeriksolem.net/2009/06/histogram-equalization-with-python-and.html |
[R88] | http://en.wikipedia.org/wiki/Histogram_equalization |
Return histogram of image.
Unlike numpy.histogram, this function returns the centers of bins and does not rebin integer arrays. For integer arrays, each integer value has its own bin, which improves speed and intensity-resolution.
The histogram is computed on the flattened image: for color images, the function should be used separately on each channel to obtain a histogram for each color channel.
Parameters: | image : array
nbins : int
|
---|---|
Returns: | hist : array
bin_centers : array
|
Examples
>>> from skimage import data, exposure, util
>>> image = util.img_as_float(data.camera())
>>> np.histogram(image, bins=2)
(array([107432, 154712]), array([ 0. , 0.5, 1. ]))
>>> exposure.histogram(image, nbins=2)
(array([107432, 154712]), array([ 0.25, 0.75]))
Return image after stretching or shrinking its intensity levels.
The image intensities are uniformly rescaled such that the minimum and maximum values given by in_range match those given by out_range.
Parameters: | image : array
in_range : 2-tuple (float, float) or str
out_range : 2-tuple (float, float) or str
|
---|---|
Returns: | out : array
|
Examples
By default, intensities are stretched to the limits allowed by the dtype:
>>> image = np.array([51, 102, 153], dtype=np.uint8)
>>> rescale_intensity(image)
array([ 0, 127, 255], dtype=uint8)
It’s easy to accidentally convert an image dtype from uint8 to float:
>>> 1.0 * image
array([ 51., 102., 153.])
Use rescale_intensity to rescale to the proper range for float dtypes:
>>> image_float = 1.0 * image
>>> rescale_intensity(image_float)
array([ 0. , 0.5, 1. ])
To maintain the low contrast of the original, use the in_range parameter:
>>> rescale_intensity(image_float, in_range=(0, 255))
array([ 0.2, 0.4, 0.6])
If the min/max value of in_range is more/less than the min/max image intensity, then the intensity levels are clipped:
>>> rescale_intensity(image_float, in_range=(0, 102))
array([ 0.5, 1. , 1. ])
If you have an image with signed integers but want to rescale the image to just the positive range, use the out_range parameter:
>>> image = np.array([-10, 0, 10], dtype=np.int8)
>>> rescale_intensity(image, out_range=(0, 127))
array([ 0, 63, 127], dtype=int8)