Some more Image Processing: Ostu's Method, Hough Transform and Motion-based Segmentation with Python and OpenCV
Some of the following problems appeared in the lectures and the exercises in the coursera course Image Processing (by NorthWestern University). Some of the following descriptions of the problems are taken from the exercise's description.
We need to find a thershold to binarize an image, by separating the background from the foreground. Using Ostu's method we can automatically find the global optimal threshold, by maximizing the between-class variance. The following figure shows the outline for the technique.
The following figures show the thresholds computed and the output binary images obtained by using Ostu's method on a few gray-scale low-contrast images:
The following figures show the output binary images obtained by using Ostu's method on a few gray-scale high-contrast images obtained using histogram equalization:
The following figures show the distribution of the between-class variance for different images and the htreshold chosen by Ostu's method:
The Hough transform can be used to find lines in an image by taking votes from each of the pixels for all possible orientations of lines, for different values of the parameters in a straight line's equation. The following figure describes the method.
The following figures show a couple of binary images and the votes obtained by the image pixels in the parametric space of any straight line and how thresholding on the votes we can find the most prominent line(s) in the image (markd by green). The parameter values marked with arrow(s) represent the most prominent line(s) in the image.
The following results are inspired by the youtube video How Hough Transform works (by Thales Sehn Korting) which can be found here: https://www.youtube.com/watch?v=4zHbI-fFIlI. Again, by thresholding on the votes by the pixels for the differrent values of the straight line parameters, we can find the most prominent line(s) in the image (markd by green). The parameter values marked with arrow(s) represent the most prominent line(s) in the image.
The next figure shows all the steps in how Hough transform can be used on any (gray-level) image to find lines (edges). As expected, the more voting threshold is increased, the lesser lines / edges are detected (since the more prominent ones will be detected by the Hough transform, they are colored red).
In this problem we basically want to separate the moving objects in consectuive frames of a video from the non-moving objects. The following figures show the problem statement that appeared in an assignment in the same course and also the theory to be used:
The following animation shows the motion of a moving rectangle.
The next figure shows how the motion-based using ADI based techniques can be applied to separate out the moving rectangle from the static backgorund.
Again, the next animations show how the moving objects can be segemented from the non-moving ones from the consecutive frames of a video. First the frames from the video are binarized using Ostu's method and then absolute ADI is applied to separate out the moving objects.
The next video is from some past cricket match with Sachin Tendulkar batting (taken from youtube) and the following one is the motion-segmented video with ADI:
The next video is captured at a live performance of a dance-drama written by Tagore and the following one is the motion-segmented video with ADI: