SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Aperture
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
24
#include "
SEFramework/Aperture/NeighbourInfo.h
"
25
26
namespace
SourceXtractor
{
27
28
NeighbourInfo::NeighbourInfo
(
const
PixelCoordinate
&
min_pixel
,
const
PixelCoordinate
&
max_pixel
,
29
const
std::vector<SourceXtractor::PixelCoordinate>
& pixel_list,
30
const
std::shared_ptr
<
SourceXtractor::Image<SourceXtractor::SeFloat>
>&
threshold_image
)
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
40
m_neighbour_image
=
VectorImage<int>::create
(width, height);
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
64
bool
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
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition
MoffatModelFittingTask.cpp:94
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition
MoffatModelFittingTask.cpp:94
NeighbourInfo.h
SourceXtractor::NeighbourInfo::m_neighbour_image
std::shared_ptr< VectorImage< int > > m_neighbour_image
Definition
NeighbourInfo.h:46
SourceXtractor::NeighbourInfo::isNeighbourObjectPixel
bool isNeighbourObjectPixel(int x, int y) const
Definition
NeighbourInfo.cpp:64
SourceXtractor::NeighbourInfo::m_offset
PixelCoordinate m_offset
Definition
NeighbourInfo.h:47
SourceXtractor::NeighbourInfo::NeighbourInfo
NeighbourInfo(const PixelCoordinate &min_pixel, const PixelCoordinate &max_pixel, const std::vector< PixelCoordinate > &pixel_list, const std::shared_ptr< Image< SeFloat > > &threshold_image)
Definition
NeighbourInfo.cpp:28
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition
VectorImage.h:100
std::function
SourceXtractor
Definition
Aperture.h:30
std::shared_ptr
SourceXtractor::PixelCoordinate
A pixel coordinate made of two integers m_x and m_y.
Definition
PixelCoordinate.h:37
SourceXtractor::PixelCoordinate::m_y
int m_y
Definition
PixelCoordinate.h:38
SourceXtractor::PixelCoordinate::clip
bool clip(int w, int h)
Definition
PixelCoordinate.h:90
SourceXtractor::PixelCoordinate::m_x
int m_x
Definition
PixelCoordinate.h:38
Generated by
1.10.0