SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
Vignet
VignetSourceTask.cpp
Go to the documentation of this file.
1
25
#include "
SEImplementation/Property/PixelCoordinateList.h
"
26
#include <
SEImplementation/Plugin/MeasurementFrameInfo/MeasurementFrameInfo.h
>
27
#include <
SEImplementation/Plugin/MeasurementFrameCoordinates/MeasurementFrameCoordinates.h
>
28
#include <
SEImplementation/Plugin/MeasurementFrameImages/MeasurementFrameImages.h
>
29
#include "
SEImplementation/Plugin/PixelCentroid/PixelCentroid.h
"
30
#include "
SEImplementation/Plugin/MeasurementFramePixelCentroid/MeasurementFramePixelCentroid.h
"
31
#include "
SEImplementation/Plugin/DetectionFrameCoordinates/DetectionFrameCoordinates.h
"
32
#include "
SEImplementation/Plugin/DetectionFrameImages/DetectionFrameImages.h
"
33
34
#include "
SEImplementation/Plugin/Vignet/Vignet.h
"
35
#include "
SEImplementation/Plugin/Vignet/VignetSourceTask.h
"
36
37
namespace
SourceXtractor
{
38
void
VignetSourceTask::computeProperties
(
SourceInterface
&
source
)
const
{
39
const
auto
&
measurement_frame_info
=
source
.getProperty<
MeasurementFrameInfo
>(
m_instance
);
40
const
auto
&
measurement_frame_images
=
source
.getProperty<
MeasurementFrameImages
>(
m_instance
);
41
42
auto
measurement_var_threshold
=
measurement_frame_info
.getVarianceThreshold();
43
44
const
auto
measurement_sub_image
=
measurement_frame_images
.getLockedImage(
LayerSubtractedImage
);
45
const
auto
measurement_var_image
=
measurement_frame_images
.getLockedImage(
LayerVarianceMap
);
46
47
// neighbor masking from the detection image
48
const
auto
&
detection_frame_images
=
source
.getProperty<
DetectionFrameImages
>();
49
const
auto
&
detection_thresh_image
=
detection_frame_images
.getLockedImage(
LayerThresholdedImage
);
50
51
// get the object pixel coordinates from the detection image
52
const
auto
&
pixel_coords
=
source
.getProperty<
PixelCoordinateList
>();
53
54
// coordinate systems
55
auto
detection_coordinate_system
=
source
.getProperty<
DetectionFrameCoordinates
>().getCoordinateSystem();
56
auto
measurement_coordinate_system
=
source
.getProperty<
MeasurementFrameCoordinates
>(
m_instance
).getCoordinateSystem();
57
58
// get the central pixel coord
59
const
auto
&
centroid
=
source
.getProperty<
MeasurementFramePixelCentroid
>(
m_instance
);
60
const
int
x_pix
=
static_cast<
int
>
(
centroid
.getCentroidX() + 0.5);
61
const
int
y_pix
=
static_cast<
int
>
(
centroid
.getCentroidY() + 0.5);
62
63
// get the sub-image boundaries
64
int
x_start
=
x_pix
-
m_vignet_size
[0] / 2;
65
int
y_start
=
y_pix
-
m_vignet_size
[1] / 2;
66
int
x_end
=
x_start
+
m_vignet_size
[0];
67
int
y_end
=
y_start
+
m_vignet_size
[1];
68
69
// create and fill the vignet vector using the measurement frame
70
std::vector<SeFloat>
vignet_vector
(
m_vignet_size
[0] *
m_vignet_size
[1],
m_vignet_default_pixval
);
71
int
index = 0;
72
for
(
int
iy
=
y_start
;
iy
<
y_end
;
iy
++) {
73
for
(
int
ix
=
x_start
;
ix
<
x_end
;
ix
++, index++) {
74
75
// skip pixels outside of the image
76
if
(
ix
< 0 ||
iy < 0 || ix >
=
measurement_sub_image
->getWidth() ||
iy
>=
measurement_sub_image
->getHeight())
77
continue
;
78
79
// translate pixel coordinates to the detection frame
80
auto
world_coord =
measurement_coordinate_system
->imageToWorld({
static_cast<
double
>
(
ix
),
static_cast<
double
>
(
iy
)});
81
auto
detection_coord
=
detection_coordinate_system
->worldToImage(world_coord);
82
83
// copy the pixel value if it is not masked, and if it does not correspond to a detection pixel
84
// if it corresponds to a detection pixel, use it if it belongs to the source
85
int
detection_x
=
static_cast<
int
>
(
detection_coord
.m_x + 0.5);
86
int
detection_y
=
static_cast<
int
>
(
detection_coord
.m_y + 0.5);
87
88
bool
is_masked
=
measurement_var_image
->getValue(
ix
,
iy
) >
measurement_var_threshold
;
89
bool
is_detection_pixel
=
detection_thresh_image
->getValue(
detection_x
,
detection_y
) > 0;
90
91
if
(!
is_masked
&& (!
is_detection_pixel
||
pixel_coords
.contains({
detection_x
,
detection_y
}))) {
92
vignet_vector
[index] =
measurement_sub_image
->getValue(
ix
,
iy
);
93
}
94
}
95
}
96
97
// set the property
98
source
.setIndexedProperty<
Vignet
>(m_instance,
99
VectorImage<DetectionImage::PixelType>::create
(m_vignet_size[0], m_vignet_size[1],
std::move
(
vignet_vector
)));
100
}
101
}
// namespace SourceXtractor
DetectionFrameCoordinates.h
DetectionFrameImages.h
MeasurementFrameCoordinates.h
MeasurementFrameImages.h
MeasurementFrameInfo.h
MeasurementFramePixelCentroid.h
PixelCentroid.h
PixelCoordinateList.h
VignetSourceTask.h
Vignet.h
SourceXtractor::DetectionFrameCoordinates
Definition
DetectionFrameCoordinates.h:26
SourceXtractor::DetectionFrameImages
Definition
DetectionFrameImages.h:30
SourceXtractor::MeasurementFrameCoordinates
Definition
MeasurementFrameCoordinates.h:26
SourceXtractor::MeasurementFrameImages
Definition
MeasurementFrameImages.h:31
SourceXtractor::MeasurementFrameInfo
Definition
MeasurementFrameInfo.h:28
SourceXtractor::MeasurementFramePixelCentroid
Definition
MeasurementFramePixelCentroid.h:31
SourceXtractor::PixelCoordinateList
Definition
PixelCoordinateList.h:33
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition
VectorImage.h:100
SourceXtractor::VignetSourceTask::computeProperties
virtual void computeProperties(SourceInterface &source) const
Computes one or more properties for the Source.
Definition
VignetSourceTask.cpp:38
SourceXtractor::VignetSourceTask::m_vignet_default_pixval
SeFloat m_vignet_default_pixval
Definition
VignetSourceTask.h:46
SourceXtractor::VignetSourceTask::m_vignet_size
std::array< int, 2 > m_vignet_size
Definition
VignetSourceTask.h:45
SourceXtractor::VignetSourceTask::m_instance
unsigned m_instance
Definition
VignetSourceTask.h:44
SourceXtractor::Vignet
Definition
Vignet.h:33
std::function
std::move
T move(T... args)
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::LayerVarianceMap
@ LayerVarianceMap
Definition
Frame.h:45
SourceXtractor::LayerThresholdedImage
@ LayerThresholdedImage
Definition
Frame.h:41
SourceXtractor::LayerSubtractedImage
@ LayerSubtractedImage
Definition
Frame.h:39
Generated by
1.10.0