The SciPy provides the ndimage (n-dimensional image) package, that contains the number of general image processing and analysis functions. It is dedicated to image processing. We can perform several tasks in image processing such as input/output image, classification, Feature extraction, Registration, etc.
Opening and Writing to Image Files
The scipy.ndimage provides the misc package, which comes with some images. We will use those images and perform image manipulation. Consider the following example:
The number in the matrix format represents any images and their color combinations. A machine uses those numbers for the manipulation. There is two way to represent the image, grayscale and RGB. RGB is the most popular way of representation.
We can perform the some basic operations such as image rotation, image up-side down. Consider the following example of image upside down:
The SciPy provide the rotate() function, which rotates the image to the specified angle.
Filtering is the process where we modify and enhance an image. For example, the filter can be applied to an image to highlight certain feature or eliminate other features. Image processing operations implemented with filtering including Smoothing and Edge Enhancement. Consider the following operations using SciPy ndimage.
Blurring is the technique that is used to reduce the noise in the image. We can perform a filter operation and observe the change in the image. The example is given below:
The sigma value denotes the level of blur on a scale of five. You can change the sigma value and see the difference.
- Edge Detection
Edge detection is an image processing term which is used for finding the boundaries of objects within the image. It is used for image segmentation and data extraction in fields such as Image Processing, Computer Vision, and Machine Vision. To understand the edge detection more specifically, visit our tutorial – click here.
Consider the following example:
The output image appears like a square block of color. Now, we will find the edges of those colored block. The ndimage provides the sobel() function to perform this operation. Whereas, NumPy provides the hypot() function which is used to combine the two resultant matrices to one. Consider the following example: