23 #ifndef _SEFRAMEWORK_IMAGE_PADDEDIMAGE_H
24 #define _SEFRAMEWORK_IMAGE_PADDEDIMAGE_H
30 namespace SourceXtractor {
34 if (v > N - 1)
return N - 1;
39 if (v >= 0 && v < N) {
49 if (ntimes % 2 == 0) {
52 return N - offset - 1;
56 if (v >= 0 && v < N) {
65 if (ntimes % 2 == 0) {
72 return (v % N + N) % N;
75 template<
typename T,
int CoordinateInterpolation(
int,
int) =
nullptr>
80 auto wdiff =
m_width - img->getWidth();
81 auto hdiff =
m_height - img->getHeight();
88 template<
typename... Args>
94 return "PaddedImage(" +
m_img->getRepr() +
")";
110 for (
int iy = 0; iy <
height; ++iy) {
111 for (
int ix = 0; ix <
width; ++ix) {
112 auto img_x = CoordinateInterpolation(img_w, ix + x -
m_lpad);
113 auto img_y = CoordinateInterpolation(img_h, iy + y -
m_tpad);
114 chunk->at(ix, iy) = accessor.
getValue(img_x, img_y);
132 auto wdiff =
m_width - img->getWidth();
133 auto hdiff =
m_height - img->getHeight();
143 template<
typename... Args>
149 return "PaddedImage(" +
m_img->getRepr() +
")";
161 ImageAccessor<T> accessor(
m_img, ImageAccessor<T>::TOP_LEFT, width, height);
164 auto img_w = accessor.getWidth();
165 auto img_h = accessor.getHeight();
166 for (
int iy = 0; iy <
height; ++iy) {
167 for (
int ix = 0; ix <
width; ++ix) {
170 if (img_x <
m_lpad || img_y < m_tpad || img_x >= img_w +
m_lpad ||
171 img_y >= img_h +
m_tpad) {
172 chunk->at(ix, iy) = m_default;
175 chunk->at(ix, iy) = accessor.getValue(img_x -
m_lpad, img_y -
m_tpad);
191 #endif // _SEFRAMEWORK_IMAGE_PADDEDIMAGE_H
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y