41 namespace afwDetection = lsst::afw::detection;
42 namespace afwGeom = lsst::afw::geom;
44 namespace afwMath = lsst::afw::math;
45 namespace measAlg = lsst::meas::algorithms;
51 template <
typename PixelT>
53 template <
typename PixelT>
55 template <
typename PixelT>
57 template <
typename PixelT>
64 T operator()(T
x)
const {
return x; }
69 andMask(T mask) : _mask(mask) {}
70 T operator()(T
x)
const {
return (x & _mask); }
76 andMask<T> makeAndMask(T
val) {
77 return andMask<T>(
val);
83 template<
typename LhsT,
typename RhsT>
90 boost::make_shared<afwImage::Image<LhsT> >(rhs.
getDimensions());
97 lhsEnd = lhs->
row_end(
y); lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
98 *lhsPtr = func(*rhsPtr);
107 return std::pow(peak.
getIx() -
x, 2) + std::pow(peak.
getIy() -
y, 2);
114 template <
typename PixelT>
118 typedef typename Image::Mask Mask;
137 virtual void operator()(
typename Image::xy_locator loc,
int x,
int y) {
138 double const central = distanceSquared(x, y, _central);
139 int const xImage = x - getImage().getX0();
140 int const yImage = y - getImage().getY0();
143 double const dist2 = distanceSquared(x, y, *
iter);
144 if (dist2 < central) {
145 (_mask)(xImage, yImage) &= _turnOff;
146 (_mask)(xImage, yImage) |= _turnOn;
152 using Super::getImage;
182 template <
typename PixelT>
191 cen[1] - height/2 - _parentExposure->getY0());
199 }
catch(lsst::pex::exceptions::LengthError &e) {
211 if (getMaskBlends()) {
214 PeakCatalog
const& peaks = foot->getPeaks();
215 if (peaks.size() > 1) {
217 double best = std::numeric_limits<double>::infinity();
219 for (PeakCatalog::const_iterator
iter = peaks.begin(), end = peaks.end();
iter != end; ++
iter) {
220 double const dist2 = distanceSquared(getXCenter(), getYCenter(), *
iter);
228 PeakCatalog others(peaks.getTable());
229 others.reserve(peaks.size() - 1);
230 for (PeakCatalog::const_iterator
iter = peaks.begin(), end = peaks.end();
iter != end; ++
iter) {
232 if (central != ptr) {
233 others.push_back(ptr);
237 BlendedFunctor<PixelT> functor(*
image, *
image->getMask(), *central, others, detected, intrp);
238 functor.apply(*foot);
253 if (feet->size() > 1) {
258 for (FootprintList::const_iterator fiter = feet->begin(); fiter != feet->end(); ++fiter) {
260 if (foot->contains(cen)) {
271 if (_pixelThreshold > 0.0) {
273 boost::make_shared<afwDetection::FootprintSet>(*
image,
275 for (FootprintList::const_iterator fpIter = fpSet->getFootprints()->begin();
276 fpIter != fpSet->getFootprints()->end(); ++fpIter) {
278 if (!fp->contains(cen)) {
294 template <
typename PixelT>
299 if (_haveImage && (width != _image->getWidth() || height != _image->getHeight())) {
304 _image = extractImage(width, height);
316 template <
typename PixelT>
319 int const width = getWidth() == 0 ? _defaultWidth : getWidth();
320 int const height = getHeight() == 0 ? _defaultWidth : getHeight();
322 return getMaskedImage(width, height);
331 template <
typename PixelT>
334 std::
string const algorithm,
337 unsigned int const width = getWidth() == 0 ? _defaultWidth : getWidth();
338 unsigned int const height = getHeight() == 0 ? _defaultWidth : getHeight();
339 if (_offsetImage && static_cast<unsigned int>(_offsetImage->getWidth()) == width + 2*buffer &&
340 static_cast<unsigned int>(_offsetImage->getHeight()) == height + 2*buffer) {
346 double const xcen = getXCenter(), ycen = getYCenter();
boost::uint16_t MaskPixel
A coordinate class intended to represent absolute positions.
x_iterator row_begin(int y) const
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
int positionToIndex(double pos)
Convert image position to nearest integer index.
boost::shared_ptr< FootprintList > feet
Use number of sigma given per-pixel s.d.
A Threshold is used to pass a threshold value to detection algorithms.
afw::table::CatalogT< PeakRecord > PeakCatalog
int getIy() const
Convenience accessors for the keys in the minimal schema.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool isotropic=true)
CatalogIterator< typename Internal::const_iterator > const_iterator
Class used by SpatialCell for spatial PSF fittig.
Represent a 2-dimensional array of bitmask pixels.
A class to manipulate images, masks, and variance as a single object.
detection::FootprintSet::FootprintList FootprintList
Support for functors over Image's pixels.
MaskT clearMaskFromFootprint(lsst::afw::image::Mask< MaskT > *mask, Footprint const &footprint, MaskT const bitmask)
(AND ~bitmask) all the Mask's pixels that are in the Footprint; that is, set to zero in the Mask-inte...
void setXY0(geom::Point2I const origin)
ImageT::Ptr offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
Return an image offset by (dx, dy) using the specified algorithm.
MaskT setMaskFromFootprint(lsst::afw::image::Mask< MaskT > *mask, Footprint const &footprint, MaskT const bitmask)
OR bitmask into all the Mask's pixels that are in the Footprint.
geom::Point2I getXY0() const
int getHeight() const
Return the number of rows in the image.
Record class that represents a peak in a Footprint.
A coordinate class intended to represent offsets and dimensions.
#define LSST_EXCEPT_ADD(e, m)
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
A class to represent a 2-dimensional array of pixels.
Class stored in SpatialCells for spatial Psf fitting.
int getIx() const
Convenience accessors for the keys in the minimal schema.