Python: Normalize image exposure

后端 未结 3 549
梦谈多话
梦谈多话 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:20

    Histogram equalisation works surprisingly well for this kind of thing. It's usually better for photographic images, but it's helpful even on line art, as long as there are some non-black/white pixels.

    It works well for colour images too: split the bands up, equalize each one separately, and recombine.

    I tried on your sample image:

    Using libvips:

    $ vips hist_equal sample.jpg x.jpg
    

    Or from Python with pyvips:

    x = pyvips.Image.new_from_file("sample.jpg")
    x = x.hist_equal()
    x.write_to_file("x.jpg")
    

提交回复
热议问题