Sunday, June 24, 2012

3rd Activity: Image Types and Formats



In this activity, we were made to familiarize ourselves with different types and formats of images.


First, we were tasked to download examples of image types. 


Below are the images I downloaded for each image type. At the left side of each image is the corresponding information of the image obtained using <imfinfo>.


Image Types:


1.  Binary image



Figure 1. An example of binary image




Filename: /home/venven/Desktop/ap186/batmanBW.jpg
Filesize: 8072
Width: 225
Height: 225
BitDepth: 8
ColorType:grayscale










2. Grayscale images





Figure 2. An example of a grayscale image




Filename: home/venven/Desktop/ap186/gaussianG.jpg
Filesize: 11349
Width: 500
Height: 500
BitDepth: 8
ColorType: grayscale










3. Truecolor images



Figure 3. An example of truecolor image
www.whatscookingamerica.net


Filename: home/venven/Desktop/ap186/cake1.jpeg
Filesize: 10594
Width: 251
Height: 201
BitDepth: 8
ColorType: truecolor










4. Indexed Images



Figure 4. An example of indexed image
http://printplanet.com/forums/enfocus/16504
-indexed-color-spaces







Filename:/home/venven/Desktop/ap186/Indexed.jpg
Filesize: 12246
Width: 288
Height: 288
BitDepth: 8
ColorType: truecolor


















5. High dynamic range images



Figure 5. An example of high dynamic range image
http://www.cambridgeincolour.com/tutorials/high
-dynamic-range.htm



Filename:  /home/venven/Desktop/ap186/hrd.jpg
Filesize: 27848
Width: 300
Height: 200
BitDepth: 8
ColorType: truecolor












6.Multi or hyperspectral image



Figure 6. An example of hyperspectral image
http://exosky.net/exosky/?p=880



Filename: /home/venven/Desktop/ap186/orion.jpg
Filesize: 1189338
Width: 1600
Height: 1600
BitDepth: 8
ColorType: truecolor


















7. 3D images



Figure 7. An example of 3D image
http://www.aeromental.net/2011/01/11/5000-
photos-for-3d-glasses-red-and-blue-cyan/



Filename: /home/venven/Desktop/ap186/3D.jpeg

Filesize: 246364
Width: 500
Height: 378
BitDepth: 8
ColorType: truecolor








--------------------------------------------------------------------------------------------------------------------
The next task was to explain image file formats. 




1. Lossy image compression


     When compressed, some information from the image is not contained in the file.


Examples of lossy image compression:


a. GIF 
      This stands for Graphics Interchange Format. It is a compressed file format and is limited only for 256 colors. As a consequence, it is usually used only for animated images, icons, and logos [1].




b. JPG or JPEG
    This file format is named after the committee that created it. It stands for Joint Photographics Experts Group. Compared to GIF, JPEG has a wider range of colors. Thus, it is more used for colorful images and high resolution images [1]. This makes it mostly used by many people. 




2. Lossless  image compression
     When compressing an image, each pixel is maintained.


Examples of lossless image compression:


a. TIFF
    This stands for Tagged Image File Format. It ranges from 1-bit to 24-bit. It is mostly used for important images since it contains all the information of the original image. 
      
b. PNG
     Another image format is PNG which means Portable Network Graphics. It is mostly used by graphic artists and web developers.




---------------------------------------------------------------------------------------------------------------


Finally, we were told to follow the procedure given in the activity sheet.


The scanned image in Activity 1 was opened in Scilab and its size was observed. The code and the output is shown in Figure 8.


Figure 8. Code in obtaining the size of scanned image and the output




We were also made to gather examples of image types. It was shown at the first part of this blog. At the right side of the images, the image properties were shown. The properties was obtained by using the code below:


info = imfinfo('/home/venven/Desktop/ap186/batman.jpg');


From the collection of images previously, I took one of the images and converted it to grayscale. The code and the output is shown in Figure 9. 


Figure 9. Convertion of an image to grayscale
In figure 9, it can also be seen that the size of the matrix varied after conversion to grayscale.




It was then converted into black and white using 0.5 as the threshold value. Figure 10 shows the code and the output. 
Figure 10. Conversion to binary image


In figure 10, it can also be noted that the matrix size is the same with the previous one. 


Same step was done to the scanned image in Activity 1. Figure 11 shows the conversion of scanned image to grayscale. 


Figure 11. Convertion of scanned plot to grayscale


To get a good approximation of the threshold value, the histogram of the grayscale image was obtained. The code used for obtaining this is shown: 






Figure 12. Code and output of the histogram






The imhist function showed values from 0 to 256. After zooming in, the approximated lowest value was at  113. To get the threshold value, I divided this to 256. Thus, the obtained binary image is shown in Figure 13. 



Figure 13. Binary image of the scanned graph


Now, the background noise can then be eliminated since it was converted to a binary image. A binary image is an image containing only black and white. As a result, only the lines in the plot can be seen. 





Self-evaluation:



For this activity, I rate myself a 10 out of 10. 5 for technical correctness since I indeed understood all the concepts and 5 for quality of presentation since I was able to show all the figures and texts in a very understandable manner.  


It was fun searching for examples of different image types. Also, I was able to discover the differences in file formats in images. 




-------------------------------------------------------------------------------------------------------------------
References
[1]http://www.techterms.com/



Tuesday, June 19, 2012

2nd Activity: Scilab Basics

In this activity, we were introduced to Scilab and its Image and Video Processing. We were tasked to familiarize ourselves with this language since we used Python in our previous subjects. 

I realized that there are many things that could be done in Scilab. Things that could be done simpler compared with other languages. 

As an exercise, we were given a code for creating a  circular aperture. The code and the image produced are shown below.

nx = 100;
ny = 100;

x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
r = sqrt(X.^2 + Y.^2);
A = zeros(nx,ny);

A(find(r<0.7)) = 1;
imshow(A);



For further problems, we were tasked to do a centered square aperture,  sinusoid along the x-direction, a grating along the x-direction,  annulus, and a circular aperture with graded transparency.

Figures 2, 3, 4, 5, and 6 shows the produced output.

Figure 2. A centered square aperture




Figure 3. A sinusoid which is along the x-direction

Figure 4. A grating which is along the x-direction


Figure 5. An annulus


Figure 6. A gaussian transparency




Self evaluation

I grade myself an 8. Technical correctness 4 and quality of presentation 4. 
I had a VERY hard time installing the Scilab and SIVP. It only took me less than an hour to finish this activity. If given an ample time, I could have done a better job in this activity.





1st Activity: Digital Scanning






In this activity, we were tasked to recreate a hand drawn plot. First, I searched for an old book and took a hand sketched plot. It is shown in figure 1. 



Figure 1. Hand-sketched graph




Using GIMP editor, I moved the pointer over several points in the plot. I noted the pixel locations of each. I gathered 46 data points from the plot. I took as many as I could (especially at the curved portions of the plot) so that I could obtain a more precise plot.



The interval between two successive tick marks is related to the interval in pixels by a constant. This constant value is the scaling factor. This is just a simple ratio and proportion principle.



(Scaling factor) (interval in pixels) = interval as shown in graph                                    (1)




Since both the interval between successive tick marks and the interval in pixels could be easily determined, the scaling factor can then be calculated. In the x-axis, the interval between each tick marks shown by the graph is 50 gauss. After taking the pixel location of successive tick marks, the interval was found to be 60pixels.  In the y-axis, the interval between successive tick marks as shown by the graph is 10 while the interval in pixels is 40. Using equation 1, the scaling factors are shown in Table 1.



Table 1. Scaling factors




Scaling factor in x

0.83 gauss/pixel

Scaling factor in y

0.25 beam intensity/pixel



Since the scaling factor is now derived, the actual location for each point in the plot can now be obtained. However, there is a need to introduce a reference point. This is needed because there is a difference in the origin of the graph and the origin of the image. I chose the reference point to be at the lower left corner of the plot which is at (66pixel, 199pixel). I subtracted this to the pixel location of each point in the plot. This length is then multiplied to the scaling factor to eliminate the pixel unit. This would be the scaled value of the point.



scaled value of each point = scaling factor * (pixel value of each point – pixel value of reference point)            (2)



For the final step in obtaining the reconstructed plot, we use the equation given by



x coordinate of each point = Actual value of reference point + scaled value of each point in x      (3a)

y coordinate of each point = Actual value of reference point – scaled value of each point in y      (3b)



Also, note that the actual value of the reference point is (3300, 60).



All the calculations were done simply in Excel and the plot was generated as shown in Figure 2.









I compared the reconstructed plot with the original plot by superimposing these two as shown in Figure 3.



Figure 3. Superimposed plots of original and reconstructed plot






It can be clearly seen that the plot that I was able to generate was exactly over the hand-sketched plot. Also note that the tick marks in x-axis and y-axis of generated plot is continuous with the horizontal and vertical lines in the hand-sketched graph (except that it was way too thicker). This indicates that the reconstruction of the hand-sketched graph was successful.




Self-evaluation:

For this activity, I give myself a score of 10. For technical correctness, I rate myself a 5 since I was able to understand the lecture completely. I was able to reconstruct the hand-drawn plot accurately. Also, I was able to produce all the required output. For quality of presentation, I also rate myself a 5 since all of the  text and images are of good quality. Captions can stand alone. All plots are properly labeled and are visually understandable.