ssim/utils.py
def to_grayscale(img):
    """Convert PIL image to numpy grayscale array and numpy alpha array.

    Args:
      img (PIL.Image): PIL Image object.

    Returns:
      (gray, alpha): both numpy arrays.
    """
    gray = numpy.asarray(ImageOps.grayscale(img)).astype(numpy.float)

    imbands = img.getbands()
    alpha = None
    if 'A' in imbands:
        alpha = numpy.asarray(img.split()[-1]).astype(numpy.float)

    return gray, alpha
def to_grayscale(img):
    gray = numpy.asarray(ImageOps.grayscale(img)).astype(numpy.float)

    imbands = img.getbands()
    alpha = None
    if 'A' in imbands:
        alpha = numpy.asarray(img.split()[-1]).astype(numpy.float)

    return gray, alpha
def to_grayscale ( img ) : gray = numpy . asarray ( ImageOps . grayscale ( img ) ) . astype ( numpy . float ) imbands = img . getbands ( ) alpha = None if 'A' in imbands : alpha = numpy . asarray ( img . split ( ) [ - 1 ] ) . astype ( numpy . float ) return gray , alpha
Convert PIL image to numpy grayscale array and numpy alpha array.

    Args:
      img (PIL.Image): PIL Image object.

    Returns:
      (gray, alpha): both numpy arrays.
Convert PIL image to numpy grayscale array and numpy alpha array .