code_device/hgdriver/ImageProcess/ImageApplyChannel.h

80 lines
2.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ====================================================
* 功能通道提取又名除色。可提取BGR图像中的单个通道、两种通道的混合以及去除彩色像素的图像目标图像均为灰度图
* 作者:刘丁维
* 生成时间2020/04/21
* 最近修改时间v1.0 2020/04/21
v1.1 2020/06/11 在除红时,增加对比度,提高除色效果。
v1.2 2020/07/21 修正之前增强红绿蓝效果的色彩配比。
v1.3 2021/05/24 替换红色增强算法方案。
v1.4 2023/03/01 增加Red_Plus、Green_Plus和Blue_Plus模式。取消使用CImageApplyAdjustColors增强通道。
v1.5 2023/03/16 可自定义Red_Plus、Green_Plus和Blue_Plus除色增强比例。
v1.5.1 2023/03/16 修复通道切换的BUG。
* 版本号v1.5.1
* ====================================================
*/
#ifndef IMAGE_APPLY_CHANNEL_H
#define IMAGE_APPLY_CHANNEL_H
#include "ImageApply.h"
class GIMGPROC_LIBRARY_API CImageApplyChannel : public CImageApply
{
public:
typedef enum channel
{
Red_Plus, //增强红色通道
Green_Plus, //增强绿色通道
Blue_Plus, //增强蓝色通道
All, //去除所有HSV色彩结构中S大于80的色彩
Invalid, //无效
Except_Red, //绿蓝色通道混合
Except_Green, //红蓝色通道混合
Except_Blue, //红绿色通道混合
Red, //红色通道
Green, //绿色通道
Blue, //蓝色通道
}Channel;
public:
CImageApplyChannel();
/// <summary>
/// 构造函数
/// 默认Red_Plus时m_scale = 0.333333Green_Plus时 m_scale = 1Blue_Plus时 m_scale = 1
/// </summary>
/// <param name="channel">通道模式</param>
CImageApplyChannel(Channel channel);
/// <summary>
/// 构造函数
/// </summary>
/// <param name="channel">通道模式</param>
/// <param name="scale">仅在Red_Plus、 Green_Plus、 Blue_Plus模式下生效。增强除色效果取值范围[0, +∞),值越大增强效果越明显</param>
CImageApplyChannel(Channel channel, double scale);
virtual ~CImageApplyChannel(void);
virtual void apply(cv::Mat& pDib, int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private:
void except_channel(const cv::Mat& src, cv::Mat& dst, int channel);
void colourless(const cv::Mat& src, cv::Mat& dst, uchar threshold = 80);
void channel_plus(const cv::Mat& src, cv::Mat& dst, int channel, double scale);
private:
Channel m_channel;
double m_scale;
};
#endif // !IMAGE_APPLY_CHANNEL_H