SCILAB is a free open source software which is gaining much popularity today. SCILAB has special toolboxes SIVP and SIP for image processing.This Blog will concentrate on Digital Image Processing With SCILAB.
Saturday, March 31, 2012
Converting RGB images to gray scale images.
RGB images can be converted into gray scale images in SCILAB by usibg RGB2gray
x=imread('C:\Documents and Settings\Administrator\Desktop\Images\lena.jpg');
imshow(x).
z=RGB2Gray(x).
imshow(z).
Friday, March 30, 2012
Thursday, March 29, 2012
Reading an image in SCILAb
The imread command is used to read an image into SCILAB (Remember that SIVP must be loaded).
Z= imread('C:\Documents and Settings\Administrator\Desktop\images\lena.jpg');
will read the image into a matrix Z.
If the image is colour image,The size will be something like.
256. 256. 3.
here 256x256 is the size of the image. And the matrix will be composed of three 2D matrices each of dimension 256x256, representing the RGB values.
Also imshow(Z) displays the image. as shown above.
Z= imread('C:\Documents and Settings\Administrator\Desktop\images\lena.jpg');
will read the image into a matrix Z.
If the image is colour image,The size will be something like.
256. 256. 3.
here 256x256 is the size of the image. And the matrix will be composed of three 2D matrices each of dimension 256x256, representing the RGB values.
Also imshow(Z) displays the image. as shown above.
Sunday, March 25, 2012
Montage in Scilab
It is often needed to display images as a montage side by side in scilab. The following functions will be helpful in doing the same.This program is given under GNU GPL
To create a montage ,just store the urls of the images into an array (say z1). and call the following
[z2,x2]=montage(z1,[500,500],5)
Here 500,500 is the size of the new image formed as a montage,and 5 is the number of images per row.
x2=0 if the process is a success.
Now if you call imshow(z2) you will get the image displayed on the screen.
Now feel free to use the code below under GNUGPL.
Note that SIVP / SIP toolboxes are required for this.
Code Developed by Dr.Kannan Balakrishnan,Department of computer applications,Cochin University of science and technology,cochin-22,India
Also in case of any doubt or clarifications,please feel free to mail me at mullayilkannan (at) gmail.com
function [Frame ,x]=deposit(Frame,Im,x1,y1)
//deposits an image Im in a frame Frame,starting from(x1,y1)
//disp("deposit called/n/n",x1,y1)
t=size(Im)
r=size(t)
if(r(1,2)==2)//greyscale image
I=zeros(t(1),t(2),3)//convert to RGB
I(:,:,1)=Im
I(:,:,2)=Im
I(:,:,3)=Im
else
I=Im
end
//xtemp =size(I);
//print("Size of the image, I");
//disp(xtemp);
[a1,b1,c1]=size(I);
b=size(Frame)
if(a1+x1-1)>b(1)
print "frame size exceeded in function deposit" ;
x=1;
return
end
if(b1+y1-1>b(2))
disp('frame size exceeded in function deposit');
x=1;
return;
end
printf("OKAY");
stacksize(80000000);
//Frame(x1,y1,1)=0.5;
z=zeros(a1+1,b1+1,3);
z(1:a1,1:b1,1:3)=I;//this step is needed to comvert I to a matrix
//of ordinary numbers instead of 0..255
//imshow(z);
m1=max(z);
z=z/m1;
Frame(x1:(x1+a1-1),y1:y1+b1-1,1:3)=z(1:a1,1:b1,1:3);
x=0;
endfunction
function [Frame, x]=resizeAndDeposit(Frame,I,x1,y1,rowsize,columnsize)
//make a copy of the image I resized into rowsize x columnsize and places that in the prescribed position
Z=imresize(I,[rowsize,columnsize],'bicubic')
[Frame,x]=deposit(Frame,Z,x1,y1)
endfunction
function [Frame,x]=montage(Imagearray,Framesize,ImagesInRow)
//here imagearray is an array of imageurls
//framesize is of the form[rows,columns]
//imagesInRow is an integer corresponding to the number of images in a row
//x=0 if the operation is sucessful else 1
var1=size(Imagearray)
nImages=var1(1)//number of images
disp(nImages);
nrows=round(nImages/ImagesInRow+0.49) ;
ncols=ImagesInRow;
disp([nrows,ncols])
Frame=zeros(Framesize(1),Framesize(2));
Imagedim1=round(Framesize(1)/nrows)
Imagedim2=round(Framesize(2)/ncols)
//disp([Imagedim1,Imagedim2]);
count=1;
posx=1;
posy=1;//current x and y positions
for(i=1:nrows)
for(j=1:ncols)
t=imread(Imagearray(count))
//count=count+1;
//disp("**************************************")
//disp("posx:",posx,"posy:",posy,"count:",count);
//disp("**************************************")
;
[Frame,x]=resizeAndDeposit(Frame,t,posx,posy,Imagedim1,Imagedim2)
clear t;
posy=posy+Imagedim2
count=count+1
disp(count);
if(count>nImages)
return;
end
end
posy=1
posx=posx+Imagedim1
end
endfunction
To create a montage ,just store the urls of the images into an array (say z1). and call the following
[z2,x2]=montage(z1,[500,500],5)
Here 500,500 is the size of the new image formed as a montage,and 5 is the number of images per row.
x2=0 if the process is a success.
Now if you call imshow(z2) you will get the image displayed on the screen.
Now feel free to use the code below under GNUGPL.
Note that SIVP / SIP toolboxes are required for this.
Code Developed by Dr.Kannan Balakrishnan,Department of computer applications,Cochin University of science and technology,cochin-22,India
Also in case of any doubt or clarifications,please feel free to mail me at mullayilkannan (at) gmail.com
function [Frame ,x]=deposit(Frame,Im,x1,y1)
//deposits an image Im in a frame Frame,starting from(x1,y1)
//disp("deposit called/n/n",x1,y1)
t=size(Im)
r=size(t)
if(r(1,2)==2)//greyscale image
I=zeros(t(1),t(2),3)//convert to RGB
I(:,:,1)=Im
I(:,:,2)=Im
I(:,:,3)=Im
else
I=Im
end
//xtemp =size(I);
//print("Size of the image, I");
//disp(xtemp);
[a1,b1,c1]=size(I);
b=size(Frame)
if(a1+x1-1)>b(1)
print "frame size exceeded in function deposit" ;
x=1;
return
end
if(b1+y1-1>b(2))
disp('frame size exceeded in function deposit');
x=1;
return;
end
printf("OKAY");
stacksize(80000000);
//Frame(x1,y1,1)=0.5;
z=zeros(a1+1,b1+1,3);
z(1:a1,1:b1,1:3)=I;//this step is needed to comvert I to a matrix
//of ordinary numbers instead of 0..255
//imshow(z);
m1=max(z);
z=z/m1;
Frame(x1:(x1+a1-1),y1:y1+b1-1,1:3)=z(1:a1,1:b1,1:3);
x=0;
endfunction
function [Frame, x]=resizeAndDeposit(Frame,I,x1,y1,rowsize,columnsize)
//make a copy of the image I resized into rowsize x columnsize and places that in the prescribed position
Z=imresize(I,[rowsize,columnsize],'bicubic')
[Frame,x]=deposit(Frame,Z,x1,y1)
endfunction
function [Frame,x]=montage(Imagearray,Framesize,ImagesInRow)
//here imagearray is an array of imageurls
//framesize is of the form[rows,columns]
//imagesInRow is an integer corresponding to the number of images in a row
//x=0 if the operation is sucessful else 1
var1=size(Imagearray)
nImages=var1(1)//number of images
disp(nImages);
nrows=round(nImages/ImagesInRow+0.49) ;
ncols=ImagesInRow;
disp([nrows,ncols])
Frame=zeros(Framesize(1),Framesize(2));
Imagedim1=round(Framesize(1)/nrows)
Imagedim2=round(Framesize(2)/ncols)
//disp([Imagedim1,Imagedim2]);
count=1;
posx=1;
posy=1;//current x and y positions
for(i=1:nrows)
for(j=1:ncols)
t=imread(Imagearray(count))
//count=count+1;
//disp("**************************************")
//disp("posx:",posx,"posy:",posy,"count:",count);
//disp("**************************************")
;
[Frame,x]=resizeAndDeposit(Frame,t,posx,posy,Imagedim1,Imagedim2)
clear t;
posy=posy+Imagedim2
count=count+1
disp(count);
if(count>nImages)
return;
end
end
posy=1
posx=posx+Imagedim1
end
endfunction
Thursday, March 22, 2012
Welcome To Image Processing In SCILAB
Sci lab is a powerful open source software for scientific computation. In this Blog We will discuss the image processing capabilities of SCI LAB.
Subscribe to:
Posts (Atom)