コード例 #1
0
ファイル: BlockBasedTrait.php プロジェクト: keradus/graphics
 public function compare()
 {
     $blocksA = Block::chunkImage($this->imageA, $this->chunkSize);
     $blocksB = Block::chunkImage($this->imageB, $this->chunkSize);
     $sizeX = count($blocksA);
     $sizeY = count($blocksA[0]);
     $this->chunksQuantity = ["x" => $sizeX, "y" => $sizeY];
     $diff = 0;
     for ($x = 0; $x < $sizeX; ++$x) {
         for ($y = 0; $y < $sizeY; ++$y) {
             $diff += $this->compareBlock($blocksA[$x][$y], $blocksB[$x][$y]);
             if ($this->wasCompared) {
                 return;
             }
         }
     }
     $this->computeResult($diff);
 }
コード例 #2
0
ファイル: BlockSimilarity.php プロジェクト: keradus/graphics
 protected function compareGreyBlock(Block $_a, Block $_b)
 {
     $colorA = $_a->getAverageColor();
     $colorB = $_b->getAverageColor();
     return $_a->getSize() * abs($colorA->getGrey() - $colorB->getGrey());
 }