Package gavo :: Package utils :: Module imgtools
[frames] | no frames]

Module imgtools

source code

Some miscellaneous helpers for making images and such.

As this may turn into a fairly expensive import, this should *not* be imported by utils.__init__. Hence, none of these functions are in gavo.api or gavo.utils.

Functions
 
jpegFromNumpyArray(pixels, gamma=0.25)
returns a normalized JPEG for numpy pixels.
source code
 
colorJpegFromNumpyArrays(rPix, gPix, bPix, gamma=0.25)
as jpegFromNumpyArray, except a color jpeg is built from red, green, and blue pixels.
source code
 
scaleNumpyArray(arr, destSize)
returns the numpy array arr scaled down to approximately destSize.
source code
 
getScaledPNG(srcFile, newWidth)
returns a PNG string that is a scaled version of an image in srcFile.
source code
Variables
  __package__ = 'gavo.utils'
Function Details

jpegFromNumpyArray(pixels, gamma=0.25)

source code 

returns a normalized JPEG for numpy pixels.

pixels is assumed to come from FITS arrays, which are flipped wrt to jpeg coordinates, which is why we're flipping here.

The normalized intensities are scaled by v^gamma; we believe the default helps with many astronomical images

getScaledPNG(srcFile, newWidth)

source code 

returns a PNG string that is a scaled version of an image in srcFile.

srcFile must correspond to something that PIL can read. Since scaling really sucks for non-RGB images, we unconditionally convert whatever we get to 3-band RGB.