SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
InterpolatedImageSource.h
Go to the documentation of this file.
1
17/*
18 * InterpolatedImageSource.h
19 *
20 * Created on: Jun 21, 2019
21 * Author: Alejandro Alvarez Ayllon
22 */
23
24#ifndef SEFRAMEWORK_SEFRAMEWORK_IMAGE_INTERPOLATEDIMAGESOURCE_H_
25#define SEFRAMEWORK_SEFRAMEWORK_IMAGE_INTERPOLATEDIMAGESOURCE_H_
26
28
29namespace SourceXtractor {
30
34template<typename T>
36public:
43
44 std::string getRepr() const override {
45 return "InterpolatedImageSource(" + getImageRepr() + "," + m_variance_map->getRepr() + ")";
46 }
47
48 ImageTile::ImageType getType() const override {
49 return ImageTile::getTypeValue(T());
50 }
51
52protected:
54
56 int x, int y, int width, int height) const override {
57 // Get the chunks we are interested in, and its surrounding area so we can convolve
59 auto chunk_end_x = x + width;
61 auto chunk_end_y = y + height;
62
63 // Remember to clip to avoid accessing the image out of bounds!
68
69 // Get the chunks for the image and the variance
70 // We rely on the underlying chain to generate them efficiently (i.e. BufferedImage across tiles)
73
74 // Fill the tile interpolating from the chunks
75 int off_x = x - chunk_pixel_x;
76 int off_y = y - chunk_pixel_y;
77 auto& tile_data = *tile.getImage();
78 for (int iy = 0; iy < height; ++iy) {
79 for (int ix = 0; ix < width; ++ix) {
81 }
82 }
83 }
84
85private:
89
90 inline T getInterpolatedValue(const ImageChunk<T>& img, const ImageChunk<T>& var, int x, int y) const {
91 if (var.getValue(x, y) < m_variance_threshold)
92 return img.getValue(x, y);
93
94 for (int i = 1; i <= m_interpolation_gap; i++) {
95 if (x - i >= 0 && var.getValue(x - i, y) < m_variance_threshold) {
96 return img.getValue(x - i, y);
97 }
98 if (y - i >= 0 && var.getValue(x, y - i) < m_variance_threshold) {
99 return img.getValue(x, y - i);
100 }
101 }
102 return img.getValue(x, y);
103 }
104};
105
106} // end namespace SourceXtractor
107
108#endif
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
static ImageType getTypeValue(float)
Definition ImageTile.h:97
T getInterpolatedValue(const ImageChunk< T > &img, const ImageChunk< T > &var, int x, int y) const
std::string getRepr() const override
Human readable representation of this source.
InterpolatedImageSource(std::shared_ptr< Image< T > > image, std::shared_ptr< WeightImage > variance_map, WeightImage::PixelType variance_threshold, int interpolation_gap)
std::shared_ptr< WeightImage > m_variance_map
void generateTile(const std::shared_ptr< Image< T > > &image, ImageTileWithType< T > &tile, int x, int y, int width, int height) const override
ImageTile::ImageType getType() const override
T max(T... args)
T min(T... args)