Histogram of HSV quantized image
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
yasmine
am 26 Dez. 2011
Kommentiert: Image Analyst
am 11 Mai 2018
Hi i want to share with you the results of an HSV quantized image Histogram
i used an image 256X384 converted it into HSV and quantized it into (8X3X3) for H, S and V respectively and after that i made a weighted sum G= 9*H + 3*S + 3*V for this matrix i used this function:
histG=imhist(G,72)
but the output is like that:
histG =
2820
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13500
is this ok or i have something wrong ? if it is right please explain to me why i got this output.
Thank you
1 Kommentar
Harsh Patel
am 4 Apr. 2017
can you please provide full code from reading image to until quntization?
Akzeptierte Antwort
Walter Roberson
am 26 Dez. 2011
G= 9*H + 3*S + 3*V
is the wrong weighted sum. You want to add V, not 3*V .
It appears that only the low bin and the high bin are being used in the histogram, as if you had an error in your quantization that led to the results always being either (0,0,0) or the maximum value (8,3,3). The V vs 3*V would not account for this, but a quantization mistake would. Or, alternately, you might have good quantization but a black and white image is being quantized.
7 Kommentare
Walter Roberson
am 26 Dez. 2011
Do not modify HueBlock11 "in place": create a new output matrix.
Hbins = [0 20 40 75 ... 316 inf]);
Ht = histc(HueBlock11, Hbins)
H = Ht(1:end-2);
H(1) = H(1) + Ht(end-1);
Those last two lines are to put 316 upward in to the same bin as less than 20
Walter Roberson
am 26 Dez. 2011
Look at your code:
if (Hueblock11(row,col) <= 316 && Hueblock11(row,col) <= 20)
Hueblock11(row,col) = 0;
elseif (Hueblock11(row,col) >= 20 && Hueblock11(row,col) <= 40)
Hueblock11(row,col) = 1;
Now what if Hueblock11(row,col) is 20 _exactly_ ? That matches the first condition, but it also matches the second condition. The bin chosen then becomes a matter of the order you coded the tests, which is not robust. If you want the first bin to include 20 exactly, then do not have the second bin include 20 exactly in its range.
Weitere Antworten (1)
Image Analyst
am 26 Dez. 2011
yasmine: If you use imhist on floating point arrays, they need to be normalized in the range 0-1. I suggest you use hist() instead of imhist() - it doesn't have that requirement.
[pixelCounts binValues] = hist(G, numberOfBins);
21 Kommentare
Naushad Varish
am 11 Mai 2018
Bearbeitet: Naushad Varish
am 11 Mai 2018
Please provide the code. It is still not working properly.
Image Analyst
am 11 Mai 2018
naushad, I'm going to ask you the same thing. Because we gave code and the original poster accepted an answer. So there's no problem here, only with your code.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!