Beatmup
Kernels::BilinearResampling< in_t, out_t > Class Template Reference

#include <resampling_kernels.h>

Static Public Member Functions

static void process (AbstractBitmap &input, AbstractBitmap &output, IntRectangle &src, IntRectangle &dst, const TaskThread &tt)
 Resamples a rectangle from an input bitmap to a rectangle in an output bitmap by bilinear interpolation. More...
 

Detailed Description

template<class in_t, class out_t>
class Kernels::BilinearResampling< in_t, out_t >

Definition at line 122 of file resampling_kernels.h.

Member Function Documentation

◆ process()

template<class in_t , class out_t >
static void Kernels::BilinearResampling< in_t, out_t >::process ( AbstractBitmap input,
AbstractBitmap output,
IntRectangle src,
IntRectangle dst,
const TaskThread tt 
)
inlinestatic

Resamples a rectangle from an input bitmap to a rectangle in an output bitmap by bilinear interpolation.

Definition at line 128 of file resampling_kernels.h.

128  {
129  in_t in(input);
130  out_t out(output);
131 
132  const int
133  srcW = src.width(), srcH = src.height(),
134  dstW = dst.width(), dstH = dst.height(),
135  shiftX = (srcW - dstW) / 2,
136  shiftY = (srcH - dstH) / 2;
137 
138  // dest image slice to process in the current thread
139  const int
140  sliceStart = tt.currentThread() * dstH / tt.numThreads(),
141  sliceStop = (tt.currentThread() + 1) * dstH / tt.numThreads();
142 
143  for (int y = sliceStart; y < sliceStop; ++y) {
144  out.goTo(dst.a.x, dst.a.y + y);
145  const float fsy = (float)(y * srcH + shiftY) / dstH;
146  const int isy = (int)fsy;
147  const float fy = fsy - (float)isy, _fy = 1 - fy;
148  const int sy = src.a.y + isy;
149 
150  const int
151  lineJump = sy < srcH - 1 ? srcW - 1 : -1,
152  xBound = srcW - 1;
153 
154  typename out_t::pixtype acc;
155  for (int x = 0; x < dstW; ++x) {
156 
157  const float fsx = (float)(x * srcW + shiftX) / dstW;
158  const int isx = (int)fsx;
159  const float fx = fsx - (float)isx;
160  const int sx = src.a.x + isx;
161 
162  in.goTo(sx, sy);
163  if (sx < xBound) {
164  acc = in() * (1 - fx) * _fy;
165  in++;
166  acc = acc + in() * fx * _fy;
167  in += lineJump;
168  acc = acc + in() * (1 - fx) * fy;
169  in++;
170  acc = acc + in() * fx * fy;
171  }
172  else {
173  acc = in() * _fy;
174  in += lineJump + 1;
175  acc = acc + in() * fy;
176  }
177 
178  out = acc;
179  out++;
180  }
181 
182  if (tt.isTaskAborted())
183  return;
184  }
185  }
numeric height() const
Definition: geometry.h:178
numeric width() const
Definition: geometry.h:174
CustomPoint< numeric > a
Definition: geometry.h:131
virtual ThreadIndex numThreads() const =0
ThreadIndex currentThread() const
Definition: parallelism.h:165
virtual bool isTaskAborted() const =0
Returns true if the task is asked to stop from outside.
jobject jlong jint jint y
jobject jlong jint x
JNIEnv jlong jint out
return(jlong) new Beatmup jlong jstring src

The documentation for this class was generated from the following file: