Detect single line of same colour

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
Lani
Posts: 1
Joined: 2014-02-18T12:47:48-07:00
Authentication code: 6789

Detect single line of same colour

Post by Lani »

Hello!

I'm aiming to make an image detection script that'll check rather large images and attempt to automatically find errors in them.

The most common sort of error is that a chunk of the image somewhere will have lines of black. This often creates large chunks of black. Needless to say, since these images are large (and scans) if there's a single monocolour line, changes are it's a bug.

How would I detect a horizontal line of single-coloured pixels in an image programmatically using ImageMagick?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Detect single line of same colour

Post by fmw42 »

Can you post a link to your image? You can upload to some free hosting service such as dropbox (public) folder and then put the link to it here.

Are the lines containing black the only black in the image or is there other black regions?

One way is to average the line down to one column. Then search the column for the black pixels.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Detect single line of same colour

Post by snibgo »

Do you want to check for entire rows that are black, or short black lines within the image? I have a standard command for turning black lines longer a certain length white. So you could:

1. Turn anything that isn't black into white.

2. Turn horizontal black lines longer than (x) pixels white.

3. If (2) is different to (1), the image has black lines.
snibgo's IM pages: im.snibgo.com
Post Reply