0% found this document useful (0 votes)
48 views5 pages

Lab 3 PDF

The document describes an experiment to perform histogram equalization and specification on an image. It reads in an image, plots the original histogram, then performs equalization using built-in and custom functions. For the custom method, it calculates the histogram, cumulative distribution function, and maps pixels to equalize the histogram. Plots show the original, equalized, and their histograms. Histogram equalization using built-in functions is also demonstrated for comparison.

Uploaded by

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

Lab 3 PDF

The document describes an experiment to perform histogram equalization and specification on an image. It reads in an image, plots the original histogram, then performs equalization using built-in and custom functions. For the custom method, it calculates the histogram, cumulative distribution function, and maps pixels to equalize the histogram. Plots show the original, equalized, and their histograms. Histogram equalization using built-in functions is also demonstrated for comparison.

Uploaded by

nandkishor joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment-3

Date: / /2013

AIM:
To read an image, plot its histogram then do histogram equalization and
histogram specification. Comment in the result. (With and Without using
inbuilt functions)

Goswami Pratikgiri R.(120420704006) Page 1


Histogram Equalization [inbuilt function]
clear all;
clc;
close all;

img = imread('cameraman.tif');
subplot(2,2,1); imshow(img); title('Original Image');
subplot(2,2,2); imhist(img);

img1 = histeq (img);


subplot(2,2,3);imshow(img1);title('Histogram equalization');
subplot(2,2,4);imhist(img1);

Goswami Pratikgiri R.(120420704006) Page 2


Histogram Equalization [user defined]

clc;
clear all;
close all;
img = imread('cameraman.tif');
subplot(2,3,1)
imshow(img);
title('Original Image');

[r,c]=size(img);
for k=0:255
count=0;
for i=1:r
for j=1:c
if (img(i,j)==k)
count=count+1;
end
N(1,k+1)=count;
end
end
end
x=0:1:255;
subplot(2,3,2)
stem(x,N);
title('Histogram of original image');

s=zeros(r,c);

for L=1:256
for i=1:r
for j=1:c
if img(i,j)==L-6

for k=1:L
s(i,j)=s(i,j)+(N(k)/(r*c));
end
s(i,j)=255*s(i,j);
end
end
end
end

subplot(2,3,4)
imshow(s,[]);
title('equalized image');

x=0:1:255;
subplot(2,3,5)
stem(x,s(x+1));
title('histogram of equalized image');

Goswami Pratikgiri R.(120420704006) Page 3


subplot(2,3,3)
imhist(img,64)
title('using inbuilt command')

eq=histeq(img);
subplot(2,3,6)
imhist(eq,64)
title('using inbuilt command')

Goswami Pratikgiri R.(120420704006) Page 4


Histogram Specialization

Goswami Pratikgiri R.(120420704006) Page 5

You might also like