skimage.exposure.rescale_intensity in Python
In this tutorial, we will learn about one of the functions of an image processing library (skimage) of Python.
scikit-image, also known as skimage is an image processing library in python. This library is a collection of algorithms for image processing such as segmentation, filtering, object detection, color manipulation, etc and works on NumPy arrays. We can import this library as skimage. The image objects can be represented as various ndarrays of integers and float.skimage contains many submodules and exposure is one of them that tell us about various characteristics of the image such as whether it is dark, light or balanced.skimage.exposure spreads the intensity value at a wider range. We can import skimage library as follows-
rescale_intensity is a function of the exposure module that stretches or shrinks the intensity level of the image.rescale_intensity take input of image as NumPy array and also return an image object of NumPy array. It has three parameters –
- image – input image as NumPy arrays
- in_range =’ image’
- out_range =dtype
in_range and out_range should be str or tuple values. The dtype of the input image and the returned image is the same.
we can import this module by executing the following code-
from skimage import exposure
After importing the module we have to give the path of the input image. The input image is read by using
io.imread() function. In the arguments, we provide the path of the image and if the image is in the same folder we only give its name otherwise we have to give the full location of the image.
Our output is the original image.
After reading the image we will use the rescale_intensity function to stretch the pixels of the image.