LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
convCpuGpuShared.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
38 #include "boost/cstdint.hpp"
39 
40 #include "lsst/pex/exceptions.h"
42 #include "lsst/afw/math/Kernel.h"
45 
46 namespace afwImage = lsst::afw::image;
47 namespace mathDetail = lsst::afw::math::detail;
48 
49 /*
50  * Assert that the dimensions of convolvedImage, inImage and kernel are compatible with convolution.
51  *
52  * @throw lsst::pex::exceptions::InvalidParameterError if convolvedImage dimensions != inImage dim.
53  * @throw lsst::pex::exceptions::InvalidParameterError if inImage smaller than kernel in width or h.
54  * @throw lsst::pex::exceptions::InvalidParameterError if kernel width or height < 1
55  *
56  * @note Same as assertDimensionsOK in basicConvolve.cc, copy-pasted
57  */
58 template <typename OutImageT, typename InImageT>
60  OutImageT const &convolvedImage,
61  InImageT const &inImage,
62  lsst::afw::math::Kernel const &kernel
63 ) {
64  if (convolvedImage.getDimensions() != inImage.getDimensions()) {
65  std::ostringstream os;
66  os << "convolvedImage dimensions = ( "
67  << convolvedImage.getWidth() << ", " << convolvedImage.getHeight()
68  << ") != (" << inImage.getWidth() << ", " << inImage.getHeight() << ") = inImage dimensions";
69  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
70  }
71  if (inImage.getWidth() < kernel.getWidth() || inImage.getHeight() < kernel.getHeight()) {
72  std::ostringstream os;
73  os << "inImage dimensions = ( "
74  << inImage.getWidth() << ", " << inImage.getHeight()
75  << ") smaller than (" << kernel.getWidth() << ", " << kernel.getHeight()
76  << ") = kernel dimensions in width and/or height";
77  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
78  }
79  if ((kernel.getWidth() < 1) || (kernel.getHeight() < 1)) {
80  std::ostringstream os;
81  os << "kernel dimensions = ( "
82  << kernel.getWidth() << ", " << kernel.getHeight()
83  << ") smaller than (1, 1) in width and/or height";
84  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
85  }
86 }
87 
88 /*
89  * Explicit instantiation
90  */
92 #define IMAGE(PIXTYPE) afwImage::Image<PIXTYPE>
93 #define MASKEDIMAGE(PIXTYPE) afwImage::MaskedImage<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
94 #define NL /* */
95 // Instantiate Image or MaskedImage versions
96 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
97  template void mathDetail::assertDimensionsOK( \
98  IMGMACRO(OUTPIXTYPE) const &convolvedImage, \
99  IMGMACRO(INPIXTYPE) const &inImage, \
100  lsst::afw::math::Kernel const &kernel \
101  );
102 
103 // Instantiate both Image and MaskedImage versions
104 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
105  INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
106  INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
107 
108 INSTANTIATE(double, double)
109 INSTANTIATE(double, float)
110 INSTANTIATE(double, int)
111 INSTANTIATE(double, boost::uint16_t)
112 INSTANTIATE(float, float)
113 INSTANTIATE(float, int)
114 INSTANTIATE(float, boost::uint16_t)
115 INSTANTIATE(int, int)
116 INSTANTIATE(boost::uint16_t, boost::uint16_t)
Convolution support.
Declare the Kernel class and subclasses.
int getWidth() const
Return the Kernel&#39;s width.
Definition: Kernel.h:240
int getHeight() const
Return the Kernel&#39;s height.
Definition: Kernel.h:247
CPU and GPU convolution shared code.
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
#define INSTANTIATE(T)
void assertDimensionsOK(OutImageT const &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel)
Implementation of the Class MaskedImage.
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:134
Include files required for standard LSST Exception handling.