how can i calculate brightness,contrast,hue and saturation of a image?

45 ビュー (過去 30 日間)
Harshit
Harshit 2013 年 2 月 26 日
回答済み: DGM 2022 年 7 月 5 日
i want to calculate brightness,hue,saturation and contrast of an image.

回答 (3 件)

Jurgen
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 件のコメント
Muhammad Ali Qadar
Muhammad Ali Qadar 2015 年 2 月 8 日
mean2(I)
DGM
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.

サインインしてコメントする。


Image Analyst
Image Analyst 2022 年 7 月 5 日
Useful conversions on the Math section here:
and here:

DGM
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(:));

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by