Image processing basic functions using MATLAB

OK, for the long time I don’t use matlab and now I use it again. I utilize matlab to support my lecture tasks about image processing :p. I use image : anggrekku.jpg and pancasila.png to do this experiments. So prepare your images and let’s see the source code!
1. Function- RGB

 I=imread('anggrekku.jpg');
 R=I(:,:,1);
 G=I(:,:,2);
 B=I(:,:,3);
 figure, imshow(I);
 figure, imshow(R);
 figure, imshow(G);
 figure, imshow(B);

2. Function – imlincomb

imlincomb used to combine 2 images that have a same size.

I=imread('anggrekku.jpg');
I2 = imread('pancasila.png');
K =imlincomb(.5,I,.5,I2);
imshow(K);

3. Function – resize

I=imread('anggrekku.jpg');
R=imresize(I,[100,500],'bicubic');
F=imtool(R);

4. Function – rotate

I=imread('anggrekku.jpg');
R=imrotate(I,90);
F=imtool(R);

5. Function – imadjust

I=imread('anggrekku.jpg');
R=imadjust(I,[0.3,0.99],[]');
F=imtool(R);

6. Function – incomplement

I=imread('anggrekku.jpg');
J = imcomplement(I);
imshow(I), figure, imshow(J)

7. Function – rgb2ind

I=imread('anggrekku.jpg');
[X,map] = rgb2ind(I,128);
figure, imshow(I);
figure, imshow(X,map);

8. Function – rgb2gray

I=imread('anggrekku.jpg');
J = rgb2gray(I);
figure, imshow(I), figure, imshow(J);

I utilize matlab R2008b and save my files (.file and image) to F:\Users\—-\Documents\MATLAB.

Happy typing codes and do experiments!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s