GDAL

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
GDALWarpKernel Class Reference

Low level image warping class. More...

`#include "gdalwarper.h"`

## Public Member Functions
CPLErr | Validate ()
| Check the settings in the GDALWarpKernel, and issue a CPLError() (and return CE_Failure) if the configuration is considered to be invalid for some reason. More...
CPLErr | PerformWarp ()
| This method performs the warp described in the GDALWarpKernel. More...

## Public Attributes
char ** | papszWarpOptions
GDALResampleAlg | eResample
| Resampling algorithm. More...
GDALDataType | eWorkingDataType
| Working pixel data type. More...
int | nBands
| Number of bands. More...
int | nSrcXSize
| Source image width in pixels. More...
int | nSrcYSize
| Source image height in pixels. More...
int | nSrcXExtraSize
| Number of pixels included in nSrcXSize that are present on the edges of the area of interest to take into account the width of the kernel. More...
int | nSrcYExtraSize
| Number of pixels included in nSrcYExtraSize that are present on the edges of the area of interest to take into account the height of the kernel. More...
GByte ** | papabySrcImage
| Array of source image band data. More...
GUInt32 ** | papanBandSrcValid
| Per band validity mask for source pixels. More...
GUInt32 * | panUnifiedSrcValid
| Per pixel validity mask for source pixels. More...
float * | pafUnifiedSrcDensity
| Per pixel density mask for source pixels. More...
int | nDstXSize
| Width of destination image in pixels. More...
int | nDstYSize
| Height of destination image in pixels. More...
GByte ** | papabyDstImage
| Array of destination image band data. More...
GUInt32 * | panDstValid
| Per pixel validity mask for destination pixels. More...
float * | pafDstDensity
| Per pixel density mask for destination pixels. More...
double | dfXScale
double | dfYScale
double | dfXFilter
double | dfYFilter
int | nXRadius
int | nYRadius
int | nFiltInitX
int | nFiltInitY
int | nSrcXOff
| X offset to source pixel coordinates for transformation. More...
int | nSrcYOff
| Y offset to source pixel coordinates for transformation. More...
int | nDstXOff
| X offset to destination pixel coordinates for transformation. More...
int | nDstYOff
| Y offset to destination pixel coordinates for transformation. More...
GDALTransformerFunc | pfnTransformer
| Source/destination location transformer. More...
void * | pTransformerArg
| Callback data for pfnTransformer. More...
GDALProgressFunc | pfnProgress
| The function to call to report progress of the algorithm, and to check for a requested termination of the operation. More...
void * | pProgress
| Callback data for pfnProgress. More...
double | dfProgressBase
double | dfProgressScale
double * | padfDstNoDataReal
void * | psThreadData

## Detailed Description

Low level image warping class.

This class is responsible for low level image warping for one "chunk" of imagery. The class is essentially a structure with all data members public - primarily so that new special-case functions can be added without changing the class declaration.

Applications are normally intended to interactive with warping facilities through the GDALWarpOperation class, though the GDALWarpKernel can in theory be used directly if great care is taken in setting up the control data.

### Design Issues

The intention is that PerformWarp() would analyze the setup in terms of the datatype, resampling type, and validity/density mask usage and pick one of many specific implementations of the warping algorithm over a continuum of optimization vs. generality. At one end there will be a reference general purpose implementation of the algorithm that supports any data type (working internally in double precision complex), all three resampling types, and any or all of the validity/density masks. At the other end would be highly optimized algorithms for common cases like nearest neighbour resampling on GDT_Byte data with no masks.

The full set of optimized versions have not been decided but we should expect to have at least:

- One for each resampling algorithm for 8bit data with no masks.
- One for each resampling algorithm for float data with no masks.
- One for each resampling algorithm for float data with any/all masks (essentially the generic case for just float data).
- One for each resampling algorithm for 8bit data with support for input validity masks (per band or per pixel). This handles the common case of nodata masking.
- One for each resampling algorithm for float data with support for input validity masks (per band or per pixel). This handles the common case of nodata masking.

Some of the specializations would operate on all bands in one pass (especially the ones without masking would do this), while others might process each band individually to reduce code complexity.

### Masking Semantics

A detailed explanation of the semantics of the validity and density masks, and their effects on resampling kernels is needed here.

## Member Function Documentation

CPLErr GDALWarpKernel::PerformWarp | ( |  | ) |

This method performs the warp described in the GDALWarpKernel.

Returns
  CE_None on success or CE_Failure if an error occurs.

CPLErr GDALWarpKernel::Validate | ( |  | ) |

Check the settings in the GDALWarpKernel, and issue a CPLError() (and return CE_Failure) if the configuration is considered to be invalid for some reason.

This method will also do some standard defaulting such as setting pfnProgress to GDALDummyProgress() if it is NULL.

Returns
  CE_None on success or CE_Failure if an error is detected.

## Member Data Documentation

GDALResampleAlg GDALWarpKernel::eResample

Resampling algorithm.

The resampling algorithm to use. One of GRA_NearestNeighbour, GRA_Bilinear, GRA_Cubic, GRA_CubicSpline, GRA_Lanczos, GRA_Average, or GRA_Mode.

This field is required. GDT_NearestNeighbour may be used as a default value.

GDALDataType GDALWarpKernel::eWorkingDataType

Working pixel data type.

The datatype of pixels in the source image (papabySrcimage) and destination image (papabyDstImage) buffers. Note that operations on some data types (such as GDT_Byte) may be much better optimized than other less common cases.

This field is required. It may not be GDT_Unknown.

int GDALWarpKernel::nBands

Number of bands.

The number of bands (layers) of imagery being warped. Determines the number of entries in the papabySrcImage, papanBandSrcValid, and papabyDstImage arrays.

This field is required.

int GDALWarpKernel::nDstXOff

X offset to destination pixel coordinates for transformation.

See pfnTransformer.

This field is required.

int GDALWarpKernel::nDstXSize

Width of destination image in pixels.

This field is required.

int GDALWarpKernel::nDstYOff

Y offset to destination pixel coordinates for transformation.

See pfnTransformer.

This field is required.

int GDALWarpKernel::nDstYSize

Height of destination image in pixels.

This field is required.

int GDALWarpKernel::nSrcXExtraSize

Number of pixels included in nSrcXSize that are present on the edges of the area of interest to take into account the width of the kernel.

This field is required.

int GDALWarpKernel::nSrcXOff

X offset to source pixel coordinates for transformation.

See pfnTransformer.

This field is required.

int GDALWarpKernel::nSrcXSize

Source image width in pixels.

This field is required.

int GDALWarpKernel::nSrcYExtraSize

Number of pixels included in nSrcYExtraSize that are present on the edges of the area of interest to take into account the height of the kernel.

This field is required.

int GDALWarpKernel::nSrcYOff

Y offset to source pixel coordinates for transformation.

See pfnTransformer.

This field is required.

int GDALWarpKernel::nSrcYSize

Source image height in pixels.

This field is required.

float * GDALWarpKernel::pafDstDensity

Per pixel density mask for destination pixels.

A single density mask layer that applies to the pixels of all destination bands. It contains values between 0.0 and 1.0.

This pointer may be NULL indicating that all pixels have a density of 1.0.

The density for a pixel may be accessed like this:

float fDensity = 1.0;
int nPixel = 3; // zero based
int nLine = 4; // zero based
assert( nPixel >= 0 && nPixel < poKern->nDstXSize );
assert( nLine >= 0 && nLine < poKern->nDstYSize );
if( poKern->pafDstDensity != NULL )
fDensity = poKern->pafDstDensity[nPixel + nLine * poKern->nDstXSize];

float * GDALWarpKernel::pafUnifiedSrcDensity

Per pixel density mask for source pixels.

A single density mask layer that applies to the pixels of all source bands. It contains values between 0.0 and 1.0 indicating the degree to which this pixel should be allowed to contribute to the output result.

This pointer may be NULL indicating that all pixels have a density of 1.0.

The density for a pixel may be accessed like this:

float fDensity = 1.0;
int nPixel = 3; // zero based
int nLine = 4; // zero based
assert( nPixel >= 0 && nPixel < poKern->nSrcXSize );
assert( nLine >= 0 && nLine < poKern->nSrcYSize );
if( poKern->pafUnifiedSrcDensity != NULL )
fDensity = poKern->pafUnifiedSrcDensity
[nPixel + nLine * poKern->nSrcXSize];

GUInt32 * GDALWarpKernel::panDstValid

Per pixel validity mask for destination pixels.

A single validity mask layer that applies to the pixels of all destination bands. It is accessed similarly to papanUnitifiedSrcValid, but based on the size of the destination image.

This pointer may be NULL indicating that all pixels are valid.

GUInt32 * GDALWarpKernel::panUnifiedSrcValid

Per pixel validity mask for source pixels.

A single validity mask layer that applies to the pixels of all source bands. It is accessed similarly to papanBandSrcValid, but without the extra level of band indirection.

This pointer may be NULL indicating that all pixels are valid.

Note that if both panUnifiedSrcValid, and papanBandSrcValid are available, the pixel isn't considered to be valid unless both arrays indicate it is valid.

GByte ** GDALWarpKernel::papabyDstImage

Array of destination image band data.

This is an array of pointers (of size GDALWarpKernel::nBands) pointers to image data. Each individual band of image data is organized as a single block of image data in left to right, then bottom to top order. The actual type of the image data is determined by GDALWarpKernel::eWorkingDataType.

To access the pixel value for the (x=3,y=4) pixel (zero based) of the second band with eWorkingDataType set to GDT_Float32 use code like this:

float dfPixelValue;
int nBand = 1; // band indexes are zero based.
int nPixel = 3; // zero based
int nLine = 4; // zero based
assert( nPixel >= 0 && nPixel < poKern->nDstXSize );
assert( nLine >= 0 && nLine < poKern->nDstYSize );
assert( nBand >= 0 && nBand < poKern->nBands );
dfPixelValue = ((float *) poKern->papabyDstImage[nBand-1])
[nPixel + nLine * poKern->nSrcYSize];

This field is required.

int GDALWarpKernel::papabySrcImage

Array of source image band data.

This is an array of pointers (of size GDALWarpKernel::nBands) pointers to image data. Each individual band of image data is organized as a single block of image data in left to right, then bottom to top order. The actual type of the image data is determined by GDALWarpKernel::eWorkingDataType.

To access the pixel value for the (x=3,y=4) pixel (zero based) of the second band with eWorkingDataType set to GDT_Float32 use code like this:

float dfPixelValue;
int nBand = 1; // band indexes are zero based.
int nPixel = 3; // zero based
int nLine = 4; // zero based
assert( nPixel >= 0 && nPixel < poKern->nSrcXSize );
assert( nLine >= 0 && nLine < poKern->nSrcYSize );
assert( nBand >= 0 && nBand < poKern->nBands );
dfPixelValue = ((float *) poKern->papabySrcImage[nBand-1])
[nPixel + nLine * poKern->nSrcXSize];

This field is required.

GUInt32 ** GDALWarpKernel::papanBandSrcValid

Per band validity mask for source pixels.

Array of pixel validity mask layers for each source band. Each of the mask layers is the same size (in pixels) as the source image with one bit per pixel. Note that it is legal (and common) for this to be NULL indicating that none of the pixels are invalidated, or for some band validity masks to be NULL in which case all pixels of the band are valid. The following code can be used to test the validity of a particular pixel.

int bIsValid = TRUE;
int nBand = 1; // band indexes are zero based.
int nPixel = 3; // zero based
int nLine = 4; // zero based
assert( nPixel >= 0 && nPixel < poKern->nSrcXSize );
assert( nLine >= 0 && nLine < poKern->nSrcYSize );
assert( nBand >= 0 && nBand < poKern->nBands );
if( poKern->papanBandSrcValid != NULL
&& poKern->papanBandSrcValid[nBand] != NULL )
{
GUInt32 *panBandMask = poKern->papanBandSrcValid[nBand];
int iPixelOffset = nPixel + nLine * poKern->nSrcXSize;
bIsValid = panBandMask[iPixelOffset>>5]
& (0x01 << (iPixelOffset & 0x1f));
}

GDALProgressFunc GDALWarpKernel::pfnProgress

The function to call to report progress of the algorithm, and to check for a requested termination of the operation.

It operates according to GDALProgressFunc() semantics.

Generally speaking the progress function will be invoked for each scanline of the destination buffer that has been processed.

This field may be NULL (internally set to GDALDummyProgress()).

GDALTransformerFunc GDALWarpKernel::pfnTransformer

Source/destination location transformer.

The function to call to transform coordinates between source image pixel/line coordinates and destination image pixel/line coordinates. See GDALTransformerFunc() for details of the semantics of this function.

The GDALWarpKern algorithm will only ever use this transformer in "destination to source" mode (bDstToSrc=TRUE), and will always pass partial or complete scanlines of points in the destination image as input. This means, among other things, that it is safe to the the approximating transform GDALApproxTransform() as the transformation function.

Source and destination images may be subsets of a larger overall image. The transformation algorithms will expect and return pixel/line coordinates in terms of this larger image, so coordinates need to be offset by the offsets specified in nSrcXOff, nSrcYOff, nDstXOff, and nDstYOff before passing to pfnTransformer, and after return from it.

The GDALWarpKernel::pfnTransformerArg value will be passed as the callback data to this function when it is called.

This field is required.

void * GDALWarpKernel::pProgress

Callback data for pfnProgress.

This field may be NULL if not required for the pfnProgress being used.

void * GDALWarpKernel::pTransformerArg

Callback data for pfnTransformer.

This field may be NULL if not required for the pfnTransformer being used.

The documentation for this class was generated from the following files:

- gdalwarper.h
- gdalwarpkernel.cpp

Generated for GDAL by 1.8.8.