Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-23205

ImageSchema.readImages incorrectly sets alpha channel to 255 for four-channel images

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.3.0
    • Component/s: ML, MLlib
    • Labels:
      None

      Description

      When parsing raw image data in ImageSchema.decode(), we use a java.awt.Color constructor that sets alpha = 255, even for four-channel images.

      See the offending line here: https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/ml/image/ImageSchema.scala#L172

      A fix is to simply update the line to: 

      val color = new Color(img.getRGB(w, h), nChannels == 4)

      instead of

      val color = new Color(img.getRGB(w, h))

        Attachments

          Activity

            People

            • Assignee:
              Siddharth Murching Siddharth Murching
              Reporter:
              Siddharth Murching Siddharth Murching
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: