SourceXtractorPlusPlus  0.14
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VignetArray.h
Go to the documentation of this file.
1 
18 #ifndef _SEIMPLEMENTATION_PLUGIN_VIGNETARRAY_H_
19 #define _SEIMPLEMENTATION_PLUGIN_VIGNETARRAY_H_
20 
21 #include <NdArray/NdArray.h>
26 
27 namespace SourceXtractor {
28 
29 class VignetArray: public Property {
30 public:
32  const auto& representative = vignets.front().get().getVignet();
33 
34  if (vignets.size() > 1) {
35  initMultiple(vignets, representative);
36  }
37  else {
38  initSingle(representative);
39  }
40  }
41 
43  return *m_vignets;
44  }
45 
46 private:
48  std::vector<size_t> shape{
49  static_cast<size_t>(representative.getWidth()), static_cast<size_t>(representative.getHeight())
50  };
51  m_vignets = Euclid::make_unique<Euclid::NdArray::NdArray<DetectionImage::PixelType>>(shape);
52 
53  for (int x = 0; x < representative.getWidth(); ++x) {
54  for (int y = 0; y < representative.getHeight(); ++y) {
55  m_vignets->at(x, y) = representative.getValue(x, y);
56  }
57  }
58  }
59 
61  const VectorImage <DetectionImage::PixelType>& representative) {
62  std::vector<size_t> shape{
63  vignets.size(), static_cast<size_t>(representative.getWidth()), static_cast<size_t>(representative.getHeight())
64  };
65  m_vignets = Euclid::make_unique<Euclid::NdArray::NdArray<DetectionImage::PixelType>>(shape);
66 
67  for (size_t v = 0; v < vignets.size(); ++v) {
68  const auto& img = vignets[v].get().getVignet();
69  assert (img.getWidth() == representative.getWidth());
70  assert (img.getHeight() == representative.getHeight());
71  for (int x = 0; x < img.getWidth(); ++x) {
72  for (int y = 0; y < img.getHeight(); ++y) {
73  m_vignets->at(v, x, y) = img.getValue(x, y);
74  }
75  }
76  }
77  }
78 
80 };
81 
82 } // end of namespace SourceXtractor
83 
84 #endif /* _SEIMPLEMENTATION_PLUGIN_VIGNETARRAY_H_ */
int getHeight() const final
Returns the height of the image in pixels.
Definition: VectorImage.h:97
const Euclid::NdArray::NdArray< DetectionImage::PixelType > & getVignets() const
Definition: VignetArray.h:42
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Base class for all Properties. (has no actual content)
Definition: Property.h:33
Image implementation which keeps the pixel values in memory.
Definition: VectorImage.h:53
VignetArray(const std::vector< std::reference_wrapper< const Vignet >> &vignets)
Definition: VignetArray.h:31
int getWidth() const final
Returns the width of the image in pixels.
Definition: VectorImage.h:101
T size(T...args)
STL class.
STL class.
void initMultiple(const std::vector< std::reference_wrapper< const Vignet >> &vignets, const VectorImage< DetectionImage::PixelType > &representative)
Definition: VignetArray.h:60
std::unique_ptr< Euclid::NdArray::NdArray< DetectionImage::PixelType > > m_vignets
Definition: VignetArray.h:79
void initSingle(const VectorImage< DetectionImage::PixelType > &representative)
Definition: VignetArray.h:47
T getValue(int x, int y) const final
Returns the value of the pixel with the coordinates (x,y)
Definition: VectorImage.h:106