Skip to content

Commit d2ec5ff

Browse files
parejkojmrawls
authored andcommitted
Rework removeBadPixels to use the original mask
This prevents the convolution-induced growth of masks from causing too large a region to be zeroed-out, resulting in more reasonable looking footprints near "excluded" masked areas.
1 parent a1f12eb commit d2ec5ff

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

python/lsst/meas/algorithms/detection.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True,
774774
convolveResults = self.convolveImage(maskedImage, psf, doSmooth=doSmooth)
775775
middle = convolveResults.middle
776776
sigma = convolveResults.sigma
777-
self.removeBadPixels(middle)
777+
self.removeBadPixels(middle, exposure.maskedImage.mask)
778778

779779
results = self.applyThreshold(middle, maskedImage.getBBox())
780780
results.background = background if background is not None else afwMath.BackgroundList()
@@ -799,17 +799,20 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True,
799799

800800
return results
801801

802-
def removeBadPixels(self, middle):
802+
def removeBadPixels(self, middle, mask):
803803
"""Set the significance of flagged pixels to zero.
804804
805805
Parameters
806806
----------
807-
middle : `lsst.afw.image.ExposureF`
808-
Score or maximum likelihood difference image.
807+
middle : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
808+
Convolved image to zero certain mask planes from.
809809
The image plane will be modified in place.
810+
mask : `lsst.afw.image.Mask`
811+
Mask to select planes from to zero the image; will be restricted
812+
to the image's bounding box.
810813
"""
811-
badPixelMask = lsst.afw.image.Mask.getPlaneBitMask(self.config.excludeMaskPlanes)
812-
badPixels = middle.mask.array & badPixelMask > 0
814+
badPixelMask = mask.getPlaneBitMask(self.config.excludeMaskPlanes)
815+
badPixels = mask.subset(middle.getBBox()).array & badPixelMask > 0
813816
middle.image.array[badPixels] = 0
814817

815818
def setPeakSignificance(self, exposure, footprints, threshold, negative=False):

0 commit comments

Comments
 (0)