Histogram of HSV quantized image
이전 댓글 표시
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
Harsh Patel
2017년 4월 4일
can you please provide full code from reading image to until quntization?
채택된 답변
추가 답변 (1개)
Image Analyst
2011년 12월 26일
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
yasmine
2011년 12월 26일
Image Analyst
2011년 12월 26일
Can you upload your image to tinypic.com so we can try your code?
Walter Roberson
2011년 12월 27일
We would also need the code that constructs the original Hueblock11, Satblock1, and Valblock1.
Image Analyst
2011년 12월 27일
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
2011년 12월 27일
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
2011년 12월 27일
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
2011년 12월 27일
yasmine
2011년 12월 27일
yasmine
2011년 12월 27일
Walter Roberson
2011년 12월 27일
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
2011년 12월 27일
yasmine
2011년 12월 27일
Walter Roberson
2011년 12월 27일
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
2011년 12월 27일
Walter Roberson
2011년 12월 27일
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
2011년 12월 27일
Image Analyst
2011년 12월 28일
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
2011년 12월 28일
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
2011년 12월 28일
OK fine, but why only two bins?
Naushad Varish
2018년 5월 11일
편집: Naushad Varish
2018년 5월 11일
Please provide the code. It is still not working properly.
Image Analyst
2018년 5월 11일
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.
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!