38 #include "boost/timer.hpp"
51 namespace afwGeom = lsst::afw::geom;
53 namespace afwMath = lsst::afw::math;
54 namespace pexExcept = lsst::pex::exceptions;
55 namespace pexPolicy = lsst::pex::policy;
64 template <
typename PixelT>
70 Eigen::MatrixXd M = Eigen::MatrixXd::Zero(rows, cols);
88 Eigen::MatrixXi M = Eigen::MatrixXi::Zero(rows, cols);
117 template <
typename PixelT,
typename BackgroundT>
122 BackgroundT background,
131 convolutionControl.setDoNormalize(
false);
133 convolutionKernel, convolutionControl);
136 *(convolvedMaskedImage.getImage()) += background;
139 convolvedMaskedImage -= scienceMaskedImage;
143 convolvedMaskedImage *= -1.0;
146 double time = t.elapsed();
147 LOGL_DEBUG(
"TRACE4.ip.diffim.convolveAndSubtract",
148 "Total compute time to convolve and subtract : %.2f s", time);
150 return convolvedMaskedImage;
168 template <
typename PixelT,
typename BackgroundT>
173 BackgroundT background,
182 convolutionControl.setDoNormalize(
false);
184 convolutionKernel, convolutionControl);
187 *(convolvedMaskedImage.getImage()) += background;
190 *convolvedMaskedImage.getImage() -= *scienceMaskedImage.
getImage();
194 *convolvedMaskedImage.getImage() *= -1.0;
196 convolvedMaskedImage.getMask()->assign(*scienceMaskedImage.
getMask());
197 convolvedMaskedImage.getVariance()->assign(*scienceMaskedImage.
getVariance());
199 double time = t.elapsed();
200 LOGL_DEBUG(
"TRACE4.ip.diffim.convolveAndSubtract",
201 "Total compute time to convolve and subtract : %.2f s", time);
203 return convolvedMaskedImage;
217 template class FindSetBits<lsst::afw::image::Mask<> >;
218 template class ImageStatistics<float>;
219 template class ImageStatistics<double>;
223 #define p_INSTANTIATE_convolveAndSubtract(TEMPLATE_IMAGE_T, TYPE) \
225 lsst::afw::image::MaskedImage<TYPE> convolveAndSubtract( \
226 lsst::afw::image::TEMPLATE_IMAGE_T<TYPE> const& templateImage, \
227 lsst::afw::image::MaskedImage<TYPE> const& scienceMaskedImage, \
228 lsst::afw::math::Kernel const& convolutionKernel, \
233 afwImage::MaskedImage<TYPE> convolveAndSubtract( \
234 lsst::afw::image::TEMPLATE_IMAGE_T<TYPE> const& templateImage, \
235 lsst::afw::image::MaskedImage<TYPE> const& scienceMaskedImage, \
236 lsst::afw::math::Kernel const& convolutionKernel, \
237 lsst::afw::math::Function2<double> const& backgroundFunction, \
240 #define INSTANTIATE_convolveAndSubtract(TYPE) \
241 p_INSTANTIATE_convolveAndSubtract(Image, TYPE) \
242 p_INSTANTIATE_convolveAndSubtract(MaskedImage, TYPE)
An include file to include the public header files for lsst::afw::math.
An include file to include the header files for lsst::afw::geom.
An include file to include the header files for lsst::ip::diffim.
Eigen::MatrixXi maskToEigenMatrix(lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &mask)
Parameters to control convolution.
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
geom::Extent2I getDimensions() const
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
afwImage::MaskedImage< PixelT > convolveAndSubtract(lsst::afw::image::MaskedImage< PixelT > const &templateImage, lsst::afw::image::MaskedImage< PixelT > const &scienceMaskedImage, lsst::afw::math::Kernel const &convolutionKernel, BackgroundT background, bool invert)
Implement fundamental difference imaging step of convolution and subtraction : D = I - (K*T + bg) whe...
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
table::Key< table::Array< Kernel::Pixel > > image
LSST DM logging module built on log4cxx.
An include file to include the header files for lsst::afw::image.
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
A class to manipulate images, masks, and variance as a single object.
int getHeight() const
Return the number of rows in the image.
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image...
#define INSTANTIATE_convolveAndSubtract(TYPE)
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
int getWidth() const
Return the number of columns in the image.
Kernels are used for convolution with MaskedImages and (eventually) Images.
A class to represent a 2-dimensional array of pixels.
Eigen::MatrixXd imageToEigenMatrix(lsst::afw::image::Image< PixelT > const &img)
Turns Image into a 2-D Eigen Matrix.