In this activity, we're to attempt to remove distortion in an image. One common type of distortion is the barrel distortion where the image looks like the face of a blown up balloon because the center appears bloated and the sides appears compressed (Figure 1). Another distortion commonly encountered is the pincushion distortion, which is just the opposite of barrel distortion in the sense that its center appears compressed and the sides seem stretched (Figure 2).

Figure 1. Barrel distorted image. (source: http://www.photos-of-the-year.com/barrel-distortion/2.jpg)

Figure 2. Pincushion distorted image. (source: http://www.dpreview.com/learn/Articles/Glossary/Optical/images/VBO_PIN01.jpg)
Correcting these distortions will require an ideal image or an image that does not have pinched up or bloated regions that has points we can easily match up with points on the distorted image. The method also requires determining the correct pixel coordinates and tagging pixels with the correct graylevel values.
In this activity, we're to attempt to correct barrel distortion of an image. But first...
In this activity, we're to attempt to correct barrel distortion of an image. But first...
Really pretty, eh? Pretty breath-taking. :) And in the photographer's description for this picture:
"Yes, there is barrel distortion... It's easy to get rid of in post processing."
Yeah. Real easy. No sweat. (!!!!!!)
Anyway, I'm not correcting that image. Let's try to correct a simple distorted grid first (Figure 1).
First, to determine the ideal image, I get pixel coordinates of a box that looks flat and lies near the optical axis using Scilab's locate command. These pixel coordinates give me the estimated no. of pixels between the horizontal lines of the grid and between the vertical lines of the grid. I found both distances to be approximately 22 pixels; as expected, they're the same because the grid boxes were squares. Then we generate the ideal grid from this and note the vertex points (Figure 3).
The next step should be to compute for c1 to c8 for each cell pair (ideal and distorted grid) BUT our distorted image is still in grid form. We need its vertices for computation. So as an application of past activities, I used imcorrcoef on the distorted grid and a patch from the grid with least noticeable distortion (Figure 4).
Then we use skel and arrive with the following:
It was made sure that the vertices at the centers of the ideal and distorted images approximately coincide:
There are still missing vertices on the left, which I think may be recreated and there are extra vertices everywhere (the white spots are not single pixels), which I think may be eliminated through distance calculations. But because actual coding attempts at these have failed, I have decided to identify vertex locations with locate. I was bored (more like desperate). Moving on, I calculated c1 to c8 for each cell so we can determine the location of each pixel in the ideal form of the image. We arrive at the following set of pixels:
Note that outer cells are more crooked than those near the center because the image is more distorted in those parts. The kink at center bottom is just due to a mistake in vertex selection.
Then we assign grayscale value or color of each pixel based on the still distorted image (since calculated pixel locations are non-integers, I rounded them off to be used as matrix indices). Figure 8 shows part of the less distorted image.
Then we assign grayscale value or color of each pixel based on the still distorted image (since calculated pixel locations are non-integers, I rounded them off to be used as matrix indices). Figure 8 shows part of the less distorted image.
It seems a bit less distorted. A better way of assigning graylevel values would be to. check values from neighboring pixels.
I give myself a grade of 8 because of efforts for this activity (in the initial and final attemts at extracting vertices especially) although an undistorted version of the image was not produced.
I give myself a grade of 8 because of efforts for this activity (in the initial and final attemts at extracting vertices especially) although an undistorted version of the image was not produced.
I would like to thank Mr. Luis Buno III and Ms. Kaye Vergel for the humongous help. Seriously, thank you guys. :D








0 comments:
Post a Comment