AverageHash.php 982 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Grafika\Imagick\ImageHash;
  3. use Grafika\Imagick\Editor;
  4. use Grafika\Imagick\Image;
  5. /**
  6. * AverageHash
  7. *
  8. * Algorithm:
  9. * Reduce size. Remove high frequencies and detail by shrinking to 8x8 so that there are 64 total pixels.
  10. * Reduce color. The tiny 8x8 picture is converted to a grayscale.
  11. * Average the colors. Compute the mean value of the 64 colors.
  12. * Compute the bits. Each bit is simply set based on whether the color value is above or below the mean.
  13. * Construct the hash. Set the 64 bits into a 64-bit integer. The order does not matter, just as long as you are consistent.
  14. *
  15. * http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
  16. *
  17. * @package Grafika\Imagick\ImageHash
  18. */
  19. class AverageHash
  20. {
  21. /**
  22. * Generate and get the average hash of the image.
  23. *
  24. * @param Image $image
  25. *
  26. * @return string
  27. */
  28. public function hash(Image $image)
  29. {
  30. return ''; // TODO: Implementation
  31. }
  32. }