65 template <
typename OutImageT,
typename InImageT>
66 inline void setEdgePixels(OutImageT& outImage, Kernel
const& kernel, InImageT
const& inImage,
bool doCopyEdge,
67 image::detail::Image_tag) {
68 const unsigned int imWidth = outImage.getWidth();
69 const unsigned int imHeight = outImage.getHeight();
70 const unsigned int kWidth = kernel.getWidth();
71 const unsigned int kHeight = kernel.getHeight();
72 const unsigned int kCtrX = kernel.getCtrX();
73 const unsigned int kCtrY = kernel.getCtrY();
75 const typename OutImageT::SinglePixel
edgePixel =
82 int const numHeight = kHeight - (1 + kCtrY);
83 int const numWidth = kWidth - (1 + kCtrX);
93 bboxIter != bboxList.end(); ++bboxIter) {
98 outView.assign(OutImageT(InImageT(inImage, *bboxIter,
image::LOCAL),
true));
117 template <
typename OutImageT,
typename InImageT>
118 inline void setEdgePixels(OutImageT& outImage, Kernel
const& kernel, InImageT
const& inImage,
bool doCopyEdge,
119 image::detail::MaskedImage_tag) {
120 const unsigned int imWidth = outImage.getWidth();
121 const unsigned int imHeight = outImage.getHeight();
122 const unsigned int kWidth = kernel.getWidth();
123 const unsigned int kHeight = kernel.getHeight();
124 const unsigned int kCtrX = kernel.getCtrX();
125 const unsigned int kCtrY = kernel.getCtrY();
127 const typename OutImageT::SinglePixel edgePixel =
134 int const numHeight = kHeight - (1 + kCtrY);
135 int const numWidth = kWidth - (1 + kCtrX);
146 bboxIter != bboxList.end(); ++bboxIter) {
151 outView.assign(OutImageT(InImageT(inImage, *bboxIter,
image::LOCAL),
true));
152 *(outView.getMask()) |= edgeMask;
161 template <
typename OutImageT,
typename InImageT>
162 void scaledPlus(OutImageT& outImage,
double c1, InImageT
const& inImage1,
double c2,
163 InImageT
const& inImage2) {
164 if (outImage.getDimensions() != inImage1.getDimensions()) {
166 os <<
"outImage dimensions = ( " << outImage.getWidth() <<
", " << outImage.getHeight() <<
") != (" 167 << inImage1.getWidth() <<
", " << inImage1.getHeight() <<
") = inImage1 dimensions";
169 }
else if (inImage1.getDimensions() != inImage2.getDimensions()) {
171 os <<
"inImage1 dimensions = ( " << inImage1.getWidth() <<
", " << inImage1.getHeight() <<
") != (" 172 << inImage2.getWidth() <<
", " << inImage2.getHeight() <<
") = inImage2 dimensions";
176 typedef typename InImageT::const_x_iterator InConstXIter;
177 typedef typename OutImageT::x_iterator OutXIter;
178 for (
int y = 0;
y != inImage1.getHeight(); ++
y) {
179 InConstXIter
const end1 = inImage1.row_end(
y);
180 InConstXIter inIter1 = inImage1.row_begin(
y);
181 InConstXIter inIter2 = inImage2.row_begin(
y);
182 OutXIter outIter = outImage.row_begin(
y);
183 for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
184 *outIter = (*inIter1 * c1) + (*inIter2 * c2);
189 template <
typename OutImageT,
typename InImageT,
typename KernelT>
190 void convolve(OutImageT& convolvedImage, InImageT
const& inImage, KernelT
const& kernel,
193 setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.
getDoCopyEdge(),
195 convolvedImage.setXY0(inImage.getXY0());
198 template <
typename OutImageT,
typename InImageT,
typename KernelT>
199 void convolve(OutImageT& convolvedImage, InImageT
const& inImage, KernelT
const& kernel,
bool doNormalize,
204 convolve(convolvedImage, inImage, kernel, convolutionControl);
214 #define IMAGE(PIXTYPE) image::Image<PIXTYPE> 215 #define MASKEDIMAGE(PIXTYPE) image::MaskedImage<PIXTYPE, image::MaskPixel, image::VariancePixel> 229 #define INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, KERNELTYPE) \ 230 template void convolve(IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const &, KERNELTYPE const&, bool, \ 232 NL template void convolve(IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const &, KERNELTYPE const&, \ 233 ConvolutionControl const&); \ 240 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \ 241 template void scaledPlus(IMGMACRO(OUTPIXTYPE)&, double, IMGMACRO(INPIXTYPE) const &, double, \ 242 IMGMACRO(INPIXTYPE) const &); \ 243 NL INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, \ 244 AnalyticKernel) INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, \ 246 DeltaFunctionKernel) \ 247 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, FixedKernel) \ 248 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, LinearCombinationKernel) \ 249 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, SeparableKernel) \ 250 INSTANTIATE_IM_OR_MI_KERNEL(IMGMACRO, OUTPIXTYPE, INPIXTYPE, Kernel) // 253 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \ 254 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \ 255 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
Parameters to control convolution.
void setDoCopyEdge(bool doCopyEdge)
void setDoNormalize(bool doNormalize)
LSST DM logging module built on log4cxx.
A base class for image defects.
bool getDoCopyEdge() const
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.
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 LSST_EXCEPT(type,...)
Create an exception with a given type.
Reports invalid arguments.
ImageT::image_category image_category
An integer coordinate rectangle.
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.
#define INSTANTIATE(FROMSYS, TOSYS)