43 #include "boost/cstdint.hpp"
52 namespace pexExcept = lsst::pex::exceptions;
53 namespace pexLog = lsst::pex::logging;
54 namespace afwGeom = lsst::afw::geom;
56 namespace afwMath = lsst::afw::math;
57 namespace mathDetail = lsst::afw::math::detail;
67 template <
typename OutImageT,
typename InImageT>
68 inline void setEdgePixels(
71 InImageT
const &inImage,
79 const unsigned int imWidth = outImage.getWidth();
80 const unsigned int imHeight = outImage.getHeight();
81 const unsigned int kWidth = kernel.
getWidth();
82 const unsigned int kHeight = kernel.
getHeight();
83 const unsigned int kCtrX = kernel.
getCtrX();
84 const unsigned int kCtrY = kernel.
getCtrY();
86 const typename OutImageT::SinglePixel
edgePixel = afwMath::edgePixel<OutImageT>(
89 std::vector<afwGeom::Box2I> bboxList;
94 int const numHeight = kHeight - (1 + kCtrY);
95 int const numWidth = kWidth - (1 + kCtrX);
109 for (std::vector<afwGeom::Box2I>::const_iterator bboxIter = bboxList.begin();
110 bboxIter != bboxList.end(); ++bboxIter
116 outView <<= OutImageT(InImageT(inImage, *bboxIter,
afwImage::LOCAL),
true);
129 template <
typename OutImageT,
typename InImageT>
130 inline void setEdgePixels(
133 InImageT
const &inImage,
141 const unsigned int imWidth = outImage.getWidth();
142 const unsigned int imHeight = outImage.getHeight();
143 const unsigned int kWidth = kernel.
getWidth();
144 const unsigned int kHeight = kernel.
getHeight();
145 const unsigned int kCtrX = kernel.
getCtrX();
146 const unsigned int kCtrY = kernel.
getCtrY();
148 const typename OutImageT::SinglePixel edgePixel = afwMath::edgePixel<OutImageT>(
151 std::vector<afwGeom::Box2I> bboxList;
156 int const numHeight = kHeight - (1 + kCtrY);
157 int const numWidth = kWidth - (1 + kCtrX);
184 for (std::vector<afwGeom::Box2I>::const_iterator bboxIter = bboxList.begin();
185 bboxIter != bboxList.end(); ++bboxIter) {
190 outView <<= OutImageT(InImageT(inImage, *bboxIter,
afwImage::LOCAL),
true);
191 *(outView.getMask()) |= edgeMask;
216 template <
typename OutImageT,
typename InImageT>
220 InImageT
const &inImage1,
222 InImageT
const &inImage2)
224 if (outImage.getDimensions() != inImage1.getDimensions()) {
225 std::ostringstream os;
226 os <<
"outImage dimensions = ( " << outImage.getWidth() <<
", " << outImage.getHeight()
227 <<
") != (" << inImage1.getWidth() <<
", " << inImage1.getHeight()
228 <<
") = inImage1 dimensions";
229 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
230 }
else if (inImage1.getDimensions() != inImage2.getDimensions()) {
231 std::ostringstream os;
232 os <<
"inImage1 dimensions = ( " << inImage1.getWidth() <<
", " << inImage1.getHeight()
233 <<
") != (" << inImage2.getWidth() <<
", " << inImage2.getHeight()
234 <<
") = inImage2 dimensions";
235 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
238 typedef typename InImageT::const_x_iterator InConstXIter;
239 typedef typename OutImageT::x_iterator OutXIter;
240 for (
int y = 0;
y != inImage1.getHeight(); ++
y) {
241 InConstXIter
const end1 = inImage1.row_end(
y);
242 InConstXIter inIter1 = inImage1.row_begin(
y);
243 InConstXIter inIter2 = inImage2.row_begin(
y);
244 OutXIter outIter = outImage.row_begin(
y);
245 for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
246 *outIter = (*inIter1 * c1) + (*inIter2 * c2);
327 template <
typename OutImageT,
typename InImageT,
typename KernelT>
329 OutImageT& convolvedImage,
330 InImageT
const& inImage,
331 KernelT
const& kernel,
335 setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.
getDoCopyEdge(),
338 convolvedImage.setXY0(inImage.getXY0());
346 template <
typename OutImageT,
typename InImageT,
typename KernelT>
348 OutImageT& convolvedImage,
349 InImageT
const& inImage,
350 KernelT
const& kernel,
370 #define IMAGE(PIXTYPE) afwImage::Image<PIXTYPE>
371 #define MASKEDIMAGE(PIXTYPE) afwImage::MaskedImage<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
385 #define INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, KERNELTYPE) \
386 template void afwMath::convolve( \
387 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, KERNELTYPE const&, bool, bool); NL \
388 template void afwMath::convolve( \
389 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, KERNELTYPE const&, ConvolutionControl const&); NL
395 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
396 template void afwMath::scaledPlus( \
397 IMGMACRO(OUTPIXTYPE)&, double, IMGMACRO(INPIXTYPE) const&, double, IMGMACRO(INPIXTYPE) const&); NL \
398 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::AnalyticKernel) \
399 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::DeltaFunctionKernel) \
400 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::FixedKernel) \
401 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::LinearCombinationKernel) \
402 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::SeparableKernel) \
403 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::Kernel) \
408 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
409 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
410 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
boost::uint16_t MaskPixel
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Declare the Kernel class and subclasses.
void setDoNormalize(bool doNormalize)
int getWidth() const
Return the Kernel's width.
int getHeight() const
Return the Kernel's height.
Parameters to control convolution.
definition of the Trace messaging facilities
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
void setDoCopyEdge(bool doCopyEdge)
void basicConvolve(OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl)
Low-level convolution function that does not set edge pixels.
ImageT::image_category image_category
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
A traits class for MaskedImage.
ImageT::SinglePixel edgePixel(lsst::afw::image::detail::Image_tag)
Return an off-the-edge pixel appropriate for a given Image type.
#define LSST_EXCEPT(type,...)
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...
Implementation of the Class MaskedImage.
int getCtrY() const
Return y index of kernel's center.
Kernels are used for convolution with MaskedImages and (eventually) Images.
Include files required for standard LSST Exception handling.
bool getDoCopyEdge() const
int getCtrX() const
Return x index of kernel's center.