8 #ifndef META_OCEAN_CV_FRAME_FILTER_DILATION_H
9 #define META_OCEAN_CV_FRAME_FILTER_DILATION_H
45 template <MorphologyFilter tDilationFilter>
46 static void filter1Channel8Bit(uint8_t* mask,
const unsigned int width,
const unsigned int height,
const unsigned int iterations,
const uint8_t maskValue = 0x00,
const unsigned int maskPaddingElements = 0u,
Worker* worker =
nullptr);
60 static inline void filter1Channel8Bit4Neighbor(
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t maskValue = 0x00,
const unsigned int maskPaddingElements = 0u,
const unsigned int targetPaddingElements = 0u,
Worker* worker =
nullptr);
74 static inline void filter1Channel8Bit8Neighbor(
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t maskValue = 0x00,
const unsigned int maskPaddingElements = 0u,
const unsigned int targetPaddingElements = 0u,
Worker* worker =
nullptr);
88 static inline void filter1Channel8Bit24Neighbor(
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t maskValue = 0x00,
const unsigned int maskPaddingElements = 0u,
const unsigned int targetPaddingElements = 0u,
Worker* worker =
nullptr);
104 static void filter1Channel8Bit4NeighborSubset(
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t maskValue,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
118 static void filter1Channel8Bit8NeighborSubset(
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t maskValue,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
132 static void filter1Channel8Bit24NeighborSubset(
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const uint8_t maskValue,
const unsigned int maskPaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
141 template <
unsigned int tSize>
142 static OCEAN_FORCE_INLINE
bool eachPixelNotEqual(
const uint8_t*
const maskPixels,
const uint8_t maskValue);
145 template <FrameFilterDilation::MorphologyFilter tDilationFilter>
148 ocean_assert(mask !=
nullptr);
149 ocean_assert(width >= 2u && height >= 2u);
150 ocean_assert(iterations >= 1u);
154 switch (tDilationFilter)
158 for (
unsigned int n = 0u; n < iterations / 2u; ++n)
164 if (iterations % 2u == 1u)
174 for (
unsigned int n = 0u; n < iterations / 2u; ++n)
180 if (iterations % 2u == 1u)
190 for (
unsigned int n = 0u; n < iterations / 2u; ++n)
196 if (iterations % 2u == 1u)
205 ocean_assert(
false &&
"Invalid dilation filter!");
208 if (iterations % 2u == 1u)
210 CV::FrameConverter::subFrame<uint8_t>(intermediateTarget.
constdata<uint8_t>(), mask, width, height, width, height, 1u, 0u, 0u, 0u, 0u, width, height, intermediateTarget.
paddingElements(), maskPaddingElements);
216 ocean_assert(mask && target);
217 ocean_assert(width >= 2u && height >= 2u);
221 worker->
executeFunction(
Worker::Function::createStatic(&
FrameFilterDilation::filter1Channel8Bit4NeighborSubset, mask, target, width, height, maskValue, maskPaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 7u, 8u, 20u);
231 ocean_assert(mask && target);
232 ocean_assert(width >= 2u && height >= 2u);
236 worker->
executeFunction(
Worker::Function::createStatic(&
FrameFilterDilation::filter1Channel8Bit8NeighborSubset, mask, target, width, height, maskValue, maskPaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 7u, 8u, 20u);
246 ocean_assert(mask && target);
247 ocean_assert(width >= 4u && height >= 4u);
251 worker->
executeFunction(
Worker::Function::createStatic(&
FrameFilterDilation::filter1Channel8Bit24NeighborSubset, mask, target, width, height, maskValue, maskPaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 7u, 8u, 20u);
260 OCEAN_FORCE_INLINE
bool FrameFilterDilation::eachPixelNotEqual<3u>(
const uint8_t*
const maskPixels,
const uint8_t maskValue)
262 ocean_assert(maskPixels !=
nullptr);
264 return maskPixels[0] != maskValue && maskPixels[1] != maskValue && maskPixels[2] != maskValue;
268 OCEAN_FORCE_INLINE
bool FrameFilterDilation::eachPixelNotEqual<4u>(
const uint8_t*
const maskPixels,
const uint8_t maskValue)
270 ocean_assert(maskPixels !=
nullptr);
272 return maskPixels[0] != maskValue && maskPixels[1] != maskValue && maskPixels[2] != maskValue && maskPixels[3] != maskValue;
276 OCEAN_FORCE_INLINE
bool FrameFilterDilation::eachPixelNotEqual<5u>(
const uint8_t*
const maskPixels,
const uint8_t maskValue)
278 ocean_assert(maskPixels !=
nullptr);
280 return maskPixels[0] != maskValue && maskPixels[1] != maskValue && maskPixels[2] != maskValue && maskPixels[3] != maskValue && maskPixels[4] != maskValue;
This class implements a frame dilation filter.
Definition: FrameFilterDilation.h:29
static void filter1Channel8Bit8Neighbor(const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t maskValue=0x00, const unsigned int maskPaddingElements=0u, const unsigned int targetPaddingElements=0u, Worker *worker=nullptr)
Applies one dilation filter iteration for an 8 bit mask image using a 8-neighborhood,...
Definition: FrameFilterDilation.h:229
static void filter1Channel8Bit4NeighborSubset(const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t maskValue, const unsigned int maskPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Applies one dilation filter iteration in a subset of an 8 bit mask image using a 4-neighborhood.
static void filter1Channel8Bit24NeighborSubset(const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t maskValue, const unsigned int maskPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Applies one dilation filter iteration in a subset of an 8 bit mask image using a 24-neighborhood.
static void filter1Channel8Bit4Neighbor(const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t maskValue=0x00, const unsigned int maskPaddingElements=0u, const unsigned int targetPaddingElements=0u, Worker *worker=nullptr)
Applies one dilation filter iteration for an 8 bit mask image using a 4-neighborhood.
Definition: FrameFilterDilation.h:214
static void filter1Channel8Bit(uint8_t *mask, const unsigned int width, const unsigned int height, const unsigned int iterations, const uint8_t maskValue=0x00, const unsigned int maskPaddingElements=0u, Worker *worker=nullptr)
Applies several dilation filter iterations for an 8 bit mask image.
Definition: FrameFilterDilation.h:146
static OCEAN_FORCE_INLINE bool eachPixelNotEqual(const uint8_t *const maskPixels, const uint8_t maskValue)
Returns whether each several pixels in a row is not equal to a specified value.
static void filter1Channel8Bit8NeighborSubset(const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t maskValue, const unsigned int maskPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Applies one dilation filter iteration in a subset of an 8 bit mask image using a 8-neighborhood.
static void filter1Channel8Bit24Neighbor(const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t maskValue=0x00, const unsigned int maskPaddingElements=0u, const unsigned int targetPaddingElements=0u, Worker *worker=nullptr)
Applies one dilation filter iteration for an 8 bit mask image using a 24-neighborhood,...
Definition: FrameFilterDilation.h:244
This class implements the base class for all morphology frame filter.
Definition: FrameFilterMorphology.h:26
@ MF_SQUARE_3
Square mask filter defined by one center point and 8 surrounded filter pixels with an area of 3x3.
Definition: FrameFilterMorphology.h:37
@ MF_CROSS_3
Cross mask filter defined by one center point and 4 (north, south, west, east) filter pixels with an ...
Definition: FrameFilterMorphology.h:35
@ MF_SQUARE_5
Square mask filter defined by one center point and 24 surrounded filter pixels with an area of 5x5.
Definition: FrameFilterMorphology.h:39
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition: Caller.h:2876
This class implements Ocean's image class.
Definition: Frame.h:1792
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition: Frame.h:4168
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition: Frame.h:4159
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition: Frame.h:4042
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
@ FORMAT_Y8
Pixel format for grayscale images with byte order Y and 8 bits per pixel.
Definition: Frame.h:594
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition: Frame.h:1050
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15