Wednesday, August 20, 2014

AP 186 Activity 3 Scilab Basics

In this activity, we explore Scilab and how it can be used to make synthetic images. For practice, an example code for a circular aperture was given and it was run into Scinotes. The resulting image is shown in Figure 2.

Figure 1. Example Scinotes code that makes a circular aperture.
Figure 2. Output image of the example code that makes a circular aperture.

           The code was then examined carefully so that we can to create the following synthetic images.
     A) Centered square aperture
            For this I had to search the internet for the equation of a square. At first my code was a centered diamond aperture but a few adjustments to the code and I got a square! 
Figure 3. Code that makes the centered square aperture.
Figure 4. Output image from the centered square aperture code.
     B) Sinusoid along the x-direction (corrugated roof)  
            As the name suggests, it needs a sine function. I wanted to see more of the roof so I chose 8*%pi as my values to be put into the sine function.    
           
Figure 5. Code that makes a corrugated roof.
Figure 6. Output image from the corrugated roof code.

     C) Grating along the x-direction
             This should look like the corrugated roof but more sharp. It took me a while to figure it out.
Figure 7. Code that makes a grating along x-direction. 
Figure 8. Output image from grating along x -direction code.
     D) Annulus
             I assumed that this is just like a circle. I just need to figure out how to hollow it out and the code will show you how I solved it.
Figure 9. Code that makes an annulus.
Figure 10. Output image from annulus code.
      E) Circular aperture with graded transparency (Gaussian transparency).
                 This is one of the trickiest images. I had to search what a Gaussian transparency is.

Figure 11. Code that makes a circular aperture with graded transparency.
Figure 12. Output image from circular aperture with graded transparency code.
     F) Ellipse
             I figured out that this is just like a circle but it should be like an annulus with a hollow center.
Figure 13. Code that makes an ellipse. 
Figure 14. Output image of ellipse code.

     G) Cross
                I wanted to make this cross thicker in the vertical axis than the horizontal.

Figure 15. Code that makes a cross.
Figure 16. Output image of the code that makes a cross.
Explorations:
        I added two synthetic images, I combined the code for the cross and of the ellipse. I didn't expect to get this image. I thought that I will get an ellipse with a cross underneath. This was a really fun way to learn about making synthetic images using Scilab.
Figure 17. Code that was combined. Made using code from cross and ellipse.

Figure 18. Output image of the code from Figure 17.

         If I would rate myself I will give a 10 since I did all the required synthetic images and the exploration part.


Sources:
[1] M. Soriano, A3 - Scilab Basics 2014(PDF File). 2014
[2] Polymathprogrammer.com, Can you describe a square with 1 equation? Retrieved from: http://polymathprogrammer.com/2010/03/01/answered-can-you-describe-a-square-with-1-equation/

AP 186 Activity 2 Digital Scanning


      The goal of this activity is to scan a hand-drawn plot or x-y plot in a scientific journal then use the pixel locations of the data points and try to graph it on Microsoft Excel. The image in the journal was scanned in a flat-bed scanner with a resolution of 100 dpi. Here is my chosen graph:


Figure 1. Scanned graph that came from Natural and Applied Science Bulletin 40(4) Oct-Dec 1988 page 293.

            The first thing I did using GIMP was to crop the image, then rotate it. It is obvious by the figure above that the picture is not straight so it was rotated. Then, the ratio of the x-axis with respect to its pixels was calculated by measuring how long the x-axis is in pixels by using the angle tool in GIMP. Afterwards,  this number was divided by the maximum value in the axis which is 16. The same was done with the y-axis which was divided by the maximum value 120. The ratio of pixel to max value of the x-axis is 13.25 while for the y-axis it is 1.358.
The points in the graphs which are shaped like x’s, their pixel location was recorded and put into Microsoft Excel. The pixel location of the origin in the graph was also recorded. To get the x-coordinates to be used in the Microsoft Excel graph, the following equation was used:

           The calculated x_excel and y_excel points were plotted into Excel. A linear trendline was added since the graph has a linear trendlined. The image of the graph is then put as a background into the plot area. The writings on the bottom right of the picture were erased so that it will be focused on the graph. Note that the scale of the x and y points in the Excel graph are arbitrary units. I just copied the x and y axis titles of the original scanned graph.


Figure 2. Superimposed scanned image of the graph and plotted Excel graph.

               If I will grade myself, I will give myself a 10 since my graph was as near as the scanned graph points. I think I did very well and this shows that I did a good job in this activity. 

              I was very frustrated in rotating the graph because it is a hand-drawn graph, it is not really straight and I have to rotate the image at least seven times. Even if I have a grid in GIMP, there I had to pick which side will be the one that is straight. But I think I chose the best side since the resulting graph was ok and near the scanned graph.

             Thank you very much to Kat Bulan and Vyke Dominguez for helping me find the journal which I chose my graph. Thank you to Kat for answering my questions about the activity and helping me figure out what to do with my data.

Sources:

[1] Z.B. Domingo, "Cholesteric liquid crystals - the storage mode," Natural and Applied Science Bulletin  40(4) Oct-Dec 1988, 293.
[2] M. Soriano, A2 - Digital Scanning 2014 (PDF file). 2014.