how can i calculate brightness,contrast,hue and saturation of a image?
41 次查看(过去 30 天)
显示 更早的评论
i want to calculate brightness,hue,saturation and contrast of an image.
0 个评论
回答(3 个)
Jurgen
2013-2-26
Assuming its an rgb image, you can do rgb2hsv to find the hue and saturation of pixels. Value is similar to brightness, but you may mean brightness from the hsb space. There is no function rgb2hsb.
Also note that saturation is/could be defined differently in other colorspaces. E.g. saturation of a pixel in hsl space is not the same as its saturation in hsv space.
Contrast could be defined as a ratio. E.g. highest brightness / lowest brightness in image.
2 个评论
DGM
2022-7-5
For sake of clarity, "HSB" typically refers directly to HSV -- asymmetric saturation space and all. So there really isn't any need for rgb2hsb() to exist.
DGM
2022-7-5
@Jurgen's answer recommending HSV is probably as appropriate as the vague question warrants. Still, since it seems people are still reading this question looking for similar answers, I might as well throw this out there.
If you want to calculate "brightness", you'll have to define what "brightness" means. If I had a bag of flour that had a "heaviness" of 3.2, what would that mean? These words have poor specificity. As Jurgen suspects, "brightness" may refer to B in HSB, which is synonymous with Value in HSV -- i.e. the maximum RGB value. As measures of "brightness" go, V is probably the worst available. You could use any other brightness metric if you wanted:
Similarly, hue is not the same in all color models. The angular (hue) displacement between two colors is also not consistent between different models. You'll have to choose what color model you want to consider.
Similarly, "contrast" is a nonspecific term. It could mean anything from a simple difference or ratio of extrema to a relatively complex expression. You'll have to pick a method that's suited to your task. A good starting point might be
simplecontrast = range(myimage(:))/mean(myimage(:));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!