code: def phash(image, hash_size=8, highfreq_factor=4):
      # type: (Image.Image, int, int) -> ImageHash
      """
      Perceptual Hash computation.
  
      Implementation follows https://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
  
      @image must be a PIL instance.
      """
      if hash_size < 2:
          raise ValueError(
              "Hash size must be greater than or equal to 2"
          )
  
      import scipy.fftpack
  
      img_size = hash_size * highfreq_factor
      image = image.convert("L").resize((img_size, img_size), ANTIALIAS)
      pixels = numpy.asarray(image)
      dct = scipy.fftpack.dct(scipy.fftpack.dct(pixels, axis=0), axis=1)
      dctlowfreq = dct[:hash_size, :hash_size]
      med = numpy.median(dctlowfreq)
      diff = dctlowfreq > med
      return ImageHash(diff)
  
imports: from __future__ import absolute_import, division, print_function
  import sys
  import numpy
  from PIL import Image, ImageFilter
label_desc: Use image node_id 7 for calling a global function with example usage: phash(image, hash_size, highfreq_factor) and returns: ImageHash