2005.10.12 12:11 "[Tiff] how to update tiled YCbCr JPEG image?", by Шебеко Евгений

2005.10.12 12:11 "[Tiff] how to update tiled YCbCr JPEG image?", by Шебеко Евгений

Hello.

I have a tiled YCbCr JPEG and try to update it

#include <stdio.h>
#include <tiff/libtiff/tiffio.h>

int main(int argc,char** argv)
{

  char buf[98304];
  memset(buf,0,sizeof(buf));
  TIFF* tif=TIFFOpen("tjpeg2.tif","a");
  TIFFSetDirectory(tif,0);

  TIFFWriteEncodedTile(tif,3000,buf,sizeof(buf));

    TIFFClose(tif);
    return 0;
}

The source image I get from image samples ftp://ftp.remotesensing.org/pub/geotiff/samples/misc

An expected result should be replacing a one tile.
But when I read modified image other tiles looks like wrong color converted.
What's I doing wrong?

There is no changes in output binary file except a requested tile and
in IDF.
Maybe it because JPEG Tables are changed too?

2 tags are added in result image is YCbCr Subsampling=2,2 and
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255

Changing it value explicity have no effect to result image.
Other IDF in this image after modification still correct.

This is a tag dump of source and result image.

Source file:

TIFF Directory at offset 0x90fefae
    Subfile Type: (0 = 0x0)
    Image Width: 16716 Image Length: 16716

Tile Width: 256 Tile Length: 256 Resolution: 714.286, 714.286 pixels/cm Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane DateTime: 2000:07:12 10:02:00

Tag 34264: 0.006915,-0.172433,0.000000,744072.520242,0.172433,0.006915,0.000000,-3741195.297250,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000
Tag 34461: 152039232
Tag 34735: 1,1,0,6,1024,0,1,1,1025,0,1,1,2048,0,1,4269,2049,34737,6,0,3072,0,1,26916,3073,34737,13,6
Tag 34737: NAD83|UTM zone 16N|
JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffac2e
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 8358 Image Length: 8358

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffd11c
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 4179 Image Length: 4179

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffdd0a
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 2090 Image Length: 2090

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffe278
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 1045 Image Length: 1045

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2

Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffe626
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 523 Image Length: 523

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffe954
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 262 Image Length: 262

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffec5a
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 131 Image Length: 131

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

Modified file:

TIFF Directory at offset 0x90fefae
    Subfile Type: (0 = 0x0)
    Image Width: 16716 Image Length: 16716

Tile Width: 256 Tile Length: 256 Resolution: 714.286, 714.286 pixels/cm Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 1, 1 Samples/Pixel: 3 Planar Configuration: single image plane Reference Black/White:

     0:     0   255
     1:   128   255
     2:   128   255
  DateTime: 2000:07:12 10:02:00
  Tag 34264: 0.006915,-0.172433,0.000000,744072.520242,0.172433,0.006915,0.000000,-3741195.297250,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000

Tag 34461: 152039232
Tag 34735: 1,1,0,6,1024,0,1,1,1025,0,1,1,2048,0,1,4269,2049,34737,6,0,3072,0,1,26916,3073,34737,13,6
Tag 34737: NAD83|UTM zone 16N|
JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffac2e
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 8358 Image Length: 8358

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffd11c
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 4179 Image Length: 4179

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffdd0a
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 2090 Image Length: 2090

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffe278
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 1045 Image Length: 1045

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffe626
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 523 Image Length: 523

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffe954
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 262 Image Length: 262

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)

TIFF Directory at offset 0x8ffec5a
    Subfile Type: reduced-resolution image (1 = 0x1)
    Image Width: 131 Image Length: 131

Tile Width: 256 Tile Length: 256 Bits/Sample: 8 Compression Scheme: JPEG Photometric Interpretation: YCbCr YCbCr Subsampling: 2, 2 Samples/Pixel: 3 Planar Configuration: single image plane JPEG Tables: (574 bytes)