SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
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
26namespace 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
64bool NeighbourInfo::isNeighbourObjectPixel(int x, int y) const {
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
Interface representing an image.
Definition Image.h:44
std::shared_ptr< VectorImage< int > > m_neighbour_image
bool isNeighbourObjectPixel(int x, int y) const
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)
A pixel coordinate made of two integers m_x and m_y.