Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6345228

ColorConvert loses color information even between the same ColorModels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.2
    • client-libs
    • 2d
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Versión 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      I've been struggling with ColorConvert for weeks to perform a quality RGB -> YCC -> RGB color conversion, and I've finally noticed it doesn't work right even when the destination ColorModel is the same that the source one. This is the code of my method:

      public static PlanarImage convertingColorModel(PlanarImage pi, ColorModel cm) {
              ParameterBlock pb = new ParameterBlock();
              pb.addSource(pi).add(cm);
              
              ImageLayout il = new ImageLayout();
              il.setSampleModel(pi.getSampleModel());
              RenderingHints hints = new RenderingHints(javax.media.jai.JAI.KEY_IMAGE_LAYOUT, il);
              
              pi = JAI.create("ColorConvert", pb, hints);
              return pi;
      }

      I'm testing with an image with the following pixels values (I'll post just the firsts of the R and G bands):
      R: 255 0 255 255 255 0 255 0
      G: 255 0 255 0 255 255 255 0

      If I call the previous method with the same image and image.getColorModel(), the colors change:

      R: 252 0 252 253 252 22 252 0
      G: 253 0 253 0 253 253 253 19

      It produces perceptually insignificant changes, but critical errors when working with watermarking as I am...



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Watch pixel values of a PlanarImage myImage
      2. Call convertingColorModel (myImage, myImage.getColorModel())
      3. Watch the new values

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was expecting to get an almost identical pixel values (maybe some roundoff errors), something like the following:
      R: 255 0 255 255 255 0 255 0
      G: 255 0 255 0 255 255 255 0
      ACTUAL -
      R: 252 0 252 253 252 22 252 0
      G: 253 0 253 0 253 253 253 19

      REPRODUCIBILITY :
      This bug can be reproduced always.

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: