24 #include <core/exception.h>
26 #include <fvfilters/morphology/geodesic_dilation.h>
27 #include <fvfilters/morphology/segenerator.h>
28 #include <fvfilters/morphology/dilation.h>
29 #include <fvfilters/min.h>
31 #include <fvutils/statistical/imagediff.h>
32 #include <fvutils/color/colorspaces.h>
33 #include <fvutils/base/roi.h>
38 namespace firevision {
44 const unsigned int FilterGeodesicDilation::MARKER = 0;
46 const unsigned int FilterGeodesicDilation::MASK = 1;
49 fawkes::Exception e("FilterGeodesicDilation failed"); \
50 e.append("Function: %s", __FUNCTION__); \
51 e.append("Message: %s", m); \
64 FilterGeodesicDilation::FilterGeodesicDilation(
unsigned int se_size)
67 this->se_size = (se_size > 0) ? se_size : 1;
96 if (
dst == NULL ) ERROR(
"dst == NULL");
97 if (
src[
MASK] == NULL ) ERROR(
"src[MASK] == NULL");
98 if (
src[
MARKER] == NULL ) ERROR(
"src[MARKER] == NULL");
101 unsigned char *tmp = (
unsigned char *)malloc(colorspace_buffer_size(YUV422_PLANAR,
src_roi[MARKER]->image_width,
src_roi[MARKER]->image_height) );
102 memcpy( tmp,
src[MARKER], colorspace_buffer_size(YUV422_PLANAR,
src_roi[MARKER]->image_width,
src_roi[MARKER]->image_height) );
119 }
while (diff->
different() && ( ++iterations < 255) );
virtual void set_structuring_element(unsigned char *se, unsigned int se_width, unsigned int se_height, unsigned int se_anchor_x, unsigned int se_anchor_y)
Set the structuring element for successive filter runs.
virtual ~FilterGeodesicDilation()
Destructor.
virtual void set_src_buffer(unsigned char *buf, ROI *roi, orientation_t ori=ORI_HORIZONTAL, unsigned int buffer_num=0)
Set source buffer with orientation.
void setBufferA(unsigned char *yuv422planar_buffer, unsigned int width, unsigned int height)
Set first buffer.
bool different()
Check if images are different.
virtual void apply()
Apply the filter.
unsigned int image_width
width of image that contains this ROI
Image difference checker.
static unsigned char * square(unsigned int width, unsigned int height)
Generate square structuring element.
Morphological filter interface.
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
unsigned int image_height
height of image that contains this ROI
virtual void apply()
Apply the filter.
static const unsigned int MASK
Mask.
virtual unsigned int num_iterations()
Get the number of iterations.
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
static const unsigned int MARKER
Marker.
void setBufferB(unsigned char *yuv422planar_buffer, unsigned int width, unsigned int height)
Set second buffer.
virtual void apply()
Apply the filter.
unsigned char * dst
Destination buffer.
ROI * dst_roi
Destination ROI.
virtual void set_dst_buffer(unsigned char *buf, ROI *roi)
Set the destination buffer.