code_device/hgdriver/ImageProcess/ImageApplyChannel.h

80 lines
2.8 KiB
C
Raw Permalink Normal View History

2022-07-29 08:41:34 +00:00
/*
* ====================================================
* BGR图像中的单个通道
*
2023-07-31 10:55:31 +00:00
* 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_PlusGreen_Plus和Blue_Plus模式使CImageApplyAdjustColors增强通道
v1.5 2023/03/16 Red_PlusGreen_Plus和Blue_Plus除色增强比例
v1.5.1 2023/03/16 BUG
* v1.5.1
2022-07-29 08:41:34 +00:00
* ====================================================
*/
#ifndef IMAGE_APPLY_CHANNEL_H
#define IMAGE_APPLY_CHANNEL_H
#include "ImageApply.h"
class GIMGPROC_LIBRARY_API CImageApplyChannel : public CImageApply
{
public:
2023-07-31 10:55:31 +00:00
typedef enum channel
{
Red_Plus, //增强红色通道
Green_Plus, //增强绿色通道
Blue_Plus, //增强蓝色通道
2022-07-29 08:41:34 +00:00
All, //去除所有HSV色彩结构中S大于80的色彩
Invalid, //无效
Except_Red, //绿蓝色通道混合
Except_Green, //红蓝色通道混合
2023-07-31 10:55:31 +00:00
Except_Blue, //红绿色通道混合
Red, //红色通道
Green, //绿色通道
Blue, //蓝色通道
}Channel;
2022-07-29 08:41:34 +00:00
public:
2023-07-31 10:55:31 +00:00
CImageApplyChannel();
/// <summary>
/// 构造函数
/// 默认Red_Plus时m_scale = 0.333333Green_Plus时 m_scale = 1Blue_Plus时 m_scale = 1
/// </summary>
/// <param name="channel">通道模式</param>
CImageApplyChannel(Channel channel);
2022-07-29 08:41:34 +00:00
2023-07-31 10:55:31 +00:00
/// <summary>
/// 构造函数
/// </summary>
/// <param name="channel">通道模式</param>
/// <param name="scale">仅在Red_Plus、 Green_Plus、 Blue_Plus模式下生效。增强除色效果取值范围[0, +∞),值越大增强效果越明显</param>
CImageApplyChannel(Channel channel, double scale);
2022-07-29 08:41:34 +00:00
2023-07-31 10:55:31 +00:00
virtual ~CImageApplyChannel(void);
2022-07-29 08:41:34 +00:00
2023-07-31 10:55:31 +00:00
virtual void apply(cv::Mat& pDib, int side);
2022-07-29 08:41:34 +00:00
2023-07-31 10:55:31 +00:00
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
2022-07-29 08:41:34 +00:00
private:
2023-07-31 10:55:31 +00:00
void except_channel(const cv::Mat& src, cv::Mat& dst, int channel);
2022-07-29 08:41:34 +00:00
void colourless(const cv::Mat& src, cv::Mat& dst, uchar threshold = 80);
2023-07-31 10:55:31 +00:00
void channel_plus(const cv::Mat& src, cv::Mat& dst, int channel, double scale);
2022-07-29 08:41:34 +00:00
2023-07-31 10:55:31 +00:00
private:
Channel m_channel;
double m_scale;
2022-07-29 08:41:34 +00:00
};
#endif // !IMAGE_APPLY_CHANNEL_H