Bug report #4159

Should detect a grayscale image with an alpha channel as grayscale (and related issues)

Added by Alister Hood over 12 years ago. Updated almost 9 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Rasters
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:14136

Description

I used the Raster Clipper with a vector mask layer to create the attached image.
When loaded into QGIS it is invisible until I open the layer properties and specify to render as single band gray.

1. Gdalinfo knows that band 1 is grayscale and band 2 is alpha, so I think QGIS should also be able to detect this and render as single band gray.
2. I would have expected rendering as three band colour to display something even if less than three bands are selected, essentially by using 255 for the missing bands. In some cases a user might want to do "two band rendering" like this. What do you think?
3. The option to select a transparency band is always disabled (but this is already reported as #2491)

test_modified_corner.tif (402 KB) Alister Hood, 2011-08-11 12:15 AM

geotiff_grayscale-w-alpha.tif - NOTE: in screen snaps this is shown as 'opengeo-test-1' (513 KB) Larry Shaffer, 2015-05-12 08:40 AM

layer-props_band-rendering_2-bands.png (183 KB) Larry Shaffer, 2015-05-12 08:40 AM

layer-props_band-rendering_1-band-stretch.png (174 KB) Larry Shaffer, 2015-05-12 08:40 AM

layer-props_transp_2-band-alpha.png (152 KB) Larry Shaffer, 2015-05-12 08:40 AM

Associated revisions

Revision 1f74cf08
Added by Larry Shaffer almost 9 years ago

Fix single band gray with alpha raster type not recognized (fix #4159)

- Add band color interpretation for WCS provider (from GDAL provider)

Backported to 2.8.3

History

#1 Updated by Giovanni Manghi over 12 years ago

  • Target version set to Version 1.7.4

#2 Updated by Paolo Cavallini almost 12 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0
  • Affected QGIS version set to master
  • Crashes QGIS or corrupts data set to No

#3 Updated by Paolo Cavallini over 11 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#4 Updated by Giovanni Manghi over 11 years ago

This seems to be a still valid issue with the latest qgis master.

#5 Updated by Alister Hood over 11 years ago

Alister wrote:

When loaded into QGIS it is invisible until I open the layer properties and specify to render as single band gray.

I also now need to manually specify min/max values of 0 and 255 (or 254 or whatever it is). I think these should be set automatically.

Alister wrote:

1. Gdalinfo knows that band 1 is grayscale and band 2 is alpha, so I think QGIS should also be able to detect this and render as single band gray.

Band 2 is now correctly identified as alpha on the "Transparency" tab, but not on the style tab.

#6 Updated by Alister Hood over 11 years ago

Alister wrote:

2. I would have expected rendering as three band colour to display something even if less than three bands are selected, essentially by using 255 for the missing bands. In some cases a user might want to do "two band rendering" like this. What do you think?

In master this now works as I expected.

#7 Updated by Jürgen Fischer over 9 years ago

  • Target version changed from Version 2.0.0 to Future Release - Lower Priority

#8 Updated by Larry Shaffer almost 9 years ago

This issue appears to still be present in current master.

Also, this happens when a GeoTiff (grayscale raster with alpha) loads via WCS, like when receiving output from GeoServer. Attached is a sample file and screen snaps.

When the sample GeoTiff is loaded into QGIS, the layer had 2 bands (see screen snap):

  • Band 1 (Gray)
  • Band 2 (Alpha)

Note: when loading a similar coverage via WCS, there is not indication of Gray/Alpha band type, like QGIS recognizes when loading the GeoTiff.

Switching the render type to singleband grayscale still requires setting or loading some min/max values and stretching the contrast to those values to get the raster data to visibly render (see screen snap). The second band (alpha) is correctly recognized and auto-loaded into the Transparency layer properties panel for the GeoTiff (see screen snap).

Other than the auto-loading of the alpha band, both WCS and the GeoTiff load as multi-band color. While there doesn't seem to be any recognition of the band types for WCS, there is for the loaded GeoTiff, i.e. at least that should have its render type properly set.

#9 Updated by Larry Shaffer almost 9 years ago

I have a fix for this, and the WCS issue, in this PR: https://github.com/qgis/QGIS/pull/2106

#10 Updated by Larry Shaffer almost 9 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF