51 namespace pexExcept = lsst::pex::exceptions;
52 namespace afwGeom = lsst::afw::geom;
54 namespace afwMath = lsst::afw::math;
55 namespace mathDetail = lsst::afw::math::detail;
65 template <
typename OutImageT,
typename InImageT>
66 inline void setEdgePixels(
69 InImageT
const &inImage,
77 const unsigned int imWidth = outImage.getWidth();
78 const unsigned int imHeight = outImage.getHeight();
79 const unsigned int kWidth = kernel.
getWidth();
80 const unsigned int kHeight = kernel.
getHeight();
81 const unsigned int kCtrX = kernel.
getCtrX();
82 const unsigned int kCtrY = kernel.
getCtrY();
84 const typename OutImageT::SinglePixel
edgePixel = afwMath::edgePixel<OutImageT>(
87 std::vector<afwGeom::Box2I> bboxList;
92 int const numHeight = kHeight - (1 + kCtrY);
93 int const numWidth = kWidth - (1 + kCtrX);
107 for (std::vector<afwGeom::Box2I>::const_iterator bboxIter = bboxList.begin();
108 bboxIter != bboxList.end(); ++bboxIter
114 outView.assign(OutImageT(InImageT(inImage, *bboxIter,
afwImage::LOCAL),
true));
127 template <
typename OutImageT,
typename InImageT>
128 inline void setEdgePixels(
131 InImageT
const &inImage,
139 const unsigned int imWidth = outImage.getWidth();
140 const unsigned int imHeight = outImage.getHeight();
141 const unsigned int kWidth = kernel.
getWidth();
142 const unsigned int kHeight = kernel.
getHeight();
143 const unsigned int kCtrX = kernel.
getCtrX();
144 const unsigned int kCtrY = kernel.
getCtrY();
146 const typename OutImageT::SinglePixel edgePixel = afwMath::edgePixel<OutImageT>(
149 std::vector<afwGeom::Box2I> bboxList;
154 int const numHeight = kHeight - (1 + kCtrY);
155 int const numWidth = kWidth - (1 + kCtrX);
182 for (std::vector<afwGeom::Box2I>::const_iterator bboxIter = bboxList.begin();
183 bboxIter != bboxList.end(); ++bboxIter) {
188 outView.assign(OutImageT(InImageT(inImage, *bboxIter,
afwImage::LOCAL),
true));
189 *(outView.getMask()) |= edgeMask;
214 template <
typename OutImageT,
typename InImageT>
218 InImageT
const &inImage1,
220 InImageT
const &inImage2)
222 if (outImage.getDimensions() != inImage1.getDimensions()) {
223 std::ostringstream os;
224 os <<
"outImage dimensions = ( " << outImage.getWidth() <<
", " << outImage.getHeight()
225 <<
") != (" << inImage1.getWidth() <<
", " << inImage1.getHeight()
226 <<
") = inImage1 dimensions";
227 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
228 }
else if (inImage1.getDimensions() != inImage2.getDimensions()) {
229 std::ostringstream os;
230 os <<
"inImage1 dimensions = ( " << inImage1.getWidth() <<
", " << inImage1.getHeight()
231 <<
") != (" << inImage2.getWidth() <<
", " << inImage2.getHeight()
232 <<
") = inImage2 dimensions";
233 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
236 typedef typename InImageT::const_x_iterator InConstXIter;
237 typedef typename OutImageT::x_iterator OutXIter;
238 for (
int y = 0;
y != inImage1.getHeight(); ++
y) {
239 InConstXIter
const end1 = inImage1.row_end(
y);
240 InConstXIter inIter1 = inImage1.row_begin(
y);
241 InConstXIter inIter2 = inImage2.row_begin(
y);
242 OutXIter outIter = outImage.row_begin(
y);
243 for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
244 *outIter = (*inIter1 * c1) + (*inIter2 * c2);
325 template <
typename OutImageT,
typename InImageT,
typename KernelT>
327 OutImageT& convolvedImage,
328 InImageT
const& inImage,
329 KernelT
const& kernel,
333 setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.
getDoCopyEdge(),
336 convolvedImage.setXY0(inImage.getXY0());
344 template <
typename OutImageT,
typename InImageT,
typename KernelT>
346 OutImageT& convolvedImage,
347 InImageT
const& inImage,
348 KernelT
const& kernel,
368 #define IMAGE(PIXTYPE) afwImage::Image<PIXTYPE>
369 #define MASKEDIMAGE(PIXTYPE) afwImage::MaskedImage<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
383 #define INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, KERNELTYPE) \
384 template void afwMath::convolve( \
385 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, KERNELTYPE const&, bool, bool); NL \
386 template void afwMath::convolve( \
387 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, KERNELTYPE const&, ConvolutionControl const&); NL
393 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
394 template void afwMath::scaledPlus( \
395 IMGMACRO(OUTPIXTYPE)&, double, IMGMACRO(INPIXTYPE) const&, double, IMGMACRO(INPIXTYPE) const&); NL \
396 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::AnalyticKernel) \
397 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::DeltaFunctionKernel) \
398 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::FixedKernel) \
399 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::LinearCombinationKernel) \
400 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::SeparableKernel) \
401 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, afwMath::Kernel) \
406 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
407 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
408 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Declare the Kernel class and subclasses.
Parameters to control convolution.
int getCtrY() const
Return y index of kernel's center.
void setDoCopyEdge(bool doCopyEdge)
int getCtrX() const
Return x index of kernel's center.
void setDoNormalize(bool doNormalize)
An integer coordinate rectangle.
int getHeight() const
Return the Kernel's height.
table::Key< table::Array< Kernel::Pixel > > image
int getWidth() const
Return the Kernel's width.
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.
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.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
#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...
ImageT::image_category image_category
Implementation of the Class MaskedImage.
Include files required for standard LSST Exception handling.
Kernels are used for convolution with MaskedImages and (eventually) Images.
bool getDoCopyEdge() const