32 template <
typename PixelT>
42 mi != detBadMaskPlanes.
end(); ++mi){
46 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection",
47 "Cannot update bad bit mask with %s", (*mi).c_str());
48 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidateDetection",
52 LOGL_DEBUG(
"TRACE2.ip.diffim.KernelCandidateDetection",
53 "Using bad bit mask %d", _badBitMask);
76 template <
typename PixelT>
83 int fpNpixMin = _policy.
getInt(
"fpNpixMin");
84 int fpGrowPix = _policy.
getInt(
"fpGrowPix");
86 bool detOnTemplate = _policy.
getBool(
"detOnTemplate");
87 double detThreshold = _policy.
getDouble(
"detThreshold");
100 if (detOnTemplate ==
true) {
102 *(templateMaskedImage),
109 LOGL_DEBUG(
"TRACE2.ip.diffim.KernelCandidateDetection.apply",
110 "Found %d total footprints in template above %.3f %s",
111 footprintListInPtr->size(), detThreshold, detThresholdType.
c_str());
115 *(scienceMaskedImage),
121 LOGL_DEBUG(
"TRACE2.ip.diffim.KernelCandidateDetection.apply",
122 "Found %d total footprints in science image above %.3f %s",
123 footprintListInPtr->size(), detThreshold, detThresholdType.
c_str());
128 i != footprintListInPtr->end(); ++i) {
130 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
131 "Processing footprint %d", (*i)->getId());
132 growCandidate((*i), fpGrowPix, templateMaskedImage, scienceMaskedImage);
135 if (_footprints.
size() == 0) {
137 "Unable to find any footprints for Psf matching");
140 LOGL_DEBUG(
"TRACE1.ip.diffim.KernelCandidateDetection.apply",
141 "Found %d clean footprints above threshold %.3f",
142 _footprints.
size(), detThreshold);
146 template <
typename PixelT>
153 int fpNpixMax = _policy.
getInt(
"fpNpixMax");
169 if (fp->getArea() >
static_cast<std::size_t>(fpNpixMax)) {
170 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
171 "Footprint has too many pix: %d (max =%d)",
172 fp->getArea(), fpNpixMax);
181 return growCandidate(fpCore, fpGrowPix, templateMaskedImage, scienceMaskedImage);
184 LOGL_DEBUG(
"TRACE5.ip.diffim.KernelCandidateDetection.apply",
185 "Original footprint in parent : %d,%d -> %d,%d -> %d,%d",
210 fp->getSpans()->dilated(fpGrowPix, afwGeom::Stencil::MANHATTAN)
216 LOGL_DEBUG(
"TRACE5.ip.diffim.KernelCandidateDetection.apply",
217 "Grown footprint in parent : %d,%d -> %d,%d -> %d,%d",
218 fpGrowBBox.getMinX(), fpGrowBBox.getMinY(),
219 int(0.5 * (fpGrowBBox.getMinX() + fpGrowBBox.getMaxX())),
220 int(0.5 * (fpGrowBBox.getMinY() + fpGrowBBox.getMaxY())),
221 fpGrowBBox.getMaxX(), fpGrowBBox.getMaxY());
226 if (!(templateMaskedImage->getBBox().contains(fpGrowBBox))) {
227 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
228 "Footprint grown off image");
233 bool subimageHasFailed =
false;
240 if (fsb.
getBits() & _badBitMask) {
241 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
242 "Footprint has masked pix (vals=%d) in image to convolve",
244 subimageHasFailed =
true;
248 if (fsb.
getBits() & _badBitMask) {
249 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
250 "Footprint has masked pix (vals=%d) in image not to convolve",
252 subimageHasFailed =
true;
256 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
257 "Exception caught extracting Footprint");
258 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidateDetection.apply",
260 subimageHasFailed =
true;
262 if (subimageHasFailed) {
Image Subtraction helper functions.
a container for holding hierarchical configuration data in memory.
void apply(MaskT const &mask)
void apply(MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage)
Runs Detection on a single image for significant peaks, and checks returned Footprints for Masked pix...
A Threshold is used to pass a threshold value to detection algorithms.
Provides consistent interface for LSST exceptions.
Detect candidates for kernels within 2 images.
const std::string getString(const std::string &name) const
return a string value associated with the given name .
KernelCandidateDetection(lsst::pex::policy::Policy const &policy)
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Class to accumulate Mask bits.
LSST DM logging module built on log4cxx.
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
A base class for image defects.
int getMaxY() const noexcept
Search through images for Footprints with no masked pixels.
A class to manipulate images, masks, and variance as a single object.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Threshold createThreshold(const double value, const std::string type="value", const bool polarity=true)
Factory method for creating Threshold objects.
int getMaxX() const noexcept
bool getBool(const std::string &name) const
return a boolean value associated with the given name.
double getDouble(const std::string &name) const
return a double value associated with the given name.
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
int getMinX() const noexcept
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
lsst::afw::detection::Footprint Footprint
bool growCandidate(std::shared_ptr< lsst::afw::detection::Footprint > fp, int fpGrowPix, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage)
int getInt(const std::string &name) const
return an integer value associated with the given name.
An integer coordinate rectangle.
MaskT::Pixel getBits() const
StringArray getStringArray(const std::string &name) const
return an array of values associated with the given name
int getMinY() const noexcept