Thursday, September 22, 2011

XIV

In this activity, the use of Normalized Chromaticity Coordinates (NCC) gives us an advantage since it can separate brightness and chromaticity. 
 (1)


Eq. 1 shows the normalization where I is the sum of all channels. We can now write b=1-r-g, and thus the mapping is reduced to 2 dimensions.
Figure 2. NCC space, x is r and y is g

Fig. 2 shows the reduced space. Notice that the blue is when r and g is zero.



Figure 3. Top: Reference image. Bottom:  Region of Interest (ROI)

Fig. 3 shows the images that will be used in the next activities. 

Parametric Probability Distribution Estimation
This method uses the NCC of the image's ROI and then fits it in a Gaussian distribution to determine the probability that a pixel is indeed a part of the ROI.
 (2)
The actual probability used is of course dependent for the 2 channels. This is called the joint probability, p(r)*p(g). Knowing this, we search for the pixels in the whole image (not the ROI only) that is within the joint probability for the ROI.

Figure 3. Resulting image of the Parametric method

Non-Parametric Probability Distribution Estimation
This method involves backprojecting the known histogram of the ROI to the new estimated image. The algorithm is partly similar to the Parametric method but instead of using the joint probability, the method is reversed to associate pixels to a blank matrix from the known 2D histogram of the ROI.
Figure 4. Resulting image of the Non-Parametric method


From the Figs. 3 and 4, we notice that the Parametric method produced a more even and connected image since it has a Gaussian distribution for the PDF while the Non-Parametric method used only direct histogram to image (ROI to whole) backprojection to estimate the association of a certain pixel.


Self-Assessment: 9/10   


XIII

Image compression is a vital tool for getting a compromise between quality and file size of our images. This activity uses Principal Component Analysis results to represent images as a superposition of weighted eigenvectors.

Figure 1. Original Image

Fig. 1 shows the original image that will be used for demonstrating image compression. To simplify things, I will use the grayscale version of the image to flatten the hypermatrix to a normal matrix.

Now, the method works by cutting the image to 10x10 px segments and converting it to a single column, thus we end up with a 100 element column for every 10x10 segment. We do this again for all segments so we end up with a nxp matrix where n is the number of segments and p is the number of elements per block. After that, we now use the pca() function to this.



Figure 2. Top-Bottom: Correlation Circle, Eigenvalue distribution and Eigenimages

The output of pca() has eigenvectors and principal components. By adjusting the amount of elements that is multiplied (eigenvectors and principal components), we also vary the compression of the method. Then this is reassembled back to the matrix size of our image.

Figure 3. Images a-i corresponds to original then 2, 5, 10, 15, 20, 25, 50, and 70 Eigenvector & Principal Components pairs  

Fig 3. shows the resulting quality of images from the compression technique that is used in this work. There is a total of 100 available eigenvectors that can be used so the original image is equal to a full 100 of those pairs used.

Figure 4. Graph of file size vs eigenvector-principal component pairs used

Fig 4. illustrates that the maximum slope is at the 0-20 eigenvector region. This is then the most optimal setting, file size wise, in which there is a sharp decrease.

Self-Assessment: 10/10 

Tuesday, September 6, 2011

XII

Preprocessing text is one real-world application for the image processing techniques that we have previously learned. For this activity, I have binarized handwritten text and performed template matching to find words within the document.

Figure 1. Original image

Figure 2. Region of Interest

Figure 3. 2D Fourier Transform of Fig. 2


Figure 4. Filtered Fourier Transform of Fig. 3

Figs. 2-3 show my attempt in removing the lines from the image. Due to the low resolution and noise of the original image, filtering in the frequency domain did not fully remove the line in the image. For me to continue to the binarization of the text, I manually removed the remaining gray-ish parts.

To facilitate the binarization, morphological transformation was implemented through the close and skel operations.

Figure 4. After operating close

Figure 5.  After operating skel() on Fig. 4

Fig. 5 shows the final preprocessed image. The "M" and "O" cannot be identified properly, but the "D", "E" and the "III" are still good. The quality of binarization is of course dependent on the quality of the original handwritten text. Due to the thinning strokes, the letters "M" and "O" were damaged by the processing.


Figure 6. Template

To end this, I finally do template correlation. Using imcorrcoef(), I tried to find other instances of the word "DESCRIPTION" in the image (Fig. 1). However, I was only able to find the same spot where my template came from.

Figure 7. imcorrcoef() result. 

Fig. 7 shows the result. Notice the white dot in the right side. This is the approximated location of the match of the used template from imcorrcoef().


  Self-Assessment: 7/10