Histogram of HSV quantized image
Mostra commenti meno recenti
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 Commento
Harsh Patel
il 4 Apr 2017
can you please provide full code from reading image to until quntization?
Risposta accettata
Più risposte (1)
Image Analyst
il 26 Dic 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 Commenti
yasmine
il 26 Dic 2011
Image Analyst
il 26 Dic 2011
Can you upload your image to tinypic.com so we can try your code?
Walter Roberson
il 27 Dic 2011
We would also need the code that constructs the original Hueblock11, Satblock1, and Valblock1.
Image Analyst
il 27 Dic 2011
Well what did you do? Because if you start with a uint8 RGB image, and use code like this:
hsvImage = rgb2hsv(rgbImage);
H = hsvImage(:,:,1); % H is double in range 0-1
S = hsvImage(:,:,2); % S is double in range 0-1
V = hsvImage(:,:,3); % V is double in range 0-1
G = 9*H + 3*S + V; % G is double in range 0-13
[pixelCount, hueValues] = imhist(H);
then H, S, V, and G will all be double. H will be in the range 0-1, G will be in the range 0-13, and the histogram (pixelCount) will be continuous, not just in the first and last bin.
Walter Roberson
il 27 Dic 2011
The 256X384 size and the (8,3,3) (72 bin) quantization scheme are fairly tied to a particular CBIR paper in which hue expressed in "degrees".
The documentation for rgb2hsv does not explicitly talk about return types when RGB images are being processed (only when a colormap is being processed.) Unfortunately I cannot test at the moment.
Image Analyst
il 27 Dic 2011
From the histogram, both imhist and hist, it's clear that, for some reason G is binary. It has only two values even though it may be double instead of logical. I think we can only solve this if she gives the actual code.
yasmine
il 27 Dic 2011
yasmine
il 27 Dic 2011
yasmine
il 27 Dic 2011
Walter Roberson
il 27 Dic 2011
After your line
hsvimage= rgb2hsv(images);
add
hsvimage(:,:,1) = hsvimage(:,:,1) * 360;
With regard to using histc(), the code I gave is a real example that only needs you to fill in the rest of the Hbins values
yasmine
il 27 Dic 2011
yasmine
il 27 Dic 2011
Walter Roberson
il 27 Dic 2011
What code are you using at present to create the histogram ? If you are using imhist() then you cannot use that, as imhist() expects values to be in the range 0 to 1 (unless the values are uint8 or uint16 data type, which your values would not be.)
yasmine
il 27 Dic 2011
Walter Roberson
il 27 Dic 2011
More simply,
xmin = min(x(:));
y = (x - xmin) ./ (max(x(:)) - xmin);
On the other hand, if you use hist() instead of imhist() then you do not need to do this normalization at all.
yasmine
il 27 Dic 2011
Image Analyst
il 28 Dic 2011
Wait a minute. You accepted Walter's answer but never said what the problem was - why you had only two values in your histogram. I suggested that they were doubles and needed to be in the range 0-1 or else use hist() instead of imhist(). But you said NO, they are integers. Then later you admitted they were in fact doubles. So how did you finally get it to work so that you had values in more than 2 bins?
Walter Roberson
il 28 Dic 2011
In the comment after she gave the link for the picture, she did say that before quantization the hues came out min value=0 and max value= 0.9167 -- so indeed not integers. But she probably figured she needed them to be integers as otherwise the 75's and 316's and so on would not be usable. And those values are taken right from the paper so they "had" to be right. Of course she could have divided all those boundary values by 360 and worked in double, but the Inertia of Authority is pretty powerful.
Image Analyst
il 28 Dic 2011
OK fine, but why only two bins?
Naushad Varish
il 11 Mag 2018
Modificato: Naushad Varish
il 11 Mag 2018
Please provide the code. It is still not working properly.
Image Analyst
il 11 Mag 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.
Categorie
Scopri di più su Convert Image Type in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!