gavo.utils.imgtools module

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.

gavo.utils.imgtools.colorJpegFromNumpyArrays(rPix, gPix, bPix, gamma=0.25)[source]

as jpegFromNumpyArray, except a color jpeg is built from red, green, and blue pixels.

gavo.utils.imgtools.getScaledPNG(srcFile, newWidth)[source]

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.

gavo.utils.imgtools.jpegFromNumpyArray(pixels, gamma=0.25)[source]

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

gavo.utils.imgtools.scaleNumpyArray(arr, destSize)[source]

returns the numpy array arr scaled down to approximately destSize.