[Qgis-developer] error for QGIS tutorials in python - adding rasters to canvas

Peter Ersts ersts at amnh.org
Mon Jan 28 08:50:44 EST 2008


Martin Dobias wrote:
> 2008/1/24 Peter Ersts <ersts at amnh.org>:
>   
>> in 0.9.2, the abstracted draw process per pixel is:
>> For gray scale or RGB images
>> Read data from band -> Check NoDataValue -> Get transparency level ->
>> Stretch -> Invert (if necessary) -> Display
>> For paletted, pseudo color, for custom color maps
>> Read data from band -> Check NoDataValue -> Get transparency level ->
>> Shade(color) -> Invert (if necessary) -> Display
>>     
> Thanks for the clarifications, Pete!
> This helped a lot.
> I'm wondering about the difference between raster shaders and contrast
> enhancements... is the difference just semantic that shaders are used
> for grayscale/RGB images and contrast enhancements for
> palleted/pseudocolor images?
>   

Actually it is the just opposite! :) Contrast enhancement is for the 
gray/RBG and shaders are for the paletted/pseudocolor image.

But as far as the differences, one of the main difference is that the 
contrast enhancement process is done band by band and effectively 
returns one integer value between 0-255 per input pixel value while the 
shader returns three values or a "color". You could actually mimic a 
contrast enhancement for a gray scale image with a shader but not the 
other way around. In this first set of refactoring, the primary goal was 
to get the raster functionality operable and heading in a better 
direction. I had originally thought about making only one shader class 
that would do both color mapping as well as contrast enhancement;  that 
can still happen if there general consensus that it would make more sense.

Deeper down there are some other differences. There is only one shader 
per raster layer but each band has a contrast enhancement. One of the 
reasons for this is that before there were min max values being stored 
in the QgsRasterLayer for each the red, green, blue and gray band. This 
did not work well when you have images with a lot of bands or want to 
switch between gray scale and RGB as you would have to manually reset 
the min max values along the way. Now, you can explore a single band as 
gray scale set your min max values, which are kept with the band, and 
when you switch back to RGB the min max values persist. It is very 
likely that the shader functionality will be extended so that each band 
has a shader rather than there being only one for the whole layer.


-pete

-- 
====================================
Peter J. Ersts, Project Specialist
American Museum of Natural History
Center for Biodiversity and Conservation
Central Park West at 79th Street
New York, New York 10024
Tel: Home Office (518)-632-4745 or NYC Office (212)-496-3488
Web: http://biodiversityinformatics.amnh.org
Web: http://cbc.amnh.org

Quantum GIS Raster Development Team. Visit http://www.qgis.org
to learn more about QGIS, a free and open source desktop GIS

Open Source,
...evolving through community cooperation to change the world bit by bit




More information about the Qgis-developer mailing list