SourceXtractorPlusPlus  0.12
Please provide a description of the project.
NeighbourInfo.cpp
Go to the documentation of this file.
1 
17 /*
18  * NeighbourInfo.cpp
19  *
20  * Created on: Oct 12, 2018
21  * Author: Alejandro Alvarez
22  */
23 
25 
26 namespace SourceXtractor {
27 
31  : m_offset{min_pixel} {
32  auto width = max_pixel.m_x - min_pixel.m_x + 1;
33  auto height = max_pixel.m_y - min_pixel.m_y + 1;
34  m_neighbour_image = VectorImage<int>::create(width, height);
35 
36  for (auto& pixel_coord : pixel_list) {
37  auto act_x = pixel_coord.m_x - m_offset.m_x;
38  auto act_y = pixel_coord.m_y - m_offset.m_y;
39 
40  if (act_x >= 0 && act_y >= 0 && act_x < width && act_y < height) {
41  m_neighbour_image->setValue(act_x, act_y, -1);
42  }
43  }
44 
45  for (int act_y = 0; act_y < height; ++act_y) {
46  for (int act_x = 0; act_x < width; ++act_x) {
47  int offset_x = act_x + m_offset.m_x;
48  int offset_y = act_y + m_offset.m_y;
49 
50  // set surrounding pixels that do not belong to the image and are above the threshold to 1, all others to 0
51  if (threshold_image->isInside(offset_x, offset_y)) {
52  bool is_above_threshold = threshold_image->getValue(offset_x, offset_y) > 0;
53  bool belongs = m_neighbour_image->getValue(act_x, act_y) == -1;
54  m_neighbour_image->setValue(act_x, act_y, is_above_threshold && !belongs);
55  }
56  }
57  }
58 }
59 
61  int act_x = x - m_offset.m_x;
62  int act_y = y - m_offset.m_y;
63  assert(act_x >= 0 && act_y >= 0 && act_x < m_neighbour_image->getWidth() &&
64  act_y < m_neighbour_image->getHeight());
65  return m_neighbour_image->getValue(act_x, act_y);
66 }
67 
68 } // end SourceXtractor
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< VectorImage< int > > m_neighbour_image
Definition: NeighbourInfo.h:46
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
NeighbourInfo(const PixelCoordinate &min_pixel, const PixelCoordinate &max_pixel, const std::vector< PixelCoordinate > &pixel_list, const std::shared_ptr< Image< SeFloat >> &threshold_image)
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:89
A pixel coordinate made of two integers m_x and m_y.
bool isNeighbourObjectPixel(int x, int y) const
Interface representing an image.
Definition: Image.h:43