Question

write a matlab code for histogram and histogram equallization code without built in commands

write a matlab code for histogram and histogram equallization code without built in commands

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question:

write a matlab code for histogram and histogram equalization code without built in commands.

Answer:

Histogram - Its are a type a bar plot for numeric data that group the data into bins.

Syntax for the same is as follows:

histogram(X)

histogram(X,nbins)

histogram(X,edges)

histogram('BinEdges',edges,'BinCounts',counts)

Below is the matlab code for Histogram Equalization without any in-built commands

=================================================

close all;
clear all;
clc
GIm=imread('myImage.png');
numofpixels=size(GIm,1)*size(GIm,2);
figure,imshow(GIm);
title('Original Image');
HIm=uint8(zeros(size(GIm,1),size(GIm,2)));
freq=zeros(256,1);
probf=zeros(256,1);
probc=zeros(256,1);
cum1=zeros(256,1);
output=zeros(256,1);
n=1:256;
%freq counts the occurrence of each pixel value.
%The probability of each occurrence is calculated by probf.
for i=1:size(GIm,1)
for j=1:size(GIm,2)
value=GIm(i,j);
freq(value+1)=freq(value+1)+1;
probf(value+1)=freq(value+1)/numofpixels;
end
end
figure,stem(n,probf)
title('Probability Distribution Function')
sum=0;
no_bins=255;
%The cumulative distribution probability is calculated.
for i=1:size(probf)
sum=sum+freq(i);
cum1(i)=sum;
probc(i)=cum1(i)/numofpixels;
output(i)=round(probc(i)*no_bins);
end
cum1
figure,stem(n,output)
for i=1:size(GIm,1)
for j=1:size(GIm,2)
HIm(i,j)=output(GIm(i,j)+1);
end
end
figure,imshow(HIm);
title('Histogram Equalization');

=================================================

Add a comment
Know the answer?
Add Answer to:
write a matlab code for histogram and histogram equallization code without built in commands
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT