Sunday, June 27, 2010

Activity 3 - Image Type and Formats

In this activity, basic image and advance image types have been studied. Examples of the four basic types of image such as binary, grayscale, true color and indexed images have been collected.

Figure 1.a. shows an example of a binary image, which is composed of either black or white image. The pixel values of this type of image is either ones (1’s) or zeros (0’s) or BITS. Other files such as document text, fingerprints, lineart, particle tracks, or signatures are saved as binary in order to get the information needed that may be found in line shapes.

Figure 1.a. Binary Image


The black and white image shown in Figure 1.b. is an example of a grayscale image. In this type, each pixel is given a value from 0 (black) to 255 (white), resulting to a byte-size per pixel. If the information needed are embedded in graytones, images are then saved as grayscale. Examples of these are medical or biological images and faces for face recognition.


Figure 1.b. Grayscale Image


Figure 1.c. shows an image with three channels or bands, wherein each channel is the intensity of a red. Green, and blue primary light. In a truecolor image, there are 2563 or about 1.6 million possible number of colors.

Figure 1.c. Truecolor Image. (from Personal File)



An indexed image whose colors are represented by numbers which denote the index of the colors in a color map is shown in Figure 1.d. In an indexed image, the image and its color map are the two sets of data stored.

Figure 1.d. Indexed Image
http://upload.wikimedia.org/wikipedia/en/7/7c/Adaptative_8bits_palette_sample_image.png

In the following, advanced types of images are shown. In Figure 2.a., a high dynamic range (HDR) image is shown. This type of image can be stored in 10- to 16-bit grayscales.

Figure 2.a. High Dynamic Range Image


Figure 2.b. shows image with more than 3 bands (Red, Green and Blue).Iimages with bands in the order of 10’s are multispectral image, while those in order of 100’s are hyperspectral images.

Figure 2.b. Hyperspectral Image.


In 3D images, the spatial 3d information can be stored. The 3D surfaces may be saved as point clouds (x,y,z), image stacks, stereopairs. Figure 2.c shows an example of 3D image.

Figure 2.c. 3D Image (from Personal File)

+ + + +

The scanned image in activity 1 was converted to grayscale and to black and white image. Thresholding was done to remove the background of the graph. Figure 4 shows how the value of the thresholding affects the conversion of the image. Among the following images, Figure 4.c. shows the image with best quality. If the thresholding is above 0.90, the coversion shows a noisy image. If the thresholding below 0.50, the lines in the graph becomes thinner.



Figure 3. Scanned Image from a Journal



thresholding = 0.40

thresholding = 0.50

thresholding = 0.60

thresholding = 0.65

thresholding = 0.70

thresholding = 0.75


thresholding = 0.80


thresholding = 0.85

thresholding = 0.90
Figure 4. Conversion to Black and White image with different thresholding.



I give myself only 8/10 points for this activity since I feel that I wasn't able to discuss some details thoroughly.

Tuesday, June 22, 2010

Activity 2: Basic Scilab and Images

In this activity, we used scilab as the programming language to be used in the class. Basic matrix operations in scilab, namely Addition, Multiplication, Element per Element multiplcation, were studied and used for creating synthetic images.

Initializations were done using the following codes:

nx = 500; ny = 500; //defines the number of elements along x and y

x = linspace(-1,1,nx); //defines the range

y = linspace(-1,1,ny);

[X,Y] = ndgrid(x,y); //creates two 2-D arrays of x and y coordinates

In figure 1, a centered circular image and a centered square image were created to simulate an aperture. The source code used is as follows:

//centered circle aperture

r = sqrt(X.^2 + Y.^2); //note element-per-element squaring of X and Y

A = zeros(nx,ny);

A(find(r<0.7))>

//scf(1); imshow(A,[]);

imwrite(A,'C:\Users\Micent\Documents\Applied Physics\acad 2010-2011 1st sem\App Phy 186 - Instrumentation Physics II\Activity 2\centered_circle_aperture.png');

//centered square aperture

A = zeros(nx,ny);

A(find(((abs(X)<0.7))&(abs(y)<0.7)))>

//scf(2); imshow(A,[]);

imwrite(A, 'C:\Users\Micent\Documents\Applied Physics\acad 2010-2011 1st sem\App Phy 186 - Instrumentation Physics II\Activity 2\centered_square_aperture.png');




Circular Aperture

Square Aperture
Figure 1. Simulated Apertures



In figure 2, a corrugated roof image was created using a sinusoid along the x-direction. A translation in the function was done to remove negative values in the matrix. In figure 2.a, observe that the image does not show a smooth transition of colors. That is why, normalization was done to produce a smoother image.

//sinusoid along the x-direction

A = zeros(nx,ny);

A = 2*sin(10*X);

A = A + abs(min(A)); //offset

A = A/max(A); //normalize

//scf(3); imshow(A,[]);

imwrite(A, 'C:\Users\Micent\Documents\Applied Physics\acad 2010-2011 1st sem\App Phy 186 - Instrumentation Physics II\Activity 2\sinusoid_along_X.png');



(a)
(b)
Figure 2. Simulated sinusoid along x-direction


Figure 3 shows an image of grating in the x-direction and an annulus. The source code used is written below:

//grating along the x-direction

A = zeros(nx,ny);

A(find(abs(X)<0.9))>

A(find(abs(X)<0.7))>

A(find(abs(X)<0.5))>

A(find(abs(X)<0.3))>

A(find(abs(X)<0.1))>

//scf(4); imshow(A,[]);

imwrite(A, 'C:\Users\Micent\Documents\Applied Physics\acad 2010-2011 1st sem\App Phy 186 - Instrumentation Physics II\Activity 2\grating_along_X.png');

//annulus

r = sqrt(X.^2 + Y.^2); //note element-per-element squaring of X and Y

A = zeros(nx,ny);

A(find(r<0.7))>

A(find(r<0.4))>

//scf(5); imshow(A,[]);

imwrite(A, 'C:\Users\Micent\Documents\Applied Physics\acad 2010-2011 1st sem\App Phy 186 - Instrumentation Physics II\Activity 2\annulus.png');



(a) grating along x-direction

(b) annulus
Figure 3



In figure 4, a circular image with graded transparency was created. A 2-D Gaussian function f(x,y) = a*exp(-(x^2+y^2)/2*c^2), where a, b, c>0 and a = 1/((std dev)*sqrt(2pi)), b = mean, and c = std dev. Observe that the gradation in figure 4.a is not observable. Again, a normalization was done to show the gaussian transparency and its peak.

//circular aperture with graded transparency (gaussian transparency)

u = 0; //mean

v = 10; //variance

a = 1/sqrt(v*2*%pi);

b = u;

c = sqrt(v);

//A = zeros(nx,ny);

r = (X-b).^2 + (Y-b).^2;

A = a*exp(-r/2*c^2); //equation taken from: http://en.wikipedia.org/wiki/Gaussian_function

A = A/max(A); //normalize

//scf(6); imshow(A,[]);

imwrite(A, 'C:\Users\Micent\Documents\Applied Physics\acad 2010-2011 1st sem\App Phy 186 - Instrumentation Physics II\Activity 2\circle_aperture_gaussian.png');


(a)
(b)
Figure 4. Circular Aperture with
graded Gaussian transparency


In this activity, I give myself 10 points since I was able to produce all the required images. Also, I was able to do some additional computations that would improve the quality of the images produced. Thanks to Cheryl Abundo for clarifying some points in constructing the sinusoid and to Bernard Racoma for explaining the need to do the offset in the graph.














Wednesday, June 16, 2010

Activity 1: Digital Scanning

In this activity, a digitally scanned hand-drawn plot was obtained from an old journal in the CS Library, titled “Physical Review Jul-Dec 1922”.


Figure 1. Scanned graph from "Physical Review Jul-Dec 1922"

The pixel locations of the points in the plot were determined using GIMP application and tabulated in the Excel. The pixel location of the graph‘s origin was also determined and then subtracted to each of the predetermined pixel location of the points. This was done in order to determine the true location of the points with respect to the origin. The number of pixels along the X and Y were determined and was compared to the physical values on the graph. Through ratio and proportion, the values of the points on the graph were determined. However, in the obtained graph, the origin is located at (9,1). Translation of the points were done to correct the values. The graph was reconstructed in Excel and was compared to the scanned graph by superimposing the two.


Figure 2. Reconstructed graph with the overlaid scanned graph.


Though the smoothing done by Excel did not fit exactly with the curve of the scanned graph, I still give myself 10 points for this activity since I was able to determine correctly the values of the points on the graph. Also, I was able to overlay the scanned image on the background of the reconstructed graph. Thanks to Cheryl Abundo for helping me change the minimum and maximum axis labels of the graph in Excel, and Xylene Azurin for helping me overlay the scanned graph.