Friday, June 25, 2010

AP 186 Acitivity 3: Image Types and Formats

Today felt like such a long day. I crammed for my 187 paper last night, which was harder than I expected because holography is such a foreign topic to me still. In any case, I've done most of the objectives of this activity and started writing the content of this entry yesterday, so all I had to do today was find the last of the image types I was lacking and get their info.

These are images from my library and from the wonderful world wide web. The ones I got from the net, I noted the url of the image. The first four image types and the conversions were done using Scilab while the last four image types were analyzed in MATLAB.

Grayscale Image
This is one of my Tia's pictures when she attended a conference in Paris.  This was taken in black and white, and saved as JPEG as most cameras do.



-->imfinfo('C:\Documents and Settings\2006-54324\Desktop\BingBW.jpg', 'verbose')
    FileName: C:\Documents and Settings\2006-54324\Desktop\BingBW.jpg
    FileSize: 639006
    Format: JPEG
    Width: 1000
    Height: 1333
    Depth: 8
    StorageType: truecolor
    NumberOfColors: 0
    ResolutionUnit: inch
    XResolution: 300.000000
    YResolution: 300.000000   


True Color Image
Two summers ago, my friends and I went to Pangasinan. We stayed at Bolinao, and this was taken in a light house overlooking white sand beach. I think Hannah resized the images she had of us, taken with her D40, and saved it as JPEG.



-->imfinfo('C:\Documents and Settings\2006-54324\Desktop\DSC_0823.jpg', 'verbose')
     FileName: C:\Documents and Settings\2006-54324\Desktop\DSC_0823.jpg
     FileSize: 516218
     Format: JPEG
     Width: 900
     Height: 597
     Depth: 8
     StorageType: truecolor
     NumberOfColors: 0
     ResolutionUnit: inch
     XResolution: 300.000000
     YResolution: 300.000000   



Binary Image
Though only black and white, this was categorized as an indexed image by Scilab.
Source: http://idlastro.gsfc.nasa.gov/idl_html_help/images/imgdisp01.gif


-->imfinfo('C:\Documents and Settings\2006-54324\Desktop\imgdisp01.gif', 'verbose')
       FileName: C:\Documents and Settings\2006-54324\Desktop\imgdisp01.gif
       FileSize: 5135
       Format: GIF
       Width: 362
       Height: 362 

       Depth: 8
       StorageType: indexed
       NumberOfColors: 256
       ResolutionUnit: centimeter
       XResolution: 72.000000
       YResolution: 72.000000  


Indexed Image
The example we had in class of an indexed image were icons, so I used this icon I made of Jane for this image type. However, Scilab categorized this as truecolor.
-->imfinfo('C:\Documents and Settings\2006-54324\Desktop\jane1.png', 'verbose')
       FileName: C:\Documents and Settings\2006-54324\Desktop\jane1.png
       FileSize: 13339
       Format: PNG
       Width: 234
       Height: 210
       Depth: 8
       StorageType: truecolor
       NumberOfColors: 0
       ResolutionUnit: centimeter
       XResolution: 72.000000
       YResolution: 72.000000  

High Dynamic Range (HDR) Image

Source: http://jamie-katz.com/images/weekly/hdrDropsOnLeaf.jpg



           Filename: '/Users/patriciaromero/Desktop/hdrDropsOnLeaf.jpg'
           FileModDate: '25-Jun-2010 17:13:21'
           FileSize: 244531
           Format: 'jpg'
           FormatVersion: ''
           Width: 1024
           Height: 768
           BitDepth: 24
           ColorType: 'truecolor'
           FormatSignature: ''
           NumberOfSamples: 3
           CodingMethod: 'Huffman'
           CodingProcess: 'Sequential'
           Comment: {}


Hyperspectral Image
This is a satellite image taken by the International Society for Photogrammetry and Remote Sensing.
Source: http://www.itc.nl/isprsc7/symposium/images/hyperspectral.jpg



        Filename: '/Users/patriciaromero/Desktop/hyperspectral.jpg'
        FileModDate: '25-Jun-2010 17:18:46'
        FileSize: 36033
        Format: 'jpg'
        FormatVersion: ''
        Width: 403
        Height: 336
        BitDepth: 24
        ColorType: 'truecolor'
        FormatSignature: ''
        NumberOfSamples: 3
        CodingMethod: 'Huffman'
        CodingProcess: 'Sequential'
        Comment: {}
        DigitalCamera: [1x1 struct]


3D image
These are Star Trek ships, image made by a fan. I think this is done using stereopairs.
Source: http://www.foundation3d.com/uploads/general/2009/10/436-09-146257.jpg



           Filename: '/Users/patriciaromero/Desktop/3d.jpg'
           FileModDate: '25-Jun-2010 17:44:02'
           FileSize: 95837
           Format: 'jpg'
           FormatVersion: ''
           Width: 1280
           Height: 850
           BitDepth: 24
           ColorType: 'truecolor'
           FormatSignature: ''
           NumberOfSamples: 3
           CodingMethod: 'Huffman'
           CodingProcess: 'Sequential'
           Comment: {}



Temporal Image
I'm not sure if this is a temporal image, but it's moving so I guess it is so.
Source: http://www.ucl.ac.uk/~ucesgvd/moebius_w1.0_moving.gif


No image information extracted using MATLAB, but here are some using the details the computer gathered.


Document Type: Graphics Interchange Format (GIF)
File Size: 516.2 KB (528,615 bytes)
Image Size: 320 × 240 pixels
Image DPI: 72 pixels/inch
Color Model: RGB


Converted Images:

Using my True Color Image, I used Scilab with SIP Toolbox to convert this image to black and white. Depending on the threshold, the images' conversion went from light to dark. At threshold=0.35 the faces are clear and details are good enough for recognition, but the light house disappeared. At threshold=0.5, a faint circular outline of the light house was recognizable. Finally, at threshold=0.8, the light house was distinct but only the outlines of the other image elements were left.


Threshold at 0.35, notice that the light house is not visible.

Threshold at 0.8, only people's outlines are visible 
but the light house is clearly defined.

I also converted it to Grayscale.

True Color to Grayscale.


Using Activity 1's scanned plot, I used the black and white conversion to threshold the unwanted data in the image. But first, we had to take the histogram plot of the original file to get a sense of how we should threshold the conversion.

Original scanned image.

-->S=gray_imread('C:\Documents and Settings\2006-54324\Desktop\186-1.jpg')
   Size:   749 rows X 995 columns
   Truecolor Image                                                         
-->a=linspace(.95,1.05,1000);
-->SH=histplot(a,S); 

The image was imported as grayscale. Then the histogram of the grayscaled image was generated to see the distribution of lightness and darkness. The x-axis represents the grayscale values and the y-axis represents the number of pixels.
Histogram of the original scanned image, full (top) and zoomed in (bottom).

Finally, using threshold=0.9, I was able to get a clear though not noiseless image. Although it has specks of unwanted data, the plot is cleaner and the lines are more distinguishable.

Activity 1's image, converted to black and white.



--
Useful links:
http://dali.feld.cvut.cz/ucebna/matlab/toolbox/images/im2bw.html
http://siptoolbox.sourceforge.net/doc/sip-0.2.0-reference/imwrite.html


--
Technical correctness: 5
Quality of presentation: 5
Initiative: Investigated further on effect of threshold value to converted image

Tuesday, June 22, 2010

AP 186 Activity 2: Scilab Basics

For research I use MATLAB, because it is useful and convenient in very visual projects, as it has a wide range of libraries that translate to a multitude of functions. Scilab is an open source software, as opposed to the very expensive MATLAB, but functions very much like MATLAB. 

In this activity, we tinkered with Scilab and its imaging toolbox otherwise known as SIP. To demonstrate our exercise, here are images of several figures we were tasked to make.

Fig 1. Centered square aperture



Fig 2. Sinusoid (corrugated roof)



Fig 3. Grating



Fig 4. Annulus



Fig 5. Circular aperture with graded transparency 
(Gaussian transparency)

CODE:

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

//circular aperture
A( find(r<0.7) )=1;

//square aperture
A(find (((Y>=-.5 & Y>=-.9) & (X>=-.5 & X>=-.9)) &((Y<=.5 & Y<=.9) & (X<=.5 & X<=.9))))=1.0;


//grating
A(find (Y>=-.9 & Y<=-.7) ) =1.0;
A(find (Y>=-.5 & Y<=-.3) ) =1.0;
A(find (Y>=-.1 & Y<=.1) ) =1.0;
A(find (Y>=.3 & Y<=.5) ) =1.0;
A(find (Y>=.7 & Y<=.9) ) =1.0;


//sinusoid
A=sin(Y*12);



//annulus
A(find (r<=0.7 & r>=0.5))=1;


//circular aperture with graded transparency
A=exp(-r);


imshow(A, []);


--
SIP is not available for Mac (boo), but a good solution is to use Wine. Wine is a software that lets you run Windows based programs on your Mac. One doesn't have to reboot to a Windows or Linux OS or to use very consuming virtual machines to be able to use Scilab with SIP.

Here is a tutorial I followed to install Wine.

I haven't installed SIP though.

--
Technical correctness: 5
Quality of presentation: 5

Thursday, June 17, 2010

AP 186 Activity 1: Digital Scanning

For this first activity, we are to analyze a scanned graph from the early twentieth century and reproduce it using today's technology. The article I chose is The Experimental Determination of the Intensities of Infra-Red Absorption Bands II. Measurements on Ethylene and Nitrous Oxide. This was published in The Journal of Chemical Physics on April 1947, not more than a year after our country's freedom from the Americans. The graph I chose was that of the experimental results for nitrous oxide. The x axis is the Equivalent Path Length measured in centimeters, while the y axis is the Integrated Apparent Absorption (also denoted by beta) measured in cycles.

Chosen graph from article, cropped.

I cropped the scanned photocopy to get the usable area, I noted the pixel locations of the graduations in the graph to get the actual values. My picture was 4.975 inches by 3.745 inches, with 200 dpi. I used Photoshop and it gave me coordinates in terms of inches. From this raw value in inches, I the pixel count may be calculated by just multiplying the value with 200. And using the graduation's pixel coordinates, I can now calculate the physical values of the points I am gathering. In the x axis, a graduation is approximately worth 1.242 inches at 200 dpi, that is, 248.4 pixels. This implied that for every 248.4 pixels measured in the x axis, there is an equivalent unit increase. For the y axis on the other hand,  a graduation measures 1.26 inches (from the cartesian origin) that is equivalent to 252 pixels. 
Reconstruction of the 2224 cm-1 band line.

Reconstruction of the 590 cm-1 band line.


Reconstruction of the 1258 cm-1 band line.

In summary, to get the physical value of the x coordinates, the noted value must be multiplied by 200 and divided by 248.4 or just multiply it by 0.8052; to get the physical value of the y coordinates, the noted value must be multiplied by 200 and divided by 252 or just multiply it by 0.7937.
Reproduced trend lines, superimposed on the original.

Unfortunately, there is a significant error in my piece due to the misaligned photocopy that I got. You may observe that the y axis has a very visible deviation especially in the upper part of the graph. This error is shown in the figure above. I must infer that even just several pixels out of line can propagate as larger errors, as can be seen above. Also, this must be a caution to those who want to squeeze out data from just given images. There are perhaps several limitations to this method, because it is quite crude and there is a lot of manual work that will surely translate to human error. A suggested improvement on the methodology is to work with a program to analyze this better.


--

Technical correctness: 5
Quality of presentation: 4
Initiative: investigated limitations of technique