mirror of http://192.168.1.51:8099/lmh188/twain3.0
147 lines
3.0 KiB
C++
147 lines
3.0 KiB
C++
//#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
|
||
// };
|
||
//
|
||
// CImageApplyBWBinaray(ThresholdType type, int threshold = 180, 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
|
||
//
|
||
/*
|
||
* ====================================================
|
||
|
||
* 功能:二值化处理
|
||
* 作者:刘丁维
|
||
* 生成时间:2020/4/21
|
||
* 最近修改时间:2020/4/21
|
||
* 版本号:v1.0
|
||
|
||
* ====================================================
|
||
*/
|
||
|
||
#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形成比例关系,作为局部筛选阈值
|
||
*/
|
||
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
|
||
|