AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

2004.02.16 09:54 "[Tiff] TIFF BUG: RGB gets swapped on YCBCR", by Kenneth Tjøstheim

I really don't know what is wrong, but I have some images that becomes BGR instead of RGB. (Others are OK)

They are tiled and layered: 6400x2400 tile size 128x128
Could be I am not using it correctly but???
Have tried to swap R with B and then they gets OK, but then others gets bad.

TIFFRGBAImageBegin()
{
  ....

    switch (img->photometric) {
    case PHOTOMETRIC_YCBCR:
   if (planarconfig != PLANARCONFIG_CONTIG) {
          sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d",
              "Planarconfiguration", planarconfig);
       return (0);
 }
       /* It would probably be nice to have a reality check here. */
   if (planarconfig == PLANARCONFIG_CONTIG)
            /* can rely on libjpeg to convert to RGB */
     /* XXX should restore current state on exit */
          switch (compress) {
         case COMPRESSION_OJPEG:
         case COMPRESSION_JPEG:
              TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
                    img->photometric = PHOTOMETRIC_RGB;


DEBUGGING GETS ME HERE


                    break;

                default:
                    /* do nothing */;
                    break;
      }
   break;

}

tiffinfo CC038114.TIF
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33918 (0x847e ) encountered.
TIFF Directory at offset 0x2003dc
  Subfile Type: (0 = 0x0)
  Image Width: 6400 Image Length: 4800
  Tile Width: 128 Tile Length: 128
  Resolution: 1000, 1000 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33918: 2,10,104,0,0,0,0,16425,0,0,0,0,0,0,0,0,0,0,21600,-16039,0,0,0,0,0,0 ,0,16425,0,0,0,0,0,0,22138,16753,0,0,0,0,0,0,0,0,0,0,0,16368,0,0,0,0,0,0,0,0 ,0,0 ,0,0,0,0,0,0,0,0,0,16368,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (1722 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x291a58
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 3200 Image Length: 2400
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2be9b8
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 1600 Image Length: 1200
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2cc3ec
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 800 Image Length: 600
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2d0d1c
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 400 Image Length: 300
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2d25e4
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 200 Image Length: 150
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2d3040
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 100 Image Length: 75
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2d3904
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 50 Image Length: 37
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)
TIFFReadDirectory: Warning, e:CC038114.TIF: unknown field with tag 33919 (0x847f) encountered.
TIFF Directory at offset 0x2d3ff4
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 25 Image Length: 18
  Tile Width: 128 Tile Length: 128
  Resolution: 0.15625, 0.208333 pixels/cm
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  Tag 33919: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  JPEG Tables: (574 bytes)