vz::Imagination  v1.0.0-2969
C++ helper class for image manipulation using OpenCV
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
vz::Imagination Class Reference

Imagination objects are used to perform simple and common image manipulations, as well as act as an image cache to store variations on an image. More...

Collaboration diagram for vz::Imagination:

Public Types

enum  EMatType {
  EMatType::kInvalid = 0,
  EMatType::kOriginalImage,
  EMatType::kO2Greyscale,
  EMatType::kO2GaussianBlur,
  EMatType::kO2BlurGreyscale,
  EMatType::kO2SimpleColourBalance,
  EMatType::kO2Invert,
  EMatType::kThreshold,
  EMatType::kErode,
  EMatType::kErodeAndDilate,
  EMatType::kCannyEdgeDetection,
  EMatType::kFindContours,
  EMatType::kFindContoursIntervals,
  EMatType::kO2Histogram,
  EMatType::kHoughLines,
  EMatType::kO2AngleCorrected,
  EMatType::kMosaic,
  EMatType::kO2DoG,
  EMatType::kThresholdOtsu,
  EMatType::kThresholdTriangle,
  EMatType::kThresholdGaussian,
  EMatType::kThresholdMeanC,
  EMatType::kThresholdDoG,
  EMatType::kUserDefined,
  EMatType::kMax
}
 The EMatType represents the numerous variations of an image that can be created using Imagination. More...
 
enum  EThresholdType {
  EThresholdType::kInvalid = 0,
  EThresholdType::kOther,
  EThresholdType::kOtsu,
  EThresholdType::kTriangle,
  EThresholdType::kAutoGaussian,
  EThresholdType::kAutoMeanC,
  EThresholdType::kDifferenceOfGaussian,
  EThresholdType::kMax
}
 

Public Member Functions

 Imagination ()
 Empty constructor. Use set_original(), an assignment, or one of the other explicit constructors to set the original image. More...
 
 Imagination (const std::string &original_image_filename)
 Constructor with an existing image file. More...
 
 Imagination (const cv::Mat &original_image)
 Constructor with an existing OpenCV image. More...
 
virtual ~Imagination ()
 Destructor. More...
 
virtual EMatType to_type (const std::string &name) const
 Convert the given name to EMatType. If the name is not an exact match, will return EMatType::kInvalid. More...
 
virtual std::string to_string (const EMatType type) const
 Provide a simple text name for the given mat image type. This is also used as the key to store images in mats. More...
 
virtual std::string to_string (const EThresholdType type) const
 Provide a simple text name for the given threshold type. More...
 
virtual bool operator== (const Imagination &rhs) const
 Deep comparison of the original image only. More...
 
bool operator!= (const Imagination &rhs) const
 Similar to operator==(). More...
 
virtual Imaginationclear ()
 Clear all of the image cv::Mat objects cached in mats. More...
 
bool empty () const
 Determine if an image has been set. More...
 
size_t size () const
 Determine the number of images that currently exist in the mats image cache. More...
 
virtual cv::Mat & get (const EMatType type, const int parm)
 Similar to the other get() method, but with the ability to pass in a single integer parameter. More...
 
virtual Imaginationreset ()
 Clears the object and resets the original image. More...
 
virtual VStr save_all (const std::string &prefix="")
 Save all of the image files to disk by repeatedly calling save() with all the image types. More...
 
virtual vz::VContours find_contours ()
 Find the contours of an image using EMatType::kCannyEdgeDetection and vz::find_contours(). More...
 
virtual cv::Mat create_threshold ()
 Get a decent binary image. More...
 
virtual cv::Mat create_hough_lines_and_angles ()
 Find the Hough lines, and make the necessary calculations to determine the angle of each line. More...
 
virtual cv::Mat create_mosaic (const bool show_labels=true)
 Create a mosaic using a thumbnail of all the images in mats. This is mostly for debug or logging purposes. More...
 
virtual cv::Mat create_threshold (const EThresholdType type)
 
virtual Imaginationclear (const EMatType type)
 Clear a specific image type from mats. The image will be re-created the next time it is requested. More...
 
virtual Imaginationclear (const std::string &name)
 Clear a specific image type from mats. The image will be re-created the next time it is requested. More...
 
bool exists (const EMatType type) const
 Determine if the given image has been created. More...
 
bool exists (const std::string &name) const
 Determine if the given image has been created. More...
 
virtual Imaginationset_original (const std::string &original_image_filename)
 Reset this object and use the given image. All previous images in mats are cleared prior to the new image being set. More...
 
virtual Imaginationset_original (const cv::Mat &original_image)
 
virtual Imaginationset_original (const EMatType type)
 Reset this object and use the given image. All previous images in mats are cleared prior to the new image being set. More...
 
virtual cv::Mat & get (const EMatType type=EMatType::kOriginalImage)
 Get the specified image from cache. More...
 
virtual cv::Mat & get (const std::string &name)
 
cv::Mat & operator[] (const EMatType type)
 Alias for get(). More...
 
cv::Mat & operator[] (const std::string &name)
 Alias for get(). More...
 
virtual Imaginationreplace (const EMatType type, cv::Mat &image)
 Replace the given image type. More...
 
virtual Imaginationreplace (const std::string &name, cv::Mat &image)
 Replace the given image type. More...
 
virtual Imaginationreset_using (const EMatType type)
 Clears the object and resets the original image to the given image type. More...
 
virtual Imaginationreset_using (const std::string &name)
 Clears the object and resets the original image to the given image type. More...
 
cv::Mat resize (const EMatType type, int width, int height=0)
 Resize (scale) the given image. More...
 
cv::Mat resize (const std::string &name, int width, int height=0)
 Resize (scale) the given image. More...
 
cv::Mat resize (const EMatType type, const double scale)
 Resize (scale) the given image. More...
 
cv::Mat resize (const std::string &name, const double scale)
 Resize (scale) the given image. More...
 
virtual std::string save (const EMatType type, const std::string &prefix="")
 Save the given image to disk. More...
 
virtual std::string save (const std::string &name, const std::string &prefix="")
 Save the given image to disk. More...
 

Public Attributes

double threshold_value
 Auto-detected threshold value. This is only set once the EMatType::kThreshold image is created. More...
 
EThresholdType threshold_type
 The threshold type that was used. This is only set once the EMatType::kThreshold image is created. More...
 
vz::VContours contours
 A vector of contours. More...
 
vz::VVDouble contours_intervals
 Contour intervals. This is only set once the EMatType::kFindContoursIntervals image is created. More...
 
vz::VV4i hough_lines
 The Hough lines, angles, angle intervals, and the correction angle are automatically calculated by create_hough_lines_and_angles() once get() is called with a parameter of EMatType::kHoughLines. More...
 
vz::VDouble hough_lines_angles
 A vector of all angles for all lines in hough_lines. More...
 
vz::VVDouble hough_lines_angle_intervals
 The interval composed of all angles in hough_lines_angles. More...
 
double hough_lines_correction_angle
 The best angle according to hough_lines_angle_intervals. More...
 
typedef std::map< std::string, cv::Mat > Mats
 Map where the key is an image type description, and the value is a OpenCV cv::Mat object. More...
 
Mats mats
 Map where the key is an image type description, and the value is a OpenCV cv::Mat object. More...
 

Detailed Description

Imagination objects are used to perform simple and common image manipulations, as well as act as an image cache to store variations on an image.

This way, if a variation is requested multiple times, it is retrieved from cache instead of performing the same calculations multiple times.

Methods to note include the multiple constructors, get(), and save().

Member Typedef Documentation

◆ Mats

typedef std::map<std::string, cv::Mat> vz::Imagination::Mats

Map where the key is an image type description, and the value is a OpenCV cv::Mat object.

While the map may be referenced directly, is is preferable to use get() or operator[] to ensure the requested image is built and cached correctly.

Example:

vz::Imagination img("capture.jpg");
process(mat);
Since
2019-04 Even though the key is now a std::string instead of EMatType, the enum is still the preferred way to access the images stored within an Imagination object.

Member Enumeration Documentation

◆ EMatType

The EMatType represents the numerous variations of an image that can be created using Imagination.

See also
get()
Enumerator
kInvalid 

Empty cv::Mat. Should never come up.

kOriginalImage 

The original unmodified image.

capture.jpg
kO2Greyscale 

The original image converted to greyscale.

capture_grey.jpg
See also
vz::to_greyscale()
kO2GaussianBlur 

The original image with a Gaussian blur (default kernel size is 3x3).

gaussian_blur_3x3.jpg
See also
vz::apply_gaussian_blur()
kO2BlurGreyscale 

The original image with a Gaussian blur and then converted to greyscale.

gaussian_blur_3x3_grey.jpg
See also
vz::apply_blur_and_convert_to_greyscale()
kO2SimpleColourBalance 

The original image with a simple colour balance applied.

simple_colour_balance.jpg
See also
vz::apply_simple_colour_balance()
kO2Invert 

The original image inverted.

coins_invert.jpg
See also
vz::invert()
kThreshold 

The EMatType::kO2SimpleColourBalance image converted to black-and-white.

threshold_coins_triangle.png
See also
vz::Imagination::threshold
vz::Imagination::create_threshold()
kErode 

The EMatType::kThreshold image eroded.

threshold_coins_result.png
See also
vz::erode()
kErodeAndDilate 

The EMatType::kThreshold image both eroded then dilated.

coins_erode_and_dilate_3.jpg
See also
vz::erode()
vz::dilate()
kCannyEdgeDetection 

The EMatType::kThreshold image with edge detection.

coins_threshold_canny_edge_detect.jpg
See also
vz::apply_canny_edge_detection()
kFindContours 

Contour detection with contours drawn over EMatType::kOriginalImage.

coins_contours.jpg
See also
vz::Imagination::contours
vz::find_contours()
vz::add_contours_to_image()
kFindContoursIntervals 

Similar to EMatType::kFindContours but includes intervals.

coins_contours_intervals.jpg
See also
vz::Imagination::contours_intervals
vz::intervals()
kO2Histogram 

Histogram of the original image.

histogram.png
See also
vz::plot_histogram()
kHoughLines 

Hough lines transform.

hough_lines.jpg
See also
vz::Imagination::hough_lines
vz::find_hough_lines()
kO2AngleCorrected 

The original image with an angle correction.

hough_lines.jpg
See also
vz::Imagination::hough_lines_correction_angle
kMosaic 

Combines thumbnails of the other images into a single large mosaic.

mosaic.jpg
vz::Imagination::create_mosaic()
kO2DoG 

Difference of Gaussian.

kThresholdOtsu 
kThresholdTriangle 
kThresholdGaussian 
kThresholdMeanC 
kThresholdDoG 

Threshold based on EMatType::kO2DoG.

kUserDefined 

Any custom image added to the map will come back as "user defined". This may apply to multiple images, while the other enums apply to a single image.

kMax 

◆ EThresholdType

Enumerator
kInvalid 
kOther 
kOtsu 
kTriangle 
kAutoGaussian 
kAutoMeanC 
kDifferenceOfGaussian 

aka DoG

kMax 

Constructor & Destructor Documentation

◆ Imagination() [1/3]

vz::Imagination::Imagination ( )

Empty constructor. Use set_original(), an assignment, or one of the other explicit constructors to set the original image.

References clear().

Here is the call graph for this function:

◆ Imagination() [2/3]

vz::Imagination::Imagination ( const std::string &  original_image_filename)

Constructor with an existing image file.

References set_original().

Here is the call graph for this function:

◆ Imagination() [3/3]

vz::Imagination::Imagination ( const cv::Mat &  original_image)

Constructor with an existing OpenCV image.

References set_original().

Here is the call graph for this function:

◆ ~Imagination()

vz::Imagination::~Imagination ( )
virtual

Destructor.

Member Function Documentation

◆ to_type()

vz::Imagination::EMatType vz::Imagination::to_type ( const std::string &  name) const
virtual

Convert the given name to EMatType. If the name is not an exact match, will return EMatType::kInvalid.

References kMax, kUserDefined, and to_string().

Referenced by create_mosaic(), get(), replace(), and save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string() [1/2]

std::string vz::Imagination::to_string ( const EMatType  type) const
virtual

◆ to_string() [2/2]

std::string vz::Imagination::to_string ( const EThresholdType  type) const
virtual

Provide a simple text name for the given threshold type.

References kAutoGaussian, kAutoMeanC, kDifferenceOfGaussian, kInvalid, kMax, kOther, kOtsu, and kTriangle.

◆ operator==()

bool vz::Imagination::operator== ( const Imagination rhs) const
virtual

Deep comparison of the original image only.

The rest of the images can always be derived from the original which is why we only need to verify that the original images are the same. The comparison is pixel-by-pixel, so any image difference will be detected.

References vz::compare_exact(), empty(), kOriginalImage, mats, and to_string().

Referenced by operator!=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool vz::Imagination::operator!= ( const Imagination rhs) const
inline

Similar to operator==().

References clear(), and operator==().

Here is the call graph for this function:

◆ clear() [1/3]

vz::Imagination & vz::Imagination::clear ( )
virtual

Clear all of the image cv::Mat objects cached in mats.

References contours, contours_intervals, hough_lines, hough_lines_angle_intervals, hough_lines_angles, hough_lines_correction_angle, kInvalid, mats, threshold_type, and threshold_value.

Referenced by Imagination(), operator!=(), and set_original().

Here is the caller graph for this function:

◆ clear() [2/3]

vz::Imagination & vz::Imagination::clear ( const EMatType  type)
virtual

Clear a specific image type from mats. The image will be re-created the next time it is requested.

References replace().

Here is the call graph for this function:

◆ clear() [3/3]

vz::Imagination & vz::Imagination::clear ( const std::string &  name)
virtual

Clear a specific image type from mats. The image will be re-created the next time it is requested.

References replace().

Here is the call graph for this function:

◆ exists() [1/2]

bool vz::Imagination::exists ( const EMatType  type) const
inline

Determine if the given image has been created.

References exists(), and to_string().

Referenced by create_threshold(), empty(), exists(), and get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exists() [2/2]

bool vz::Imagination::exists ( const std::string &  name) const
inline

Determine if the given image has been created.

◆ empty()

bool vz::Imagination::empty ( ) const
inline

Determine if an image has been set.

See also
set_original()
clear()

References exists(), and kOriginalImage.

Referenced by operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

size_t vz::Imagination::size ( ) const
inline

Determine the number of images that currently exist in the mats image cache.

This includes the original image.

Note
This is not the pixel dimensions of the image!

References kOriginalImage, and set_original().

Here is the call graph for this function:

◆ set_original() [1/3]

vz::Imagination & vz::Imagination::set_original ( const std::string &  original_image_filename)
virtual

Reset this object and use the given image. All previous images in mats are cleared prior to the new image being set.

Exceptions
std::runtime_errorif the image fails to load (file does not exist?)

References clear().

Referenced by Imagination(), replace(), reset(), reset_using(), set_original(), and size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_original() [2/3]

vz::Imagination & vz::Imagination::set_original ( const cv::Mat &  original_image)
virtual
Note
If the cv::Mat is empty, then this is equivalent to calling clear().

References clear(), kOriginalImage, mats, and to_string().

Here is the call graph for this function:

◆ set_original() [3/3]

vz::Imagination & vz::Imagination::set_original ( const EMatType  type)
virtual

Reset this object and use the given image. All previous images in mats are cleared prior to the new image being set.

Exceptions
std::runtime_errorif the image fails to load (file does not exist?)

References set_original().

Here is the call graph for this function:

◆ get() [1/3]

◆ get() [2/3]

cv::Mat & vz::Imagination::get ( const std::string &  name)
virtual
Exceptions
std::logic_errorif the specified image type does not exist

References exists(), kInvalid, kUserDefined, mats, and to_type().

Here is the call graph for this function:

◆ get() [3/3]

cv::Mat & vz::Imagination::get ( const EMatType  type,
const int  parm 
)
virtual

Similar to the other get() method, but with the ability to pass in a single integer parameter.

This is used by several specific types to alter the default behaviour. Other types that don't use a parameter will fall through to the original get() method.

Note
For the types named in table below, the image will be cleared from cache (if it exists) and re-created with the specified parameter.

Types that support a parameter:

type parameter
EMatType::kO2GaussianBlur kernel_size for vz::apply_gaussian_blur()
EMatType::kO2BlurGreyscale kernel_size for vz::apply_gaussian_blur()
EMatType::kErode number of iterations for vz::erode()
EMatType::kErodeAndDilate number of iterations for both vz::erode() and vz::dilate()
EMatType::kCannyEdgeDetection canny threshold for vz::apply_canny_edge_detection()

References vz::apply_canny_edge_detection(), vz::apply_gaussian_blur(), vz::dilate(), vz::erode(), kCannyEdgeDetection, kErode, kErodeAndDilate, kO2BlurGreyscale, kO2GaussianBlur, kOriginalImage, kThreshold, mats, vz::to_greyscale(), and to_string().

Here is the call graph for this function:

◆ operator[]() [1/2]

cv::Mat& vz::Imagination::operator[] ( const EMatType  type)
inline

Alias for get().

Example:

vz::Imagination img("capture.jpg");

◆ operator[]() [2/2]

cv::Mat& vz::Imagination::operator[] ( const std::string &  name)
inline

Alias for get().

Example:

vz::Imagination img("capture.jpg");

References replace().

Here is the call graph for this function:

◆ replace() [1/2]

vz::Imagination & vz::Imagination::replace ( const EMatType  type,
cv::Mat &  image 
)
virtual

Replace the given image type.

If an image already exists for this type, then it is replaced. If an image type does not yet exist, then it is inserted into the map. If the image is empty, then the type is completely removed from mats.

See also
set_original()

References to_string().

Referenced by clear(), and operator[]().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace() [2/2]

vz::Imagination & vz::Imagination::replace ( const std::string &  name,
cv::Mat &  image 
)
virtual

Replace the given image type.

If an image already exists for this type, then it is replaced. If an image type does not yet exist, then it is inserted into the map. If the image is empty, then the type is completely removed from mats.

See also
set_original()

References kOriginalImage, kOther, kThreshold, mats, set_original(), threshold_type, threshold_value, and to_type().

Here is the call graph for this function:

◆ reset()

virtual Imagination& vz::Imagination::reset ( )
inlinevirtual

Clears the object and resets the original image.

All of the image types (except for EMatType::kOriginalImage) will need to be re-calculated. This used to be a separate function but is now an alias for set_original().

References kOriginalImage, and set_original().

Here is the call graph for this function:

◆ reset_using() [1/2]

virtual Imagination& vz::Imagination::reset_using ( const EMatType  type)
inlinevirtual

Clears the object and resets the original image to the given image type.

This used to be a separate function but is now an alias for set_original().

References set_original().

Here is the call graph for this function:

◆ reset_using() [2/2]

virtual Imagination& vz::Imagination::reset_using ( const std::string &  name)
inlinevirtual

Clears the object and resets the original image to the given image type.

This used to be a separate function but is now an alias for set_original().

References set_original().

Here is the call graph for this function:

◆ resize() [1/4]

cv::Mat vz::Imagination::resize ( const EMatType  type,
int  width,
int  height = 0 
)
inline

Resize (scale) the given image.

Either the width or the height (but not both) should be specified as zero, in which case it will be calculated using the other dimension to maintain the original aspect ratio.

References vz::resize().

Here is the call graph for this function:

◆ resize() [2/4]

cv::Mat vz::Imagination::resize ( const std::string &  name,
int  width,
int  height = 0 
)
inline

Resize (scale) the given image.

Either the width or the height (but not both) should be specified as zero, in which case it will be calculated using the other dimension to maintain the original aspect ratio.

References vz::resize().

Here is the call graph for this function:

◆ resize() [3/4]

cv::Mat vz::Imagination::resize ( const EMatType  type,
const double  scale 
)
inline

Resize (scale) the given image.

A scale less than 1.0 makes the image smaller, while a scale greater than 1.0 makes the image larger.

References vz::resize().

Here is the call graph for this function:

◆ resize() [4/4]

cv::Mat vz::Imagination::resize ( const std::string &  name,
const double  scale 
)
inline

Resize (scale) the given image.

A scale less than 1.0 makes the image smaller, while a scale greater than 1.0 makes the image larger.

References create_hough_lines_and_angles(), create_mosaic(), create_threshold(), find_contours(), vz::resize(), save(), save_all(), and to_string().

Here is the call graph for this function:

◆ save() [1/2]

std::string vz::Imagination::save ( const EMatType  type,
const std::string &  prefix = "" 
)
virtual

Save the given image to disk.

Returns the filename used, which is based on to_string(). The image filename will be appended to the prefix (if any is specified), and unless the prefix includes an absolute or relative path, will be saved into the current working directory.

References to_string().

Referenced by resize(), and save_all().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save() [2/2]

std::string vz::Imagination::save ( const std::string &  name,
const std::string &  prefix = "" 
)
virtual

Save the given image to disk.

Returns the filename used, which is based on to_string(). The image filename will be appended to the prefix (if any is specified), and unless the prefix includes an absolute or relative path, will be saved into the current working directory.

References to_type().

Here is the call graph for this function:

◆ save_all()

vz::VStr vz::Imagination::save_all ( const std::string &  prefix = "")
virtual

Save all of the image files to disk by repeatedly calling save() with all the image types.

Returns a vector of all the files that were saved.

See also
save()

References kInvalid, kMax, kMosaic, kUserDefined, mats, and save().

Referenced by resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_contours()

vz::VContours vz::Imagination::find_contours ( )
virtual

Find the contours of an image using EMatType::kCannyEdgeDetection and vz::find_contours().

The results are cached as Imagination::contours for later use. This method is called when get() is invoked with a parameter of EMatType::kFindContours or EMatType::kFindContoursIntervals.

References contours, vz::find_contours(), and kCannyEdgeDetection.

Referenced by get(), and resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_threshold() [1/2]

cv::Mat vz::Imagination::create_threshold ( void  )
virtual

Get a decent binary image.

This will try 2 different methods of creating a binary image, automatically return the best image, and discard the other.

This method is called when get() is invoked with a parameter of EMatType::kThreshold.

Note
If the resulting image seems to have a white background, the binary image will be inverted so that objects appear as white-on-black.

Examples of binary threshold images created by this method:

original image triangle threshold gaussian threshold output
threshold_capture_balanced.jpg
threshold_capture_triangle.png
threshold_capture_gaussian.png
threshold_capture_result.png
threshold_coins_balanced.jpg
threshold_coins_triangle.png
threshold_coins_gaussian.png
threshold_coins_result.png
threshold_sudoku_balanced.jpg
threshold_sudoku_triangle.png
threshold_sudoku_gaussian.png
threshold_sudoku_result.png

References vz::apply_gaussian_blur(), exists(), vz::invert(), kAutoGaussian, kO2BlurGreyscale, kO2GaussianBlur, kO2SimpleColourBalance, kThreshold, kThresholdDoG, kThresholdGaussian, kThresholdMeanC, kThresholdOtsu, kThresholdTriangle, kTriangle, mats, threshold_type, vz::to_greyscale(), and to_string().

Referenced by get(), and resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_hough_lines_and_angles()

cv::Mat vz::Imagination::create_hough_lines_and_angles ( )
virtual

Find the Hough lines, and make the necessary calculations to determine the angle of each line.

This method is called when get() is invoked with a parameter of EMatType::kHoughLines.

The lines, angles, intervals, and best angle are stored in hough_lines, hough_lines_angles, hough_lines_angle_intervals, and hough_lines_correction_angle.

References vz::best_value_from_intervals(), vz::find_hough_lines(), hough_lines, hough_lines_angle_intervals, hough_lines_angles, hough_lines_correction_angle, vz::intervals(), kHoughLines, kThreshold, mats, and to_string().

Referenced by get(), and resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_mosaic()

cv::Mat vz::Imagination::create_mosaic ( const bool  show_labels = true)
virtual

Create a mosaic using a thumbnail of all the images in mats. This is mostly for debug or logging purposes.

References kMosaic, kOriginalImage, mats, vz::resize(), and to_type().

Referenced by get(), and resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_threshold() [2/2]

cv::Mat vz::Imagination::create_threshold ( const EThresholdType  type)
virtual
Exceptions
std::invalid_argumentif the threshold type is invalid
std::logic_errorif the threshold image wasn't created (internal error)

References vz::apply_DoG_threshold(), kAutoGaussian, kAutoMeanC, kDifferenceOfGaussian, kInvalid, kMax, kO2BlurGreyscale, kOriginalImage, kOther, kOtsu, kTriangle, threshold_value, and to_string().

Here is the call graph for this function:

Member Data Documentation

◆ mats

Mats vz::Imagination::mats

Map where the key is an image type description, and the value is a OpenCV cv::Mat object.

While the map may be referenced directly, is is preferable to use get() or operator[] to ensure the requested image is built and cached correctly.

Example:

vz::Imagination img("capture.jpg");
process(mat);
Since
2019-04 Even though the key is now a std::string instead of EMatType, the enum is still the preferred way to access the images stored within an Imagination object.

Referenced by clear(), create_hough_lines_and_angles(), create_mosaic(), create_threshold(), get(), operator==(), replace(), save_all(), and set_original().

◆ threshold_value

double vz::Imagination::threshold_value

Auto-detected threshold value. This is only set once the EMatType::kThreshold image is created.

Referenced by clear(), create_threshold(), get(), and replace().

◆ threshold_type

EThresholdType vz::Imagination::threshold_type

The threshold type that was used. This is only set once the EMatType::kThreshold image is created.

Referenced by clear(), create_threshold(), and replace().

◆ contours

vz::VContours vz::Imagination::contours

A vector of contours.

This is only set once the EMatType::kFindContours image is created. This can then be used with functions such as cv::contourArea() and vz::add_contours_to_image().

Referenced by clear(), find_contours(), and get().

◆ contours_intervals

vz::VVDouble vz::Imagination::contours_intervals

Contour intervals. This is only set once the EMatType::kFindContoursIntervals image is created.

Referenced by clear().

◆ hough_lines

vz::VV4i vz::Imagination::hough_lines

The Hough lines, angles, angle intervals, and the correction angle are automatically calculated by create_hough_lines_and_angles() once get() is called with a parameter of EMatType::kHoughLines.

All detected Hough lines.

See also
vz::find_hough_lines()

Referenced by clear(), and create_hough_lines_and_angles().

◆ hough_lines_angles

vz::VDouble vz::Imagination::hough_lines_angles

A vector of all angles for all lines in hough_lines.

Referenced by clear(), and create_hough_lines_and_angles().

◆ hough_lines_angle_intervals

vz::VVDouble vz::Imagination::hough_lines_angle_intervals

The interval composed of all angles in hough_lines_angles.

See also
vz::intervals()

Referenced by clear(), and create_hough_lines_and_angles().

◆ hough_lines_correction_angle

double vz::Imagination::hough_lines_correction_angle

The best angle according to hough_lines_angle_intervals.

Referenced by clear(), create_hough_lines_and_angles(), and get().


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