| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #ifndef SRC_DISTANCE_EDGE_HPP_ | ||
| 2 | #define SRC_DISTANCE_EDGE_HPP_ | ||
| 3 | |||
| 4 | #include <memory> | ||
| 5 | #include <functional> | ||
| 6 | |||
| 7 | #include "common/style.hpp" | ||
| 8 | #include "common/pipeline/stages.hpp" | ||
| 9 | |||
| 10 | namespace found { | ||
| 11 | |||
| 12 | /** | ||
| 13 | * The EdgeDetection Algorithm class houses the Edge Detection Algorithm. This algorithm uses | ||
| 14 | * a picture of Earth and finds all points on the horizon within the picture. | ||
| 15 | */ | ||
| 16 | class EdgeDetectionAlgorithm : public FunctionStage<Image, Points> {}; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * The SimpleEdgeDetection Algorithm class houses the Edge Detection Algorithm. This algorithm uses | ||
| 20 | * a picture of Earth and finds all points on the horizon within the picture by employing thresholding | ||
| 21 | * to identify "space", and then figure out the contour of "space" that is shared by Earth's edge, returning | ||
| 22 | * that as the result | ||
| 23 | */ | ||
| 24 | class SimpleEdgeDetectionAlgorithm : public EdgeDetectionAlgorithm { | ||
| 25 | public: | ||
| 26 | /** | ||
| 27 | * @brief Constructs a new SimpleEdgeDetectionAlgorithm | ||
| 28 | * | ||
| 29 | * @param threshold The threshold to use for detecting space | ||
| 30 | * @param borderLength The thickness of the image's borders | ||
| 31 | * @param offset The offset to apply to edge points | ||
| 32 | */ | ||
| 33 | 21 | SimpleEdgeDetectionAlgorithm(unsigned char threshold, int borderLength, decimal offset) : | |
| 34 | 21 | threshold_(threshold), borderLength_(borderLength), offset_(offset) {} | |
| 35 | |||
| 36 | /// @brief Destroys the algorithm | ||
| 37 | 60 | virtual ~SimpleEdgeDetectionAlgorithm() {} | |
| 38 | |||
| 39 | /** | ||
| 40 | * Provides an estimate of the edge points of Earth, as | ||
| 41 | * the shared edge between space and Earth. | ||
| 42 | * | ||
| 43 | * @param image The image of Earth | ||
| 44 | * | ||
| 45 | * @return The points on Earth's edge in image | ||
| 46 | * | ||
| 47 | * @post The edge points returned are in polar order, i.e. | ||
| 48 | * if we define the centroid of the points as P, for any | ||
| 49 | * three consecutive points A B and C, angle APB is less than | ||
| 50 | * angle APC | ||
| 51 | */ | ||
| 52 | Points Run(const Image &image) override; | ||
| 53 | |||
| 54 | private: | ||
| 55 | /// The space-ether threshold to use | ||
| 56 | unsigned char threshold_; | ||
| 57 | /// The border length to use | ||
| 58 | int borderLength_; | ||
| 59 | /// The edge offset to use | ||
| 60 | decimal offset_; | ||
| 61 | }; | ||
| 62 | |||
| 63 | /** | ||
| 64 | * The LoGEdgeDetection Algorithm class houses the Edge Detection Algorithm. This algorithm uses | ||
| 65 | * a picture of Earth and finds all points on the horizon within the picture by employing a | ||
| 66 | * Laplacian of Gaussian (LoC) filter to the image. | ||
| 67 | */ | ||
| 68 | class LoCEdgeDetectionAlgorithm : public EdgeDetectionAlgorithm { | ||
| 69 | public: | ||
| 70 | /** | ||
| 71 | * Place documentation here. Press enter to automatically make a new line | ||
| 72 | * */ | ||
| 73 | LoCEdgeDetectionAlgorithm(/*Put more fields here!*/); | ||
| 74 | |||
| 75 | /** | ||
| 76 | * Place documentation here. Press enter to automatically make a new line | ||
| 77 | * */ | ||
| 78 | virtual ~LoCEdgeDetectionAlgorithm(/*Put more fields here!*/); | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Place documentation here. Press enter to automatically make a new line | ||
| 82 | * | ||
| 83 | * @param image The image to process | ||
| 84 | * | ||
| 85 | * @return The edge points in the image most closely resembling that of earth | ||
| 86 | * */ | ||
| 87 | Points Run(const Image &image) override; | ||
| 88 | private: | ||
| 89 | // useful fields specific to this algorithm and helper methods | ||
| 90 | }; | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Computes the groups of components within the image | ||
| 94 | * | ||
| 95 | * @param image The image that defines the possible pixels | ||
| 96 | * @param Criteria A function that accepts a pixel index and the image and returns | ||
| 97 | * true iff the pixel is part of the component | ||
| 98 | * | ||
| 99 | * @return Components The components that are part of the image | ||
| 100 | * | ||
| 101 | * @note This function iterates through each pixel in the image, but treats the image | ||
| 102 | * as 2D, not 3D. You must program Criteria correctly to handle cases where there | ||
| 103 | * are multiple channels (i.e. This algorithm doesn't know how many channels are involved). | ||
| 104 | */ | ||
| 105 | Components ConnectedComponentsAlgorithm(const Image &image, std::function<bool(uint64_t, const Image &)> Criteria); | ||
| 106 | |||
| 107 | } // namespace found | ||
| 108 | |||
| 109 | #endif // SRC_DISTANCE_EDGE_HPP_ | ||
| 110 |