LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
applyLookupTable.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2016 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 
25 #include <cstdint>
26 
27 #include "lsst/pex/exceptions.h"
29 
30 namespace lsst {
31 namespace ip {
32 namespace isr {
33 
34 template<typename PixelT>
37  ndarray::Array<PixelT, 1, 1> const &table,
38  PixelT indOffset
39 ) {
40  int numOutOfRange = 0;
41  auto const maxLookupCol = table.size() - 1;
42  for (int col = 0, imHeight = image.getHeight(); col < imHeight; ++col) {
43  for (auto imPtr = image.row_begin(col), end = image.row_end(col); imPtr != end; ++imPtr) {
44  auto lookupCol = static_cast<int>(indOffset + *imPtr);
45  if (lookupCol < 0) {
46  lookupCol = 0;
47  ++numOutOfRange;
48  } else if (lookupCol > maxLookupCol) {
49  lookupCol = maxLookupCol;
50  ++numOutOfRange;
51  }
52  *imPtr += table[lookupCol];
53  }
54  }
55  return numOutOfRange;
56 }
57 
58 #define INSTANTIATE(T) \
59  template int applyLookupTable<T>(afw::image::Image<T> &, ndarray::Array<T, 1, 1> const &, T);
60 
61 INSTANTIATE(float);
62 INSTANTIATE(double);
63 
64 }}} // lsst::ip::isr
#define INSTANTIATE(T)
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:326
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:241
x_iterator row_begin(int y) const
Definition: Image.h:321
Include files required for standard LSST Exception handling.
int applyLookupTable(afw::image::Image< PixelT > &image, ndarray::Array< PixelT, 1, 1 > const &table, PixelT indOffset)
int col
Definition: CR.cc:158