"static" to "self"

This commit is contained in:
travail 2015-10-09 18:14:42 +09:00
parent f497698622
commit b357936a84
3 changed files with 12 additions and 12 deletions

View File

@ -15,15 +15,15 @@ class AverageHash implements Algorithm
public function bin($resource) public function bin($resource)
{ {
// Resize // Resize
$resized = imagecreatetruecolor(static::SIZE, static::SIZE); $resized = imagecreatetruecolor(self::SIZE, self::SIZE);
imagecopyresampled( imagecopyresampled(
$resized, $resource, 0, 0, 0, 0, $resized, $resource, 0, 0, 0, 0,
static::SIZE, static::SIZE, imagesx($resource), imagesy($resource)); self::SIZE, self::SIZE, imagesx($resource), imagesy($resource));
// Create an array of gray-scaled pixel values. // Create an array of gray-scaled pixel values.
$pixels = array(); $pixels = array();
for ($y = 0; $y < static::SIZE; $y++) { for ($y = 0; $y < self::SIZE; $y++) {
for ($x = 0; $x < static::SIZE; $x++) { for ($x = 0; $x < self::SIZE; $x++) {
$rgb = imagecolorsforindex($resized, imagecolorat($resized, $x, $y)); $rgb = imagecolorsforindex($resized, imagecolorat($resized, $x, $y));
$pixels[] = ($rgb['red'] + $rgb['green'] + $rgb['blue']) / 3; $pixels[] = ($rgb['red'] + $rgb['green'] + $rgb['blue']) / 3;
} }

View File

@ -14,8 +14,8 @@ class DifferenceHash implements Algorithm
*/ */
public function bin($resource) public function bin($resource)
{ {
$width = static::SIZE + 1; $width = self::SIZE + 1;
$heigth = static::SIZE; $heigth = self::SIZE;
// Resize the image. // Resize the image.
$resized = imagecreatetruecolor($width, $heigth); $resized = imagecreatetruecolor($width, $heigth);

View File

@ -14,16 +14,16 @@ class PerceptionHash implements Algorithm
*/ */
public function bin($resource) public function bin($resource)
{ {
$resized = imagecreatetruecolor(static::SIZE, static::SIZE); $resized = imagecreatetruecolor(self::SIZE, self::SIZE);
imagecopyresampled($resized, $resource, 0, 0, 0, 0, imagecopyresampled($resized, $resource, 0, 0, 0, 0,
static::SIZE, static::SIZE, imagesx($resource), imagesy($resource)); self::SIZE, self::SIZE, imagesx($resource), imagesy($resource));
// Get luma value (YCbCr) from RGB colors and calculate the DCT for each row. // Get luma value (YCbCr) from RGB colors and calculate the DCT for each row.
$matrix = array(); $matrix = array();
$row = array(); $row = array();
$rows = array(); $rows = array();
$col = array(); $col = array();
for ($y = 0; $y < static::SIZE; $y++) { for ($y = 0; $y < self::SIZE; $y++) {
for ($x = 0; $x < static::SIZE; $x++) { for ($x = 0; $x < self::SIZE; $x++) {
$rgb = imagecolorsforindex($resized, imagecolorat($resized, $x, $y)); $rgb = imagecolorsforindex($resized, imagecolorat($resized, $x, $y));
$row[$x] = floor(($rgb['red'] * 0.299) + ($rgb['green'] * 0.587) + ($rgb['blue'] * 0.114)); $row[$x] = floor(($rgb['red'] * 0.299) + ($rgb['green'] * 0.587) + ($rgb['blue'] * 0.114));
} }
@ -32,8 +32,8 @@ class PerceptionHash implements Algorithm
imagedestroy($resized); imagedestroy($resized);
for ($x = 0; $x < static::SIZE; $x++) { for ($x = 0; $x < self::SIZE; $x++) {
for ($y = 0; $y < static::SIZE; $y++) { for ($y = 0; $y < self::SIZE; $y++) {
$col[$y] = $rows[$y][$x]; $col[$y] = $rows[$y][$x];
} }
$matrix[$x] = $this->dct($col); $matrix[$x] = $this->dct($col);