Open computing language, or OpenCV, as the name suggests, is an open source software that aims at computing efficiency and bettering real-time computer vision. An image processing software, OpenCV, helps us achieve whatever we want to do with images, right from understanding these to completely ripping these apart.
What can you do with OpenCV
Images can be of two kinds, namely, hand drawn or captured. In both cases, when we are dealing with images, there are two things we might want to do: understand the images completely and make these visually appealing.
OpenCV lets you do both, by providing a variety of functions and features, which, when used correctly, give the desired result. With more than 2500 optimised library algorithms and new algorithms that can be written easily, it lets you work with images in an easy and comfortable manner.
Masking. A mask is a spatial filter. When we need to hide a certain region of an image, we can use a corresponding mask. It is like using a black-and-white filter on the image, wherein the black region blocks out the image, while the white region acts as a transparent sheet. An example can be seen in Fig 1.
Contrast and brightness. To enchance the image’s appeal, we can play around with brightness and contrast features. Changing the contrast changes the difference between the selected region and its background, while brightness changes the appearance. We use the two to please our visual perception.
Smoothing, blurring, blending and sharpening. The anti-aliasing approach that finds usage right from image to audio processing is similar to smoothing and blurring the image.
Smoothing and blurring help us nullify the difference between jagged edges and the rest of the image. These aid in generating background effects, shadows and even achieve region highlighting.
Blending involves mixing two layers by placing one on top of the other. Depending on the opacity of the two layers, the resulting effect can be hiding the bottom layer or dissolving the two or a transparent top layer. The reverse process; if we want to recover fine details of an image that is blur or low on resolution, we can sharpen the image.
Add noise. OpenCV lets us add a realistic angle to the image by corrupting it. This is like simulating the setup, taking into account noise from the detector, salt-and-pepper noise or data-transmission noise and also image-dependent noise.
Boost, identify and recognise. We can follow eye movements in a video by tracking or measuring the point of gaze or the motion of the eye relative to the head. Removing red eyes in an image taken using flash is also a simple task. Boosting image classification by categorising images that can be used as a base in future. We can recognise scenery, as the tool compares the new image with previously-recorded ones.
The same goes with identifying or tagging people. Tracking objects and detecting motion in videos also take place using the same process.
Segmentation, edge detection and morphology. With this tool, the image under processing can be partitioned into multiple segments by using the thresholding approach. Also, points, lines and edges in an image can be easily detected by simply applying different order derivatives to the image. Fig. 2 shows what an edge-detected image looks like.
Morphological operations process the image based on shapes or templates called structuring elements, and we can apply image pyramids to either upsize or downsize the image.
Histogram. Analyse your image by obtaining the image histogram and studying the intensity distribution. The tool scans the entire image, tabulates different intensities and increases the corresponding intensity count as it scans the image, simultaneously. Fig. 3 shows a sample histogram.
We can use this information, which is generally seen as a graph, to fix threshold limits and decide the pixel adjustments to be made to the image. The histogram can also be equalised to improve image contrast.
Transformations. Convert the image from the existing spatial domain to corresponding frequency domain by applying Fourier transform. To find imperfect instances of objects, like circles and other classes of shapes in your image, apply Hough transform. The image can also be remapped by moving existing pixels to a new image.
The complex math and a little beyond. Statistical evaluation using expectation-maximisation algorithm, k-nearest neighbour algorithm, random forest and support vector machine is made easy by simply coding it into the tool and then applying the same on the image.
Decision tree learning can be used to predict an image’s target value by mapping observations. Multi-dimensional scaling, naive bayers classifiers and gradient boosting help you work with the images better. Image analysis can even be extended to the level of neural networks, converting neuron connections to numeric weights that can be worked with.