22 namespace afwGeom = lsst::afw::geom;
24 namespace afwDetect = lsst::afw::detection;
25 namespace pexExcept = lsst::pex::exceptions;
32 template <
typename PixelT>
38 _footprints(std::vector<lsst::afw::detection::
Footprint::
Ptr>()) {
41 for (std::vector<std::string>::iterator mi = detBadMaskPlanes.begin();
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",
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");
88 std::string detThresholdType = _policy.getString(
"detThresholdType");
94 std::shared_ptr<std::vector<afwDetect::Footprint::Ptr> > footprintListInPtr;
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());
127 for (std::vector<afwDetect::Footprint::Ptr>::iterator i = footprintListInPtr->begin();
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->getNpix() >
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->getNpix(), fpNpixMax);
179 return growCandidate(fpCore, fpGrowPix, templateMaskedImage, scienceMaskedImage);
182 LOGL_DEBUG(
"TRACE5.ip.diffim.KernelCandidateDetection.apply",
183 "Original footprint in parent : %d,%d -> %d,%d -> %d,%d",
213 LOGL_DEBUG(
"TRACE5.ip.diffim.KernelCandidateDetection.apply",
214 "Grown footprint in parent : %d,%d -> %d,%d -> %d,%d",
223 if (!(templateMaskedImage->getBBox().contains(fpGrowBBox))) {
224 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
225 "Footprint grown off image");
230 bool subimageHasFailed =
false;
237 if (fsb.
getBits() & _badBitMask) {
238 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
239 "Footprint has masked pix (vals=%d) in image to convolve",
241 subimageHasFailed =
true;
245 if (fsb.
getBits() & _badBitMask) {
246 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
247 "Footprint has masked pix (vals=%d) in image not to convolve",
249 subimageHasFailed =
true;
253 LOGL_DEBUG(
"TRACE3.ip.diffim.KernelCandidateDetection.apply",
254 "Exception caught extracting Footprint");
255 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidateDetection.apply",
257 subimageHasFailed =
true;
259 if (subimageHasFailed) {
263 _footprints.push_back(fpGrow);
Image Subtraction helper functions.
An include file to include the header files for lsst::afw::geom.
lsst::pex::policy::Policy _policy
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > MaskedImagePtr
a container for holding hierarchical configuration data in memory.
lsst::afw::detection::Footprint Footprint
StringArray getStringArray(const std::string &name) const
return an array of values associated with the given name
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.
Detect candidates for kernels within 2 images.
KernelCandidateDetection(lsst::pex::policy::Policy const &policy)
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
lsst::afw::image::MaskPixel _badBitMask
Class to accumulate Mask bits.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
std::shared_ptr< KernelCandidateDetection > Ptr
LSST DM logging module built on log4cxx.
MaskT::Pixel getBits() const
An include file to include the header files for lsst::afw::image.
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool isotropic=true)
Grow a Footprint by nGrow pixels, returning a new Footprint.
An include file to include the header files for lsst::afw::detection.
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
Search through images for Footprints with no masked pixels.
A class to manipulate images, masks, and variance as a single object.
bool growCandidate(lsst::afw::detection::Footprint::Ptr fp, int fpGrowPix, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage)
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Threshold createThreshold(double const value, std::string const typeStr, bool const polarity)
Factory method for creating Threshold objects.
virtual char const * what(void) const
Return a character string summarizing this exception.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...