how to normalized a hsv histogram?

i want to normalize hsv histogram. i have three different of each h,s,and v. i want to normalize them so that i can compare it with h,s and v plot. for this firstly i have to normalize the histogram i tried in following way but it did not work..
rgb = imread('wheatimage.jpg');hsv = rgb2hsv(rgb);
h = hsv(:, :, 1);
v = hsv(:, :, 3);
numberOfBins = 50;
s = hsv(:, :, 2); % or whatever.
[countsH valuesH] = hist(h, numberOfBins);
figure; subplot(2, 2, 1);
bar(valuesH, countsH, 'BarWidth', 1);
title('Histogram of the H Channel', 'FontSize', 15);
[countsS, valuesS] = hist(s, numberOfBins);
subplot(2, 2, 2);
bar(valuesS, countsS, 'BarWidth', 1);
title('Histogram of the S Channel', 'FontSize', 15);
[countsV, valuesV] = hist(v, numberOfBins);
bar(valuesV, countsV, 'BarWidth', 1);
title('Histogram of the V Channel', 'FontSize', 15);%# create histogram from a normal distribution.
g=1/sqrt(2*pi)*exp(-0.5*valuesH.^2);%# pdf of the normal distribution
% DIVIDE BY AREA figure(1)
bar(valuesH,countsH/trapz(valuesH,countsH));hold on
plot(valuesH,g,'r');hold off

댓글 수: 4

Jan
Jan 2013년 7월 11일
What exactly does not work? Do you get an error message or do the results differ from your expectations?
R
R 2013년 7월 11일
the output is not a normalized histogram...
R
R 2013년 7월 11일
is their any other way to normalize hsv histogram other than this.
Jan
Jan 2013년 7월 11일
What exactly should be "normal" after the normalization? All we see is the code, which does not do what you want. But this does not allow to identify, what you want.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2013년 7월 11일

0 개 추천

What exactly should be normalized? The area under each curve or all 3 curves?
Perhaps this helps: FEX: NormalizedHistogram

댓글 수: 9

R
R 2013년 7월 11일
sir i had tried histnorm but its not working well. suggest me something valid
R
R 2013년 7월 11일
sir i want just that my histgram of h get normalize ....
Jan
Jan 2013년 7월 11일
편집: Jan 2013년 7월 11일
I cannot guess what "not well" and "valid" means in your case. Let me ask another time, what you exactly want: "normalization" can mean, that the maximum value is set to 1.0, or that the area under the fitted Gaussian distribution is set to 1.0, or that the sum of the measured values is set to 1.0, etc. I think if you find out, what you exactly want, the implementation is very easy and most likely you can solve this by your own.
Of course I could try to guess, but this is not why I want the nature of this forum should be. I like to offer assistence for learning how users can find solutions by their own.
Did you search in the net already? Perhaps Answers: normalizing a histogram helps.
Image Analyst
Image Analyst 2013년 7월 11일
And even beyond that, what if you did normalize your histogram, through whatever means and algorithm you choose? What then? Why do you want to normalize it? What do you think you can do that you can't do without it normalized? Saying you want to normalize h so that you can "compare it with h plot" doesn't really make sense. I don't know what's being compared with what.
R
R 2013년 7월 11일
yes sir i tried histnorm , i histogram should be normalize in such away that it can be compare with histogram of another image h value..the values at boundary should be clear . in case of normal histogram of hsv it is hard to identify boundary if normalize graph build on histogram its boundry get clear..
R
R 2013년 7월 11일
편집: R 2013년 7월 11일
sir from last many days i had tried what have been possible function or formula to get clear normalize histogram..
Jan
Jan 2013년 7월 11일
@Ramandeep: I have the impression that the communication got more complicated then necessary. So let's try to be as clear as possible: "normalizing a histogram" is not uniquely defined. A mathematically unique definition is required, before this can be implemented in a function. I expect something like: "The sum of XYZ is 1.0".
I do not understand, what a "clear boundary" is.
R
R 2013년 7월 11일
i want to compare to image on the base of hsv and compare their histogram on bases of chi-square dist method. so for that i want to normalize my hsv histograms..
R
R 2013년 7월 11일
comparsion is latter issue firstly graph need to be normalize.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

질문:

R
R
2013년 7월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by