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

#include <resampling_kernels.h>

Classes

class  BicubicKernel
 Precomputes kernel coefficients in function of bicubic kernel parameter. More...
 

Static Public Member Functions

static void process (AbstractBitmap &input, AbstractBitmap &output, IntRectangle &src, IntRectangle &dst, const float alpha, const TaskThread &tt)
 Resamples a rectangle from an input bitmap to a rectangle in an output bitmap applying a bicubic kernel. More...
 

Detailed Description

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

Definition at line 189 of file resampling_kernels.h.

Member Function Documentation

◆ process()

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

Resamples a rectangle from an input bitmap to a rectangle in an output bitmap applying a bicubic kernel.

Definition at line 232 of file resampling_kernels.h.

232  {
233  in_t in(input);
234  out_t out(output);
235 
236  const int
237  srcW = src.width(), srcH = src.height(),
238  dstW = dst.width(), dstH = dst.height(),
239  shiftX = (srcW - dstW) / 2,
240  shiftY = (srcH - dstH) / 2;
241 
242  // dest image slice to process in the current thread
243  const int
244  sliceStart = tt.currentThread() * dstH / tt.numThreads(),
245  sliceStop = (tt.currentThread() + 1) * dstH / tt.numThreads();
246 
247  BicubicKernel kx(alpha), ky(alpha);
248 
249  for (int y = sliceStart; y < sliceStop; ++y) {
250  out.goTo(dst.a.x, dst.a.y + y);
251  const float fsy = (float)(y * srcH + shiftY) / dstH;
252  const int isy = (int)fsy;
253  const float fy = fsy - (float)isy;
254  const int sy = src.a.y + isy;
255 
256  const int lineJump[3] = {
257  sy > 0 ? srcW : 0,
258  sy < srcH - 1 ? srcW : 0,
259  sy < srcH - 2 ? srcW : 0
260  };
261 
262  // preparing kernel
263  ky(fy);
264 
265  typename out_t::pixtype acc;
266  for (int x = 0; x < dstW; ++x) {
267 
268  const float fsx = (float)(x * srcW + shiftX) / dstW;
269  const int isx = (int)fsx;
270  const float fx = fsx - (float)isx;
271  const int sx = src.a.x + isx;
272 
273  kx(fx);
274 
275  const int pixJump[3] = {
276  sx > 0 ? -1 : 0,
277  sx < srcW - 1 ? +1 : 0,
278  sx < srcW - 2 ? +2 : 0
279  };
280 
281  in.goTo(sx, sy > 0 ? sy - 1 : 0);
282  acc = in[pixJump[0]] * kx[0] * ky[0] + in() * kx[1] * ky[0] + in[pixJump[1]] * kx[2] * ky[0] + in[pixJump[2]] * kx[3] * ky[0];
283  in += lineJump[0];
284  acc = acc + in[pixJump[0]] * kx[0] * ky[1] + in() * kx[1] * ky[1] + in[pixJump[1]] * kx[2] * ky[1] + in[pixJump[2]] * kx[3] * ky[1];
285  in += lineJump[1];
286  acc = acc + in[pixJump[0]] * kx[0] * ky[2] + in() * kx[1] * ky[2] + in[pixJump[1]] * kx[2] * ky[2] + in[pixJump[2]] * kx[3] * ky[2];
287  in += lineJump[2];
288  acc = acc + in[pixJump[0]] * kx[0] * ky[3] + in() * kx[1] * ky[3] + in[pixJump[1]] * kx[2] * ky[3] + in[pixJump[2]] * kx[3] * ky[3];
289 
290  out = acc;
291  out++;
292  }
293 
294  if (tt.isTaskAborted())
295  return;
296  }
297  }
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: