def testSaturated(self): """Test interpolating saturated pixels""" satValue = 1000.0 for f in [R, G, B]: self.images[f] = saturate(self.images[f], satValue) rgb.replaceSaturatedPixels(self.images[R], self.images[G], self.images[B], 1, 2000) # # Check that we replaced those NaNs with some reasonable value # for f in [R, G, B]: self.assertTrue(np.isfinite(self.images[f].getImage().getArray()).all()) if False: ds9.mtv(self.images[B], frame=0, title="B") ds9.mtv(self.images[G], frame=1, title="G") ds9.mtv(self.images[R], frame=2, title="R") # # Prepare for generating an output file # for f in [R, G, B]: self.images[f] = self.images[f].getImage() asinhMap = rgb.AsinhMapping(self.min, self.range, self.Q) rgbImage = asinhMap.makeRgbImage(self.images[R], self.images[G], self.images[B]) if display: rgb.displayRGB(rgbImage)
def makeThumbnail(exposure, isrQaConfig=None): """Create a snapshot thumbnail from input exposure. The output thumbnail image is constructed based on the parameters in the configuration file. Currently, the asinh mapping is the only mapping method used. Parameters ---------- exposure : `lsst.afw.image.Exposure` The exposure to be converted into a thumbnail. isrQaConfig : `Config` Configuration object containing all parameters to control the thumbnail generation. Returns ------- rgbImage : `numpy.ndarray` Binned and scaled version of the exposure, converted to an integer array to allow it to be written as PNG. """ if isrQaConfig is not None: binning = isrQaConfig.thumbnailBinning binnedImage = afwMath.binImage(exposure.getMaskedImage(), binning, binning, afwMath.MEAN) statsCtrl = afwMath.StatisticsControl() statsCtrl.setAndMask(binnedImage.getMask().getPlaneBitMask( ["SAT", "BAD", "INTRP"])) stats = afwMath.makeStatistics( binnedImage, afwMath.MEDIAN | afwMath.STDEVCLIP | afwMath.MAX, statsCtrl) low = stats.getValue( afwMath.MEDIAN) - isrQaConfig.thumbnailStdev * stats.getValue( afwMath.STDEVCLIP) if isrQaConfig.thumbnailSatBorder: afwRGB.replaceSaturatedPixels(binnedImage, binnedImage, binnedImage, isrQaConfig.thumbnailSatBorder, stats.getValue(afwMath.MAX)) asinhMap = afwRGB.AsinhMapping(low, isrQaConfig.thumbnailRange, Q=isrQaConfig.thumbnailQ) rgbImage = asinhMap.makeRgbImage(binnedImage) return rgbImage