58 template <
typename OutImageT,
typename InImageT>
59 inline void setEdgePixels(OutImageT& outImage, Kernel
const& kernel, InImageT
const& inImage,
bool doCopyEdge,
60 image::detail::Image_tag) {
61 const unsigned int imWidth = outImage.getWidth();
62 const unsigned int imHeight = outImage.getHeight();
63 const unsigned int kWidth = kernel.getWidth();
64 const unsigned int kHeight = kernel.getHeight();
65 const unsigned int kCtrX = kernel.getCtr().getX();
66 const unsigned int kCtrY = kernel.getCtr().getY();
68 const typename OutImageT::SinglePixel
edgePixel =
75 int const numHeight = kHeight - (1 + kCtrY);
76 int const numWidth = kWidth - (1 + kCtrX);
85 for (
auto const &bboxIter : bboxList) {
90 outView.assign(OutImageT(InImageT(inImage, bboxIter,
image::LOCAL),
true));
109 template <
typename OutImageT,
typename InImageT>
110 inline void setEdgePixels(OutImageT& outImage, Kernel
const& kernel, InImageT
const& inImage,
bool doCopyEdge,
111 image::detail::MaskedImage_tag) {
112 const unsigned int imWidth = outImage.getWidth();
113 const unsigned int imHeight = outImage.getHeight();
114 const unsigned int kWidth = kernel.getWidth();
115 const unsigned int kHeight = kernel.getHeight();
116 const unsigned int kCtrX = kernel.getCtr().getX();
117 const unsigned int kCtrY = kernel.getCtr().getY();
119 const typename OutImageT::SinglePixel
edgePixel =
126 int const numHeight = kHeight - (1 + kCtrY);
127 int const numWidth = kWidth - (1 + kCtrX);
137 for (
auto const &bboxIter : bboxList) {
142 outView.assign(OutImageT(InImageT(inImage, bboxIter,
image::LOCAL),
true));
143 *(outView.getMask()) |= edgeMask;
152 template <
typename OutImageT,
typename InImageT>
153 void scaledPlus(OutImageT& outImage,
double c1, InImageT
const& inImage1,
double c2,
154 InImageT
const& inImage2) {
155 if (outImage.getDimensions() != inImage1.getDimensions()) {
157 os <<
"outImage dimensions = ( " << outImage.getWidth() <<
", " << outImage.getHeight() <<
") != ("
158 << inImage1.getWidth() <<
", " << inImage1.getHeight() <<
") = inImage1 dimensions";
160 }
else if (inImage1.getDimensions() != inImage2.getDimensions()) {
162 os <<
"inImage1 dimensions = ( " << inImage1.getWidth() <<
", " << inImage1.getHeight() <<
") != ("
163 << inImage2.getWidth() <<
", " << inImage2.getHeight() <<
") = inImage2 dimensions";
167 using InConstXIter =
typename InImageT::const_x_iterator;
168 using OutXIter =
typename OutImageT::x_iterator;
169 for (
int y = 0;
y != inImage1.getHeight(); ++
y) {
170 InConstXIter
const end1 = inImage1.row_end(
y);
171 InConstXIter inIter1 = inImage1.row_begin(
y);
172 InConstXIter inIter2 = inImage2.row_begin(
y);
173 OutXIter outIter = outImage.row_begin(
y);
174 for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
175 *outIter = (*inIter1 * c1) + (*inIter2 * c2);
180 template <
typename OutImageT,
typename InImageT,
typename KernelT>
181 void convolve(OutImageT& convolvedImage, InImageT
const& inImage, KernelT
const& kernel,
184 setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.
getDoCopyEdge(),
186 convolvedImage.setXY0(inImage.getXY0());
189 template <
typename OutImageT,
typename InImageT,
typename KernelT>
190 void convolve(OutImageT& convolvedImage, InImageT
const& inImage, KernelT
const& kernel,
bool doNormalize,
195 convolve(convolvedImage, inImage, kernel, convolutionControl);
205 #define IMAGE(PIXTYPE) image::Image<PIXTYPE>
206 #define MASKEDIMAGE(PIXTYPE) image::MaskedImage<PIXTYPE, image::MaskPixel, image::VariancePixel>
220 #define INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, KERNELTYPE) \
221 template void convolve(IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const &, KERNELTYPE const&, bool, \
223 NL template void convolve(IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const &, KERNELTYPE const&, \
224 ConvolutionControl const&); \
231 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
232 template void scaledPlus(IMGMACRO(OUTPIXTYPE)&, double, IMGMACRO(INPIXTYPE) const &, double, \
233 IMGMACRO(INPIXTYPE) const &); \
234 NL INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, \
235 AnalyticKernel) INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, \
237 DeltaFunctionKernel) \
238 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, FixedKernel) \
239 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, LinearCombinationKernel) \
240 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, SeparableKernel) \
241 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, Kernel)
244 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
245 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
246 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
#define INSTANTIATE(FROMSYS, TOSYS)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Parameters to control convolution.
void setDoCopyEdge(bool doCopyEdge)
bool getDoCopyEdge() const
void setDoNormalize(bool doNormalize)
Reports invalid arguments.
T emplace_back(T... args)
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.
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
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::SinglePixel edgePixel(lsst::afw::image::detail::Image_tag)
Return an off-the-edge pixel appropriate for a given Image type.
Extent< int, 2 > Extent2I
A base class for image defects.
typename ImageT::image_category image_category