Thursday, June 13, 2013

Creating synthetic images using Scilab



In this activity, we created two-dimensional images using Scilab. The following images were generated, along with the Scilab code:
Figure 1. Circular aperture of radius 0.6

Figure 2. Annulus with inner radius of 0.4 and outer radius of 0.7


 Figure 3. Square of dimension 1.0x1.0 centered at (0,0)



Figure 4.  Sinusoidal pattern along the x-axis (corrugated roof). 

The frequency of the sinusoidal pattern was set to three. This means that there will be three peaks within one unit. As you can see, there are three bright bands from -1 to 0 and another three from 0 to 1. Also, the value was scaled to zero to one so that the lowest value of the sine wave (which is now zero) corresponds to the lowest value of the color map and the highest value (which is now one) corresponds to the highest value of the color map. 

Figure 5.  Three-dimensional representation of the sinusoidal pattern along the x-axis (corrugated roof). 

Using the plot3d function of Scilab, Figure 5 was produced. The code snippet is as follows:
nx = 100;
ny = 100;
x = linspace(-1, 1, nx);
y = linspace(-1, 1, ny);
[X, Y] = ndgrid(x,y);
A = zeros(nx, ny);
frequency = 3;
A = (sin(2*frequency*%pi*X)+1)/2;
plot3d(x, y,A)
Figure 6. Grating with spacing of 50 units. Since the entire x-axis of the image has 500 units, the code produced 5 pairs of white and black bands to create the grating pattern.

Figure 7. Circular aperture with a Gaussian gradient. The standard deviation of the Gaussian function was 0.5

Recall the Gaussian distibution function:
$\begin{equation}
f(r) = A e^{-\frac{(r-B)^2}{2 \sigma^2}}
 \end{equation}$

With A = 1 and B = 0, the circular aperture is centered at (0,0) with the maximum amplitude of the gradient equal to 1. The line "A(find(r>0.7)) = 0;" simply sets the boundary of the aperture. Without this, we will see a continuously fading image from the center outward.

Also, the pattern can be changed by varying the $\sigma$:
Figure 8. Varying the standard deviation of the Gaussian distribution function. The standard deviation increases from the top left to top right then from bottom left to bottom right.

In this activity, I would rate my performance as 10/10. My classmates, Eric Limos and Alix Santos, were very kind to help me in learning Scilab and performing the activity.

References:
1. Soriano, M. Applied Physics 186 A3 - Scilab basics.

No comments :

Post a Comment