replace black rectangles with white

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
gatorfalcon
Posts: 1
Joined: 2014-01-24T22:22:30-07:00
Authentication code: 6789

replace black rectangles with white

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: replace black rectangles with white

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: replace black rectangles with white

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply