69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
/*
|
||
* ====================================================
|
||
|
||
* 功能:色彩识别,将识别会“灰度”的24位图转化为256色8位图, 把识别为“黑白”图转化为二值化的8位图
|
||
* 作者:刘丁维
|
||
* 生成时间:2020/7/17
|
||
* 最近修改时间:2021/04/19
|
||
* 版本号:v1.0 2020/7/17
|
||
* v1.1 2020/12/15 调整策略,仅判断红色像素,存在红色像素为彩色,否则为灰度;删除输出结果,直接转换图像。
|
||
* v1.2 2020/12/16 增加颜色限制模式(输出结果只可能两种),增加结果访问接口
|
||
* v1.3 2021/04/19 修改识别策略,能够识别占比1‰的彩色图像。只区分彩色和灰度图。
|
||
* v1.4 2021/06/18 调整二级色彩区间,从原来的[90, 200]调整为[50, 200]。
|
||
* ====================================================
|
||
*/
|
||
|
||
#ifndef IMAGE_APPLY_COLOR_RECOGNITION_H
|
||
#define IMAGE_APPLY_COLOR_RECOGNITION_H
|
||
|
||
#include "ImageApply.h"
|
||
|
||
class GIMGPROC_LIBRARY_API CImageApplyColorRecognition : public CImageApply
|
||
{
|
||
public:
|
||
|
||
//色彩识别模式
|
||
enum ColorRecognitionMode
|
||
{
|
||
AllColor, //全色模式 识别结果可能会是彩色、灰度、黑白
|
||
Color_Gray, //彩色灰度模式 识别结果只会是彩色或者灰度
|
||
Color_Mono, //彩色黑白模式 识别结果只会是彩色或者黑白
|
||
Gray_Mono //灰度黑白模式 识别结果只会是灰度或者黑白
|
||
};
|
||
|
||
//色彩类型
|
||
enum ColorType
|
||
{
|
||
Color, //彩色
|
||
Gray, //灰度
|
||
Mono //黑白
|
||
};
|
||
public:
|
||
CImageApplyColorRecognition(ColorRecognitionMode mode = AllColor);
|
||
|
||
virtual ~CImageApplyColorRecognition(void);
|
||
|
||
virtual void apply(cv::Mat& pDib, int side);
|
||
|
||
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
|
||
|
||
/// <summary>
|
||
/// 获取图片色彩类型。配合void apply(cv::Mat&, int)接口使用
|
||
/// </summary>
|
||
/// <returns>色彩类型</returns>
|
||
ColorType getResult();
|
||
|
||
/// <summary>
|
||
/// 获取图片色彩类型。配合void apply(std::vector<cv::Mat>&, int)接口使用
|
||
/// </summary>
|
||
/// <returns>色彩类型数组</returns>
|
||
std::vector<ColorType> getResults();
|
||
|
||
private:
|
||
ColorType m_result;
|
||
std::vector<ColorType> m_results;
|
||
ColorRecognitionMode m_mode;
|
||
};
|
||
|
||
#endif // !IMAGE_APPLY_CONCATENATION_H
|