Tuesday, June 22, 2010

AP 186 Activity 2: Scilab Basics

For research I use MATLAB, because it is useful and convenient in very visual projects, as it has a wide range of libraries that translate to a multitude of functions. Scilab is an open source software, as opposed to the very expensive MATLAB, but functions very much like MATLAB. 

In this activity, we tinkered with Scilab and its imaging toolbox otherwise known as SIP. To demonstrate our exercise, here are images of several figures we were tasked to make.

Fig 1. Centered square aperture



Fig 2. Sinusoid (corrugated roof)



Fig 3. Grating



Fig 4. Annulus



Fig 5. Circular aperture with graded transparency 
(Gaussian transparency)

CODE:

nx = 100;
ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = meshgrid(x,y);
r=sqrt(X.^2 + Y.^2);
A=zeros (nx,ny);

//circular aperture
A( find(r<0.7) )=1;

//square aperture
A(find (((Y>=-.5 & Y>=-.9) & (X>=-.5 & X>=-.9)) &((Y<=.5 & Y<=.9) & (X<=.5 & X<=.9))))=1.0;


//grating
A(find (Y>=-.9 & Y<=-.7) ) =1.0;
A(find (Y>=-.5 & Y<=-.3) ) =1.0;
A(find (Y>=-.1 & Y<=.1) ) =1.0;
A(find (Y>=.3 & Y<=.5) ) =1.0;
A(find (Y>=.7 & Y<=.9) ) =1.0;


//sinusoid
A=sin(Y*12);



//annulus
A(find (r<=0.7 & r>=0.5))=1;


//circular aperture with graded transparency
A=exp(-r);


imshow(A, []);


--
SIP is not available for Mac (boo), but a good solution is to use Wine. Wine is a software that lets you run Windows based programs on your Mac. One doesn't have to reboot to a Windows or Linux OS or to use very consuming virtual machines to be able to use Scilab with SIP.

Here is a tutorial I followed to install Wine.

I haven't installed SIP though.

--
Technical correctness: 5
Quality of presentation: 5

No comments:

Post a Comment