LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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