0% found this document useful (0 votes)
56 views3 pages

Lab - 1 Thresholding: I Imread ('Desert - JPG') #Reading A Color Image Figure Imshow (I) Title ('Original Img')

The document discusses thresholding techniques applied to an image. It reads in a color image, separates it into the red, green, and blue color scales. Histograms are generated of each color scale and used to manually threshold each scale by setting pixel value ranges. Automatic thresholding is also performed on each scale using the im2bw command. The results of manual versus automatic thresholding are displayed for each color scale and thresholding is used to extract parts of the image.

Uploaded by

surya teja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views3 pages

Lab - 1 Thresholding: I Imread ('Desert - JPG') #Reading A Color Image Figure Imshow (I) Title ('Original Img')

The document discusses thresholding techniques applied to an image. It reads in a color image, separates it into the red, green, and blue color scales. Histograms are generated of each color scale and used to manually threshold each scale by setting pixel value ranges. Automatic thresholding is also performed on each scale using the im2bw command. The results of manual versus automatic thresholding are displayed for each color scale and thresholding is used to extract parts of the image.

Uploaded by

surya teja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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.

You might also like