#include <string>
#include "testSpatialCell.h"
namespace afwDetect = lsst::afw::detection;
namespace afwMath = lsst::afw::math;
namespace afwGeom = lsst::afw::geom;
void SpatialCellSetDemo() {
boost::tie(im, fs) = readImage();
afwMath::SpatialCellSet cellSet(
im->getBBox(),
260, 200
);
for (afwDetect::FootprintSet::
FootprintList::iterator ptr = fs->getFootprints()->begin(),
end = fs->getFootprints()->end(); ptr != end; ++ptr) {
ExampleCandidate::Ptr tc(new ExampleCandidate(xc, yc, im, bbox));
cellSet.insertCandidate(tc);
}
ExampleCandidateVisitor visitor;
cellSet.visitCandidates(&visitor);
std::cout <<
boost::format(
"There are %d candidates\n") % visitor.getN();
for (unsigned int i = 0; i != cellSet.getCellList().size(); ++i) {
candidate != candidateEnd; ++candidate) {
dynamic_cast<ExampleCandidate *>((*candidate).get())->getBBox();
#if 0
% i % (*candidate)->getXCenter() % (*candidate)->getYCenter() % (
w*h);
#endif
}
}
}
for (unsigned int i = 0; i != cellSet.getCellList().size(); ++i) {
cell->visitCandidates(&visitor);
cell->setIgnoreBad(false);
std::cout <<
boost::format(
"%s nobj=%d N_good=%d NPix_good=%d\n") %
cell->getLabel() % cell->size() % visitor.getN() % visitor.getNPix();
}
cellSet.setIgnoreBad(true);
cellSet.visitCandidates(&visitor);
std::cout <<
boost::format(
"There are %d good candidates\n") % visitor.getN();
}
readImage() {
try {
std::string filename = dataDir + "/CFHT/D4/cal-53535-i-797722_1.fits";
);
} catch (lsst::pex::exceptions::NotFoundError &e) {
std::cerr << e << std::endl;
exit(1);
}
bctrl.setNxSample(mi->
getWidth()/256 + 1);
bctrl.getStatisticsControl()->setNumSigmaClip(3.0);
bctrl.getStatisticsControl()->setNumIter(2);
try {
} catch(std::exception &) {
}
int const grow = 1;
bool const isotropic = false;
PTR(afwDetect::FootprintSet) grownFs(new afwDetect::FootprintSet(*fs, grow, isotropic));
grownFs->setMask(mi->getMask(), "DETECTED");
return std::make_pair(mi, grownFs);
}
assert (data.first != NULL);
SpatialCellSetDemo();
}