Imaging systems are imperfect. Individual components such as lenses usually introduce noticable distortions in images. Many cameras have been designed to minimize such effects. For simpler ones such as camera phones, the distortions are obvious, especially when the object of interest is considerably far from the optical axis or the middle where distortions are negligible.
Two of the most common distortions are the barrel and pincushion distortion. In the first case, the image becomes smaller as one moves farther from the optical axis. The opposite is true for the second case. Below is an example of a barrel distortion.

Figure 1. Ideal Grid
Figure 2. Grid with Barrel Distortion
In image 2, the distortion is not extreme. In fact, if we look at any square, it still looks like a polygon with four straight sides. Thus, we can work on the corners of one square, find their undistorted counterparts, determine the linear transformation, and use this knowledge to recover the square, including the pixels contained in the square. The counterpart may be found by simply generating a straight grid based on the squares in the middle of the image since their distortions are imperceptible.
In principle ,we can fully recover the ideal image. However, images are discretized into pixels. A point on the reconstructed will almost always never fall exactly on a pixel in the distorted image but at some "fraction of a pixel" from it. The simplest is to assume the value of the pixel nearest it. However, the quality may be poor. A more involved but still quick method is to assume a bilinear interpolation. Using the steps outlined here, we get the following reconstructions of the distorted grid in figure 2. Note that each square has its own transformation. In scilab, for loops may be used to go through each square.

Figure 3. Reconstructed Grid (Nearest Neighbor)
Figure 3. Reconstructed Grid (Bilinear interpolation)
Figure 3 has a much better quality than figure 2. The lines are smoother and more accurate. This reconstruction may be very useful as shown by the next example below.
Figure 4. Tilted and distorted image of oscilloscope display
Some experiments require gathering data that can only be displayed as in figure 4. The usual approach is to estimate the desired parameter manually. Image processing can help improve the accuracy tremendously, especially if the data is not as regular as the example in figure 4. First, we have to reconstruct the image. Note how the gridlines of the display may serve as reference squares and rectangles for the reconstruction. Nearest neighbor and bilinear interpolation produced the following results.
Figure 5. Reconstructed Oscilloscope Display (nearest neighbor)
Figure 6.Reconstructed Oscilloscope Display (bilinear interpolation)
The result of nearest neighbor approximation for images with "thick" elements are not as bad as for thin ones (compare figure 3 and figure 5), precisely because being one pixel off is not too big for objects much thicker than one pixel. In figure 3, the grid lines are mostly one pixel thick, so being off by one pixel makes a relatively huge difference.
The techniques learned from previous blog entries may be used to extract data. For instance, conversion to black and white and thinning may be used to obtain a result such as the following.

Figure 7. Binarized and thinned
The quality of figure 7 may be improved, if we will, be additional morplological processes and added care in applying image processing techniques. Then we can determine the coordinates of the white pixels above and convert them via ratio and proportion into physically meaningful variables since each unit length of a side of a square in figure 6 corresponds to, say 10 Volts, which corresponds to 40 pixels (assumed width of an ideal square in figure 7).
...
This activity was frustrating and fun at the same time. I used four for loops and a few if conditions within, which ate up a lot of my mental energy. I was only too happy when I finally succeeded. 10 points for completely understanding the concepts.




0 comments:
Post a Comment