LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions
lsst.afw.detection.multiband Namespace Reference

Classes

class  MultibandFootprint
 

Functions

def getSpanSetFromImages (images, thresh=0, xy0=None)
 
def heavyFootprintToImage (heavy, fill=np.nan, bbox=None, imageType=MaskedImage)
 

Function Documentation

◆ getSpanSetFromImages()

def lsst.afw.detection.multiband.getSpanSetFromImages (   images,
  thresh = 0,
  xy0 = None 
)
Create a Footprint from a set of Images

Parameters
----------
images : `lsst.afw.image.MultibandImage` or list of `lsst.afw.image.Image`, array
    Images to extract the footprint from
thresh : `float`
    All pixels above `thresh` will be included in the footprint
xy0 : `lsst.geom.Point2I`
    Location of the minimum value of the images bounding box
    (if images is an array, otherwise the image bounding box is used).

Returns
-------
spans : `lsst.afw.geom.SpanSet`
    Union of all spans in the images above the threshold
imageBBox : `lsst.afw.detection.Box2I`
    Bounding box for the input images.

Definition at line 35 of file multiband.py.

35 def getSpanSetFromImages(images, thresh=0, xy0=None):
36  """Create a Footprint from a set of Images
37 
38  Parameters
39  ----------
40  images : `lsst.afw.image.MultibandImage` or list of `lsst.afw.image.Image`, array
41  Images to extract the footprint from
42  thresh : `float`
43  All pixels above `thresh` will be included in the footprint
44  xy0 : `lsst.geom.Point2I`
45  Location of the minimum value of the images bounding box
46  (if images is an array, otherwise the image bounding box is used).
47 
48  Returns
49  -------
50  spans : `lsst.afw.geom.SpanSet`
51  Union of all spans in the images above the threshold
52  imageBBox : `lsst.afw.detection.Box2I`
53  Bounding box for the input images.
54  """
55  # Set the threshold for each band
56  if not hasattr(thresh, "__len__"):
57  thresh = [thresh] * len(images)
58 
59  # If images is a list of `afw Image` objects then
60  # merge the SpanSet in each band into a single Footprint
61  if isinstance(images, MultibandBase) or isinstance(images[0], Image):
62  spans = SpanSet()
63  for n, image in enumerate(images):
64  mask = image.array > thresh[n]
65  mask = Mask(mask.astype(np.int32), xy0=image.getBBox().getMin())
66  spans = spans.union(SpanSet.fromMask(mask))
67  imageBBox = images[0].getBBox()
68  else:
69  # Use thresh to detect the pixels above the threshold in each band
70  thresh = np.array(thresh)
71  if xy0 is None:
72  xy0 = Point2I(0, 0)
73  mask = np.any(images > thresh[:, None, None], axis=0)
74  mask = Mask(mask.astype(np.int32), xy0=xy0)
75  spans = SpanSet.fromMask(mask)
76  imageBBox = mask.getBBox()
77  return spans, imageBBox
78 
79 
def getSpanSetFromImages(images, thresh=0, xy0=None)
Definition: multiband.py:35
Point< int, 2 > Point2I
Definition: Point.h:321

◆ heavyFootprintToImage()

def lsst.afw.detection.multiband.heavyFootprintToImage (   heavy,
  fill = np.nan,
  bbox = None,
  imageType = MaskedImage 
)
Create an image of a HeavyFootprint

Parameters
----------
heavy : `HeavyFootprint`
    The HeavyFootprint to insert into the image
fill: number
    Number to fill the pixels in the image that are not
    contained in `heavy`.
bbox : `Box2I`
    Bounding box of the output image.
imageType : `type`
    This should be either a `MaskedImage` or `Image` and describes
    the type of the output image.

Returns
-------
image : `lsst.afw.image.MaskedImage` or `lsst.afw.image.Image`
    An image defined by `bbox` and padded with `fill` that
    contains the projected flux in `heavy`.

Definition at line 80 of file multiband.py.

80 def heavyFootprintToImage(heavy, fill=np.nan, bbox=None, imageType=MaskedImage):
81  """Create an image of a HeavyFootprint
82 
83  Parameters
84  ----------
85  heavy : `HeavyFootprint`
86  The HeavyFootprint to insert into the image
87  fill: number
88  Number to fill the pixels in the image that are not
89  contained in `heavy`.
90  bbox : `Box2I`
91  Bounding box of the output image.
92  imageType : `type`
93  This should be either a `MaskedImage` or `Image` and describes
94  the type of the output image.
95 
96  Returns
97  -------
98  image : `lsst.afw.image.MaskedImage` or `lsst.afw.image.Image`
99  An image defined by `bbox` and padded with `fill` that
100  contains the projected flux in `heavy`.
101  """
102  if bbox is None:
103  bbox = heavy.getBBox()
104  image = imageType(bbox, dtype=heavy.getImageArray().dtype)
105  image.set(fill)
106  heavy.insert(image)
107  return image
108 
109 
def heavyFootprintToImage(heavy, fill=np.nan, bbox=None, imageType=MaskedImage)
Definition: multiband.py:80