mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
eigenCube.hpp
Go to the documentation of this file.
1 /** \file eigenCube.hpp
2  * \brief An image cube with an Eigen API
3  *
4  * \author Jared R. Males (jaredmales@gmail.com)
5  *
6  * \ingroup image_processing_files
7  *
8  */
9 
10 #ifndef eigenCube_hpp
11 #define eigenCube_hpp
12 
13 #pragma GCC system_header
14 #include <Eigen/Dense>
15 
16 
17 #include "../math/vectorUtils.hpp"
18 #include "eigenImage.hpp"
19 #include "imageUtils.hpp"
20 
21 namespace mx
22 {
23 namespace improc
24 {
25 
26 /// An image cube with an Eigen-like API
27 /** \ingroup eigen_image_processing
28  */
29 template<typename dataT>
30 class eigenCube
31 {
32 public:
33  typedef bool is_eigenCube;
34  typedef dataT Scalar;
35 
36  typedef typename Eigen::Array<dataT,Eigen::Dynamic,Eigen::Dynamic>::Index Index;
37 
38  typedef Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > imageRef;
39 
40  typedef Eigen::Array<dataT,Eigen::Dynamic,Eigen::Dynamic> imageT;
41 
42 protected:
43 
44  Index _rows;
45  Index _cols;
46  Index _planes;
47 
48  dataT * m_data {nullptr};
49 
50  bool _owner;
51 
52 public:
53 
54  eigenCube();
55 
56  /// C'tor which will allocate space..
57  /**
58  */
59  eigenCube( Index nrows, ///< [in] Number of rows in the cube
60  Index ncols, ///< [in] Number of columns the cube
61  Index nplanes ///< [in] Number of planes in the cube
62  );
63 
64  /// C'tor taking an existing array as an argument.
65  /** The existing array is used as is, as in a map, and ownership is not taken. You are
66  * responsible for memory management, e.g. free-ing this array.
67  */
68  eigenCube( dataT * ndata, ///< [in] Allocated array with a cube of nrows x ncols x nplanes
69  size_t nrows, ///< [in] Number of rows in the cube
70  size_t ncols, ///< [in] Number of columns the cube
71  size_t nplanes ///< [in] Number of planes in the cube
72  );
73 
74  ~eigenCube();
75 
76  void setZero();
77 
78  eigenCube<dataT> & operator=(const eigenCube<dataT> & ec);
79 
80  void shallowCopy(eigenCube<dataT> & src, bool takeOwner = false);
81 
82  /// De-allocate and set all sizes to 0
83  void clear();
84 
85  void resize(int r, int c, int p);
86 
87  void resize(int r, int c);
88 
89  dataT * data();
90 
91  const dataT * data() const;
92 
93  const Index rows() const;
94 
95  const Index cols() const;
96 
97  const Index planes() const;
98 
99  /// Returns a 2D Eigen::Eigen::Map pointed at the entire cube.
100  Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > cube();
101 
102  /// Returns a 2D Eigen::Eigen::Map pointed at the specified image.
103  Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > image(Index n /**< [in] the image number */);
104 
105  /// Returns a 2D Eigen::Eigen::Map pointed at the specified image.
106  const Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > image(Index n /**< [in] the image number */) const;
107 
108  /// Returns an Eigen::Eigen::Map-ed vector of the pixels at the given coordinate
109  Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Unaligned, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> > pixel(Index i, Index j);
110 
111  ///Return an Eigen::Eigen::Map of the cube where each image is a vector
112  Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > asVectors();
113 
114  ///Calculate the covariance matrix of the images in the cube
115  void Covar(Eigen::Matrix<dataT, Eigen::Dynamic, Eigen::Dynamic> & cv);
116 
117  ///Calculate the sum image of the cube
118  /**
119  * \tparam eigenT an Eigen-like type.
120  */
121  template<typename eigenT>
122  void sum( eigenT & mim /**< [out] the resultant sum image. Is resized. */);
123 
124  ///Calculate the mean image of the cube
125  /**
126  * \tparam eigenT an Eigen-like type.
127  */
128  template<typename eigenT>
129  void mean( eigenT & mim /**< [out] the resultant mean image. Is resized. */);
130 
131  ///Calculate the mean image of the cube with a mask.
132  /**
133  * \tparam eigenT an Eigen-like type.
134  * \tparam eigenCubeT an eigenCube type.
135  */
136  template<typename eigenT, typename eigenCubeT>
137  void mean( eigenT & mim, ///< [out] the resultant mean image. Is resized.
138  eigenCubeT & mask, ///< [in] a mask cube. Only pixels with value 1 are included in the mean calculation.
139  double minGoodFract = 0.0 ///< [in] [optional] the minimum fraction of good pixels, if not met then the pixel is NaN-ed.
140  );
141 
142  ///Calculate the weighted mean image of the cube
143  /**
144  * \tparam eigenT an Eigen-like type.
145  */
146  template<typename eigenT>
147  void mean( eigenT & mim, ///< [out] the resultant mean image. Is resized.
148  std::vector<dataT> & weights ///< [in] a vector of weights to use for calculating the mean
149  );
150 
151  ///Calculate the weighted mean image of the cube, with a mask cube.
152  /**
153  * \tparam eigenT an Eigen-like type.
154  * \tparam eigenCubeT an eigenCube type.
155  */
156  template<typename eigenT, typename eigenCubeT>
157  void mean( eigenT & mim, ///< [out] the resultant mean image. Is resized.
158  std::vector<dataT> & weights, ///< [in] a vector of weights to use for calculating the mean
159  eigenCubeT & mask, ///< [in] a mask cube. Only pixels with value 1 are included in the mean calculation.
160  double minGoodFract = 0.0 ///< [in] [optional] the minimum fraction of good pixels, if not met then the pixel is NaN-ed.
161  );
162 
163  ///Calculate the median image of the cube
164  /**
165  * \tparam eigenT an Eigen-like type.
166  */
167  template<typename eigenT>
168  void median( eigenT & mim /**< [out] the resultant median image. Is resized. */);
169 
170  ///Calculate the sigma clipped mean image of the cube
171  /**
172  * \tparam eigenT an Eigen-like type.
173  */
174  template<typename eigenT>
175  void sigmaMean( eigenT & mim, ///< [out] the resultant mean image
176  Scalar sigma ///< [in] the sigma value at which to clip.
177  );
178 
179  ///Calculate the sigma clipped mean image of the cube, with a mask cube
180  /**
181  * \tparam eigenT an Eigen-like type.
182  * \tparam eigenCubeT an eigenCube type.
183  */
184  template<typename eigenT, typename eigenCubeT>
185  void sigmaMean( eigenT & mim, ///< [out] the resultant mean image. Is resized.
186  eigenCubeT & mask, ///< [in] a mask cube. Only pixels with value 1 are included in the mean calculation.
187  Scalar sigma, ///< [in] the sigma value at which to clip.
188  double minGoodFract = 0.0 ///< [in] [optional] the minimum fraction of good pixels, if not met then the pixel is NaN-ed.
189  );
190 
191  ///Calculate the sigma clipped weighted mean image of the cube
192  /**
193  * \tparam eigenT an Eigen-like type.
194  */
195  template<typename eigenT>
196  void sigmaMean( eigenT & mim, ///< [out] the resultant mean image. Is resized.
197  std::vector<dataT> & weights, ///< [in] a vector of weights to use for calculating the mean
198  Scalar sigma ///< [in] the sigma value at which to clip.
199  );
200 
201  ///Calculate the sigma clipped weighted mean image of the cube, with a mask cube.
202  /**
203  * \tparam eigenT an Eigen-like type.
204  * \tparam eigenCubeT an eigenCube type.
205  */
206  template<typename eigenT, typename eigenCubeT>
207  void sigmaMean( eigenT & mim, ///< [out] the resultant mean image. Is resized.
208  std::vector<dataT> & weights, ///< [in] a vector of weights to use for calculating the mean
209  eigenCubeT & mask, ///< [in] a mask cube. Only pixels with value 1 are included in the mean calculation.
210  Scalar sigma, ///< [in] the sigma value at which to clip.
211  double minGoodFract = 0.0 ///< [in] [optional] the minimum fraction of good pixels, if not met then the pixel is NaN-ed.
212  );
213 
214 
215 };
216 
217 
218 template<typename dataT>
220 {
221  _rows = 0;
222  _cols = 0;
223  _planes = 0;
224  _owner = false;
225 }
226 
227 template<typename dataT>
228 eigenCube<dataT>::eigenCube(Index nrows, Index ncols, Index nplanes)
229 {
230  _rows = nrows;
231  _cols = ncols;
232  _planes = nplanes;
233 
234  m_data = new dataT[_rows*_cols*_planes];
235  _owner = true;
236 }
237 
238 template<typename dataT>
239 eigenCube<dataT>::eigenCube(dataT * ndata, size_t nrows, size_t ncols, size_t nplanes)
240 {
241  _rows = nrows;
242  _cols = ncols;
243  _planes = nplanes;
244 
245  m_data = ndata;
246  _owner = false;
247 }
248 
249 template<typename dataT>
251 {
252  if(_owner && m_data)
253  {
254  delete[] m_data;
255  }
256 }
257 
258 template<typename dataT>
259 void eigenCube<dataT>::setZero()
260 {
261  int N = _rows*_cols*_planes;
262 
263  for(int i=0;i<N;++i) m_data[i] = ((dataT) 0);
264 }
265 
266 template<typename dataT>
267 eigenCube<dataT> & eigenCube<dataT>::operator=(const eigenCube<dataT> & ec)
268 {
269  resize(ec.rows(), ec.cols(), ec.planes());
270 
271  int N = _rows*_cols*_planes;
272 
273  for(int i=0;i<N;++i) m_data[i] = ec.m_data[i];
274 
275  return *this;
276 }
277 
278 template<typename dataT>
279 void eigenCube<dataT>::shallowCopy(eigenCube<dataT> & src, bool takeOwner)
280 {
281  if(_owner && m_data)
282  {
283  delete m_data;
284  _owner = false;
285  }
286 
287  _rows = src._rows;
288  _cols = src._cols;
289  _planes = src._planes;
290  m_data = src.m_data;
291 
292  if(takeOwner == true)
293  {
294  _owner = true;
295  src._owner = false;
296  }
297  else
298  {
299  _owner = false;
300  }
301 }
302 
303 template<typename dataT>
305 {
306  if(_owner && m_data)
307  {
308  delete[] m_data;
309  }
310 
311  _rows = 0;
312  _cols = 0;
313  _planes = 0;
314 }
315 
316 template<typename dataT>
317 void eigenCube<dataT>::resize(int r, int c, int p)
318 {
319  if(_owner && m_data)
320  {
321  delete[] m_data;
322  }
323 
324  _rows = r;
325  _cols = c;
326  _planes = p;
327 
328  m_data = new dataT[_rows*_cols*_planes];
329  _owner = true;
330 
331 }
332 
333 template<typename dataT>
334 void eigenCube<dataT>::resize(int r, int c)
335 {
336  resize(r, c, 1);
337 }
338 
339 template<typename dataT>
340 dataT * eigenCube<dataT>::data()
341 {
342  return m_data;
343 }
344 
345 template<typename dataT>
346 const dataT * eigenCube<dataT>::data() const
347 {
348  return m_data;
349 }
350 
351 template<typename dataT>
352 const typename eigenCube<dataT>::Index eigenCube<dataT>::rows() const
353 {
354  return _rows;
355 }
356 
357 template<typename dataT>
358 const typename eigenCube<dataT>::Index eigenCube<dataT>::cols() const
359 {
360  return _cols;
361 }
362 
363 template<typename dataT>
364 const typename eigenCube<dataT>::Index eigenCube<dataT>::planes() const
365 {
366  return _planes;
367 }
368 
369 template<typename dataT>
370 Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > eigenCube<dataT>::cube()
371 {
372  return Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> >(m_data, _rows*_cols, _planes);
373 }
374 
375 template<typename dataT>
376 Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > eigenCube<dataT>::image(Index n)
377 {
378  return Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> >(m_data + n*_rows*_cols, _rows, _cols);
379 }
380 
381 template<typename dataT>
382 const Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > eigenCube<dataT>::image(Index n) const
383 {
384  return Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> >(m_data + n*_rows*_cols, _rows, _cols);
385 }
386 
387 template<typename dataT>
388 Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Unaligned, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> > eigenCube<dataT>::pixel(Index i, Index j)
389 {
390  return Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Unaligned, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> >(m_data + j*_rows + i, _planes, 1, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>(0,_rows*_cols));
391 }
392 
393 template<typename dataT>
394 Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> > eigenCube<dataT>::asVectors()
395 {
396  return Eigen::Map<Eigen::Array<dataT, Eigen::Dynamic, Eigen::Dynamic> >(m_data, _rows*_cols, _planes);
397 }
398 
399 template<typename dataT>
400 void eigenCube<dataT>::Covar(Eigen::Matrix<dataT, Eigen::Dynamic, Eigen::Dynamic> & cv)
401 {
402  cv = asVectors().matrix().transpose()*asVectors().matrix();
403 }
404 
405 template<typename dataT>
406 template<typename eigenT>
407 void eigenCube<dataT>::sum(eigenT & mim)
408 {
409  mim.resize(_rows, _cols);
410 
411  #pragma omp parallel for schedule(static, 1) num_threads(Eigen::nbThreads())
412  for(Index i=0; i < _rows; ++i)
413  {
414  for(Index j=0;j< _cols; ++j)
415  {
416  mim(i,j) = pixel(i,j).sum();
417  }
418  }
419 }
420 
421 template<typename dataT>
422 template<typename eigenT>
423 void eigenCube<dataT>::mean(eigenT & mim)
424 {
425  mim.resize(_rows, _cols);
426 
427  #pragma omp parallel for schedule(static, 1) num_threads(Eigen::nbThreads())
428  for(Index i=0; i < _rows; ++i)
429  {
430  for(Index j=0;j< _cols; ++j)
431  {
432  mim(i,j) = pixel(i,j).mean();
433  }
434  }
435 }
436 
437 template<typename dataT>
438 template<typename eigenT, typename eigenCubeT>
439 void eigenCube<dataT>::mean( eigenT & mim,
440  eigenCubeT & mask,
441  double minGoodFract
442  )
443 {
444  mim.resize(_rows, _cols);
445 
446  #pragma omp parallel num_threads(Eigen::nbThreads())
447  {
448  std::vector<dataT> work;
449 
450  #pragma omp for schedule(static, 1)
451  for(Index i=0; i < _rows; ++i)
452  {
453  for(Index j=0;j< _cols; ++j)
454  {
455 
456  work.clear();
457 
458  for(Index k=0; k<_planes; ++k)
459  {
460 
461  if( (mask.pixel(i,j))(k,0) == 1)
462  {
463  work.push_back( (pixel(i,j))(k,0) );
464  }
465  }
466  if(work.size() > minGoodFract*_planes)
467  {
468  mim(i,j) = math::vectorMean(work);
469  }
470  else mim(i,j) = std::numeric_limits<dataT>::quiet_NaN();
471 
472  }
473  }
474  }
475 }
476 
477 template<typename dataT>
478 template<typename eigenT>
479 void eigenCube<dataT>::mean( eigenT & mim,
480  std::vector<dataT> & weights
481  )
482 {
483  mim.resize(_rows, _cols);
484 
485  #pragma omp parallel num_threads(Eigen::nbThreads())
486  {
487  std::vector<Scalar> work;
488 
489  #pragma omp for schedule(static, 10)
490  for(Index i=0; i < _rows; ++i)
491  {
492  for(Index j=0;j< _cols; ++j)
493  {
494  work.resize(_planes);//work could be smaller after sigmaMean
495  //int ii=0;
496  for(int k =0; k< _planes; ++k) work[k] = (pixel(i,j))(k,0);
497 
498  mim(i,j) = math::vectorMean(work, weights);
499  }
500  }
501  }
502 }
503 
504 template<typename dataT>
505 template<typename eigenT, typename eigenCubeT>
506 void eigenCube<dataT>::mean( eigenT & mim,
507  std::vector<dataT> & weights,
508  eigenCubeT & mask,
509  double minGoodFract
510  )
511 {
512  mim.resize(_rows, _cols);
513 
514  #pragma omp parallel num_threads(Eigen::nbThreads())
515  {
516  std::vector<Scalar> work, wwork;
517 
518  #pragma omp for schedule(static, 10)
519  for(Index i=0; i < _rows; ++i)
520  {
521  for(Index j=0;j< _cols; ++j)
522  {
523  work.clear();
524  wwork.clear();
525 
526  //int ii=0;
527 
528  for(Index k =0; k< _planes; ++k)
529  {
530  if( (mask.pixel(i,j))(k,0) == 1)
531  {
532  work.push_back( (pixel(i,j))(k,0) );
533  wwork.push_back( weights[k] );
534  }
535  }
536  if(work.size() > minGoodFract*_planes)
537  {
538  mim(i,j) = math::vectorMean(work, wwork);
539  }
540  else mim(i,j) = std::numeric_limits<dataT>::quiet_NaN();
541  }
542  }
543  }
544 }
545 
546 template<typename dataT>
547 template<typename eigenT>
548 void eigenCube<dataT>::median(eigenT & mim)
549 {
550  mim.resize(_rows, _cols);
551 
552  #pragma omp parallel for schedule(static, 10) num_threads(Eigen::nbThreads())
553  for(Index i=0; i < _rows; ++i)
554  {
555  //Eigen::Eigen::Array<Scalar, Eigen::Eigen::Dynamic, Eigen::Eigen::Dynamic> work;
556  std::vector<Scalar> work;
557  for(Index j=0;j< _cols; ++j)
558  {
559  mim(i,j) = imageMedian(pixel(i,j), &work);
560  }
561  }
562 }
563 
564 template<typename dataT>
565 template<typename eigenT>
566 void eigenCube<dataT>::sigmaMean(eigenT & mim, dataT sigma)
567 {
568  mim.resize(_rows, _cols);
569 
570  #pragma omp parallel num_threads(Eigen::nbThreads())
571  {
572  std::vector<Scalar> work;
573 
574  #pragma omp for schedule(static, 10)
575  for(Index i=0; i < _rows; ++i)
576  {
577  for(Index j=0;j< _cols; ++j)
578  {
579  work.resize(_planes);//work could be smaller after sigmaMean
580  for(int k =0; k< _planes; ++k) work[k] = (pixel(i,j))(k,0);
581 
582  mim(i,j) = math::vectorSigmaMean(work, sigma);
583  }
584  }
585 
586 
587  }
588 }
589 
590 template<typename dataT>
591 template<typename eigenT, typename eigenCubeT>
592 void eigenCube<dataT>::sigmaMean( eigenT & mim,
593  eigenCubeT & mask,
594  dataT sigma,
595  double minGoodFract
596  )
597 {
598  mim.resize(_rows, _cols);
599 
600  #pragma omp parallel num_threads(Eigen::nbThreads())
601  {
602  std::vector<Scalar> work;
603 
604  #pragma omp for schedule(static, 10)
605  for(Index i=0; i < _rows; ++i)
606  {
607  for(Index j=0;j< _cols; ++j)
608  {
609  work.clear();
610  int ii=0;
611 
612  for(Index k =0; k< _planes; ++k)
613  {
614  if( (mask.pixel(i,j))(k,0) == 1)
615  {
616  work.push_back( (pixel(i,j))(k,0) );
617  }
618  }
619  if(work.size() > minGoodFract*_planes)
620  {
621  mim(i,j) = math::vectorSigmaMean(work, sigma);
622  }
623  else mim(i,j) = std::numeric_limits<dataT>::quiet_NaN();
624 
625  }
626  }
627 
628 
629  }
630 }
631 
632 template<typename dataT>
633 template<typename eigenT>
634 void eigenCube<dataT>::sigmaMean(eigenT & mim, std::vector<dataT> & weights, dataT sigma)
635 {
636  mim.resize(_rows, _cols);
637 
638  #pragma omp parallel num_threads(Eigen::nbThreads())
639  {
640  std::vector<Scalar> work;
641 
642  #pragma omp for schedule(static, 10)
643  for(Index i=0; i < _rows; ++i)
644  {
645  for(Index j=0;j< _cols; ++j)
646  {
647  work.resize(_planes);//work could be smaller after sigmaMean
648  int ii=0;
649  for(int k =0; k< _planes; ++k) work[k] = (pixel(i,j))(k,0);
650 
651  mim(i,j) = math::vectorSigmaMean(work, weights, sigma);
652  }
653  }
654 
655 
656  }
657 }
658 
659 template<typename dataT>
660 template<typename eigenT, typename eigenCubeT>
661 void eigenCube<dataT>::sigmaMean( eigenT & mim,
662  std::vector<dataT> & weights,
663  eigenCubeT & mask,
664  dataT sigma,
665  double minGoodFract
666  )
667 {
668  mim.resize(_rows, _cols);
669 
670  #pragma omp parallel num_threads(Eigen::nbThreads())
671  {
672  std::vector<Scalar> work, wwork;
673 
674  #pragma omp for schedule(static, 10)
675  for(Index i=0; i < _rows; ++i)
676  {
677  for(Index j=0;j< _cols; ++j)
678  {
679  work.clear();
680  wwork.clear();
681 
682  int ii=0;
683 
684  for(Index k =0; k< _planes; ++k)
685  {
686  if( (mask.pixel(i,j))(k,0) == 1)
687  {
688  work.push_back( (pixel(i,j))(k,0) );
689  wwork.push_back( weights[k] );
690  }
691  }
692  if(work.size() > minGoodFract*_planes)
693  {
694  mim(i,j) = math::vectorSigmaMean(work, wwork, sigma);
695  }
696  else mim(i,j) = std::numeric_limits<dataT>::quiet_NaN();
697  }
698  }
699  }
700 }
701 
702 } //namespace improc
703 
704 } //namespace mx
705 
706 #endif //eigenCube_hpp
An image cube with an Eigen-like API.
Definition: eigenCube.hpp:31
void sigmaMean(eigenT &mim, std::vector< dataT > &weights, eigenCubeT &mask, Scalar sigma, double minGoodFract=0.0)
Calculate the sigma clipped weighted mean image of the cube, with a mask cube.
Definition: eigenCube.hpp:661
void Covar(Eigen::Matrix< dataT, Eigen::Dynamic, Eigen::Dynamic > &cv)
Calculate the covariance matrix of the images in the cube.
Definition: eigenCube.hpp:400
void sigmaMean(eigenT &mim, Scalar sigma)
Calculate the sigma clipped mean image of the cube.
Definition: eigenCube.hpp:566
void mean(eigenT &mim, std::vector< dataT > &weights, eigenCubeT &mask, double minGoodFract=0.0)
Calculate the weighted mean image of the cube, with a mask cube.
Definition: eigenCube.hpp:506
void clear()
De-allocate and set all sizes to 0.
Definition: eigenCube.hpp:304
const Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image(Index n) const
Returns a 2D Eigen::Eigen::Map pointed at the specified image.
Definition: eigenCube.hpp:382
void sum(eigenT &mim)
Calculate the sum image of the cube.
Definition: eigenCube.hpp:407
void sigmaMean(eigenT &mim, std::vector< dataT > &weights, Scalar sigma)
Calculate the sigma clipped weighted mean image of the cube.
Definition: eigenCube.hpp:634
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic >, Eigen::Unaligned, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > pixel(Index i, Index j)
Returns an Eigen::Eigen::Map-ed vector of the pixels at the given coordinate.
Definition: eigenCube.hpp:388
void median(eigenT &mim)
Calculate the median image of the cube.
Definition: eigenCube.hpp:548
void mean(eigenT &mim, std::vector< dataT > &weights)
Calculate the weighted mean image of the cube.
Definition: eigenCube.hpp:479
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > cube()
Returns a 2D Eigen::Eigen::Map pointed at the entire cube.
Definition: eigenCube.hpp:370
void mean(eigenT &mim, eigenCubeT &mask, double minGoodFract=0.0)
Calculate the mean image of the cube with a mask.
Definition: eigenCube.hpp:439
void mean(eigenT &mim)
Calculate the mean image of the cube.
Definition: eigenCube.hpp:423
eigenCube(dataT *ndata, size_t nrows, size_t ncols, size_t nplanes)
C'tor taking an existing array as an argument.
Definition: eigenCube.hpp:239
void sigmaMean(eigenT &mim, eigenCubeT &mask, Scalar sigma, double minGoodFract=0.0)
Calculate the sigma clipped mean image of the cube, with a mask cube.
Definition: eigenCube.hpp:592
eigenCube(Index nrows, Index ncols, Index nplanes)
C'tor which will allocate space..
Definition: eigenCube.hpp:228
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > asVectors()
Return an Eigen::Eigen::Map of the cube where each image is a vector.
Definition: eigenCube.hpp:394
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image(Index n)
Returns a 2D Eigen::Eigen::Map pointed at the specified image.
Definition: eigenCube.hpp:376
Tools for using the eigen library for image processing.
constexpr units::realT c()
The speed of light.
Definition: constants.hpp:60
constexpr units::realT sigma()
Stefan-Boltzmann Constant.
Definition: constants.hpp:82
constexpr units::realT k()
Boltzmann Constant.
Definition: constants.hpp:71
@ imageMedian
The median of each image (within the search region) is subtracted from itself.
vectorT::value_type vectorSigmaMean(const vectorT &vec, const vectorT *weights, typename vectorT::value_type sigma, int &maxPasses)
Calculate the sigma-clipped mean of a vector.
valueT vectorMean(const valueT *vec, size_t sz)
Calculate the mean of a vector.
Header for the image processing utilities.
The mxlib c++ namespace.
Definition: mxError.hpp:107