SourceXtractorPlusPlus  0.15
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  m_offset.clip(threshold_image->getWidth(), threshold_image->getHeight());
33 
34  auto max_pixel_copy = max_pixel;
35  max_pixel_copy.clip(threshold_image->getWidth(), threshold_image->getHeight());
36 
37  auto width = max_pixel_copy.m_x - m_offset.m_x + 1;
38  auto height = max_pixel_copy.m_y - m_offset.m_y + 1;
39 
41 
42  auto threshold_cutout = threshold_image->getChunk(m_offset, max_pixel_copy);
43 
44  for (auto& pixel_coord : pixel_list) {
45  auto act_x = pixel_coord.m_x - m_offset.m_x;
46  auto act_y = pixel_coord.m_y - m_offset.m_y;
47 
48  if (act_x >= 0 && act_y >= 0 && act_x < width && act_y < height) {
49  m_neighbour_image->setValue(act_x, act_y, -1);
50  }
51  }
52 
53  for (int act_y = 0; act_y < height; ++act_y) {
54  for (int act_x = 0; act_x < width; ++act_x) {
55  // set surrounding pixels that do not belong to the image and are above the threshold to 1,
56  // all others to 0
57  bool is_above_threshold = threshold_cutout->getValue(act_x, act_y) > 0;
58  bool belongs = m_neighbour_image->getValue(act_x, act_y) == -1;
59  m_neighbour_image->setValue(act_x, act_y, is_above_threshold && !belongs);
60  }
61  }
62 }
63 
65  int act_x = x - m_offset.m_x;
66  int act_y = y - m_offset.m_y;
67  assert(m_neighbour_image->isInside(act_x, act_y));
68  return m_neighbour_image->getValue(act_x, act_y);
69 }
70 
71 } // end SourceXtractor
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Interface representing an image.
Definition: Image.h:43
NeighbourInfo(const PixelCoordinate &min_pixel, const PixelCoordinate &max_pixel, const std::vector< PixelCoordinate > &pixel_list, const std::shared_ptr< Image< SeFloat >> &threshold_image)
std::shared_ptr< VectorImage< int > > m_neighbour_image
Definition: NeighbourInfo.h:46
bool isNeighbourObjectPixel(int x, int y) const
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:100
A pixel coordinate made of two integers m_x and m_y.