[英]Detect black/almost black JPG images in PERL
I want to detect the black/almost black JPEG images from a folder using PERL. 我想使用PERL从文件夹中检测黑色/几乎黑色的JPEG图像。 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: 您可以在命令行中使用ImageMagick的
identify
获得图像像素的平均值,如下所示:
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: 或像这样使用
Perl
:
#!/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. 在Perl的情况下,范围是0-65535,因此深色的平均值小于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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.