Page 1 of 1

Identify images with blocks of black colour

Posted: 2015-08-22T08:35:00-07:00
by teresaejunior
Hello! I would like to know if it is possible to identify image with black blocks. I'm downloading static aerial pictures from the Google API, but for places where Google has not images available, it returns black, but with street names and other things. Example picture:

Image

Such pictures are generally smaller in size than working ones, but that is not always the case, as in the example below of an image that is small too, but has almost only the green colour:

Image

The only thing I want is for ImageMagick to identify such images as the first one, so I can delete them and retry downloading again every month.

I have the command-line ImageMagick 6.7.7.10 on Linux. Thank you for your attention!

Re: Identify images with blocks of black colour

Posted: 2015-08-22T09:05:16-07:00
by snibgo
The first image has a low mean and high standard deviation. The second has a high mean with low standard deviation. This might be a reliable indicator.

Or you could turn all non-black pixels white (within a fuzz limit, as JPEG will not create solid blacks). Then find the mean: a high value means there was litle black; a low value means there was much black. This might be more reliable.

Code: Select all

f:\web\im>%IM%convert oNarCc5.jpg -fuzz 1% -fill White +opaque Black -format %[fx:mean] info:

0.15052

f:\web\im>%IM%convert 5GzLkbj.jpg -fuzz 1% -fill White +opaque Black -format %[fx:mean] info:

0.999852
See also http://www.imagemagick.org/script/escape.php

Re: Identify images with blocks of black colour

Posted: 2015-08-22T09:56:49-07:00
by teresaejunior
That seems to be enough, @snibgo. Thank you so much!