LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Namespaces | Classes | Functions
lsst::ip::isr Namespace Reference

Namespaces

 assembleCcdTask
 
 fringe
 
 isr
 
 isrTask
 
 linearize
 
 version
 

Classes

class  CountMaskedPixels
 

Functions

template<typename PixelT >
int applyLookupTable (afw::image::Image< PixelT > &image, ndarray::Array< PixelT, 1, 1 > const &table, PixelT indOffset)
 Add the values in a lookup table to an image, e.g. More...
 
template int applyLookupTable< float > (afw::image::Image< float > &, ndarray::Array< float, 1, 1 > const &, float)
 
template int applyLookupTable< double > (afw::image::Image< double > &, ndarray::Array< double, 1, 1 > const &, double)
 
template<typename PixelT >
size_t maskNans (afw::image::MaskedImage< PixelT > const &mi,afw::image::MaskPixel maskVal,afw::image::MaskPixel allow=0)
 Mask NANs in an image. More...
 
template<typename ImagePixelT , typename FunctionT >
void fitOverscanImage (std::shared_ptr< afw::math::Function1< FunctionT > > &overscanFunction, afw::image::MaskedImage< ImagePixelT > const &overscan, double ssize, int sigma)
 
std::string between (std::string &s, char ldelim, char rdelim)
 
template void fitOverscanImage (std::shared_ptr< afw::math::Function1< double > > &overscanFunction, afw::image::MaskedImage< float > const &overscan, double ssize, int sigma)
 
template void fitOverscanImage (std::shared_ptr< afw::math::Function1< double > > &overscanFunction, afw::image::MaskedImage< double > const &overscan, double ssize, int sigma)
 
template size_t maskNans< float > (afw::image::MaskedImage< float > const &, afw::image::MaskPixel, afw::image::MaskPixel)
 
template size_t maskNans< double > (afw::image::MaskedImage< double > const &, afw::image::MaskPixel, afw::image::MaskPixel)
 
template<typename ImagePixelT , typename FunctionT >
void fitOverscanImage (std::shared_ptr< lsst::afw::math::Function1< FunctionT > > &overscanFunction, lsst::afw::image::MaskedImage< ImagePixelT > const &overscan, double ssize=1., int sigma=1)
 

Function Documentation

template<typename PixelT >
int lsst::ip::isr::applyLookupTable ( afw::image::Image< PixelT > &  image,
ndarray::Array< PixelT, 1, 1 > const &  table,
PixelT  indOffset 
)

Add the values in a lookup table to an image, e.g.

for non-linearity correction

The algorithm is as follows: numOutOfRange = 0 For each i,j of the image: lookupInd = int(indOffset + image[i,j]) if lookupInd not in range [0, table.size() - 1]: set lookupInd to nearest edge and increment numOutOfRange image[i,j] += table[lookupInd] return numOutOfRange

Parameters
[in,out]imageimage to which to add the values; modified in place
[in]tablelookup table
[in]indOffsetscalar added to image value before truncating to lookup column
Returns
the number of pixels whose values were out of range

Definition at line 35 of file applyLookupTable.cc.

39  {
40  if (table.size() == 0u) {
41  throw LSST_EXCEPT(
42  pex::exceptions::LengthError,
43  "Lookup table has zero size."
44  );
45  }
46  int numOutOfRange = 0;
47  int const maxLookupCol = table.size() - 1;
48  for (int col = 0, imHeight = image.getHeight(); col < imHeight; ++col) {
49  for (auto imPtr = image.row_begin(col), end = image.row_end(col); imPtr != end; ++imPtr) {
50  int lookupCol = indOffset + *imPtr;
51  if (lookupCol < 0) {
52  lookupCol = 0;
53  ++numOutOfRange;
54  } else if (lookupCol > maxLookupCol) {
55  lookupCol = maxLookupCol;
56  ++numOutOfRange;
57  }
58  *imPtr += table[lookupCol];
59  }
60  }
61  return numOutOfRange;
62 }
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int col
Definition: CR.cc:157
template int lsst::ip::isr::applyLookupTable< double > ( afw::image::Image< double > &  ,
ndarray::Array< double, 1, 1 > const &  ,
double   
)
template int lsst::ip::isr::applyLookupTable< float > ( afw::image::Image< float > &  ,
ndarray::Array< float, 1, 1 > const &  ,
float   
)
std::string lsst::ip::isr::between ( std::string &  s,
char  ldelim,
char  rdelim 
)

Definition at line 99 of file Isr.cc.

99  {
100  std::string::iterator b(s.begin());
101  std::string::iterator e(s.end());
102  std::string::iterator lp;
103  std::string::iterator rp;
104 
105  std::string result;
106 
107  if((lp = std::find(b, e, ldelim)) != e)
108  if((rp = std::find(++lp, e, rdelim)) != e)
109  result = std::string(lp, rp);
110 
111  return result;
112 }
afw::table::Key< double > b
template<typename ImagePixelT , typename FunctionT >
void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< afw::math::Function1< FunctionT > > &  overscanFunction,
afw::image::MaskedImage< ImagePixelT > const &  overscan,
double  ssize,
int  sigma 
)

afw::geom::Box2I bbox = afw::geom::Box2I( afw::geom::Point2I(0, y), afw::geom::Point2I(0, width) ); The above was how this was defined before ticket #1556. As I understand it the following is the new way to do this

Definition at line 52 of file Isr.cc.

57  {
58  typedef afw::image::MaskedImage<ImagePixelT> MaskedImage;
59 
60 
61  const int height = overscan.getHeight();
62  const int width = overscan.getWidth();
63  std::vector<double> values(height);
64  std::vector<double> errors(height);
65  std::vector<double> positions(height);
66 
67  std::vector<double> parameters(overscanFunction->getNParameters(), 0.);
68  std::vector<double> stepsize(overscanFunction->getNParameters(), ssize);
69 
70  for (int y = 0; y < height; ++y) {
77  afw::geom::Box2I bbox = afw::geom::Box2I(afw::geom::Point2I(0,y), afw::geom::Point2I(width,y));
78  MaskedImage mi = MaskedImage(overscan, bbox);
79  afw::math::Statistics stats = afw::math::makeStatistics(*(mi.getImage()), afw::math::MEAN | afw::math::STDEV);
80 
81  values[y] = stats.getValue(afw::math::MEAN);
82  errors[y] = stats.getValue(afw::math::STDEV);
83  positions[y] = y;
84 
85  }
86  afw::math::FitResults fitResults = afw::math::minimize(
87  *overscanFunction,
88  parameters,
89  stepsize,
90  values,
91  errors,
92  positions,
93  sigma
94  );
95 
96  overscanFunction->setParameters(fitResults.parameterList);
97 }
int y
estimate sample standard deviation
Definition: Statistics.h:68
FitResults minimize(lsst::afw::math::Function1< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, double errorDef)
Point< int, 2 > Point2I
Definition: Point.h:285
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:43
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
estimate sample mean
Definition: Statistics.h:67
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1107
template<typename ImagePixelT , typename FunctionT >
void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< lsst::afw::math::Function1< FunctionT > > &  overscanFunction,
lsst::afw::image::MaskedImage< ImagePixelT > const &  overscan,
double  ssize = 1.,
int  sigma = 1 
)
template void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< afw::math::Function1< double > > &  overscanFunction,
afw::image::MaskedImage< float > const &  overscan,
double  ssize,
int  sigma 
)
template void lsst::ip::isr::fitOverscanImage ( std::shared_ptr< afw::math::Function1< double > > &  overscanFunction,
afw::image::MaskedImage< double > const &  overscan,
double  ssize,
int  sigma 
)
template<typename PixelT >
size_t lsst::ip::isr::maskNans ( afw::image::MaskedImage< PixelT > const &  mi,
afw::image::MaskPixel  maskVal,
afw::image::MaskPixel  allow = 0 
)

Mask NANs in an image.

NANs in the image or variance that are not already masked by the 'allow' value are masked with the 'maskVal'.

Returns
Number of pixels masked
Parameters
miInput image
maskValBit mask value to give a NaN
allowAllow NANs with this bit mask (0 to disallow all NANs)

Definition at line 34 of file Isr.cc.

36 {
37  typedef typename afw::image::MaskedImage<PixelT>::x_iterator x_iterator;
38  size_t nPix = 0;
39  for (int y = 0; y != mi.getHeight(); ++y) {
40  for (x_iterator ptr = mi.row_begin(y), end = mi.row_end(y); ptr != end; ++ptr) {
41  if (!(ptr.mask() & allow) && (!std::isfinite(ptr.image()) ||
42  !std::isfinite(ptr.variance()))) {
43  nPix += 1;
44  ptr.mask() |= maskVal;
45  }
46  }
47  }
48  return nPix;
49 }
int y
template size_t lsst::ip::isr::maskNans< double > ( afw::image::MaskedImage< double > const &  ,
afw::image::MaskPixel  ,
afw::image::MaskPixel   
)
template size_t lsst::ip::isr::maskNans< float > ( afw::image::MaskedImage< float > const &  ,
afw::image::MaskPixel  ,
afw::image::MaskPixel   
)