You are on page 1of 3

# To format images to other format:1]

## to convert any rgb to grayscale we use command:- rgb2gray(image);

*we cannot convert grayscale to rgb because rgb is 3d type of image.
2] to convert index image to grayscale :- use command. ind2gray(image name);
Eg.
b1=ind2gray(b,c);
imshow(b1)
3] to convert gray to index image.:use command :- gray2ind(imagename,map v
alue);
* map value can be 8 ,16 or 32 or any type of uint8,uint16 and uint32.
Eg.
>> [i1,map]=gray2ind(d,16);
>> imshow(i1,map)
4]
to convert index image to rgb image. use command:-

ind2rgb(image,map);

Eg.
a) g1=ind2rgb(b,c);
>> imshow(g1)
5] to convert an image to black and white or binary.the image can be rgb,index
ed or grayscale image.use command:im2bw(Image,level);
* level will decide the threshold value .if level is 0.5 then the value abo
ve 0.5 will be given 1 and 0 vice versa.(0.5 means 50% pixel value);
Eg.
a)
b)

j1=im2bw(a,0.65);
>> imshow(j1)
k1=im2bw(b,c,0.3);
>> imshow(k1)

(RGB IMAGE)
(INDEXED IMAGE)

## a) to watch the histogram of an image use command:imhist(image);

the image can be only gray and binary only.t owatch histogram of it.

## b) to equalize the histogram of image.Equalizing an image will make image l

ook better. use command:- histeq(image);
c) imadjust(image name) :ding to hin by 1%

## or imadjust(image,[low-in,high-in],[low-out,high out]):mage saturation according to useer not matlab self.

>> imshow(c)
* high in and high out always has high intensity so we generally saturate
low in and low out..
out saturation we use it.

## :- to do not adjust high out and low

For RGB imges:- i) imadjust(image name, [ high in R,high in G,high in B ; low in R , low i
n G, low in B])
here the matrix is of 2*3
** this command will increase intensity of each color in images.
>> a1=imadjust(a,[0.2 0.3 0.4;0.5 0.6 0.7]);
>> imshow(a1)
*** contrast for high in and high out is always high so there is no need of a
djusting intensity of the image.
7] TO SHARPEN AN IMAGE:a) imsharpen(Image name);
* it will sharpen the image edges.
but to do it manually by user we use following command:use command:b) imsharpen(Image,'radius',radius value,'amount',amount value);
we use sharpen command when image is blur...high amount of sharpening will
give very sharp image...
>> imshow(a)
>> imcontrast(gca)
**imcontrast tool will only work with grayscale images.
\$ imcontrast(gca) will open a contrast image adjustment tool ...by which you c
an adjust contrast of image sliding the margins on histogram graph ion tool.
9] HISTOGRAM MATCHED:if you have 2 same but with different contrast images ..if both images's his
togram are matching then this command will adjust histogram of both imges.
it will plot only best area of histogram and neglect other areas.
Command is-

## imhistmatch(first image,refrence of first image);

@@ [mn,mk]=imhistmatch(a,b);
ograms is matching.

## use command imtool(image name) to watch it on image tool windows.

imtool will only work on grayscale and b&w images.we can adjust contrast and cho
ose colormap,rotate and crop the images on toolbox .
use command:- colormap(jet/pink.....etc.) after showing the image.
10] TO CROP AN IMAGE:command is--- imcrop

*** we use it to crop an area from image... after executing this command a plu
s sign(+) will be shown...use that sign to crop the image and right click to cro
p image.
but if we dotn want to do it on image show figure window and iof we know pixel
value...then we can do it manually..by using following command:Eg. imcrop(71,123,234,12);
11] TO ROTATE THE IMAGE:
imrotate(image,angle);
this will rotate the image by given angle.
{ press ctrl+c to abort the execution mode of MATLAB);
11] MORPHOLOGY:- im image processing morphological operations are resize and re
shape of binary image. (logical means 0 and 1).
to do manipulations on image binary .. two types of operations
in morphology:*** image should be binary.
1) dillation .:command is : - imdilate(image name ,Sc);
is structure element (SE)=PARAMETERS WILL BE LENGTH AND ANGLE of text
2) errosion. :command is : -

here Sc