Loading...
Searching...
No Matches
casacore::ImageRegrid< T > Class Template Reference
images package (libcasa_images) » Images_module

More...

`#include <ImageRegrid.h>`

## Public Member Functions

| ImageRegrid ()
| Default constructor.
| ImageRegrid (const ImageRegrid &other)
| copy constructor (copy semantics)
| ~ImageRegrid ()
| destructor
ImageRegrid< T > & | operator= (const ImageRegrid &other)
| Assignment copy semantics).
void | regrid (ImageInterface< T > &outImage, typename Interpolate2D::Method method, const IPosition &whichOutPixelAxes, const ImageInterface< T > &inImage, Bool replicate=False, uInt decimate=0, Bool showProgress=False, Bool forceRegrid=False, Bool verbose=False)
| Regrid inImage onto the grid specified by outImage.
void | get2DCoordinateGrid (Cube< Double > &grid, Matrix< Bool > &gridMask) const
| Get and set the 2-D coordinate grid.
void | set2DCoordinateGrid (const Cube< Double > &grid, const Matrix< Bool > &gridMask, Bool notify=False)
Bool | insert (ImageInterface< T > &outImage, const Vector< Double > &outPixelLocation, const ImageInterface< T > &inImage)
| Inserts inImage into outImage.
void | showDebugInfo (Int level=0)
| Print out useful debugging information (level 0 is none, 1 is some, 2 is too much).
void | disableReferenceConversions (Bool disable=True)
| Enable/disable Measures Reference conversions.

## Static Public Member Functions

static CoordinateSystem | makeCoordinateSystem (LogIO &os, std::set< Coordinate::Type > &coordsToBeRegridded, const CoordinateSystem &cSysTo, const CoordinateSystem &cSysFrom, const IPosition &axes, const IPosition &inShape=IPosition(), Bool giveStokesWarning=True)
| Helper function.

## Private Member Functions

void | _checkAxes (IPosition &outPixelAxes, const IPosition &inShape, const IPosition &outShape, const Vector< Int > &pixelAxisMap, const CoordinateSystem &outCoords, Bool verbose)
| Check shape and axes.
void | findMaps (uInt nDim, Vector< Int > &pixelAxisMap1, Vector< Int > &pixelAxisMap2, const CoordinateSystem &inCoords, const CoordinateSystem &outCoords) const
| Find maps between coordinate systems.
Double | findScaleFactor (const Unit &units, const CoordinateSystem &inCoords, const CoordinateSystem &outCoords, Int inCoordinate, Int outCoordinate, LogIO &os) const
| Find scale factor to conserve flux.

void

_regridOneCoordinate (LogIO &os, IPosition &outShape2, Vector< Bool > &doneOutPixelAxes, MaskedLattice< T > *&finalOutPtr, MaskedLattice< T > *&inPtr, MaskedLattice< T > *&outPtr, CoordinateSystem &outCoords, const CoordinateSystem &inCoords, Int outPixelAxis, const ImageInterface< T > &inImage, const IPosition &outShape, Bool replicate, uInt decimate, Bool outIsMasked, Bool showProgress, Bool forceRegrid, typename Interpolate2D::Method method, Bool verbose)

| Regrid one Coordinate.

void

regridTwoAxisCoordinate (LogIO &os, MaskedLattice< T > &outLattice, const MaskedLattice< T > &inLattice, const Unit &imageUnit, const CoordinateSystem &inCoords, const CoordinateSystem &outCoords, Int inCoordinate, Int outCoordinate, const Vector< Int > inPixelAxes, const Vector< Int > outPixelAxes, const Vector< Int > pixelAxisMap1, const Vector< Int > pixelAxisMap2, typename Interpolate2D::Method method, Bool replicate, uInt decimate, Bool showProgress)

| Regrid DirectionCoordinate or 2-axis LinearCoordinate.

void

make2DCoordinateGrid (LogIO &os, Bool &allFail, Bool &missedIt, Double &minInX, Double &minInY, Double &maxInX, Double &maxInY, Cube< Double > &in2DPos, Matrix< Bool > &succeed, const CoordinateSystem &inCoords, const CoordinateSystem &outCoords, Int inCoordinate, Int outCoordinate, uInt xInAxis, uInt yInAxis, uInt xOutAxis, uInt yOutAxis, const IPosition &inPixelAxes, const IPosition &outPixelAxes, const IPosition &inShape, const IPosition &outPos, const IPosition &cursorShape, uInt decimate=0)

| Make regridding coordinate grid for this cursor.
void | make2DCoordinateGrid (Cube< Double > &in2DPos, Double &minInX, Double &minInY, Double &maxInX, Double &maxInY, const Vector< Double > &pixelScale, uInt xInAxis, uInt yInAxis, uInt xOutAxis, uInt yOutAxis, uInt xInCorrAxis, uInt yInCorrAxis, uInt xOutCorrAxis, uInt yOutCorrAxis, const IPosition &outPos, const IPosition &cursorShape)
| Make replication coordinate grid for this cursor.
void | make1DCoordinateGrid (Block< typename NumericTraits< T >::BaseType > &xOut, Vector< Bool > &failed, Bool &allFailed, Bool &allGood, const Coordinate &inCoord, const Coordinate &outCoord, Int inAxisInCoordinate, Int outAxisInCoordinate, MFrequency::Convert &machine, Bool useMachine)
| Make regridding coordinate grid for this axis.
void | make1DCoordinateGrid (Block< typename NumericTraits< T >::BaseType > &xOut, typename NumericTraits< T >::BaseType pixelScale) const
| Make replication coordinate grid for this axis.

void

regrid1D (MaskedLattice< T > &outLattice, const MaskedLattice< T > &inLattice, const Coordinate &inCoord, const Coordinate &outCoord, const Vector< Int > &inPixelAxes, const Vector< Int > &outPixelAxes, Int inAxisInCoordinate, Int outAxisInCoordinate, const Vector< Int > pixelAxisMap, typename Interpolate2D::Method method, MFrequency::Convert &machine, Bool replicate, Bool useMachine, Bool showProgress)

| Regrid 1 axis.

void

regrid2DMatrix (Lattice< T > &outCursor, LatticeIterator< Bool > *&outMaskIterPtr, const Interpolate2D &interp, ProgressMeter *&pProgress, Double &iPix, uInt nDim, uInt xInAxis, uInt yInAxis, uInt xOutAxis, uInt yOutAxis, Double scale, Bool inIsMasked, Bool outIsMasked, const IPosition &outPos, const IPosition &outCursorShape, const IPosition &inChunkShape, const IPosition &inChunkBlc, const IPosition &pixelAxisMap2, Array< T > &inDataChunk, Array< Bool > *&inMaskChunkPtr, const Cube< Double > &pix2DPos, const Matrix< Bool > &succeed)

void | findXYExtent (Bool &missedIt, Bool &allFailed, Double &minInX, Double &minInY, Double &maxInX, Double &maxInY, Cube< Double > &in2DPos, const Matrix< Bool > &succeed, uInt xInAxis, uInt yInAxis, uInt xOutAxis, uInt yOutAxis, const IPosition &outPos, const IPosition &outCursorShape, const IPosition &inShape)
Bool | minmax (Double &minX, Double &maxX, Double &minY, Double &maxY, const Array< Double > &xData, const Array< Double > &yData, const Array< Bool > &mask)

## Private Attributes

Int | itsShowLevel
Bool | itsDisableConversions
Cube< Double > | its2DCoordinateGrid
Matrix< Bool > | its2DCoordinateGridMask
Cube< Double > | itsUser2DCoordinateGrid
Matrix< Bool > | itsUser2DCoordinateGridMask
Bool | itsNotify

## Detailed Description

template<class T>
class casacore::ImageRegrid< T >

This regrids one image to match the coordinate system of another

### Intended use:

Public interface

### Review Status

Date Reviewed:
  yyyy/mm/dd

### Prerequisite

- ImageInterface
- CoordinateSystem
- Interpolate2D
- InterpolateArray1D

### Etymology

Regrids, or resamples, images.

### Synopsis

This class enables you to regrid one image to the coordinate system of another. You can regrid any or all of the axes in the image. A range of interpolation schemes are available.

It will cope with coordinate systems being in different orders (coordinate, world axes, pixel axes). The basic approach is to make a mapping from the input to the output coordinate systems, but the output CoordinateSystem order is preserved in the output image.

Any DirectionCoordinate or LinearCoordinate holding exactly two axes is regridded in one pass with a 2-D interpolation scheme. All other axes are regridded in separate passes with a 1D interpolation scheme. This means that a LinearCoordinate holding say 3 axes where some of them are coupled will not be correctly regridded. StokesCoordinates cannot be regridded.

Multiple passes are made through the data, and the output of each pass is the input of the next pass. The intermediate images are stored as TempImages which may be in memory or on disk, depending on their size.

It can also simply insert this image into that one via an integer shift.

### Example

### Motivation

A common image analysis need is to regrid images, e.g. to compare images from different telescopes.

### Thrown Exceptions

- AipsError

Definition at line 116 of file ImageRegrid.h.

## Constructor & Destructor Documentation

## ImageRegrid() [1/2]

template<class T>

casacore::ImageRegrid< T >::ImageRegrid | ( |  | ) |

Default constructor.

Referenced by ImageRegrid(), and operator=().

## ImageRegrid() [2/2]

template<class T>

casacore::ImageRegrid< T >::ImageRegrid | ( | const ImageRegrid< T > & | other | ) |

copy constructor (copy semantics)

References ImageRegrid().

## ~ImageRegrid()

template<class T>

casacore::ImageRegrid< T >::~ImageRegrid | ( |  | ) |

destructor

## Member Function Documentation

## _checkAxes()

template<class T>

void casacore::ImageRegrid< T >::_checkAxes | ( | IPosition & | outPixelAxes,
|  | const IPosition & | inShape,
|  | const IPosition & | outShape,
|  | const Vector< Int > & | pixelAxisMap,
|  | const CoordinateSystem & | outCoords,
|  | Bool | verbose )

private

Check shape and axes.

Exception if no good. If pixelAxes of length 0, set to all axes according to shape

## _regridOneCoordinate()

template<class T>

void casacore::ImageRegrid< T >::_regridOneCoordinate | ( | LogIO & | os,
|  | IPosition & | outShape2,
|  | Vector< Bool > & | doneOutPixelAxes,
|  | MaskedLattice< T > *& | finalOutPtr,
|  | MaskedLattice< T > *& | inPtr,
|  | MaskedLattice< T > *& | outPtr,
|  | CoordinateSystem & | outCoords,
|  | const CoordinateSystem & | inCoords,
|  | Int | outPixelAxis,
|  | const ImageInterface< T > & | inImage,
|  | const IPosition & | outShape,
|  | Bool | replicate,
|  | uInt | decimate,
|  | Bool | outIsMasked,
|  | Bool | showProgress,
|  | Bool | forceRegrid,
|  | typename Interpolate2D::Method | method,
|  | Bool | verbose )

private

Regrid one Coordinate.

## disableReferenceConversions()

template<class T>

void casacore::ImageRegrid< T >::disableReferenceConversions | ( | Bool | disable = True | ) |

inline

Enable/disable Measures Reference conversions.

Definition at line 186 of file ImageRegrid.h.

References itsDisableConversions, and casacore::True.

## findMaps()

template<class T>

void casacore::ImageRegrid< T >::findMaps | ( | uInt | nDim,
|  | Vector< Int > & | pixelAxisMap1,
|  | Vector< Int > & | pixelAxisMap2,
|  | const CoordinateSystem & | inCoords,
|  | const CoordinateSystem & | outCoords ) const

private

Find maps between coordinate systems.

## findScaleFactor()

template<class T>

Double casacore::ImageRegrid< T >::findScaleFactor | ( | const Unit & | units,
|  | const CoordinateSystem & | inCoords,
|  | const CoordinateSystem & | outCoords,
|  | Int | inCoordinate,
|  | Int | outCoordinate,
|  | LogIO & | os ) const

private

Find scale factor to conserve flux.

## findXYExtent()

template<class T>

void casacore::ImageRegrid< T >::findXYExtent | ( | Bool & | missedIt,
|  | Bool & | allFailed,
|  | Double & | minInX,
|  | Double & | minInY,
|  | Double & | maxInX,
|  | Double & | maxInY,
|  | Cube< Double > & | in2DPos,
|  | const Matrix< Bool > & | succeed,
|  | uInt | xInAxis,
|  | uInt | yInAxis,
|  | uInt | xOutAxis,
|  | uInt | yOutAxis,
|  | const IPosition & | outPos,
|  | const IPosition & | outCursorShape,
|  | const IPosition & | inShape )

private

## get2DCoordinateGrid()

template<class T>

void casacore::ImageRegrid< T >::get2DCoordinateGrid | ( | Cube< Double > & | grid,
|  | Matrix< Bool > & | gridMask ) const

Get and set the 2-D coordinate grid.

After a call to function regrid in which coupled 2D coordinate (presently only DirectionCoordinate) is regridded, this coordinate grid will be available. It can be reused via the set2DCoordinateGrid function for another like plane (e.g. if you choose to regrid planes of a cube separately). When you provide the coordinate grid, it will no longer (for that 2D coordinate only) be computed internally, which may save a lot of time. Ordinarily, if you regridded many planes of a cube in one call to regrid, the coordinate grid is cached for you. To trigger successive calls to regrid to go back to internal computation, set zero length Cube and Matrix. gridMask is True for successfull coordinate conversions, and False otherwise.

## insert()

template<class T>

Bool casacore::ImageRegrid< T >::insert | ( | ImageInterface< T > & | outImage,
|  | const Vector< Double > & | outPixelLocation,
|  | const ImageInterface< T > & | inImage )

Inserts inImage into outImage.

The alignment is done by placing the blc of inImage at the specified absolute pixel of the outImage (outPixelLocation). If the outPixelLocation vector is of zero length, then the images are aligned by their reference pixels. Only integral shifts are done in the aligment process. If outImage has a mask, it will be updated. Returns False if no overlap of images, in which case the output is not updated.

## make1DCoordinateGrid() [1/2]

template<class T>

void casacore::ImageRegrid< T >::make1DCoordinateGrid | ( | Block< typename NumericTraits< T >::BaseType > & | xOut,
|  | typename NumericTraits< T >::BaseType | pixelScale ) const

private

Make replication coordinate grid for this axis.

## make1DCoordinateGrid() [2/2]

template<class T>

void casacore::ImageRegrid< T >::make1DCoordinateGrid | ( | Block< typename NumericTraits< T >::BaseType > & | xOut,
|  | Vector< Bool > & | failed,
|  | Bool & | allFailed,
|  | Bool & | allGood,
|  | const Coordinate & | inCoord,
|  | const Coordinate & | outCoord,
|  | Int | inAxisInCoordinate,
|  | Int | outAxisInCoordinate,
|  | MFrequency::Convert & | machine,
|  | Bool | useMachine )

private

Make regridding coordinate grid for this axis.

## make2DCoordinateGrid() [1/2]

template<class T>

void casacore::ImageRegrid< T >::make2DCoordinateGrid | ( | Cube< Double > & | in2DPos,
|  | Double & | minInX,
|  | Double & | minInY,
|  | Double & | maxInX,
|  | Double & | maxInY,
|  | const Vector< Double > & | pixelScale,
|  | uInt | xInAxis,
|  | uInt | yInAxis,
|  | uInt | xOutAxis,
|  | uInt | yOutAxis,
|  | uInt | xInCorrAxis,
|  | uInt | yInCorrAxis,
|  | uInt | xOutCorrAxis,
|  | uInt | yOutCorrAxis,
|  | const IPosition & | outPos,
|  | const IPosition & | cursorShape )

private

Make replication coordinate grid for this cursor.

## make2DCoordinateGrid() [2/2]

template<class T>

void casacore::ImageRegrid< T >::make2DCoordinateGrid | ( | LogIO & | os,
|  | Bool & | allFail,
|  | Bool & | missedIt,
|  | Double & | minInX,
|  | Double & | minInY,
|  | Double & | maxInX,
|  | Double & | maxInY,
|  | Cube< Double > & | in2DPos,
|  | Matrix< Bool > & | succeed,
|  | const CoordinateSystem & | inCoords,
|  | const CoordinateSystem & | outCoords,
|  | Int | inCoordinate,
|  | Int | outCoordinate,
|  | uInt | xInAxis,
|  | uInt | yInAxis,
|  | uInt | xOutAxis,
|  | uInt | yOutAxis,
|  | const IPosition & | inPixelAxes,
|  | const IPosition & | outPixelAxes,
|  | const IPosition & | inShape,
|  | const IPosition & | outPos,
|  | const IPosition & | cursorShape,
|  | uInt | decimate = 0 )

private

Make regridding coordinate grid for this cursor.

## makeCoordinateSystem()

template<class T>

CoordinateSystem casacore::ImageRegrid< T >::makeCoordinateSystem | ( | LogIO & | os,
|  | std::set< Coordinate::Type > & | coordsToBeRegridded,
|  | const CoordinateSystem & | cSysTo,
|  | const CoordinateSystem & | cSysFrom,
|  | const IPosition & | axes,
|  | const IPosition & | inShape = IPosition(),
|  | Bool | giveStokesWarning = True )

static

Helper function.

We are regridding from cSysFrom to cSysTo for the specified pixel axes of cSyFrom. This function returns a CoordinateSystem which, for the pixel axes being regridded, copies the coordinates from cSysTo (if coordinate type present in cSysTo) or cSysFrom (coordinate type not present in cSysTo). For the axes not being regridded, it copies the coordinates from cSysFrom. This helps you build the cSys for function regrid. The ObsInfo from cSysFrom is copied to the output CoordinateSystem. If inShape has one or more elements it represenents the size of the image to be regridded. It this must have the same number of elements as the number of pixel axes in cSysFrom. If any of the values are unity (ie the axes are degenerate), and the corresponding axis in csysFrom is the only axis in its corresponding coordinate, this coordinate will not be replaced even if the axis is specified in axes. Upon return, coordsToBeRegridded will contain a list of the coordinates that will be regridded.

References casacore::True.

## minmax()

template<class T>

Bool casacore::ImageRegrid< T >::minmax | ( | Double & | minX,
|  | Double & | maxX,
|  | Double & | minY,
|  | Double & | maxY,
|  | const Array< Double > & | xData,
|  | const Array< Double > & | yData,
|  | const Array< Bool > & | mask )

private

References casacore::mask().

## operator=()

template<class T>

ImageRegrid< T > & casacore::ImageRegrid< T >::operator= | ( | const ImageRegrid< T > & | other | ) |

Assignment copy semantics).

References ImageRegrid().

## regrid()

template<class T>

void casacore::ImageRegrid< T >::regrid | ( | ImageInterface< T > & | outImage,
|  | typename Interpolate2D::Method | method,
|  | const IPosition & | whichOutPixelAxes,
|  | const ImageInterface< T > & | inImage,
|  | Bool | replicate = False,
|  | uInt | decimate = 0,
|  | Bool | showProgress = False,
|  | Bool | forceRegrid = False,
|  | Bool | verbose = False )

Regrid inImage onto the grid specified by outImage.

If outImage has a writable mask, it will be updated in that output pixels at which the regridding failed will be masked bad (False) and the pixel value set to zero. Otherwise the output mask is not changed. Specify which pixel axes of outImage are to be regridded. The coordinate and axis order of outImage is preserved, regardless of where the relevant coordinates are in inImage.

decimate only applies when replicate=False. it is the coordinate grid computation decimation FACTOR (e.g. nCoordGrid ~ nIn / decimate). 0 means no decimation (slowest and most accurate)

References casacore::False.

## regrid1D()

template<class T>

void casacore::ImageRegrid< T >::regrid1D | ( | MaskedLattice< T > & | outLattice,
|  | const MaskedLattice< T > & | inLattice,
|  | const Coordinate & | inCoord,
|  | const Coordinate & | outCoord,
|  | const Vector< Int > & | inPixelAxes,
|  | const Vector< Int > & | outPixelAxes,
|  | Int | inAxisInCoordinate,
|  | Int | outAxisInCoordinate,
|  | const Vector< Int > | pixelAxisMap,
|  | typename Interpolate2D::Method | method,
|  | MFrequency::Convert & | machine,
|  | Bool | replicate,
|  | Bool | useMachine,
|  | Bool | showProgress )

private

Regrid 1 axis.

## regrid2DMatrix()

template<class T>

void casacore::ImageRegrid< T >::regrid2DMatrix | ( | Lattice< T > & | outCursor,
|  | LatticeIterator< Bool > *& | outMaskIterPtr,
|  | const Interpolate2D & | interp,
|  | ProgressMeter *& | pProgress,
|  | Double & | iPix,
|  | uInt | nDim,
|  | uInt | xInAxis,
|  | uInt | yInAxis,
|  | uInt | xOutAxis,
|  | uInt | yOutAxis,
|  | Double | scale,
|  | Bool | inIsMasked,
|  | Bool | outIsMasked,
|  | const IPosition & | outPos,
|  | const IPosition & | outCursorShape,
|  | const IPosition & | inChunkShape,
|  | const IPosition & | inChunkBlc,
|  | const IPosition & | pixelAxisMap2,
|  | Array< T > & | inDataChunk,
|  | Array< Bool > *& | inMaskChunkPtr,
|  | const Cube< Double > & | pix2DPos,
|  | const Matrix< Bool > & | succeed )

private

## regridTwoAxisCoordinate()

template<class T>

void casacore::ImageRegrid< T >::regridTwoAxisCoordinate | ( | LogIO & | os,
|  | MaskedLattice< T > & | outLattice,
|  | const MaskedLattice< T > & | inLattice,
|  | const Unit & | imageUnit,
|  | const CoordinateSystem & | inCoords,
|  | const CoordinateSystem & | outCoords,
|  | Int | inCoordinate,
|  | Int | outCoordinate,
|  | const Vector< Int > | inPixelAxes,
|  | const Vector< Int > | outPixelAxes,
|  | const Vector< Int > | pixelAxisMap1,
|  | const Vector< Int > | pixelAxisMap2,
|  | typename Interpolate2D::Method | method,
|  | Bool | replicate,
|  | uInt | decimate,
|  | Bool | showProgress )

private

Regrid DirectionCoordinate or 2-axis LinearCoordinate.

## set2DCoordinateGrid()

template<class T>

void casacore::ImageRegrid< T >::set2DCoordinateGrid | ( | const Cube< Double > & | grid,
|  | const Matrix< Bool > & | gridMask,
|  | Bool | notify = False )

References casacore::False.

## showDebugInfo()

template<class T>

void casacore::ImageRegrid< T >::showDebugInfo | ( | Int | level = 0 | ) |

inline

Print out useful debugging information (level 0 is none, 1 is some, 2 is too much).

Definition at line 183 of file ImageRegrid.h.

References itsShowLevel.

## Member Data Documentation

## its2DCoordinateGrid

template<class T>

Cube<Double> casacore::ImageRegrid< T >::its2DCoordinateGrid

private

Definition at line 219 of file ImageRegrid.h.

## its2DCoordinateGridMask

template<class T>

Matrix<Bool> casacore::ImageRegrid< T >::its2DCoordinateGridMask

private

Definition at line 220 of file ImageRegrid.h.

## itsDisableConversions

template<class T>

Bool casacore::ImageRegrid< T >::itsDisableConversions

private

Definition at line 217 of file ImageRegrid.h.

Referenced by disableReferenceConversions().

## itsNotify

template<class T>

Bool casacore::ImageRegrid< T >::itsNotify

private

Definition at line 224 of file ImageRegrid.h.

## itsShowLevel

template<class T>

Int casacore::ImageRegrid< T >::itsShowLevel

private

Definition at line 216 of file ImageRegrid.h.

Referenced by showDebugInfo().

## itsUser2DCoordinateGrid

template<class T>

Cube<Double> casacore::ImageRegrid< T >::itsUser2DCoordinateGrid

private

Definition at line 222 of file ImageRegrid.h.

## itsUser2DCoordinateGridMask

template<class T>

Matrix<Bool> casacore::ImageRegrid< T >::itsUser2DCoordinateGridMask

private

Definition at line 223 of file ImageRegrid.h.

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

- images/Images/ImageRegrid.h