PHP,检测水印图像? [英] PHP, detecting watermarked images?

查看:224
本文介绍了PHP,检测水印图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似100万张图片的图书馆,其中大约有一半是在同一地点加上相同的,半透明水印的水印。

I have a library of like 1 million images, and roughly half of these are watermarked with the same, half transparent watermark in the same spot.

我在哪里开始,用水印检测图像?是否有一些标准工具用于此目的?

Where do I begin, detecting the images with the watermarks? Is there some standard tools for this purpose?

推荐答案

如果根据您的问题,您只想检测带水印的图像,您可以使用以下算法:

If according to your question, you just want to detect the images that are watermarked, you can use the following algorithm:


  • 提取水印图像样本扫描水印图像

  • 逐个像素地存储数组中的第一个像素。逐个像素地扫描每个

  • 图像并存储在一个数组中。每当来自被扫描图像的行矩阵

  • 包含

  • 相同顺序的数组元素时,它很可能是匹配。

  • Extract a sample of the watermarking image Scan the watermark image
  • pixel by pixel and store the first pixels in an array. Scan each
  • image pixel by pixel and store in an array. Whenever a row matrix
  • from the image being scanned contains elements of the array in the
  • same order, it's most likely a match.

代码可能是这样的:

$no_of_pixels = what_you_got;
$matched = 0;
$thumbpixels = array();
$wmark = imagecreatefrompng("watermark.png");
list($width, $height) =  getimagesize("watermark.png");
$tesimage = imagecreatefrompng("test.png");
for($h = 0; $h < $height; $h++){    
    for($w = 0; $w < $width; $w++){
        if(imagecolorsforindex($testimage, imagecolorat($testimage, $w, $h)) == $thumbpixels[0]){
            while($thumbpixels[$i++] === imagecolorsforindex($tesimage, imagecolorat($wmark, $w, $h)) && $no_of_pixels != $matched){
                $matched++;
            }
            if($matched == $no_of_pixels) echo "Voila, we found it!";
        }
    }
}






编辑



只看到你的缩略图示例。如果您只想检测文字,可以尝试 tesseract-ocr PhpOCR

您也可以考虑 PHPSane

这篇关于PHP,检测水印图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆