SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
KronRadiusTask.cpp
Go to the documentation of this file.
1
17/*
18 * KronRadiusTask.cpp
19 *
20 * Created on: Sep 12, 2016
21 * Author: mkuemmel@usm.lmu.de
22 */
23
24#include <math.h>
25
28
36
39
40namespace SourceXtractor {
41
42namespace {
43 // the typical radius for determining the Kron-radius
44 const SeFloat KRON_NRADIUS = 3*2.0;
45 const SeFloat CROWD_THRESHOLD_KRON = 0.1;
46 const SeFloat BADAREA_THRESHOLD_KRON = 0.1;
47}
48
50
52 // get the detection frame info
53 const auto& detection_frame_info = source.getProperty<DetectionFrameInfo>();
54 const auto variance_threshold = detection_frame_info.getVarianceThreshold();
55
56 // get detection frame images
57 const auto& detection_frame_images = source.getProperty<DetectionFrameImages>();
58
62
63
64 // get the object center
65 const auto& centroid_x = source.getProperty<PixelCentroid>().getCentroidX();
66 const auto& centroid_y = source.getProperty<PixelCentroid>().getCentroidY();
67
68 // get the shape parameters
69 const auto& cxx = source.getProperty<ShapeParameters>().getEllipseCxx();
70 const auto& cyy = source.getProperty<ShapeParameters>().getEllipseCyy();
71 const auto& cxy = source.getProperty<ShapeParameters>().getEllipseCxy();
72
73 // create the elliptical aperture
75
76 // get the aperture borders on the image
77 const auto& min_pixel = ell_aper->getMinPixel(centroid_x, centroid_y);
78 const auto& max_pixel = ell_aper->getMaxPixel(centroid_x, centroid_y);
79
80 // get the pixel list
81 const auto& pix_list = source.getProperty<PixelCoordinateList>().getCoordinateList();
82
83 // get the neighbourhood information
85
87 SeFloat flux_sum = 0.;
88 SeFloat area_sum = 0;
89 SeFloat area_bad = 0;
91 long int flag = 0;
92
93 // iterate over the aperture pixels
94 for (int pixel_y = min_pixel.m_y; pixel_y <= max_pixel.m_y; pixel_y++) {
95 for (int pixel_x = min_pixel.m_x; pixel_x <= max_pixel.m_x; pixel_x++) {
96
97 // check whether the current pixel is inside
99 if (area <= 0) {
100 continue;
101 }
102
103 // make sure the pixel is inside the image
104 if (detection_image->isInside(pixel_x, pixel_y)) {
105 SeFloat value = 0;
106
107 // enhance the area
108 area_sum += 1;
109
110 // get the variance value
112
113 // check whether the pixel is good
115 value = detection_image->getValue(pixel_x, pixel_y) * is_good;
116 area_bad += !is_good;
117
118 // check whether the pixel is part of another object
119 if (neighbour_info.isNeighbourObjectPixel(pixel_x, pixel_y)) {
120 area_full += 1;
121 }
122 else {
123 // add the pixel quantity
124 radius_flux_sum += value * sqrt(ell_aper->getRadiusSquared(centroid_x, centroid_y, pixel_x, pixel_y));
125 flux_sum += value;
126 }
127 }
128 else {
129 // set the border flag
130 flag |= 0x0008;
131 }
132 }
133 }
134
135 // check/set the bad area flag
137 flag |= 0x0001 * bad_threshold;
138
139 // check/set the crowded area flag
141 flag |= crowded;
142
143 // set the property
144 source.setProperty<KronRadius>(flux_sum > 0 ? radius_flux_sum / flux_sum : 0, flag);
145}
146}
147
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values.
The SourceInterface is an abstract "source" that has properties attached to it.
@ LayerVarianceMap
Definition Frame.h:45
@ LayerThresholdedImage
Definition Frame.h:41
@ LayerSubtractedImage
Definition Frame.h:39
SeFloat32 SeFloat
Definition Types.h:32
T sqrt(T... args)