But, help from the heavens came. :)
Thanks to Ma'am Jing for giving us tips on how to start the activity and another thanks to my seatmates, Ash, Barts and Maine, for pointing out whatever I did wrong in my codes. These people saved my day! :)
So, here I am, feeling quite proud that the the day turned out well and I'm finally done with the activity.
I will be posting here the codes that I used and the composite images I generated just to test different values for the different variables.
Centered Square Aperture
Code:
nx = 200; //number of elements along x and y
ny = 200;
x = linspace(-1,1,nx); //range of x and y
y = linspace(-1,1,ny);
[X, Y] = ndgrid(x,y); //2D arrays of x and y
a = 0.1; // limit
A = zeros(nx,ny);
A (find(X < a & X > -a)) = 1;
A (find(Y < a & Y > -a)) = 1;
A (find(X < -a & Y < a)) = 0;
A (find(X < a & Y < -a)) = 0;
A (find(X > -a & Y > a)) = 0;
A (find(X > a & Y > -a)) = 0;
imshow (A);
Increasing centered square aperture
By increasing "a", the square aperture is also increasing. It still depends though on one's algorithm.
|
Corrugated Roof
Code:
nx = 200; //number of elements along x and y
ny = 200;
x = linspace(-1,1,nx); //range of x and y
y = linspace(-1,1,ny);
[X, Y] = ndgrid(x,y); //2D arrays of x and y
w = 100; //omega
y = sin(w*[Y]);
mesh(y);
Corrugated Roof at varying values for omega |
Grating along the X-direction
Code:
nx = 200; //number of elements along x and y
ny = 200;
x = linspace(-1,1,nx); //range of x and y
y = linspace(-1,1,ny);
[X, Y] = ndgrid(x,y); //2D arrays of x and y
w = 100; // omega
y = sin(w*[Y]);
y = round(y);
imshow(y);
Annulus
Code:
nx = 200;
ny = 200;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X, Y] = ndgrid(x,y);
r = sqrt(X.^2 + Y.^2); // radius
A = zeros(nx,ny);
A (find(r > 0.8)) = 1;
A (find(r > 1 )) = 0;
imshow (A);
Increasing Radius of the Annulus Aperture |
Code:
nx = 200;
ny = 200;
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.5)) = 1;
F = fspecial('gaussian', hsize = [100,100], sigma = 0.5);
imf = imfilter(A, F);
imshow(imf);
Gaussian Transparency at Different Values for Sigma |
The sigma dictates how transparent the aperture (white circle) will be. Increasing the sigma also increases the transparency. However, at very large values for sigma, such as 10000, there isn't a really observable change if we compare it to the transparency when sigma is 1000.
I find the activity interesting and quite enjoyable. It was fun tweaking values and waiting for surprise changes in the images. Other interesting apertures can be formed depending on your parameters.
For this activity, I give myself a 10. =p
Can't wait for the next image processing topics. :)
No comments:
Post a Comment