23 __all__ = [
"clipImage",
"resetFilters",
"defineFilter",
24 "projectImage",
"getProjectionIndices"]
26 from deprecated.sphinx
import deprecated
31 from .maskedImage
import MaskedImage, makeMaskedImage
32 from .image
import Mask
33 from .filter
import Filter, FilterProperty
37 """Clip an image to lie between minClip and maxclip (None to ignore)"""
38 if isinstance(im, MaskedImage):
43 if minClip
is not None:
44 ds = afwDetect.FootprintSet(
45 mi, afwDetect.Threshold(-minClip, afwDetect.Threshold.VALUE,
False))
46 afwDetect.setImageFromFootprintList(
47 mi.getImage(), ds.getFootprints(), minClip)
49 if maxClip
is not None:
50 ds = afwDetect.FootprintSet(mi, afwDetect.Threshold(maxClip))
51 afwDetect.setImageFromFootprintList(
52 mi.getImage(), ds.getFootprints(), maxClip)
55 @deprecated(reason=("Removed with no replacement (FilterLabels do not need to be reset).
"
56 " Will be removed after v22."), category=FutureWarning, version=
"v22")
58 """Reset registry of filters and filter properties"""
60 FilterProperty.reset()
63 @deprecated(reason=("Removed with no replacement (but see lsst::afw::image::TransmissionCurve for how to set"
"and retrieve filter wavelength information). Will be removed after v22.
"),
64 category=FutureWarning, version="v22")
65 def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False):
66 """Define a filter and its properties in the filter registry"""
67 prop =
FilterProperty(name, lambdaEff, lambdaMin, lambdaMax, force)
69 if isinstance(alias, str):
70 Filter.defineAlias(name, alias)
73 Filter.defineAlias(name, a)
77 """Get the indices to project an image
79 Given an image and target bounding box,
80 calculate the indices needed to appropriately
81 slice the input image and target image to
82 project the image to the target.
87 Bounding box of the input image
89 Bounding box of the target image
94 Slices of the target image in the form (by, bx), (iy, ix).
96 Slices of the input image in the form (by, bx), (iy, ix).
99 """Get minimum indices"""
106 return bxStart, ixStart
109 """Get maximum indices"""
120 dXmin = targetBBox.getMinX() - imageBBox.getMinX()
121 dXmax = targetBBox.getMaxX() - imageBBox.getMaxX()
122 dYmin = targetBBox.getMinY() - imageBBox.getMinY()
123 dYmax = targetBBox.getMaxY() - imageBBox.getMaxY()
125 bxStart, ixStart = getMin(dXmin)
126 byStart, iyStart = getMin(dYmin)
127 bxEnd, ixEnd = getMax(dXmax)
128 byEnd, iyEnd = getMax(dYmax)
130 bx = slice(bxStart, bxEnd)
131 by = slice(byStart, byEnd)
132 ix = slice(ixStart, ixEnd)
133 iy = slice(iyStart, iyEnd)
134 return (by, bx), (iy, ix)
138 """Project an image into a bounding box
140 Return a new image whose pixels are equal to those of
141 `image` within `bbox`, and equal to `fill` outside.
145 image: `afw.Image` or `afw.MaskedImage`
148 The bounding box to project onto.
150 The value to fill the region of the new
151 image outside the bounding box of the original.
155 newImage: `afw.Image` or `afw.MaskedImage`
156 The new image with the input image projected
157 into its bounding box.
159 if image.getBBox() == bbox:
163 if isinstance(image, MaskedImage):
164 newImage =
type(image.image)(bbox)
165 newImage.array[by, bx] = image.image.array[iy, ix]
166 newMask =
type(image.mask)(bbox)
167 newMask.array[by, bx] = image.mask.array[iy, ix]
168 newVariance =
type(image.image)(bbox)
169 newVariance.array[by, bx] = image.variance.array[iy, ix]
170 newImage =
MaskedImage(image=newImage, mask=newMask, variance=newVariance, dtype=newImage.array.dtype)
172 newImage =
type(image)(bbox)
175 newImage.array[by, bx] = image.array[iy, ix]
177
Represent a 2-dimensional array of bitmask pixels.
def clipImage(im, minClip, maxClip)
def getProjectionIndices(imageBBox, targetBBox)
def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False)
def projectImage(image, bbox, fill=0)
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.
FilterProperty(FilterProperty const &)=default