twain3.0/huagao/ImageProcess/ImageApplyBWBinaray.h

87 lines
2.3 KiB
C
Raw Normal View History

2020-06-20 03:17:06 +00:00
/*
* ====================================================
*
*
* 2020/4/21
* 2020/5/28 v1.1
2020/5/29 v1.2
2020/6/19 v1.3
2020/12/21 v1.3.1
2020/12/21 v1.3.2 blockSize,5125
* v1.3.2
2020-06-20 03:17:06 +00:00
* ====================================================
*/
#ifndef IMAGE_APPLY_BW_BINARAY_H
#define IMAGE_APPLY_BW_BINARAY_H
#include "ImageApply.h"
class CImageApplyBWBinaray:public CImageApply
{
public:
enum class ThresholdType
{
THRESH_BINARY = 0, //传统二值化
THRESH_OTSU, //大津阈值
ADAPTIVE_GAUSSIAN, //高斯局部自适应阈值
ADAPTIVE_MEAN, //均值局部自适应阈值
ERROR_DIFFUSION //错误扩散
};
/*
* type [in]:
* threshold [in]:THRESH_OTSU时无效
* blockSize [in]:ADAPTIVE_GAUSSIAN和ADAPTIVE_MEAN模式有效
* constant [in]:ADAPTIVE_GAUSSIAN和ADAPTIVE_MEAN模式有效blockSize形成比例关系
*/
2020-06-20 03:17:06 +00:00
CImageApplyBWBinaray(ThresholdType type, int threshold = 120, int blockSize = 25, int constant = 5);
CImageApplyBWBinaray();
virtual ~CImageApplyBWBinaray(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
double getThreshold() { return m_threshold; }
ThresholdType getThresholdType() { return m_type; }
int getBlockSize() { return m_blockSize; }
double getConstant() { return m_constant; }
void setThreshold(double value) { m_threshold = value; }
void setThresholdType(ThresholdType type) { m_type = type; }
void setBlockSize(int value) { m_blockSize = value; }
void setConstant(double value) { m_constant = value; }
private:
void errorDiffuse(cv::Mat& image);
private:
double m_threshold;
ThresholdType m_type;
int m_blockSize;
double m_constant;
uchar* m_table;
};
#endif //!IMAGE_APPLY_BW_BINARAY_H