23 __all__ = [
"clipImage",
"resetFilters",
"defineFilter",
24 "CalibNoThrow",
"projectImage",
"getProjectionIndices"]
29 from .maskedImage
import MaskedImage, makeMaskedImage
30 from .image
import Mask
31 from .filter
import Filter, FilterProperty
32 from .calib
import Calib
36 """Clip an image to lie between minClip and maxclip (None to ignore)""" 37 if isinstance(im, MaskedImage):
42 if minClip
is not None:
45 afwDetect.setImageFromFootprintList(
46 mi.getImage(), ds.getFootprints(), minClip)
48 if maxClip
is not None:
50 afwDetect.setImageFromFootprintList(
51 mi.getImage(), ds.getFootprints(), maxClip)
55 """Reset registry of filters and filter properties""" 57 FilterProperty.reset()
60 def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False):
61 """Define a filter and its properties in the filter registry""" 62 prop = FilterProperty(name, lambdaEff, lambdaMin, lambdaMax, force)
64 if isinstance(alias, str):
65 Filter.defineAlias(name, alias)
68 Filter.defineAlias(name, a)
72 """A class intended to be used with python's with statement, to return NaNs for negative fluxes 73 instead of raising exceptions (exceptions may be raised for other purposes). 77 ax.plot([exposure.getCalib().getMagnitude(a) for a in candAmps], zGood[:,k], 'b+') 82 Calib.setThrowOnNegativeFlux(
False)
89 """Get the indices to project an image 91 Given an image and target bounding box, 92 calculate the indices needed to appropriately 93 slice the input image and target image to 94 project the image to the target. 99 Bounding box of the input image 101 Bounding box of the target image 106 Slices of the target image in the form (by, bx), (iy, ix). 108 Slices of the input image in the form (by, bx), (iy, ix). 111 """Get minimum indices""" 118 return bxStart, ixStart
121 """Get maximum indices""" 132 dXmin = targetBBox.getMinX() - imageBBox.getMinX()
133 dXmax = targetBBox.getMaxX() - imageBBox.getMaxX()
134 dYmin = targetBBox.getMinY() - imageBBox.getMinY()
135 dYmax = targetBBox.getMaxY() - imageBBox.getMaxY()
137 bxStart, ixStart = getMin(dXmin)
138 byStart, iyStart = getMin(dYmin)
139 bxEnd, ixEnd = getMax(dXmax)
140 byEnd, iyEnd = getMax(dYmax)
142 bx = slice(bxStart, bxEnd)
143 by = slice(byStart, byEnd)
144 ix = slice(ixStart, ixEnd)
145 iy = slice(iyStart, iyEnd)
146 return (by, bx), (iy, ix)
150 """Project an image into a bounding box 152 Return a new image whose pixels are equal to those of 153 `image` within `bbox`, and equal to `fill` outside. 157 image: `afw.Image` or `afw.MaskedImage` 160 The bounding box to project onto. 162 The value to fill the region of the new 163 image outside the bounding box of the original. 167 newImage: `afw.Image` or `afw.MaskedImage` 168 The new image with the input image projected 169 into its bounding box. 171 if image.getBBox() == bbox:
175 if isinstance(image, MaskedImage):
176 newImage =
type(image.image)(bbox)
177 newImage.array[by, bx] = image.image.array[iy, ix]
178 newMask =
type(image.mask)(bbox)
179 newMask.array[by, bx] = image.mask.array[iy, ix]
180 newVariance =
type(image.image)(bbox)
181 newVariance.array[by, bx] = image.variance.array[iy, ix]
182 newImage =
MaskedImage(image=newImage, mask=newMask, variance=newVariance, dtype=newImage.array.dtype)
184 newImage =
type(image)(bbox)
187 newImage.array[by, bx] = image.array[iy, ix]
A Threshold is used to pass a threshold value to detection algorithms.
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.
def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False)
Represent a 2-dimensional array of bitmask pixels.
def clipImage(im, minClip, maxClip)
def projectImage(image, bbox, fill=0)
def getProjectionIndices(imageBBox, targetBBox)