This note describes how the MrSID SDK implements the concepts of "nodata" and "background" pixelsPixels.
NOTE: The following is not applicable to the MG4 format, in which transparency is implemented through the use of alpha bands.
Nodata
The nodata pixel of an image is used to indicate which pixels within the bounds of the image are to be ignored when performing an operation on the image, for example mosaicking, rendering, etc. The default is to have no nodata pixel associated with an image; in this case, all pixels in the image represent valid data.
Background Data
The background pixel of an image is used to provide valid pixel values outside of the bounds of the image. In rendering the image, if the specified scene exceeds the boundaries of the image, the background pixel can be used by an application to fill in the portion of the output buffer beyond the image boundary.
The default is to have no background pixel associated with an image. In this case, when pixels "outside of" the image are required, the black pixel consisting of a zero in each band will be used. For CMYK images, however, the pixel consisting of the maximum sample values in each band will be used.
While the LTIImageStage::read() function does not allow for decoding outside the bounds of the image, the background pixel and the nodata pixel are used when mosaicking multiple images together.
Transparency
The MrSID SDK does not support transparency operations more generally than the above simple nodata support, for example via bitmasks, clipping paths, or alpha blending.
For compatibility reasons, the classical metadata tag names used in MrSID do not correlate well with the definitions given above.
The tags used are:
IMAGE::NO_DATA_VALUE
Represents the background pixel (used by older MrSID images)
IMAGE::DEFAULT_DATA_VALUE
Represents the background pixel (used by newer MrSID images)
IMAGE::TRANSPARENT_DATA_VALUE
Represents the nodata pixel
Figure 1 shows two images, A and B, that are to be mosaicked together into image C, such that B lies precisely on top of A. Both images have a background color of red and a nodata color of blue. In the mosaic C, the upper rectangle is yellow because the data comes from the nodata region of B, which allows the A image to “show through”. The lower rectangle is red, however, because we again "see through" B and onto the corresponding region of A; that region is set to the nodata color, therefore the red background of A is used.
Figure 1: Nodata and background color in overlapping images
When mosaicking two images together, the nodata pixel of the image "on top" is honored. Many images do not have a nodata pixel explicitly set, however, so the following rules are applied:
The motivation for this treatment of nodata is to give the best looking image for the case when two images are being mosaicked together such that only their corners overlap, resulting in a large image with a lot of "black" background. If this resulting mosaic is then laid on top of some other even bigger image, we want to be able to treat that black background as nodata. (Note: this solution does allow for speckling in the image, as the original two squares might have legitimate black pixels within their data.)
If either background or nodata is to be set for an image, set both properties to the same value. When mosaicking images together, all images should have the same background and nodata color.