Beatmup
Kernels::BoxResampling< 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 applying a box filter. More...
 

Detailed Description

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

Definition at line 67 of file resampling_kernels.h.

Member Function Documentation

◆ process()

template<class in_t , class out_t >
static void Kernels::BoxResampling< 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 applying a box filter.

Definition at line 73 of file resampling_kernels.h.

73  {
74  in_t in(input);
75  out_t out(output);
76 
77  const int
78  srcW = src.width(), srcH = src.height(),
79  dstW = dst.width(), dstH = dst.height();
80 
81  // dest image slice to process in the current thread
82  const int
83  sliceStart = tt.currentThread() * dstH / tt.numThreads(),
84  sliceStop = (tt.currentThread() + 1) * dstH / tt.numThreads();
85 
86  int x0, y0, x1, y1 = src.a.y + (sliceStart) * srcH / dstH; // coordinates of source pixels box mapped to a given dest pixel
87 
88  typename in_t::pixtype acc;
89  for (int y = sliceStart; y < sliceStop; ++y) {
90  out.goTo(dst.a.x, dst.a.y + y);
91  y0 = y1;
92  y1 = src.a.y + (y + 1) * srcH / dstH;
93  x1 = src.a.x;
94  for (int x = 0; x < dstW; ++x) {
95  x0 = x1;
96  x1 = src.a.x + (x + 1) * srcW / dstW;
97 
98  // loop over the source area
99  acc.zero();
100  int y = y0;
101  do {
102  in.goTo(x0, y);
103  int x = x0;
104  do {
105  acc = acc + in();
106  in++;
107  } while (++x < x1);
108  } while (++y < y1);
109 
110  // write out
111  out = acc / std::max(1, (x1 - x0)*(y1 - y0));
112  out++;
113  }
114 
115  if (tt.isTaskAborted())
116  return;
117  }
118  }
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.
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Definition: geometry.h:728
JNIEnv jlong jint x1
JNIEnv jlong jint jint jint y1
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: