Page 1 of 1

Detect single line of same colour

Posted: 2014-02-18T12:50:17-07:00
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?

Re: Detect single line of same colour

Posted: 2014-02-18T15:28:48-07:00
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.

Re: Detect single line of same colour

Posted: 2014-02-18T18:39:58-07:00
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.