http://upload.wikimedia.org/wikipedia/en/7/7c/Adaptative_8bits_palette_sample_image.png
Sunday, June 27, 2010
Activity 3 - Image Type and Formats
http://upload.wikimedia.org/wikipedia/en/7/7c/Adaptative_8bits_palette_sample_image.png
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');
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');
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');
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');
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”.
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.
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.