Beatmup
Kernels::CircularDilatation< out_t > Class Template Reference

Circular dilatation kernel for flood fill contours postprocessing. More...

#include <region_filling.h>

Static Public Member Functions

static void process (AbstractBitmap &bitmap, std::vector< IntPoint > &pointSet, int val, float holdRad, float releaseRad)
 Circular dilatation of a mask at given points. More...
 

Detailed Description

template<typename out_t>
class Kernels::CircularDilatation< out_t >

Circular dilatation kernel for flood fill contours postprocessing.

Definition at line 146 of file region_filling.h.

Member Function Documentation

◆ process()

template<typename out_t >
static void Kernels::CircularDilatation< out_t >::process ( AbstractBitmap bitmap,
std::vector< IntPoint > &  pointSet,
int  val,
float  holdRad,
float  releaseRad 
)
inlinestatic

Circular dilatation of a mask at given points.

Parameters
bitmapThe mask bitmap
pointSetThe points
valMax value (amplitude)
holdRadInner kernel radius; all pixels inside take val value
releaseRadRelease ring outer radius; all pixels in the ring take linearly attenuated val value

Definition at line 156 of file region_filling.h.

156  {
157  out_t mask(bitmap);
158  const int morphoSize = (int)ceilf(holdRad + releaseRad);
159  const float morphoReleaseRing = releaseRad - holdRad;
160  // for each point in the point set...
161  for (auto p : pointSet) {
162  // determine a bounding box to apply the kernel
163  int
164  x1 = std::max(0, p.x - morphoSize),
165  y1 = std::max(0, p.y - morphoSize),
166  x2 = std::min(mask.getWidth() - 1, p.x + morphoSize),
167  y2 = std::min(mask.getHeight() - 1, p.y + morphoSize);
168  // apply the kernel
169  for (int y = y1; y <= y2; ++y) {
170  mask.goTo(x1, y);
171  for (int x = x1; x <= x2; ++x, mask++) {
172  // squared distance to center
173  int d2 = sqr(x - p.x) + sqr(y - p.y);
174  if (d2 < sqr(holdRad))
175  mask.assign(val);
176  else if (d2 < sqr(releaseRad)) {
177  // linear attenuation
178  int c = (int)roundf((float)val * (1.0f - (sqrtf((float)d2) - holdRad) / morphoReleaseRing));
179  if (mask().x < c)
180  mask.assign(c);
181  }
182  }
183  }
184  }
185  }
#define sqr(X)
Definition: geometry.h:24
CustomPoint< numeric > min(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Definition: geometry.h:724
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Definition: geometry.h:728
JNIEnv jlong jint jint jint jint y2
JNIEnv jlong jint x1
JNIEnv jlong jint jint jint x2
JNIEnv jlong jint jint jint y1
jobject jlong jint jint y
jobject jlong jint x
return(jlong) new Beatmup jlong jstring jint val
Beatmup::InternalBitmap * bitmap
Beatmup::IntPoint p((int) x,(int) y)

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