Page 1 of 1

replace black rectangles with white

Posted: 2014-01-24T22:49:07-07:00
by gatorfalcon
I have an image that is a scanned page that has been redacted by having black rectangles drawn on various parts of the image. I would like to automatically find these rectangles and change them from black to white.

I'm a newbie, so if you do have an answer, would you mind spelling it out? Reviewing the forum, I see that possibles are using mogriphy to find the center of the rectangles and then do something with the results of that.

I'm also on windows, so I probably already have one strike against me.

Thanks.

-Dan

Re: replace black rectangles with white

Posted: 2014-01-24T23:33:04-07:00
by fmw42
Post a link to an example image. You can post your image to some free image hosting service and put a link to it here. From the sounds of it, this may be a hard thing to do, if you also have black letters on a white background.

mogrify likely is not what you want to use. Probably convert is what you need due to the complexity of the processing that may be needed. You may have to create a script loop over each image you want to process.

Re: replace black rectangles with white

Posted: 2014-01-25T06:32:10-07:00
by snibgo
If you just have a single page, it would be faster to do the job in Gimp.

For hundreds of pages, it would be worth writing a script. Perhaps all the redactions are the same height, say 15 pixels. Then resizing by multiplying the height by 1/15 might identify the exact x-coords of each redaction, and the approx y-coord, without false positives.