What are some methods to analyze image brightness using Python?

前端 未结 4 1804
再見小時候
再見小時候 2020-12-22 20:15

I\'d like some advice on performing a simple image analysis in python. I need to calculate a value for the \"brightness\" of an image. I know PIL is the goto library for doi

4条回答
  •  独厮守ぢ
    2020-12-22 20:52

    Given that you're just looking for an average across the whole image, and not per-pixel brightness values, averaging PIL's histogram and applying the brightness function to the output seems like the best approach for that library.

    If using ImageMagick (with the PythonMagick bindings), I would suggest using the identify command with the "verbose" option set. This will provide you with a mean value for each channel, saving you the need to sum and average a histogram — you can just multiply each channel directly.

提交回复
热议问题