24#ifndef _SEIMPLEMENTATION_IMAGE_WRITEABLEIMAGEINTERFACETRAITS_H_
25#define _SEIMPLEMENTATION_IMAGE_WRITEABLEIMAGEINTERFACETRAITS_H_
127 return image->getWidth();
131 return image->getHeight();
152 double scale_factor,
double x,
double y);
161 double x_shift,
double y_shift) {
162 int window_width =
width(window);
163 int window_height =
height(window);
164 for (
int x_win = 0; x_win < window_width; x_win++) {
165 for (
int y_win = 0; y_win < window_height; y_win++) {
166 double x = (x_win - 0.5 - x_shift) / scale_factor;
167 double y = (y_win - 0.5 - y_shift) / scale_factor;
172 double x_delta = x - xi;
173 double y_delta = y - yi;
178 double v11 =
getClamped(source, xi + 1, yi + 1);
180 window->setValue(x_win, y_win, (1.0 - y_delta) * ((1.0 - x_delta) * v00 + x_delta * v10) +
181 y_delta * ((1.0 - x_delta) * v01 + x_delta * v11));
189 double x_shift,
double y_shift) {
191 int window_width =
width(window);
192 int window_height =
height(window);
193 for (
int x_win = 0; x_win < window_width; x_win++) {
194 for (
int y_win = 0; y_win < window_height; y_win++) {
195 float x = (x_win - x_shift) / scale_factor;
196 float y = (y_win - y_shift) / scale_factor;
208 if (source->isInside(src_x, src_y)) {
214 window->setValue(x_win, y_win,
228 double scale_factor,
double x,
double y) {
230 double scaled_width =
width(image2) * scale_factor;
231 double scaled_height =
height(image2) * scale_factor;
233 int x_min =
std::floor(x - scaled_width / 2.);
234 int x_max =
std::ceil(x + scaled_width / 2.);
235 int window_width = x_max - x_min;
236 int y_min =
std::floor(y - scaled_height / 2.);
237 int y_max =
std::ceil(y + scaled_height / 2.);
238 int window_height = y_max - y_min;
240 double x_shift = x - scaled_width / 2. - x_min;
241 double y_shift = y - scaled_height / 2. - y_min;
243 auto window =
factory(window_width, window_height);
250 double corr_factor = 1. / (scale_factor * scale_factor);
252 for (
int x_im =
std::max(x_min, 0); x_im < std::min<int>(x_max,
width(image1)); ++x_im) {
253 for (
int y_im =
std::max(y_min, 0); y_im < std::min<int>(y_max,
height(image1)); ++y_im) {
254 int x_win = x_im - x_min;
255 int y_win = y_im - y_min;
256 at(image1, x_im, y_im) += corr_factor *
at(window, x_win, y_win);
#define INTERP_MAXKERNELWIDTH
WriteableInterfaceTypePtr m_image
WriteableSetter & operator*()
bool operator!=(const WriteableIterator &b) const
WriteableIterator & operator++()
WriteableIterator(WriteableInterfaceTypePtr image)
SourceXtractor::ImageAccessor< WriteableInterfaceType::PixelType > m_accessor
WriteableIterator(WriteableInterfaceTypePtr image, int)
SourceXtractor::ImageAccessor< WriteableInterfaceType::PixelType > m_accessor
WriteableInterfaceType::PixelType operator+=(WriteableInterfaceType::PixelType v)
friend class WriteableIterator
WriteableInterfaceTypePtr m_image
WriteableSetter(WriteableInterfaceTypePtr &image, int x, int y)
WriteableInterfaceType::PixelType operator=(WriteableInterfaceType::PixelType v)
std::shared_ptr< WriteableInterfaceType > WriteableInterfaceTypePtr
SourceXtractor::WriteableImage< SourceXtractor::SeFloat > WriteableInterfaceType
WriteableIterator iterator
static WriteableSetter at(WriteableInterfaceTypePtr &image, std::size_t x, std::size_t y)
static double getClamped(const WriteableInterfaceTypePtr &image, int x, int y)
static iterator end(const WriteableInterfaceTypePtr &image)
static iterator begin(const WriteableInterfaceTypePtr &image)
static void shiftResize(const WriteableInterfaceTypePtr &source, WriteableInterfaceTypePtr &window, double scale_factor, double x_shift, double y_shift)
static std::size_t width(const WriteableInterfaceTypePtr &image)
static WriteableInterfaceTypePtr factory(std::size_t width, std::size_t height)
static std::size_t height(const WriteableInterfaceTypePtr &image)
static void shiftResizeLancszos(const WriteableInterfaceTypePtr &source, WriteableInterfaceTypePtr &window, double scale_factor, double x_shift, double y_shift)
static ImageInterfaceType::PixelType at(const WriteableInterfaceTypePtr &image, std::size_t x, std::size_t y)
static std::size_t height(ImageType &image)
static std::size_t width(ImageType &image)
static void addImageToImage(ImageType &image1, const ImageType &image2, double scale, double x, double y)
static double & at(ImageType &image, std::size_t x, std::size_t y)