Beatmup
Kernels::CircularErosion< out_t > Class Template Reference

Circular erosion 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 erosion of a mask at given points. More...
 

Detailed Description

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

Circular erosion kernel for flood fill contours postprocessing.

Definition at line 192 of file region_filling.h.

Member Function Documentation

◆ process()

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

Circular erosion 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 202 of file region_filling.h.

202  {
203  out_t mask(bitmap);
204  const int morphoSize = (int)ceilf(holdRad + releaseRad);
205  const float morphoReleaseRing = releaseRad - holdRad;
206  // for each point in the point set...
207  for (auto p : pointSet) {
208  // determine a bounding box to apply the kernel
209  int
210  x1 = std::max(0, p.x - morphoSize),
211  y1 = std::max(0, p.y - morphoSize),
212  x2 = std::min(mask.getWidth() - 1, p.x + morphoSize),
213  y2 = std::min(mask.getHeight() - 1, p.y + morphoSize);
214  // apply the kernel
215  for (int y = y1; y <= y2; ++y) {
216  mask.goTo(x1, y);
217  for (int x = x1; x <= x2; ++x, mask++) {
218  // squared distance to center
219  int d2 = sqr(x - p.x) + sqr(y - p.y);
220  if (d2 < sqr(holdRad))
221  mask.assign(0);
222  else if (d2 < sqr(releaseRad)) {
223  // linear attenuation
224  int c = (int)roundf((float)val * (sqrtf((float)d2) - holdRad) / morphoReleaseRing);
225  if (mask().x > c)
226  mask.assign(c);
227  }
228  }
229  }
230  }
231  }
#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: