21 #include "../bitmap/processing.h"
22 #include "../bitmap/internal_bitmap.h"
29 input(nullptr), output(nullptr), maskPos(0, 0), bounds(0,0,0,0), borderMorphology(
NONE),
tolerance(0), borderHold(0), borderRelease(0), computeContours(false)
42 this->
input = inputBitmap;
58 for (
int n = 0;
n < seedCount;
n++)
59 this->seeds.push_back(
seeds[
n]);
65 for (
int n = 0;
n < seedCount;
n++)
81 std::vector<IntPoint> border;
84 std::vector<IntegerContour2D*> myContours;
127 for (
auto contour : myContours)
175 "Contour index is out of range. Contours computation may have been disabled.");
A very basic class for any image.
Context & getContext() const
const ImageResolution getSize() const
Returns the bitmap resolution within ImageResolution object.
virtual const pixbyte * getData(int x, int y) const =0
Returns a pointer to given pixel.
virtual const msize getMemorySize() const =0
Bitmap size in bytes.
static ThreadIndex validThreadCount(int number)
Valid thread count from a given integer value.
void unlock(AbstractBitmap *bitmap)
Drops a lock to the bitmap.
void lock(GraphicPipeline *gpu, AbstractBitmap *input, AbstractBitmap *output)
void writeLock(GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target)
Locks content of a bitmap for writing using a specific processing target device.
void limit(const CustomRectangle &frame)
Truncates a rectangle to a limiting frame.
std::mutex access
access control assuring internal thread safety
void setSeeds(const IntPoint seeds[], int seedCount)
Specifies a set of seeds (starting points)
BorderMorphology
Morphological postprocessing operation applied to discovered connected components.
@ DILATE
apply a dilatation
AbstractBitmap * ignoredSeeds
1-bit bitmap storing flags marking used pixels
BorderMorphology borderMorphology
border morphological postprocessing
void setComputeContours(bool)
Enables or disables contours computation.
std::vector< IntegerContour2D * > contours
contours to store borders for each seed
void setInput(AbstractBitmap *)
Sets the input bitmap.
AbstractBitmap * output
resulting mask
void setBorderPostprocessing(BorderMorphology operation, float holdRadius, float releaseRadius)
Specifies a morphological operation to apply to the mask border.
void setMaskPos(const IntPoint &)
Specifies left-top corner position of the mask to compute inside the input bitmap.
const IntegerContour2D & getContour(int contourIndex) const
Returns a contour by index if computeContours was true, throws an exception otherwise.
virtual void afterProcessing(ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted) final
Instruction called after the task is executed.
IntPoint maskPos
left-top corner of the mask to compute over the input bitmap
virtual void beforeProcessing(ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu) final
Instruction called before the task is executed.
std::vector< IntPoint > seeds
set of starting points (seed points)
void setTolerance(float)
Sets the intensity tolerance threshold used to decide on similarity of neighboring pixels.
float tolerance
intensity tolerance value
AbstractBitmap * input
input bitmap
IntRectangle bounds
mask bounds
virtual bool process(TaskThread &thread) final
Executes the task on CPU within a given thread.
bool computeContours
if true, border contours will be computed per each seed
void setOutput(AbstractBitmap *)
Specifies the bitmap to put the resulting mask to.
ThreadIndex getMaxThreads() const
Gives the upper limint on the number of threads the task may be performed by.
virtual const int getHeight() const =0
Height of the texture in pixels.
virtual const int getWidth() const =0
Width of the texture in pixels.
Internal low-level GPU control API.
IntRectangle closedRectangle() const
A sequence of integer-valued 2D points.
static void computeBoundary(std::vector< IntegerContour2D * > &boundary, AbstractBitmap &bitmap, std::vector< IntPoint > &border, BinaryMaskWriter &testedPixels, float level=0.5f)
Discovers an area boundary in a bitmap following a level curve, starting from a given set of points.
Bitmap whose memory is managed by the Beatmup engine.
A generic to write mask bitmap data lookup tables for masks values.
static void check(const bool condition, const std::string &message)
virtual ThreadIndex numThreads() const =0
ThreadIndex currentThread() const
virtual bool isTaskAborted() const =0
Returns true if the task is asked to stop from outside.
unsigned char ThreadIndex
number of threads / thread index
@ BinaryMask
1 bit per pixel
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)