LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
Classes | Functions
lsst.afw.detection.multiband Namespace Reference

Classes

class  MultibandFootprint
 

Functions

 getSpanSetFromImages (images, thresh=0, xy0=None)
 

Function Documentation

◆ getSpanSetFromImages()

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 38 of file multiband.py.

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