LSSTApplications  19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+10,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+5,19.0.0-20-g5a5a17ab+8,19.0.0-21-g2644856+10,19.0.0-22-gc5dc5b1+5,19.0.0-23-gdc29a50+2,19.0.0-24-g923e380+10,19.0.0-25-g6c8df7140,19.0.0-27-g567f04d+6,19.0.0-3-g2b32d65+5,19.0.0-3-g8227491+9,19.0.0-3-g9c54d0d+9,19.0.0-3-gca68e65+5,19.0.0-3-gcfc5f51+5,19.0.0-3-ge110943+8,19.0.0-3-ge74d124,19.0.0-3-gfe04aa6+10,19.0.0-4-g06f5963+5,19.0.0-4-g3d16501+10,19.0.0-4-g4a9c019+5,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8278b9b+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+10,19.0.0-4-ge404a01+9,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gfb03ce7+10,19.0.0-6-gbaebbfb+9,19.0.0-60-gafafd468+10,19.0.0-64-gf672fef+7,19.0.0-7-g039c0b5+8,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+10,19.0.0-8-g3a3ce09+5,19.0.0-9-g463f923+9,w.2020.21
LSSTDataManagementBasePackage
Classes | Functions
lsst.afw.display.rgb.rgbContinued Namespace Reference

Classes

class  _RgbImageF
 
class  AsinhMapping
 
class  asinhMappingF
 
class  AsinhZScaleMapping
 
class  LinearMapping
 
class  Mapping
 
class  ZScaleMapping
 

Functions

def computeIntensity (imageR, imageG=None, imageB=None)
 
def makeRGB (imageR, imageG=None, imageB=None, minimum=0, dataRange=5, Q=8, fileName=None, saturatedBorderWidth=0, saturatedPixelValue=None, xSize=None, ySize=None, rescaleFactor=None)
 
def displayRGB (rgb, show=True)
 
def writeRGB (fileName, rgbImage)
 
def RgbImageF (imageR, imageG, imageB, mapping)
 

Function Documentation

◆ computeIntensity()

def lsst.afw.display.rgb.rgbContinued.computeIntensity (   imageR,
  imageG = None,
  imageB = None 
)
Return a naive total intensity from the red, blue, and green intensities

Parameters
----------
imageR : `lsst.afw.image.MaskedImage`, `lsst.afw.image.Image`, or `numpy.ndarray`, (Nx, Ny)
    intensity of image that'll be mapped to red; or intensity if imageG and imageB are None
imageG : `lsst.afw.image.MaskedImage`, `lsst.afw.image.Image`, or `numpy.ndarray`, (Nx, Ny)
    intensity of image that'll be mapped to green; or None
imageB : `lsst.afw.image.MaskedImage`, `lsst.afw.image.Image`, or `numpy.ndarray`, (Nx, Ny)
    intensity of image that'll be mapped to blue; or None

Returns
-------
image : type of ``imageR``, ``imageG``, and `imageB``

Definition at line 31 of file rgbContinued.py.

31 def computeIntensity(imageR, imageG=None, imageB=None):
32  """Return a naive total intensity from the red, blue, and green intensities
33 
34  Parameters
35  ----------
36  imageR : `lsst.afw.image.MaskedImage`, `lsst.afw.image.Image`, or `numpy.ndarray`, (Nx, Ny)
37  intensity of image that'll be mapped to red; or intensity if imageG and imageB are None
38  imageG : `lsst.afw.image.MaskedImage`, `lsst.afw.image.Image`, or `numpy.ndarray`, (Nx, Ny)
39  intensity of image that'll be mapped to green; or None
40  imageB : `lsst.afw.image.MaskedImage`, `lsst.afw.image.Image`, or `numpy.ndarray`, (Nx, Ny)
41  intensity of image that'll be mapped to blue; or None
42 
43  Returns
44  -------
45  image : type of ``imageR``, ``imageG``, and `imageB``
46  """
47  if imageG is None or imageB is None:
48  assert imageG is None and imageB is None, \
49  "Please specify either a single image or red, green, and blue images"
50  return imageR
51 
52  imageRGB = [imageR, imageG, imageB]
53 
54  for i, c in enumerate(imageRGB):
55  if hasattr(c, "getImage"):
56  c = imageRGB[i] = c.getImage()
57  if hasattr(c, "getArray"):
58  imageRGB[i] = c.getArray()
59 
60  intensity = (imageRGB[0] + imageRGB[1] + imageRGB[2])/float(3)
61  #
62  # Repack into whatever type was passed to us
63  #
64  Image = afwImage.ImageU if intensity.dtype == 'uint16' else afwImage.ImageF
65 
66  if hasattr(imageR, "getImage"): # a maskedImage
67  intensity = afwImage.makeMaskedImage(Image(intensity))
68  elif hasattr(imageR, "getArray"):
69  intensity = Image(intensity)
70 
71  return intensity
72 
73 

◆ displayRGB()

def lsst.afw.display.rgb.rgbContinued.displayRGB (   rgb,
  show = True 
)
Display an rgb image using matplotlib

Parameters
----------
rgb
    The RGB image in question
show : `bool`
    If `True`, call `matplotlib.pyplot.show()`

Definition at line 433 of file rgbContinued.py.

433 def displayRGB(rgb, show=True):
434  """Display an rgb image using matplotlib
435 
436  Parameters
437  ----------
438  rgb
439  The RGB image in question
440  show : `bool`
441  If `True`, call `matplotlib.pyplot.show()`
442  """
443  import matplotlib.pyplot as plt
444  plt.imshow(rgb, interpolation='nearest', origin="lower")
445  if show:
446  plt.show()
447  return plt
448 
449 

◆ makeRGB()

def lsst.afw.display.rgb.rgbContinued.makeRGB (   imageR,
  imageG = None,
  imageB = None,
  minimum = 0,
  dataRange = 5,
  Q = 8,
  fileName = None,
  saturatedBorderWidth = 0,
  saturatedPixelValue = None,
  xSize = None,
  ySize = None,
  rescaleFactor = None 
)
Make a set of three images into an RGB image using an asinh stretch and
optionally write it to disk

Parameters
----------
imageR
imageG
imageB
minimum : `float` or sequence of `float`
dataRange
Q : `int`
fileName : `str`
    The output file. The suffix defines the format, and must be supported by matplotlib
saturatedBorderWidth
    If saturatedBorderWidth is non-zero, replace saturated pixels with
    ``saturatedPixelValue``. Note that replacing saturated pixels requires
    that the input images be `lsst.afw.image.MaskedImage`.
saturatedPixelValue
xSize
ySize
rescaleFactor

Definition at line 386 of file rgbContinued.py.

386 def makeRGB(imageR, imageG=None, imageB=None, minimum=0, dataRange=5, Q=8, fileName=None,
387  saturatedBorderWidth=0, saturatedPixelValue=None,
388  xSize=None, ySize=None, rescaleFactor=None):
389  """Make a set of three images into an RGB image using an asinh stretch and
390  optionally write it to disk
391 
392  Parameters
393  ----------
394  imageR
395  imageG
396  imageB
397  minimum : `float` or sequence of `float`
398  dataRange
399  Q : `int`
400  fileName : `str`
401  The output file. The suffix defines the format, and must be supported by matplotlib
402  saturatedBorderWidth
403  If saturatedBorderWidth is non-zero, replace saturated pixels with
404  ``saturatedPixelValue``. Note that replacing saturated pixels requires
405  that the input images be `lsst.afw.image.MaskedImage`.
406  saturatedPixelValue
407  xSize
408  ySize
409  rescaleFactor
410  """
411  if imageG is None:
412  imageG = imageR
413  if imageB is None:
414  imageB = imageR
415 
416  if saturatedBorderWidth:
417  if saturatedPixelValue is None:
418  raise ValueError(
419  "saturatedPixelValue must be set if saturatedBorderWidth is set")
420  replaceSaturatedPixels(imageR, imageG, imageB,
421  saturatedBorderWidth, saturatedPixelValue)
422 
423  asinhMap = AsinhMapping(minimum, dataRange, Q)
424  rgb = asinhMap.makeRgbImage(imageR, imageG, imageB,
425  xSize=xSize, ySize=ySize, rescaleFactor=rescaleFactor)
426 
427  if fileName:
428  writeRGB(fileName, rgb)
429 
430  return rgb
431 
432 

◆ RgbImageF()

def lsst.afw.display.rgb.rgbContinued.RgbImageF (   imageR,
  imageG,
  imageB,
  mapping 
)
Deprecated legacy API

Definition at line 500 of file rgbContinued.py.

500 def RgbImageF(imageR, imageG, imageB, mapping):
501  """Deprecated legacy API
502  """
503  return _RgbImageF(imageR, imageG, imageB, mapping)

◆ writeRGB()

def lsst.afw.display.rgb.rgbContinued.writeRGB (   fileName,
  rgbImage 
)
Write an RGB image to disk

Parameters
----------
fileName : `str`
    The output file. The suffix defines the format, and must be supported by matplotlib

    Most versions of matplotlib support png and pdf (although the eps/pdf/svg writers may be buggy,
    possibly due an interaction with useTeX=True in the matplotlib settings).

    If your matplotlib bundles pil/pillow you should also be able to write jpeg and tiff files.
rgbImage
    The image, as made by e.g. makeRGB

Definition at line 450 of file rgbContinued.py.

450 def writeRGB(fileName, rgbImage):
451  """Write an RGB image to disk
452 
453  Parameters
454  ----------
455  fileName : `str`
456  The output file. The suffix defines the format, and must be supported by matplotlib
457 
458  Most versions of matplotlib support png and pdf (although the eps/pdf/svg writers may be buggy,
459  possibly due an interaction with useTeX=True in the matplotlib settings).
460 
461  If your matplotlib bundles pil/pillow you should also be able to write jpeg and tiff files.
462  rgbImage
463  The image, as made by e.g. makeRGB
464  """
465  import matplotlib.image
466  matplotlib.image.imsave(fileName, rgbImage)
467 
468 #
469 # Support the legacy API
470 #
471 
472 
473 @deprecated(reason="Use `AsinhMapping` instead. To be removed after 20.0.0.",
474  category=FutureWarning) # noqa: N801
lsst::afw.display.rgb.rgbContinued.displayRGB
def displayRGB(rgb, show=True)
Definition: rgbContinued.py:433
lsst::afw.display.rgb.rgbContinued.RgbImageF
def RgbImageF(imageR, imageG, imageB, mapping)
Definition: rgbContinued.py:500
lsst::afw.display.rgb.rgbContinued.makeRGB
def makeRGB(imageR, imageG=None, imageB=None, minimum=0, dataRange=5, Q=8, fileName=None, saturatedBorderWidth=0, saturatedPixelValue=None, xSize=None, ySize=None, rescaleFactor=None)
Definition: rgbContinued.py:386
lsst::afw.display.rgb.rgbContinued.computeIntensity
def computeIntensity(imageR, imageG=None, imageB=None)
Definition: rgbContinued.py:31
lsst::afw.display::replaceSaturatedPixels
void replaceSaturatedPixels(ImageT &rim, ImageT &gim, ImageT &bim, int borderWidth=2, float saturatedPixelValue=65535)
Definition: saturated.cc:30
lsst::afw::image::makeMaskedImage
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT >> image, typename std::shared_ptr< Mask< MaskPixelT >> mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT >> variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
Definition: MaskedImage.h:1279
lsst::afw.display.rgb.rgbContinued.writeRGB
def writeRGB(fileName, rgbImage)
Definition: rgbContinued.py:450