mPad

Description:

Occasionally we want to pad the border of an image so that there is room for annotation, a color bar, or just for visual effect. mPad does this and if a color bar is desired it adds one (wherever the user specifies, which might be in the pad or might be over the image).

The pad around the edges is filled with NULLS (which will be rendered the same as the minimum in the color table but mJPEG/mViewer). However the user can optionally have NULLs translated to another value with the "-val" argument.

Syntax:
mPad [-nowcs][-d level][-val NaN-value][-bar xmin xmax ymin ymax histfile] in.fits out.fits left right top bottom

Switches:

-nowcs
If the image has WCS values in the header, these need to be adjusted to compensate for the padding. This flag is used to tell the software that the image does not contain WCS keywords so not to try.
-d level
Set debugging level (default none)
-val NaN-value
Value to which NULL pixels should be converted.
-bar xmin xmax
ymin ymax
histfile

Adding a color bar as part of the image is a little trickier than it might at first seem.

A color bar is a rectangular region of pixels whose data values are set so that it gives the impression of the lookup-table used to render the image. To do this, we need the image histogram that mViewer (or whatever renderer) would use when displaying the data.

The easiest way to do this is to 1) use mHistogram to generate the stretchl 2) use mPad to add the pixel array (usually in a pad added around the outside of the image(; and 3) use mViewer with the same pre-build histogram to render the image.

Arguments:

in.fits
Original FITS image.
out.fits
Padded FITS image.
left right top bottom
Number of pixels with which to pad the four sides of the image.
Results:
If successful, the result is a new image almost identical to the original but padded around the edges and possibly containing an embedded color bar. When sent to mViewer, that tool can optionally add annotation to the bar.

Examples:

(mHistogram -file SDSS_r.fits -2s max gaussian-log -out SDSS_r.hist)

mPad -bar -100 -50 50 -50 SDSS_r.hist SDSS_r.fits sdss.fits 50 250 50 50

[struct stat="OK"]

Padded image with color bar:

Return Codes:

  • [struct stat="ERROR", msg="Usage: mPad [-nowcs][-d level][-val NaN-value][-bar xmin xmax ymin ymax histfile] in.fits out.fits left right top bottom"]
  • [struct stat="ERROR", msg="No debug level given"]
  • [struct stat="ERROR", msg="Debug level string is invalid: 'badstring'"]
  • [struct stat="ERROR", msg="Debug level value cannot be negative"]
  • [struct stat="ERROR", msg="Not enough information given to draw color bar"]
  • [struct stat="ERROR", msg="Bar X min string is invalid: 'badstring'"]
  • [struct stat="ERROR", msg="Bar X max string is invalid: 'badstring'"]
  • [struct stat="ERROR", msg="Bar Y min string is invalid: 'badstring'"]
  • [struct stat="ERROR", msg="Bar Y max string is invalid: 'badstring'"]
  • [struct stat="ERROR", msg="Cannot open histogram file badfile"]
  • [struct stat="ERROR", msg="No value given for NaN conversion"]
  • [struct stat="ERROR", msg="NaN conversion value string is invalid: 'badstring'"]
  • [struct stat="ERROR", status=stat, msg="FITS library error"]
  • [struct stat="ERROR", msg="general error message"]