The first image that was made was a circle aperture. This was given as an example to us. The code is shown below.
Circle Aperture
[1] nx = 100; ny = 100; //defines the the number of elements along x and y
[2] x = linspace(-1,1,nx); //defines the range
[3] y = linspace(-1,1,ny);
[4] [X,Y] = ndgrid(x,y); //creates two 2D arrays with x and y coordinates
[5] r= sqrt(X.^2 + Y.^2); //note element-per-element squaring of X and Y
[6] A = zeros (nx,ny);
[7] A (find(r<0.7) ) = 1;
[8] imshow (A, []);
The image generated from this code is shown below.
Fig. 1 Image of the circle aperture generated using Scilab
Annulus
To create the annulus, I used the lines 1 to 6 from the code to generate the circle aperture. I then add lines 7 -11 below. This was done to generate an outer and inner circle for the annulus.
[7] ro = 0.8; //radius of outer circle
[8] ri = 0.4; //radius of inner circle
[9] A(find(r<ro)) = 1;
[10] A(find(r<ri)) = 0;
[11] imshow(A, []);
Fig. 2 Image of the annulus generated using Scilab
Circular aperture with graded transparency
To create the circular aperture with graded transparency, I once again used lines 1 to 6 from the code to generate the circle aperture. I add to the code lines 7-8 since I assumed a gaussian distribution for the beam and multiplied the matrix of the circular aperture with it.
[7] G = exp(-4*X.^2 - 4*Y.^2); //gaussian multiply to matrix
[8] imshow(G,[]);
Fig. 3 Image of the circle aperture with graded transparency generated using Scilab
Centered square aperture
I added lines 5-8 to generate the aperture. The side was set to 0.3
[5] A = zeros(nx,ny);
[6] s = 0.3; //sets the length of a side
[7] A(find(abs(X) <s & abs(Y)<s))=1;
[8] imshow(A, []);
Fig. 4 Image of the centered square aperture generated using Scilab
I added lines 5-10 tp set the amplitude and frequency for the sinusoid and restricted it to zero and positive values to generate the sinusoid.
[5] A = zeros(nx,ny);
[6] a = 3; //sets the amplitude of sinusoid
[7] f = 30; //sets the frequency of sinusoid
[8] A = a*sin(f*X);
[9] A = A + abs(min(A)); // restricts to non-negative values
[10] imshow(A, []);
Fig. 5 Image of the sinusoid along x-direction generated using Scilab
Grating along the x-direction 8 divisions
I add lines 5-10 to the code. What this does is divide the elements along x by 8 to produce a grating with 8 divisions.
[5] A = zeros(nx,ny);
[6] A(1:nx/8, 1:ny) = 1;
[7] A(2*nx/8:3*nx/8, 1:ny) = 1;
[8] A(4*nx/8:5*nx/8, 1:ny) = 1;
[9] A(6*nx/8:7*nx/8, 1:ny) = 1;
[10] imshow(A, []);
Fig. 6 Image of the grating generated using Scilab
For this activity, I would give myself a grade of 9/10. It was a little bit rushed so my presentation wasn't that great and very detailed but I did all the requirements. The image generated looked correct. I would like to thank Ma'am Soriano for the tip she gave me to make my scilab and sip toolbox work. I also looked at the Scilab hands on tutorial by satish annigeri.
Walang komento:
Mag-post ng isang Komento