Why does RGB2HSV return an incorrect result for double images in MATLAB 7.7(R2008b)?
2 views (last 30 days)
Show older comments
When I used rgb2hsv on a double image, I expected return numbers of less than or equal to 1.0.
For example, the following code snippet results in [0.0370 0.5385 117.0000] whereas I expected [0.0370 0.5385 0.4588].
Reproduction steps:
x=[117,68,54]
class(x)
rgb2hsv(x)
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
This is an expected behavior in MATLAB 7.7 (R2008b) in the way the function RGB2HSV handles double images.
The reason is as follows:
When working with images, MATLAB assumes that if the datatype of the image is double then the range of input values are from 0 to 1. So in the case where the input x is double, one should scale the inital vector [117,68,54] by 255 to get the correct answers.
x=[117,68,54]/255
rgb2hsv(x)
For more information on 8-bit and 16-bit image handling in MATLAB, please refer the following:
<http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f2-1667.html>
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!