I want to detect the black/almost black JPEG images from a folder using PERL. Do you have any suggestions about the method/module that I should use?
Dark images will generally have a low-ish mean pixel value.
You can get the mean of the image's pixels using ImageMagick's identify
at the command line like this:
identify -format "%[mean]" input.png
or using
identify -verbose input.png
and looking for the parameter you think will help most.
Or use Perl
like this:
#!/usr/bin/perl
use strict;
use warnings;
use Image::Magick;
my $image = Image::Magick->new;
$image->ReadImage("c.png");
print $image->Get("%[mean]");
In the Perl case, the range is 0-65535, so dark ones will have a mean below say 5,000.
Example:
Here is a dark image:
identify -format "%[mean]" dark.jpg
16914.6
And here is a lighter one:
identify -format "%[mean]" light.jpg
37265.7