Visual Servoing Platform  version 3.6.1 under development (2024-04-25)
vpImgproc.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Static functions for basic image processing functions.
32  */
33 
40 #ifndef _vpImgproc_h_
41 #define _vpImgproc_h_
42 
43 #include <visp3/core/vpConfig.h>
44 #include <visp3/core/vpImage.h>
45 #include <visp3/core/vpImageMorphology.h>
46 #include <visp3/imgproc/vpContours.h>
47 
48 #define USE_OLD_FILL_HOLE 0
49 
50 namespace vp
51 {
57 {
60  RETINEX_HIGH = 2
61 };
62 
66 typedef enum
67 {
94 
98 typedef enum vpGammaMethod
99 {
101  GAMMA_LOG_BASED = 1,
106  GAMMA_CDF_BASED = 3,
116 
125 VISP_EXPORT std::string vpGammaMethodList(const std::string &pref = "<", const std::string &sep = " , ",
126  const std::string &suf = ">");
127 
134 VISP_EXPORT std::string vpGammaMethodToString(const vpGammaMethod &type);
135 
142 VISP_EXPORT vpGammaMethod vpGammaMethodFromString(const std::string &name);
143 
148 {
149  GAMMA_RGB = 0,
150  GAMMA_HSV = 1,
154 
163 VISP_EXPORT std::string vpGammaColorHandlingList(const std::string &pref = "<", const std::string &sep = " , ",
164  const std::string &suf = ">");
165 
172 VISP_EXPORT std::string vpGammaColorHandlingToString(const vpGammaColorHandling &type);
173 
180 VISP_EXPORT vpGammaColorHandling vpGammaColorHandlingFromString(const std::string &name);
181 
192 VISP_EXPORT void adjust(vpImage<unsigned char> &I, double alpha, double beta);
193 
205 VISP_EXPORT void adjust(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2, double alpha, double beta);
206 
217 VISP_EXPORT void adjust(vpImage<vpRGBa> &I, const double alpha, double beta);
218 
230 VISP_EXPORT void adjust(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2, double alpha, double beta);
231 
261 VISP_EXPORT void clahe(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2, int blockRadius = 150,
262  int bins = 256, float slope = 3.0f, bool fast = true);
263 
291 VISP_EXPORT void clahe(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2, int blockRadius = 150, int bins = 256,
292  float slope = 3.0f, bool fast = true);
293 
304 VISP_EXPORT void equalizeHistogram(vpImage<unsigned char> &I, const vpImage<bool> *p_mask = nullptr);
305 
317 VISP_EXPORT void equalizeHistogram(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2,
318  const vpImage<bool> *p_mask = nullptr);
319 
333 VISP_EXPORT void equalizeHistogram(vpImage<vpRGBa> &I, bool useHSV = false);
334 
349 VISP_EXPORT void equalizeHistogram(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2, bool useHSV = false);
350 
366 VISP_EXPORT void gammaCorrection(vpImage<unsigned char> &I, const float &gamma, const vpGammaMethod &method = vp::GAMMA_MANUAL,
367  const vpImage<bool> *p_mask = nullptr);
368 
385 VISP_EXPORT void gammaCorrection(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2, const float &gamma,
386  const vpGammaMethod &method = vp::GAMMA_MANUAL, const vpImage<bool> *p_mask = nullptr);
387 
401 VISP_EXPORT void gammaCorrection(vpImage<vpRGBa> &I, const float &gamma, const vpGammaColorHandling &colorHandling = vp::GAMMA_RGB,
402  const vpGammaMethod &method = vp::GAMMA_MANUAL, const vpImage<bool> *p_mask = nullptr);
403 
418 VISP_EXPORT void gammaCorrection(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2, const float &gamma,
419  const vpGammaColorHandling &colorHandling = vp::GAMMA_RGB,
420  const vpGammaMethod &method = vp::GAMMA_MANUAL, const vpImage<bool> *p_mask = nullptr);
421 
443 VISP_EXPORT void retinex(vpImage<vpRGBa> &I, int scale = 240, int scaleDiv = 3, int level = RETINEX_UNIFORM,
444  double dynamic = 1.2, int kernelSize = -1);
445 
468 VISP_EXPORT void retinex(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2, int scale = 240, int scaleDiv = 3,
469  int level = RETINEX_UNIFORM, double dynamic = 1.2, int kernelSize = -1);
470 
478 VISP_EXPORT void stretchContrast(vpImage<unsigned char> &I);
479 
488 VISP_EXPORT void stretchContrast(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2);
489 
497 VISP_EXPORT void stretchContrast(vpImage<vpRGBa> &I);
498 
507 VISP_EXPORT void stretchContrast(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2);
508 
517 VISP_EXPORT void stretchContrastHSV(vpImage<vpRGBa> &I);
518 
528 VISP_EXPORT void stretchContrastHSV(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2);
529 
539 VISP_EXPORT void unsharpMask(vpImage<unsigned char> &I, float sigma, double weight = 0.6);
540 
551 VISP_EXPORT void unsharpMask(const vpImage<unsigned char> &I, vpImage<unsigned char> &Ires, float sigma,
552  double weight = 0.6);
553 
563 VISP_EXPORT void unsharpMask(vpImage<vpRGBa> &I, float sigma, double weight = 0.6);
564 
575 VISP_EXPORT void unsharpMask(const vpImage<vpRGBa> &I, vpImage<vpRGBa> &Ires, float sigma, double weight = 0.6);
576 
587 VISP_EXPORT void connectedComponents(const vpImage<unsigned char> &I, vpImage<int> &labels, int &nbComponents,
589 
597 VISP_EXPORT void fillHoles(vpImage<unsigned char> &I
598 #if USE_OLD_FILL_HOLE
599  ,
601 #endif
602 );
603 
615 VISP_EXPORT void floodFill(vpImage<unsigned char> &I, const vpImagePoint &seedPoint, const unsigned char oldValue,
616  const unsigned char newValue,
618 
637 VISP_EXPORT void reconstruct(const vpImage<unsigned char> &marker, const vpImage<unsigned char> &mask,
638  vpImage<unsigned char> &h_kp1 /*alias I */,
640 
651 VISP_EXPORT unsigned char autoThreshold(vpImage<unsigned char> &I, const vp::vpAutoThresholdMethod &method,
652  const unsigned char backgroundValue = 0,
653  const unsigned char foregroundValue = 255);
654 } // namespace vp
655 
656 #endif
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
VISP_EXPORT void clahe(const vpImage< unsigned char > &I1, vpImage< unsigned char > &I2, int blockRadius=150, int bins=256, float slope=3.0f, bool fast=true)
Definition: vpCLAHE.cpp:198
VISP_EXPORT void adjust(vpImage< unsigned char > &I, double alpha, double beta)
Definition: vpImgproc.cpp:177
VISP_EXPORT void floodFill(vpImage< unsigned char > &I, const vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const vpImageMorphology::vpConnexityType &connexity=vpImageMorphology::CONNEXITY_4)
Definition: vpFloodFill.cpp:71
VISP_EXPORT void connectedComponents(const vpImage< unsigned char > &I, vpImage< int > &labels, int &nbComponents, const vpImageMorphology::vpConnexityType &connexity=vpImageMorphology::CONNEXITY_4)
VISP_EXPORT void stretchContrast(vpImage< unsigned char > &I)
Definition: vpImgproc.cpp:705
VISP_EXPORT void stretchContrastHSV(vpImage< vpRGBa > &I)
Definition: vpImgproc.cpp:816
VISP_EXPORT void gammaCorrection(vpImage< unsigned char > &I, const float &gamma, const vpGammaMethod &method=vp::GAMMA_MANUAL, const vpImage< bool > *p_mask=nullptr)
Definition: vpImgproc.cpp:601
VISP_EXPORT void equalizeHistogram(vpImage< unsigned char > &I, const vpImage< bool > *p_mask=nullptr)
Definition: vpImgproc.cpp:220
VISP_EXPORT void fillHoles(vpImage< unsigned char > &I)
Definition: vpMorph.cpp:45
VISP_EXPORT void reconstruct(const vpImage< unsigned char > &marker, const vpImage< unsigned char > &mask, vpImage< unsigned char > &h_kp1, const vpImageMorphology::vpConnexityType &connexity=vpImageMorphology::CONNEXITY_4)
Definition: vpMorph.cpp:121
VISP_EXPORT void retinex(vpImage< vpRGBa > &I, int scale=240, int scaleDiv=3, int level=RETINEX_UNIFORM, double dynamic=1.2, int kernelSize=-1)
Definition: vpRetinex.cpp:244
VISP_EXPORT void unsharpMask(vpImage< unsigned char > &I, float sigma, double weight=0.6)
Definition: vpImgproc.cpp:867
VISP_EXPORT unsigned char autoThreshold(vpImage< unsigned char > &I, const vp::vpAutoThresholdMethod &method, const unsigned char backgroundValue=0, const unsigned char foregroundValue=255)
vpGammaMethod
Gamma Correction automatic methods.
Definition: vpImgproc.h:99
@ GAMMA_CDF_BASED
Definition: vpImgproc.h:106
@ GAMMA_LOG_BASED
Definition: vpImgproc.h:101
@ GAMMA_SPATIAL_VARIANT_BASED
Definition: vpImgproc.h:111
@ GAMMA_MANUAL
Definition: vpImgproc.h:100
@ GAMMA_NONLINEAR_BASED
Definition: vpImgproc.h:104
@ GAMMA_METHOD_COUNT
Definition: vpImgproc.h:114
@ GAMMA_CLASSIFICATION_BASED
Definition: vpImgproc.h:109
VISP_EXPORT vpGammaColorHandling vpGammaColorHandlingFromString(const std::string &name)
Cast a string into a vp::vpGammaColorHandling.
Definition: vpImgproc.cpp:160
vpGammaColorHandling
How to handle color images when applying Gamma Correction.
Definition: vpImgproc.h:148
@ GAMMA_RGB
Definition: vpImgproc.h:149
@ GAMMA_HSV
Definition: vpImgproc.h:150
@ GAMMA_COLOR_HANDLING_COUNT
Definition: vpImgproc.h:152
VISP_EXPORT std::string vpGammaColorHandlingList(const std::string &pref="<", const std::string &sep=" , ", const std::string &suf=">")
Get the list of available vpGammaColorHandling.
Definition: vpImgproc.cpp:129
RETINEX_LEVEL
Definition: vpImgproc.h:57
@ RETINEX_HIGH
Enhances the bright regions of the image.
Definition: vpImgproc.h:60
@ RETINEX_LOW
Enhances dark regions of the image.
Definition: vpImgproc.h:59
@ RETINEX_UNIFORM
Tends to treat all image intensities similarly.
Definition: vpImgproc.h:58
vpAutoThresholdMethod
Definition: vpImgproc.h:67
@ AUTO_THRESHOLD_ISODATA
Definition: vpImgproc.h:76
@ AUTO_THRESHOLD_HUANG
Definition: vpImgproc.h:68
@ AUTO_THRESHOLD_INTERMODES
Definition: vpImgproc.h:72
@ AUTO_THRESHOLD_TRIANGLE
Definition: vpImgproc.h:88
@ AUTO_THRESHOLD_MEAN
Definition: vpImgproc.h:80
@ AUTO_THRESHOLD_OTSU
Definition: vpImgproc.h:84
VISP_EXPORT std::string vpGammaMethodList(const std::string &pref="<", const std::string &sep=" , ", const std::string &suf=">")
Get the list of available vpGammaMethod.
Definition: vpImgproc.cpp:69
VISP_EXPORT std::string vpGammaColorHandlingToString(const vpGammaColorHandling &type)
Cast a vp::vpGammaColorHandling into a string, to know its name.
Definition: vpImgproc.cpp:143
VISP_EXPORT vpGammaMethod vpGammaMethodFromString(const std::string &name)
Cast a string into a vp::vpGammaMethod.
Definition: vpImgproc.cpp:112
VISP_EXPORT std::string vpGammaMethodToString(const vpGammaMethod &type)
Cast a vp::vpGammaMethod into a string, to know its name.
Definition: vpImgproc.cpp:83