Vous êtes sur la page 1sur 3

Lab – 1 thresholding

I = imread('Desert.jpg');

#reading a color image…

figure();

imshow(I);title('original img');

R=I(:,:,1);

G=I(:,:,2);

B=I(:,:,3);

#Dividing into R G B scales of a color img

Gray = (R+G+B)/3;

#converting color img to gray scale…

figure();

imshow(‘Gray’);

figure();

subplot(321);
imhist(R);title('histogram of R scale');

subplot(322);

imshow(R);title('R-scale img');

subplot(323);

imhist(G);title('histogram of G scale');

subplot(324);

imshow(G);title('G scale img');

subplot(325);

imhist(B);title('histogram of B scale');

subplot(326);

imshow(B);title('B scale img');

#Getting the histograms of all the scales using imhist command which can be used for thresholding

R1=(R<150);

R2=im2bw(R,0.44);

figure();

subplot(321);

imshow(R1);title('manual threshold R scale');

subplot(322);
imshow(R2);title('cmd threshold R scale');

G1=(G>100&G<150);

G2=im2bw(G,0.75);

subplot(323);

imshow(G1);title('manual threshold G scale');

subplot(324);

imshow(G2);title('cmd threshold G scale');

B1=(B>200&B<220);

B2=im2bw(B,0.66);

subplot(325);

imshow(B1);title('manual threshold B scale');

subplot(326);

imshow(B2);title('cmd threshold B scale');

# thresholding of the RGB scales using im2bw command and manual by the histogram graph

Conclusion:
In this experiment had done the thresholding on BW and color images. The main use of the thresholding is to get the
part of image which we want. It literally mean that extracting a part of image either automatically (or) by manually.
For doing that job manually we need the histogram of the image. By the histogram we can set the range of the image
to be extracted.

Vous aimerez peut-être aussi