Ejemplo n.º 1
0
 function getHash()
 {
     $hashRect = $this->getHashRectangle();
     $hashImg = imagecreatetruecolor($hashRect->getWidth(), $hashRect->getHeight());
     imagecopy($hashImg, $this->_img, 0, 0, $hashRect->getLeft(), $hashRect->getTop(), $hashRect->getWidth(), $hashRect->getHeight());
     $tempFile = tempnam('', 'phashr');
     imagepng($hashImg, $tempFile, 0);
     $hash = ph_dct_imagehash($tempFile);
     unlink($tempFile);
     return $hash;
 }
Ejemplo n.º 2
0
 public static function byImage($inputFilePath)
 {
     $binaryHash = sha1_file($inputFilePath);
     $phash = ph_dct_imagehash($inputFilePath);
     if (!$phash) {
         return false;
     }
     $results = ImageHash::whereRaw('binary_hash = ? or bit_count(phash ^ ?) <= ?', array($binaryHash, $phash, self::SEARCH_THRESHOLD))->get();
     $paths = array();
     foreach ($results as $hash) {
         $record = $hash->pathRecord;
         $path = $record->getPath();
         $paths[$record->id] = $path;
     }
     return $paths;
 }
Ejemplo n.º 3
0
$PATH_ORIG = "../phash/bilder";
$PATH_MOD = "../phash/bilder_mod";
$d = dir($PATH_ORIG);
$bilder = array();
while (false !== ($entry = $d->read())) {
    if ($entry == "." || $entry == ".." || !file_exists($PATH_MOD . "/" . $entry)) {
        continue;
    }
    $bilder[] = $entry;
}
$d->close();
$results = array();
for ($i = 0; $i <= sizeof($bilder); $i++) {
    if ($bilder[$i] == null) {
        break;
    }
    $image1 = ph_dct_imagehash($PATH_ORIG . "/" . $bilder[$i]);
    $image2 = ph_dct_imagehash($PATH_MOD . "/" . $bilder[$i]);
    $results[] = ph_image_dist($image1, $image2);
}
$graph = new Graph(350, 200, "auto");
$graph->SetScale("textlin");
$lineplot = new LinePlot($results);
$graph->Add($lineplot);
$lineplot->SetColor("orange");
//$lineplot->SetFillColor("darkorange@0.6");
$lineplot->SetWeight(2);
$lineplot->value->Show();
$lineplot->value->SetFont(FF_FONT0, FS_NORMAL);
$lineplot->value->SetColor("orange");
$graph->Stroke();