Tuesday, June 21, 2011

Scilab Basics

Right of the bat I had problems with this activity. First and foremost, my scilab doesn't even know imshow and imwrite T^T. This caused me a lot of problems to the point that I had to borrow MP's laptop just to be able to complete the activity. Then another problem with imwrite shows up>,<.for some unknown reason, my figures just won't save and it took me over an hour just to realize that the problem is that unlike in matlab, scilab doesn't have a current directory so upon saving I needed to include the whole directory address to save. *sigh* -,-

Now that that's out of my system...

This activity is -like the title says- about the basics of scilab, especially in terms of image processing. In this activity we were made to create different synthetic images using scilab.

The first created image was just a practice run, in which we were given a premade code on making a numerical aperture.

Figure 1. Basic numerical aperture of size 0.7
In order to create this, 2 2-D arrays were used, one would contain the binary information of the aperture in terms of ones and zeros, the other containing the "radius" information of each pixel. This radius is then compared to a threshold which would determine the size of the aperture.those elements whose radius is greater than the threshold would be set to zero while those inside are given the value of one. This creates a filter which when used would remove anything outside the circle and retain those inside.

The next image is a centered square aperture, as shown below:

Figure 2. Centered Square Aperture
This one was easily created by setting all the picture elements within a certain range to one and everything else to zero. Not really that hard although I could still improve my code by making it easier to change the aperture size.

The third image is that of a sinusoid along the x-direction, also known as a corrugated roof:
Figure 3. Sinusoid along the X-direction.
For this image, I created a sinusoid which propagated along the x-direction. The values are then copied to all the row in order to create the sinusoidal bars.I added 1 to the values in the array to get all positive values since negative numbers are just depicted as black when the image is formed

Truth be told, the grating took me the longest time to create. this is because my initial plan was so complicated that in the end I opted not to use it. My initial plan was to use a variable that switches every number of pixels to create the bars for the grating. But before I finished it I realized that if I just set all the positive values to one and negative values to zero in the sinusoid, I would basically get the grating I needed:

Figure 4. Grating along the X- direction.

The annulus was created by using 2 circular aperture images like the one on figure 1 but with different sizes. We then multiply the 2 images element by element so that only those pixels with a value of one for both images would remain. the final product would then become something like this:
Figure 5. Annulus

The final image we needed to make was to make a circular aperture with Gaussian transparency. This was accomplished by first making a Gaussian transparency filter as shown below:

Figure 6. Gaussian Filter
This was then multiplied to a circular aperture to produce:

Figure 7. Circular aperture with Gaussian transparency

In this activity, I would give myself a 10/10 since I was able to create of the images I needed. Although there have been troubles with this activity, I had fun creating these images^^. I would like to thank MP in this activity for lending me his scilab which knows imshow and imwrite. I would like to resolve this problem before the next activity and Tracy told me that it may be because of the scilab version. That's why I will be trying to change my scilab to a 4.xx version. I hope that would fix the problem.

No comments:

Post a Comment