Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-47385: Refine mask exclusion behavior in removeBadPixels (aka cancel original masks) #398

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions python/lsst/meas/algorithms/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True,
convolveResults = self.convolveImage(maskedImage, psf, doSmooth=doSmooth)
middle = convolveResults.middle
sigma = convolveResults.sigma
self.removeBadPixels(middle, exposure.maskedImage.mask)
self.removeBadPixels(middle)

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

return results

def removeBadPixels(self, middle, mask):
def removeBadPixels(self, middle):
"""Set the significance of flagged pixels to zero.

Parameters
----------
middle : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
Convolved image to zero certain mask planes from.
middle : `lsst.afw.image.Exposure`
Score or maximum likelihood difference image.
The image plane will be modified in place.
mask : `lsst.afw.image.Mask`
Mask to select planes from to zero the image; will be restricted
to the image's bounding box.
"""
badPixelMask = mask.getPlaneBitMask(self.config.excludeMaskPlanes)
badPixels = mask.subset(middle.getBBox()).array & badPixelMask > 0
badPixelMask = middle.mask.getPlaneBitMask(self.config.excludeMaskPlanes)
badPixels = middle.mask.array & badPixelMask > 0
middle.image.array[badPixels] = 0

def setPeakSignificance(self, exposure, footprints, threshold, negative=False):
Expand Down
Loading