[GIS] Imported TIF has dark gray background instead of white

colormapgeotiff-tiffimportqgis

using QGIS 2.6

I import a TIF file, and expect the import to show an image that has black lines on a white background (with some other colors here and there), as the native windows viewer will see a white background. The file, 49MB, imports, but

The TIF image has a dark gray background instead of a white background

I can't tell why. Any hints?

The same thing happens if I import the TIF image into georeference, which is how I discovered this in the first place.

I created/exported the TIF image using PDFCreator (from a print of a PDF to a TIF, using that program). Within PDFCreator, I chose a TIF export that set the color map to 4096 colors, as the default created a TIF file that was twice as large.

On testing with the default size (16 million colors or some such)….
That file imported and showed the background as white.

And I can't tell why, for that, either. Any hints?

========
In response to the comment/question by @BradHards:

The TIFFTAG_PHOTOMETRIC is not present in either file.

The gdalinfo for the large file and small file are identical, but for the presence of two extra lines on the file where the white background turns to dark gray. Each band sets NBITS=4 for Image Structure Metadata: eg:

Band 1 Block=5100x68 Type=Byte, ColorInterp=Red
  Image Structure Metadata:
    NBITS=4
Band 2 Block=5100x68 Type=Byte, ColorInterp=Green
  Image Structure Metadata:
    NBITS=4
Band 3 Block=5100x68 Type=Byte, ColorInterp=Blue
  Image Structure Metadata:
    NBITS=4

Something about the NBITS=4 state turns the background dark gray. Alternatively, there is some other problem with the PDFCreator export.

These are the full GDALInfo:

Small with dark gray background:

Driver: GTiff/GeoTIFF
Files: small file.tif
Size is 5100, 6600
Coordinate System is `'
Metadata:
  TIFFTAG_DATETIME=2015:01:28 16:41:04
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=GPL Ghostscript 9.07
  TIFFTAG_XRESOLUTION=600
  TIFFTAG_YRESOLUTION=600
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 6600.0)
Upper Right ( 5100.0,    0.0)
Lower Right ( 5100.0, 6600.0)
Center      ( 2550.0, 3300.0)
Band 1 Block=5100x68 Type=Byte, ColorInterp=Red
  Image Structure Metadata:
    NBITS=4
Band 2 Block=5100x68 Type=Byte, ColorInterp=Green
  Image Structure Metadata:
    NBITS=4
Band 3 Block=5100x68 Type=Byte, ColorInterp=Blue
  Image Structure Metadata:
    NBITS=4

Large with white background

Driver: GTiff/GeoTIFF
Files: larger file.tif
Size is 5100, 6600
Coordinate System is `'
Metadata:
  TIFFTAG_DATETIME=2015:01:28 17:07:16
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=GPL Ghostscript 9.07
  TIFFTAG_XRESOLUTION=600
  TIFFTAG_YRESOLUTION=600
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 6600.0)
Upper Right ( 5100.0,    0.0)
Lower Right ( 5100.0, 6600.0)
Center      ( 2550.0, 3300.0)
Band 1 Block=5100x68 Type=Byte, ColorInterp=Red
Band 2 Block=5100x68 Type=Byte, ColorInterp=Green
Band 3 Block=5100x68 Type=Byte, ColorInterp=Blue

Best Answer

4096 colour input looks like it uses paletted colours. These can not be handled correctly by the georeferencer, because he has to interpolate between pixel values. That only works with full 16mill colours in all three RGB bands.

So you have to use that 16mill colours version to georeference.

Related Question