casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Static Public Member Functions | Static Private Member Functions
casa::ImageUtilities Class Reference

Utility functions for Image manipulation
More...

#include <ImageUtilities.h>

List of all members.

Static Public Member Functions

static void openImage (std::auto_ptr< ImageInterface< Float > > &image, const String &fileName, LogIO &os)
 Open disk image (can be any registered image).
static void openImage (ImageInterface< Float > *&image, const String &fileName, LogIO &os)
template<typename T , typename U >
static void copyMiscellaneous (ImageInterface< T > &out, const ImageInterface< U > &in, const Bool copyImageInfo=True)
 Copy MiscInfo, ImageInfo, brightness unit and logger (history) from in to out.
static void copyMask (ImageInterface< Float > &out, const ImageInterface< Float > &in, const String &maskOut, const String &maskIn, AxesSpecifier axesSpecifier)
 Copy a mask from one image to another.
static void addDegenerateAxes (LogIO &os, PtrHolder< ImageInterface< Float > > &outImage, const ImageInterface< Float > &inImage, const String &outFile, Bool direction, Bool spectral, const String &stokes, Bool linear, Bool tabular, Bool overwrite)
 Add one degenerate axis for each of the specified coordinate types.
template<typename T >
static void bin (MaskedArray< T > &out, Coordinate &coordOut, const MaskedArray< T > &in, const Coordinate &coordIn, uInt axis, uInt bin)
 Function to bin up (average data) one axis of an N-D MaskedArray.
static Bool pixToWorld (Vector< String > &sWorld, CoordinateSystem &cSys, const Int &pixelAxis, const Vector< Int > &cursorAxes, const IPosition &blc, const IPosition &trc, const Vector< Double > &pixels, const Int &prec, const Bool usePrecForMixed=False)
 This function converts pixel coordinates to world coordinates.
static String shortAxisName (const String &axisName)
 Convert long axis names "Right Ascension", "Declination", "Frequency" and "Velocity" to "RA", "Dec", "Freq", "Vel" respectively.
static SkyComponent encodeSkyComponent (LogIO &os, Double &facToJy, const CoordinateSystem &cSys, const Unit &brightnessUnit, ComponentType::Shape type, const Vector< Double > &parameters, Stokes::StokesTypes stokes, Bool xIsLong, const GaussianBeam &beam)
 These functions convert between a vector of doubles holding SkyComponent values (the output from SkyComponent::toPixel) and a SkyComponent.
static casa::SkyComponent encodeSkyComponent (casa::LogIO &os, casa::Double &fluxRatio, const casa::ImageInterface< casa::Float > &im, casa::ComponentType::Shape modelType, const casa::Vector< casa::Double > &parameters, casa::Stokes::StokesTypes stokes, casa::Bool xIsLong, casa::Bool deconvolveIt, const GaussianBeam &beam)
 for some reason, this method was in ImageAnalysis but also belongs here.
static SkyComponent deconvolveSkyComponent (LogIO &os, const SkyComponent &skyIn, const GaussianBeam &beam)
 Deconvolve SkyComponent from beam moved from ImageAnalysis.
static GaussianBeam putBeamInXYFrame (const GaussianBeam &beam, const casa::DirectionCoordinate &dirCoord)
*static Vector< DoubledecodeSkyComponent (const SkyComponent &sky, const ImageInfo &ii, const CoordinateSystem &cSys, const Unit &brightnessUnit, Stokes::StokesTypes stokes, Bool xIsLong)
 moved from ImageAnalysis.
static void worldWidthsToPixel (LogIO &os, Vector< Double > &dParameters, const Vector< Quantum< Double > > &parameters, const CoordinateSystem &cSys, const IPosition &pixelAxes, Bool doRef=False)
 moved from ImageAnalysis.
static Bool pixelWidthsToWorld (LogIO &os, GaussianBeam &wParameters, const Vector< Double > &pParameters, const CoordinateSystem &cSys, const IPosition &pixelAxes, Bool doRef=False)
 Convert 2d shape from pixels (parameters=x,y, major axis, minor axis, position angle) to world (major, minor, pa) at specified location.
static void writeImage (const TiledShape &mapShape, const CoordinateSystem &coordinateInfo, const String &imageName, const Array< Float > &pixels, LogIO &log, const Array< Bool > &pixelMask=Array< Bool >())
 write the specified image and add the specified pixels to it.
static GaussianBeam makeFakeBeam (LogIO &logIO, const CoordinateSystem &csys, Bool suppressWarnings=False)
static void getUnitAndDoppler (String &xUnit, String &doppler, const uInt axis, const CoordinateSystem &csys)

Static Private Member Functions

static Bool skyPixelWidthsToWorld (LogIO &os, GaussianBeam &wParameters, const CoordinateSystem &cSys, const Vector< Double > &pParameters, const IPosition &pixelAxes, Bool doRef)
 Convert 2d sky shape (parameters=major axis, minor axis, position angle) from pixels to world at reference pixel.
static Double worldWidthToPixel (LogIO &os, Double positionAngle, const Quantum< Double > &length, const CoordinateSystem &cSys, const IPosition &pixelAxes)
 Convert a length and position angle in world units (for a non-coupled coordinate) to pixels.
static Quantum< DoublepixelWidthToWorld (LogIO &os, Double positionAngle, Double length, const CoordinateSystem &cSys, const IPosition &pixelAxes)

Detailed Description

Utility functions for Image manipulation

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

Some helpful static functions that are common to some of my image analysis application classes.

Motivation

I needed some bits and pieces. My goal isto move this rag-tag bunch out of here into other classes as time goes on. So far I have eliminated 80% of the original !

To Do

Definition at line 95 of file ImageUtilities.h.


Member Function Documentation

static void casa::ImageUtilities::addDegenerateAxes ( LogIO os,
PtrHolder< ImageInterface< Float > > &  outImage,
const ImageInterface< Float > &  inImage,
const String outFile,
Bool  direction,
Bool  spectral,
const String stokes,
Bool  linear,
Bool  tabular,
Bool  overwrite 
) [static]

Add one degenerate axis for each of the specified coordinate types.

If the outfile string is given the new image is a PagedImage. If the outfile string is empty, the new image is a TempImage.

template<typename T >
static void casa::ImageUtilities::bin ( MaskedArray< T > &  out,
Coordinate coordOut,
const MaskedArray< T > &  in,
const Coordinate coordIn,
uInt  axis,
uInt  bin 
) [static]

Function to bin up (average data) one axis of an N-D MaskedArray.

The interface is pretty specific to a particular application. It's here because its implemented with ImageRebin. On input, the output MA must have zero shape. The input and output Coordinates must have the same type and have only one axis (Linear,Spectral & Tabular). The output coordinate is adjusted for the binning. The binning factor does not have to fit integrally into the shape of the specified axis.

static void casa::ImageUtilities::copyMask ( ImageInterface< Float > &  out,
const ImageInterface< Float > &  in,
const String maskOut,
const String maskIn,
AxesSpecifier  axesSpecifier 
) [static]

Copy a mask from one image to another.

template<typename T , typename U >
static void casa::ImageUtilities::copyMiscellaneous ( ImageInterface< T > &  out,
const ImageInterface< U > &  in,
const Bool  copyImageInfo = True 
) [static]

Copy MiscInfo, ImageInfo, brightness unit and logger (history) from in to out.

* static Vector<Double> casa::ImageUtilities::decodeSkyComponent ( const SkyComponent sky,
const ImageInfo ii,
const CoordinateSystem cSys,
const Unit brightnessUnit,
Stokes::StokesTypes  stokes,
Bool  xIsLong 
) [static]

moved from ImageAnalysis.

this needs to be moved to a more appropriate class at some point

static SkyComponent casa::ImageUtilities::deconvolveSkyComponent ( LogIO os,
const SkyComponent skyIn,
const GaussianBeam beam 
) [static]

Deconvolve SkyComponent from beam moved from ImageAnalysis.

this needs to be moved to a more appropriate class at some point

static SkyComponent casa::ImageUtilities::encodeSkyComponent ( LogIO os,
Double facToJy,
const CoordinateSystem cSys,
const Unit brightnessUnit,
ComponentType::Shape  type,
const Vector< Double > &  parameters,
Stokes::StokesTypes  stokes,
Bool  xIsLong,
const GaussianBeam beam 
) [static]

These functions convert between a vector of doubles holding SkyComponent values (the output from SkyComponent::toPixel) and a SkyComponent.

The coordinate values are in the 'x' and 'y' frames. It is possible that the x and y axes of the pixel array are lat/long (xIsLong=False) rather than long/lat. facToJy converts the brightness units from whatevers per whatever to Jy per whatever (e.g. mJy/beam to Jy/beam). It is unity if it can't be done and you get a warning. In the SkyComponent the flux is integral. In the parameters vector it is peak.

pars(0) = FLux image units (e.g. Jy/beam). pars(1) = x cen abs pix pars(2) = y cen abs pix pars(3) = major pix pars(4) = minor pix pars(5) = pa radians (pos +x -> +y)

5 values for ComponentType::Gaussian, CT::Disk. 3 values for CT::Point.

static casa::SkyComponent casa::ImageUtilities::encodeSkyComponent ( casa::LogIO os,
casa::Double fluxRatio,
const casa::ImageInterface< casa::Float > &  im,
casa::ComponentType::Shape  modelType,
const casa::Vector< casa::Double > &  parameters,
casa::Stokes::StokesTypes  stokes,
casa::Bool  xIsLong,
casa::Bool  deconvolveIt,
const GaussianBeam beam 
) [static]

for some reason, this method was in ImageAnalysis but also belongs here.

Obviously hugely confusing to have to methods with the same name and which presumably are for the same thing in two different classes. I'm moving ImageAnalysis' method here and also moving that implamentation to here as well and also being consistent regarding callers (ie those that called the ImageAnalysis method will now call this method). I couldn't tell you which of the two implementations is the better one to use for new code, but this version does call the version that already existed in ImageUtilities, so this version seems to do a bit more. I also hate having a class with anything like Utilities in the name, but I needed to move this somewhere and can only tackle one issue at a time.

static void casa::ImageUtilities::getUnitAndDoppler ( String xUnit,
String doppler,
const uInt  axis,
const CoordinateSystem csys 
) [static]
static GaussianBeam casa::ImageUtilities::makeFakeBeam ( LogIO logIO,
const CoordinateSystem csys,
Bool  suppressWarnings = False 
) [static]
static void casa::ImageUtilities::openImage ( std::auto_ptr< ImageInterface< Float > > &  image,
const String fileName,
LogIO os 
) [static]

Open disk image (can be any registered image).

Exception if fileName empty or file does not exist or file is not of legal image type. For aips++ images, the default mask is applied.

static void casa::ImageUtilities::openImage ( ImageInterface< Float > *&  image,
const String fileName,
LogIO os 
) [static]
static Bool casa::ImageUtilities::pixelWidthsToWorld ( LogIO os,
GaussianBeam wParameters,
const Vector< Double > &  pParameters,
const CoordinateSystem cSys,
const IPosition pixelAxes,
Bool  doRef = False 
) [static]

Convert 2d shape from pixels (parameters=x,y, major axis, minor axis, position angle) to world (major, minor, pa) at specified location.

pixelAxes describes which 2 pixel axes of the coordinate system our 2D shape is in. If doRef is True, then x and y are taken from the reference pixel rather than the paraneters vector.

On input pa is positive for +x -> +y in pixel frame On output pa is positive N->E Returns True if major/minor exchanged themselves on conversion to world.

static Quantum<Double> casa::ImageUtilities::pixelWidthToWorld ( LogIO os,
Double  positionAngle,
Double  length,
const CoordinateSystem cSys,
const IPosition pixelAxes 
) [static, private]
static Bool casa::ImageUtilities::pixToWorld ( Vector< String > &  sWorld,
CoordinateSystem cSys,
const Int pixelAxis,
const Vector< Int > &  cursorAxes,
const IPosition blc,
const IPosition trc,
const Vector< Double > &  pixels,
const Int prec,
const Bool  usePrecForMixed = False 
) [static]

This function converts pixel coordinates to world coordinates.

You specify a vector of pixel coordinates (pixels) for only one axis, the pixelAxis. For the other pixel axes in the CoordinateSystem, if a pixel axis "i" is found in the CursorAxes vector, its pixel coordinate is set to the average of the selected region from the image for that axis ((blc(i)+trc(i))/2)), otherwise it is set to the reference pixel. The vector of world coordinates for pixelAxis is returned as formatted Strings. If for some reason it can't make the conversion, the element element is returned as "?" Returns False if the lengths of <blc and trc are not equal to the number of pixel axes in the coordinate system.

static GaussianBeam casa::ImageUtilities::putBeamInXYFrame ( const GaussianBeam beam,
const casa::DirectionCoordinate dirCoord 
) [static]
static String casa::ImageUtilities::shortAxisName ( const String axisName) [static]

Convert long axis names "Right Ascension", "Declination", "Frequency" and "Velocity" to "RA", "Dec", "Freq", "Vel" respectively.

Unknown strings are returned as given.

static Bool casa::ImageUtilities::skyPixelWidthsToWorld ( LogIO os,
GaussianBeam wParameters,
const CoordinateSystem cSys,
const Vector< Double > &  pParameters,
const IPosition pixelAxes,
Bool  doRef 
) [static, private]

Convert 2d sky shape (parameters=major axis, minor axis, position angle) from pixels to world at reference pixel.

pixelAxes describes which 2 pixel axes of the coordinate system our 2D shape is in. On input pa is positive for +x -> +y in pixel frame On output pa is positive N->E Returns True if major/minor exchanged themselves on conversion to world.

static void casa::ImageUtilities::worldWidthsToPixel ( LogIO os,
Vector< Double > &  dParameters,
const Vector< Quantum< Double > > &  parameters,
const CoordinateSystem cSys,
const IPosition pixelAxes,
Bool  doRef = False 
) [static]

moved from ImageAnalysis.

this needs to be moved to a more appropriate class at some point Deconvolve from beam Returns True if the deconvolved source is a point source, False otherwise. Convert 2d shape from world (world parameters=x, y, major axis, minor axis, position angle) to pixel (major, minor, pa). Can handle quantum units 'pix'. If one width is in pixel units both must be in pixel units. pixelAxes describes which 2 pixel axes of the coordinate system our 2D shape is in. If axes are not from the same coordinate type units must be pixels. If doRef is True, then x and y are taken from the reference value rather than the parameters vector.

On input, pa is N->E (at ref pix) for celestial planes. Otherwise pa is in pixel coordinate system +x -> +y On output, pa (radians) is positive +x -> +y in pixel frame

static Double casa::ImageUtilities::worldWidthToPixel ( LogIO os,
Double  positionAngle,
const Quantum< Double > &  length,
const CoordinateSystem cSys,
const IPosition pixelAxes 
) [static, private]

Convert a length and position angle in world units (for a non-coupled coordinate) to pixels.

The length is in some 2D plane in the CoordinateSystem specified by pixelAxes.

static void casa::ImageUtilities::writeImage ( const TiledShape mapShape,
const CoordinateSystem coordinateInfo,
const String imageName,
const Array< Float > &  pixels,
LogIO log,
const Array< Bool > &  pixelMask = ArrayBool >() 
) [static]

write the specified image and add the specified pixels to it.

Currently no checks are done to ensure the pixel array size and mapShape are compatible; the caller is responsible for this check.


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