Borrar filtros
Borrar filtros

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

40 visualizaciones (últimos 30 días)
Harshit
Harshit el 26 de Feb. de 2013
Respondida: DGM el 5 de Jul. de 2022
i want to calculate brightness,hue,saturation and contrast of an image.

Respuestas (3)

Jurgen
Jurgen el 26 de Feb. de 2013
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 comentarios
DGM
DGM el 5 de Jul. de 2022
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.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 5 de Jul. de 2022
Useful conversions on the Math section here:
and here:

DGM
DGM el 5 de Jul. de 2022
@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(:));

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by