Python: Normalize image exposure

后端 未结 3 556
梦谈多话
梦谈多话 2021-02-06 04:38

I\'m working on a project to measure and visualize image similarity. The images in my dataset come from photographs of images in books, some of which have very high or low expos

3条回答
  •  长情又很酷
    2021-02-06 05:37

    It's very hard to say if it will work for you without seeing a larger sample of your images, but you may find an "auto-gamma" useful. There is one built into ImageMagick and the description - so that you can calculate it yourself - is:

    Automagically adjust gamma level of image.

    This calculates the mean values of an image, then applies a calculated -gamma adjustment so that the mean color in the image will get a value of 50%.

    This means that any solid 'gray' image becomes 50% gray.

    This works well for real-life images with little or no extreme dark and light areas, but tend to fail for images with large amounts of bright sky or dark shadows. It also does not work well for diagrams or cartoon like images.

    You can try it out yourself on the command line very simply before you go and spend a lot of time coding something that may not work:

    convert Tribunal.jpg -auto-gamma result.png
    

    You can do -auto-level as per your own code beforehand, and a thousand other things too:

    convert Tribunal.jpg -auto-level -auto-gamma result.png
    

提交回复
热议问题