BoB robotics
The Brains on Board robotics library
BoBRobotics::ImgProc::Mask Class Reference

A class providing extra checks and type safety for image masks. More...

#include <mask.h>

Public Member Functions

 Mask ()=default
 Create an empty mask (i.e. treat all pixels as unmasked)
 
 Mask (cv::Mat mask, const cv::Size &resizeTo={})
 Construct a mask based on a cv::Mat where zero pixels are treated as masked.
 
 Mask (const cv::Mat &image, const cv::Scalar &lower, const cv::Scalar &upper, const cv::Size &resizeTo={})
 Construct a mask based on a cv::Mat where pixels outside of lower and upper range are masked.
 
 Mask (const filesystem::path &imagePath, const cv::Size &resizeTo={})
 Load a mask from an image file.
 
void apply (const cv::Mat &in, cv::Mat &out) const
 Zero out the masked pixels in in and copy the result to out
 
void combine (const Mask &otherMask, Mask &outputMask) const
 Combine this mask with another, saving to outputMask.
 
size_t countUnmaskedPixels (const cv::Size &size) const
 
bool empty () const
 
const cv::Mat & get () const
 
bool isValid (const cv::Size &imageSize) const
 
Mask clone () const
 Clone mask.
 
void roll (Mask &out, size_t pixelsLeft) const
 Roll the mask the specified number of pixels to the left. More...
 
void set (cv::Mat mask, const cv::Size &size={})
 
void set (const cv::Mat &image, const cv::Scalar &lower, const cv::Scalar &upper, const cv::Size &size={})
 
void set (const filesystem::path &imagePath, const cv::Size &size={})
 

Detailed Description

A class providing extra checks and type safety for image masks.

Member Function Documentation

◆ roll()

void Mask::roll ( Mask out,
size_t  pixelsLeft 
) const

Roll the mask the specified number of pixels to the left.

Internally this just uses ImgProc::roll, but this method is provided for type safety.


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