SourceXtractorPlusPlus 0.19
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
ApertureFlagTask.cpp
Go to the documentation of this file.
1
17/*
18 * ApertureFlagTask.cpp
19 *
20 * Created on: Oct 09, 2018
21 * Author: Alejandro Alvarez Ayllon
22 */
23
27
35
38
39namespace SourceXtractor {
40
41
43 // get the detection frame info
44 const auto& detection_frame_info = source.getProperty<DetectionFrameInfo>();
45 const auto variance_threshold = detection_frame_info.getVarianceThreshold();
46
47 // get detection frame images
48 const auto& detection_frame_images = source.getProperty<DetectionFrameImages>();
49
50 const auto detection_image = detection_frame_images.getLockedImage(LayerSubtractedImage);
51 const auto detection_variance = detection_frame_images.getLockedImage(LayerVarianceMap);
52 const auto threshold_image = detection_frame_images.getLockedImage(LayerThresholdedImage);
53
54 // get the object center
55 const auto& centroid_x = source.getProperty<PixelCentroid>().getCentroidX();
56 const auto& centroid_y = source.getProperty<PixelCentroid>().getCentroidY();
57
58 // get the pixel list
59 const auto& pix_list = source.getProperty<PixelCoordinateList>().getCoordinateList();
60
61 std::map<float, Flags> all_flags;
62
63 for (auto aperture_diameter : m_apertures) {
64 auto aperture = std::make_shared<CircularAperture>(aperture_diameter / 2.);
65 auto flag = computeFlags(aperture, centroid_x, centroid_y, pix_list, detection_image,
66 detection_variance, threshold_image, variance_threshold);
67 all_flags.emplace(std::make_pair(aperture_diameter, flag));
68 }
69
70 // set the source properties
71 source.setProperty<ApertureFlag>(all_flags);
72
73 // draw check image for all apertures
74 auto aperture_check_img = CheckImages::getInstance().getDetectionApertureImage(detection_frame_info.getHduIndex());
75 if (aperture_check_img) {
76 for (auto aperture_diameter : m_apertures) {
77 unsigned int src_id = source.getProperty<SourceID>().getId();
78 auto aperture = std::make_shared<CircularAperture>(aperture_diameter / 2.);
79 drawAperture<int>(aperture, centroid_x, centroid_y, aperture_check_img, static_cast<unsigned>(src_id));
80 }
81 }
82}
83
84} // end of namespace SourceXtractor
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
std::vector< SeFloat > m_apertures
Aperture photometry flag.
Definition: ApertureFlag.h:38
static CheckImages & getInstance()
Definition: CheckImages.h:150
std::shared_ptr< WriteableImage< int > > getDetectionApertureImage(size_t index) const
Definition: CheckImages.h:94
std::shared_ptr< ImageAccessor< SeFloat > > getLockedImage(FrameImageLayer layer) const
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values.
Definition: PixelCentroid.h:37
The SourceInterface is an abstract "source" that has properties attached to it.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
T emplace(T... args)
T make_pair(T... args)
Flags computeFlags(const std::shared_ptr< Aperture > &aperture, SeFloat centroid_x, SeFloat centroid_y, const std::vector< PixelCoordinate > &pix_list, const std::shared_ptr< Image< SeFloat > > &detection_img, const std::shared_ptr< Image< SeFloat > > &detection_variance, const std::shared_ptr< Image< SeFloat > > &threshold_image, SeFloat variance_threshold)
Definition: Flagging.cpp:27
@ LayerVarianceMap
Definition: Frame.h:45
@ LayerThresholdedImage
Definition: Frame.h:41
@ LayerSubtractedImage
Definition: Frame.h:39