[Qgis-developer] QgsRasterLayer::drawMultiBandColor

Peter Ersts ersts at amnh.org
Thu Aug 16 15:35:50 EDT 2007


Marco Hugentobler wrote:
> On Thursday 16 August 2007 20:23:16 Peter Ersts wrote:
>> If the bands use the same nodatavalue then technically checking just the
>> red channel should be sufficient, though there is a question in the code
>> regarding whether all channels should be checked.
>>     
>
> In the case of my example, checking all the bands seems reasonable to me.
>
> It may however be a problem for other cases, if e.g. nodata value is -9999 and 
> only red band has nodata value. Though that case may not be very likely.
>
>   

After a few more minutes of thought on this I think all three channels 
should always be check. For straight image data that are from, say a 
satellite, the nodatavalue areas would typically overlap exactly so any 
pixel in the channel stack could be used. However, the user could in 
theory create their own composite multichannel image from data layers 
that have nodatavalues at any location, and may appear in only one, two, 
or all three of the displaying channels/bands. So

if((myRedValueDouble == noDataValueDouble || myRedValueDouble != 
myRedValueDouble) &&
   (myGreenValueDouble == noDataValueDouble || myGreenValueDouble != 
myGreenValueDouble) &&
   (myBlueValueDouble == noDataValueDouble || myBlueValueDouble != 
myBlueValueDouble))
{
  continue;
}

requires that all three values be nodata and will work fine with typical 
image data but not well the the user created composite image where as

if((myRedValueDouble == noDataValueDouble || myRedValueDouble != 
myRedValueDouble) ||
   (myGreenValueDouble == noDataValueDouble || myGreenValueDouble != 
myGreenValueDouble) ||
   (myBlueValueDouble == noDataValueDouble || myBlueValueDouble != 
myBlueValueDouble))
{
  continue;
}
requires only one value in the channel stack to be nodata to skip the 
current pixel and would be the most robust case

In your situation where you want 0,0,0 to be 'nodata', but 0,255,255 to 
display that would best be done by setting 0,0,0 as transparent pixel 
rather than saying 0 is the nodatavalue.

What do you think?

-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: (212)-496-3488 or (212)-769-5742
Fax: (212)-313-7295 or (212)-769-5292
Web: http://cbc.amnh.org
Web: http://geospatial.amnh.org

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





More information about the Qgis-developer mailing list