I have thousends of scans of old documents (all greyscale, all of different grey backgrounds). I would like to use convert-stretch on each file individually.
I thought I could use the histogram to calculate the white-point I have to use.
Sample histogram "convert Test_001.png -define histogram:unique-colors=true -format %c histogram:info:-"
Code: Select all
25289: ( 0, 0, 0) #000000 gray(0,0,0)
2986: ( 1, 1, 1) #010101 gray(1,1,1)
...
...
68148: (210,210,210) #D2D2D2 gray(210,210,210)
68784: (211,211,211) #D3D3D3 gray(211,211,211)
67654: (212,212,212) #D4D4D4 gray(212,212,212)
...
...
435: (254,254,254) #FEFEFE gray(254,254,254)
2491: (255,255,255) #FFFFFF gray(255,255,255)
But how can I do this automatically on each file? Any ideas to do that?
My version: ImageMagick 6.7.7-10 2014-03-06 Q16
Thanks!