1

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
  • There is a TIFF tag called Photometric Interpretation (awaresystems.be/imaging/tiff/tifftags/…). That can flip black and white if not set correctly. What does gdalinfo show for that tag? – BradHards Jan 29 '15 at 9:34
  • @BradHards, there is no such tag in either file. The smaller file, with the dark gray background, has extra lines in gdalinfo, setting NBITS=4 for Image Structure Metadata. I note, however, that the background color does not flip to pure black, rather very dark gray. See my edits to the question. – John Jan 29 '15 at 13:57
  • @andre: I discovered that merely importing the 4096 color TIF into QGIS causes this issue; it is not a georeferencing problem, only. I am amending the question to reflect this general case. – John Jan 29 '15 at 14:02
1

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.

0

I noticed, on viewing the histogram for the TIF image, that there is a huge peak at 15 for all bands...which corresponds to the dark gray, apparently.

I still can't make sense of why QGIS adds that gray, in the first place.

Also...removing that color at 15, on all bands, using additional no data, or a custom setting with 15 for all bands, turns the gray-out color'd areas to all black. Which I don't understand....I was thinking it should leave them with some color, or all of their color...?

See: How to make dark gray background on TIF image transparent or white in QGIS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.