LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Functions
lsst.afw.image.utils Namespace Reference

Functions

def clipImage (im, minClip, maxClip)
 
def resetFilters ()
 
def defineFilter (name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False)
 
def getProjectionIndices (imageBBox, targetBBox)
 
def projectImage (image, bbox, fill=0)
 

Function Documentation

◆ clipImage()

def lsst.afw.image.utils.clipImage (   im,
  minClip,
  maxClip 
)
Clip an image to lie between minClip and maxclip (None to ignore)

Definition at line 34 of file utils.py.

34 def clipImage(im, minClip, maxClip):
35  """Clip an image to lie between minClip and maxclip (None to ignore)"""
36  if isinstance(im, MaskedImage):
37  mi = im
38  else:
39  mi = makeMaskedImage(im, Mask(im.getDimensions()))
40 
41  if minClip is not None:
43  mi, afwDetect.Threshold(-minClip, afwDetect.Threshold.VALUE, False))
44  afwDetect.setImageFromFootprintList(
45  mi.getImage(), ds.getFootprints(), minClip)
46 
47  if maxClip is not None:
49  afwDetect.setImageFromFootprintList(
50  mi.getImage(), ds.getFootprints(), maxClip)
51 
52 
A Threshold is used to pass a threshold value to detection algorithms.
Definition: Threshold.h:43
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
def clipImage(im, minClip, maxClip)
Definition: utils.py:34
A set of Footprints, associated with a MaskedImage.
Definition: FootprintSet.h:53

◆ defineFilter()

def lsst.afw.image.utils.defineFilter (   name,
  lambdaEff,
  lambdaMin = np.nan,
  lambdaMax = np.nan,
  alias = [],
  force = False 
)
Define a filter and its properties in the filter registry

Definition at line 59 of file utils.py.

59 def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False):
60  """Define a filter and its properties in the filter registry"""
61  prop = FilterProperty(name, lambdaEff, lambdaMin, lambdaMax, force)
62  Filter.define(prop)
63  if isinstance(alias, str):
64  Filter.defineAlias(name, alias)
65  else:
66  for a in alias:
67  Filter.defineAlias(name, a)
68 
69 
def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False)
Definition: utils.py:59

◆ getProjectionIndices()

def lsst.afw.image.utils.getProjectionIndices (   imageBBox,
  targetBBox 
)
Get the indices to project an image

Given an image and target bounding box,
calculate the indices needed to appropriately
slice the input image and target image to
project the image to the target.

Parameters
----------
imageBBox: Box2I
    Bounding box of the input image
targetBBox: Box2I
    Bounding box of the target image

Returns
-------
targetSlices: tuple
    Slices of the target image in the form (by, bx), (iy, ix).
imageIndices: tuple
    Slices of the input image in the form (by, bx), (iy, ix).

Definition at line 70 of file utils.py.

70 def getProjectionIndices(imageBBox, targetBBox):
71  """Get the indices to project an image
72 
73  Given an image and target bounding box,
74  calculate the indices needed to appropriately
75  slice the input image and target image to
76  project the image to the target.
77 
78  Parameters
79  ----------
80  imageBBox: Box2I
81  Bounding box of the input image
82  targetBBox: Box2I
83  Bounding box of the target image
84 
85  Returns
86  -------
87  targetSlices: tuple
88  Slices of the target image in the form (by, bx), (iy, ix).
89  imageIndices: tuple
90  Slices of the input image in the form (by, bx), (iy, ix).
91  """
92  def getMin(dXmin):
93  """Get minimum indices"""
94  if dXmin < 0:
95  bxStart = -dXmin
96  ixStart = 0
97  else:
98  bxStart = 0
99  ixStart = dXmin
100  return bxStart, ixStart
101 
102  def getMax(dXmax):
103  """Get maximum indices"""
104  if dXmax < 0:
105  bxEnd = None
106  ixEnd = dXmax
107  elif dXmax != 0:
108  bxEnd = -dXmax
109  ixEnd = None
110  else:
111  bxEnd = ixEnd = None
112  return bxEnd, ixEnd
113 
114  dXmin = targetBBox.getMinX() - imageBBox.getMinX()
115  dXmax = targetBBox.getMaxX() - imageBBox.getMaxX()
116  dYmin = targetBBox.getMinY() - imageBBox.getMinY()
117  dYmax = targetBBox.getMaxY() - imageBBox.getMaxY()
118 
119  bxStart, ixStart = getMin(dXmin)
120  byStart, iyStart = getMin(dYmin)
121  bxEnd, ixEnd = getMax(dXmax)
122  byEnd, iyEnd = getMax(dYmax)
123 
124  bx = slice(bxStart, bxEnd)
125  by = slice(byStart, byEnd)
126  ix = slice(ixStart, ixEnd)
127  iy = slice(iyStart, iyEnd)
128  return (by, bx), (iy, ix)
129 
130 
def getProjectionIndices(imageBBox, targetBBox)
Definition: utils.py:70

◆ projectImage()

def lsst.afw.image.utils.projectImage (   image,
  bbox,
  fill = 0 
)
Project an image into a bounding box

Return a new image whose pixels are equal to those of
`image` within `bbox`, and equal to `fill` outside.

Parameters
----------
image: `afw.Image` or `afw.MaskedImage`
    The image to project
bbox: `Box2I`
    The bounding box to project onto.
fill: number
    The value to fill the region of the new
    image outside the bounding box of the original.

Returns
-------
newImage: `afw.Image` or `afw.MaskedImage`
    The new image with the input image projected
    into its bounding box.

Definition at line 131 of file utils.py.

131 def projectImage(image, bbox, fill=0):
132  """Project an image into a bounding box
133 
134  Return a new image whose pixels are equal to those of
135  `image` within `bbox`, and equal to `fill` outside.
136 
137  Parameters
138  ----------
139  image: `afw.Image` or `afw.MaskedImage`
140  The image to project
141  bbox: `Box2I`
142  The bounding box to project onto.
143  fill: number
144  The value to fill the region of the new
145  image outside the bounding box of the original.
146 
147  Returns
148  -------
149  newImage: `afw.Image` or `afw.MaskedImage`
150  The new image with the input image projected
151  into its bounding box.
152  """
153  if image.getBBox() == bbox:
154  return image
155  (by, bx), (iy, ix) = getProjectionIndices(image.getBBox(), bbox)
156 
157  if isinstance(image, MaskedImage):
158  newImage = type(image.image)(bbox)
159  newImage.array[by, bx] = image.image.array[iy, ix]
160  newMask = type(image.mask)(bbox)
161  newMask.array[by, bx] = image.mask.array[iy, ix]
162  newVariance = type(image.image)(bbox)
163  newVariance.array[by, bx] = image.variance.array[iy, ix]
164  newImage = MaskedImage(image=newImage, mask=newMask, variance=newVariance, dtype=newImage.array.dtype)
165  else:
166  newImage = type(image)(bbox)
167  if fill != 0:
168  newImage.set(fill)
169  newImage.array[by, bx] = image.array[iy, ix]
170  return newImage
171 
table::Key< int > type
Definition: Detector.cc:163
def projectImage(image, bbox, fill=0)
Definition: utils.py:131
def getProjectionIndices(imageBBox, targetBBox)
Definition: utils.py:70

◆ resetFilters()

def lsst.afw.image.utils.resetFilters ( )
Reset registry of filters and filter properties

Definition at line 53 of file utils.py.

53 def resetFilters():
54  """Reset registry of filters and filter properties"""
55  Filter.reset()
56  FilterProperty.reset()
57 
58