38 #include "boost/timer.hpp"
53 namespace afwGeom = lsst::afw::geom;
55 namespace afwMath = lsst::afw::math;
56 namespace pexExcept = lsst::pex::exceptions;
57 namespace pexLog = lsst::pex::logging;
58 namespace pexPolicy = lsst::pex::policy;
67 template <
typename PixelT>
73 Eigen::MatrixXd M = Eigen::MatrixXd::Zero(rows, cols);
91 Eigen::MatrixXi M = Eigen::MatrixXi::Zero(rows, cols);
120 template <
typename PixelT,
typename BackgroundT>
125 BackgroundT background,
134 convolutionControl.setDoNormalize(
false);
136 convolutionKernel, convolutionControl);
139 *(convolvedMaskedImage.getImage()) += background;
142 convolvedMaskedImage -= scienceMaskedImage;
146 convolvedMaskedImage *= -1.0;
149 double time = t.elapsed();
150 pexLog::TTrace<5>(
"lsst.ip.diffim.convolveAndSubtract",
151 "Total compute time to convolve and subtract : %.2f s", time);
153 return convolvedMaskedImage;
171 template <
typename PixelT,
typename BackgroundT>
176 BackgroundT background,
185 convolutionControl.setDoNormalize(
false);
187 convolutionKernel, convolutionControl);
190 *(convolvedMaskedImage.getImage()) += background;
193 *convolvedMaskedImage.getImage() -= *scienceMaskedImage.
getImage();
197 *convolvedMaskedImage.getImage() *= -1.0;
199 *convolvedMaskedImage.getMask() <<= *scienceMaskedImage.
getMask();
200 *convolvedMaskedImage.getVariance() <<= *scienceMaskedImage.
getVariance();
202 double time = t.elapsed();
203 pexLog::TTrace<5>(
"lsst.ip.diffim.convolveAndSubtract",
204 "Total compute time to convolve and subtract : %.2f s", time);
206 return convolvedMaskedImage;
220 template class FindSetBits<lsst::afw::image::Mask<> >;
221 template class ImageStatistics<float>;
222 template class ImageStatistics<double>;
226 #define p_INSTANTIATE_convolveAndSubtract(TEMPLATE_IMAGE_T, TYPE) \
228 lsst::afw::image::MaskedImage<TYPE> convolveAndSubtract( \
229 lsst::afw::image::TEMPLATE_IMAGE_T<TYPE> const& templateImage, \
230 lsst::afw::image::MaskedImage<TYPE> const& scienceMaskedImage, \
231 lsst::afw::math::Kernel const& convolutionKernel, \
236 afwImage::MaskedImage<TYPE> convolveAndSubtract( \
237 lsst::afw::image::TEMPLATE_IMAGE_T<TYPE> const& templateImage, \
238 lsst::afw::image::MaskedImage<TYPE> const& scienceMaskedImage, \
239 lsst::afw::math::Kernel const& convolutionKernel, \
240 lsst::afw::math::Function2<double> const& backgroundFunction, \
243 #define INSTANTIATE_convolveAndSubtract(TYPE) \
244 p_INSTANTIATE_convolveAndSubtract(Image, TYPE) \
245 p_INSTANTIATE_convolveAndSubtract(MaskedImage, TYPE)
An include file to include the public header files for lsst::afw::math.
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
An include file to include the header files for lsst::afw::geom.
An include file to include the header files for lsst::ip::diffim.
x_iterator row_begin(int y) const
Eigen::MatrixXi maskToEigenMatrix(lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &mask)
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Parameters to control convolution.
definition of the Trace messaging facilities
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...
table::Key< table::Array< Kernel::Pixel > > image
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
An include file to include the header files for lsst::afw::image.
int getWidth() const
Return the number of columns in the image.
A class to manipulate images, masks, and variance as a single object.
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...
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
#define INSTANTIATE_convolveAndSubtract(TYPE)
int getHeight() const
Return the number of rows in the image.
geom::Extent2I getDimensions() const
Kernels are used for convolution with MaskedImages and (eventually) Images.
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Eigen::MatrixXd imageToEigenMatrix(lsst::afw::image::Image< PixelT > const &img)
Turns Image into a 2-D Eigen Matrix.