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:
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:
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!
Identify images with blocks of black colour
-
- Posts: 2
- Joined: 2015-08-22T08:18:11-07:00
- Authentication code: 1151
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Identify images with blocks of black colour
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.
See also http://www.imagemagick.org/script/escape.php
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
snibgo's IM pages: im.snibgo.com
-
- Posts: 2
- Joined: 2015-08-22T08:18:11-07:00
- Authentication code: 1151
Re: Identify images with blocks of black colour
That seems to be enough, @snibgo. Thank you so much!