LSSTApplications  15.0+21,16.0+1,16.0+3,16.0+4,16.0+8,16.0-1-g2115a9e+2,16.0-1-g4515a79+6,16.0-1-g5c6f5ee+4,16.0-1-g7bb14cc,16.0-1-g80120d7+4,16.0-1-g98efed3+4,16.0-1-gb7f560d+1,16.0-14-gb4f0cd2fa,16.0-2-g1ad129e+1,16.0-2-g2ed7261+1,16.0-2-g311bfd2,16.0-2-g568a347+3,16.0-2-g852da13+6,16.0-2-gd4c87cb+3,16.0-3-g099ede0,16.0-3-g150e024+3,16.0-3-g1f513a6,16.0-3-g958ce35,16.0-4-g08dccf71+4,16.0-4-g128aaef,16.0-4-g84f75fb+5,16.0-4-gcfd1396+4,16.0-4-gde8cee2,16.0-4-gdfb0d14+1,16.0-5-g7bc0afb+3,16.0-5-g86fb31a+3,16.0-6-g2dd73041+4,16.0-7-g95fb7bf,16.0-7-gc37dbc2+4,w.2018.28
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | List of all members
lsst.afw.display.rgb.Mapping Class Reference

Baseclass to map red, blue, green intensities into uint8 values. More...

Inheritance diagram for lsst.afw.display.rgb.Mapping:
lsst.afw.display.rgb.AsinhMapping lsst.afw.display.rgb.LinearMapping lsst.afw.display.rgb.AsinhZScaleMapping lsst.afw.display.rgb.ZScaleMapping

Public Member Functions

def __init__ (self, minimum=None, image=None)
 Create a mapping. More...
 
def makeRgbImage (self, imageR=None, imageG=None, imageB=None, xSize=None, ySize=None, rescaleFactor=None)
 Convert 3 arrays, imageR, imageG, and imageB into a numpy RGB image. More...
 
def intensity (self, imageR, imageG, imageB)
 Return the total intensity from the red, blue, and green intensities. More...
 
def mapIntensityToUint8 (self, intensity)
 

Public Attributes

 minimum
 

Detailed Description

Baseclass to map red, blue, green intensities into uint8 values.

Definition at line 65 of file rgb.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.afw.display.rgb.Mapping.__init__ (   self,
  minimum = None,
  image = None 
)

Create a mapping.

Parameters
minimumIntensity that should be mapped to black (a scalar or array for R, G, B)
imageThe image to be used to calculate the mapping.

If provided, also the default for makeRgbImage()

Definition at line 68 of file rgb.py.

68  def __init__(self, minimum=None, image=None):
69  """!Create a mapping
70  @param minimum Intensity that should be mapped to black (a scalar or array for R, G, B)
71  @param image The image to be used to calculate the mapping.
72 
73  If provided, also the default for makeRgbImage()
74  """
75  self._uint8Max = float(np.iinfo(np.uint8).max)
76 
77  try:
78  len(minimum)
79  except TypeError:
80  minimum = 3*[minimum]
81  assert len(minimum) == 3, "Please provide 1 or 3 values for minimum"
82 
83  self.minimum = minimum
84  self._image = image
85 
def __init__(self, minimum, dataRange, Q)
Definition: rgb.py:414

Member Function Documentation

◆ intensity()

def lsst.afw.display.rgb.Mapping.intensity (   self,
  imageR,
  imageG,
  imageB 
)

Return the total intensity from the red, blue, and green intensities.

This is a naive computation, and may be overridden by subclasses

Definition at line 143 of file rgb.py.

143  def intensity(self, imageR, imageG, imageB):
144  """!Return the total intensity from the red, blue, and green intensities
145 
146  This is a naive computation, and may be overridden by subclasses
147  """
148  return computeIntensity(imageR, imageG, imageB)
149 
def computeIntensity(imageR, imageG=None, imageB=None)
Return a naive total intensity from the red, blue, and green intensities.
Definition: rgb.py:30

◆ makeRgbImage()

def lsst.afw.display.rgb.Mapping.makeRgbImage (   self,
  imageR = None,
  imageG = None,
  imageB = None,
  xSize = None,
  ySize = None,
  rescaleFactor = None 
)

Convert 3 arrays, imageR, imageG, and imageB into a numpy RGB image.

Parameters
imageRImage to map to red (if None, use the image passed to the ctor)
imageGImage to map to green (if None, use imageR)
imageBImage to map to blue (if None, use imageR)
xSizeDesired width of RGB image (or None). If ySize is None, preserve aspect ratio
ySizeDesired height of RGB image (or None)
rescaleFactorMake size of output image rescaleFactor*size of the input image (or None)

N.b. images may be afwImage.Images or numpy arrays

Definition at line 87 of file rgb.py.

87  xSize=None, ySize=None, rescaleFactor=None):
88  """!Convert 3 arrays, imageR, imageG, and imageB into a numpy RGB image
89  @param imageR Image to map to red (if None, use the image passed to the ctor)
90  @param imageG Image to map to green (if None, use imageR)
91  @param imageB Image to map to blue (if None, use imageR)
92  @param xSize Desired width of RGB image (or None). If ySize is None, preserve aspect ratio
93  @param ySize Desired height of RGB image (or None)
94  @param rescaleFactor Make size of output image rescaleFactor*size of the input image (or None)
95 
96  N.b. images may be afwImage.Images or numpy arrays
97  """
98  if imageR is None:
99  if self._image is None:
100  raise RuntimeError(
101  "You must provide an image (or pass one to the constructor)")
102  imageR = self._image
103 
104  if imageG is None:
105  imageG = imageR
106  if imageB is None:
107  imageB = imageR
108 
109  imageRGB = [imageR, imageG, imageB]
110  for i, c in enumerate(imageRGB):
111  if hasattr(c, "getImage"):
112  c = imageRGB[i] = c.getImage()
113  if hasattr(c, "getArray"):
114  imageRGB[i] = c.getArray()
115 
116  if xSize is not None or ySize is not None:
117  assert rescaleFactor is None, "You may not specify a size and rescaleFactor"
118  h, w = imageRGB[0].shape
119  if ySize is None:
120  ySize = int(xSize*h/float(w) + 0.5)
121  elif xSize is None:
122  xSize = int(ySize*w/float(h) + 0.5)
123 
124  size = (ySize, xSize) # n.b. y, x order for scipy
125  elif rescaleFactor is not None:
126  size = float(rescaleFactor) # an int is intepreted as a percentage
127  else:
128  size = None
129 
130  if size is not None:
131  try:
132  import scipy.misc
133  except ImportError as e:
134  raise RuntimeError(
135  "Unable to rescale as scipy.misc is unavailable: %s" % e)
136 
137  for i, im in enumerate(imageRGB):
138  imageRGB[i] = scipy.misc.imresize(
139  im, size, interp='bilinear', mode='F')
140 
141  return np.dstack(self._convertImagesToUint8(*imageRGB)).astype(np.uint8)
142 

◆ mapIntensityToUint8()

def lsst.afw.display.rgb.Mapping.mapIntensityToUint8 (   self,
  intensity 
)
Map an intensity into the range of a uint8, [0, 255] (but not converted to uint8)

Definition at line 150 of file rgb.py.

150  def mapIntensityToUint8(self, intensity):
151  """Map an intensity into the range of a uint8, [0, 255] (but not converted to uint8)"""
152  with np.errstate(invalid='ignore', divide='ignore'): # n.b. np.where can't and doesn't short-circuit
153  return np.where(intensity <= 0, 0,
154  np.where(intensity < self._uint8Max, intensity, self._uint8Max))
155 

Member Data Documentation

◆ minimum

lsst.afw.display.rgb.Mapping.minimum

Definition at line 83 of file rgb.py.


The documentation for this class was generated from the following file: