更新防渗透算法和调整防渗透等级

This commit is contained in:
yangjiaxuan 2023-11-21 17:37:16 +08:00
parent e79bed40dd
commit b3a7503be9
10 changed files with 58 additions and 68 deletions

View File

@ -1,52 +1,21 @@
#include "ImageApplyRefuseInflow.h" #include "ImageApplyRefuseInflow.h"
#include "ImageApplyAdjustColors.h"
CImageApplyRefuseInflow::CImageApplyRefuseInflow(int constrast) CImageApplyRefuseInflow::CImageApplyRefuseInflow(int d, int sigmaColor, int sigmaSpace)
: m_adjustColor(new CImageApplyAdjustColors(0, constrast, 1.0f)) : m_d(d)
, m_sigmaColor(sigmaColor)
, m_sigmaSpace(sigmaSpace)
{ {
} }
CImageApplyRefuseInflow::~CImageApplyRefuseInflow() CImageApplyRefuseInflow::~CImageApplyRefuseInflow()
{ {
delete m_adjustColor;
} }
void CImageApplyRefuseInflow::apply(cv::Mat& pDib, int side) void CImageApplyRefuseInflow::apply(cv::Mat& pDib, int side)
{ {
(void)side; cv::Mat dst;
#if 0 cv::bilateralFilter(pDib, dst, m_d, m_sigmaColor, m_sigmaSpace);
static unsigned char table_contrast[] = { pDib = dst;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255 };
static cv::Mat mat_table(1, 256, CV_8UC1, table_contrast);
cv::LUT(pDib, mat_table, pDib);
#else
m_adjustColor->apply(pDib, side);
#endif
} }
void CImageApplyRefuseInflow::apply(std::vector<cv::Mat>& mats, bool isTwoSide) void CImageApplyRefuseInflow::apply(std::vector<cv::Mat>& mats, bool isTwoSide)

View File

@ -6,7 +6,9 @@
* 2020/4/21 * 2020/4/21
* v1.0 2020/04/21 * v1.0 2020/04/21
* v1.1 2022/05/04 * v1.1 2022/05/04
* v1.1 * v2.0 2023/08/12
* v2.1 2023/10/20 BUG
* v2.1
* ==================================================== * ====================================================
*/ */
@ -16,11 +18,17 @@
#include "ImageApply.h" #include "ImageApply.h"
class CImageApplyAdjustColors;
class GIMGPROC_LIBRARY_API CImageApplyRefuseInflow : public CImageApply class GIMGPROC_LIBRARY_API CImageApplyRefuseInflow : public CImageApply
{ {
public: public:
CImageApplyRefuseInflow(int constrast = 15);
/// <summary>
/// 构造函数
/// </summary>
/// <param name="d">邻域的直径。取值范围[0, +∞)</param>
/// <param name="sigmaColor">颜色空间滤波器的标准差。取值范围[0, +∞)</param>
/// <param name="sigmaSpace">空域滤波器的标准差。取值范围[0, +∞。注意当d为0时该参数才生效</param>
CImageApplyRefuseInflow(int d, int sigmaColor, int sigmaSpace);
virtual ~CImageApplyRefuseInflow(); virtual ~CImageApplyRefuseInflow();
@ -29,6 +37,8 @@ public:
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide); virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private: private:
CImageApplyAdjustColors* m_adjustColor; int m_d;
int m_sigmaColor;
int m_sigmaSpace;
}; };
#endif // !IMAGE_APPLY_REFUSE_INFLOW_H #endif // !IMAGE_APPLY_REFUSE_INFLOW_H

View File

@ -105,11 +105,11 @@ g_text_direction[] =
g_permeate_lv[] = g_permeate_lv[] =
{ {
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_JR), PERMAEATE_WEAKER}, {MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_JR), PERMAEATE_WEAK},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_R), PERMAEATE_WEAK}, {MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_R), PERMAEATE_WEAKER},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_YB), PERMAEATE_ORDINARY}, {MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_YB), PERMAEATE_ORDINARY},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_Q), PERMAEATE_STRONG}, {MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_Q), PERMAEATE_STRONGER},
{MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_JQ), PERMAEATE_STRONGER} {MAKE_ID_AND_STR(ID_OPTION_VALUE_FZSTDJ_JQ), PERMAEATE_STRONG}
}, },
g_img_quality[] = g_img_quality[] =
{ {

View File

@ -5334,7 +5334,18 @@ void hg_scanner::image_process(std::shared_ptr<tiny_buffer>& buffer, uint32_t id
if ((img_conf_.refuseInflow) && (pid_ != 0x239 && pid_ != 0x439)) if ((img_conf_.refuseInflow) && (pid_ != 0x239 && pid_ != 0x439))
{ {
int lv = 5 + image_prc_param_.bits.is_permeate_lv_ * 10; //image_prc_param_.bits.is_permeate_lv_ = 0 1 2 3 4 int lv = image_prc_param_.bits.is_permeate_lv_; //image_prc_param_.bits.is_permeate_lv_ = 0 1 2 3 4
if (0 == lv)
lv = 3;
else if (1 == lv)
lv = 5;
else if (2 == lv)
lv = 7;
else if (3 == lv)
lv = 9;
else if (4 == lv)
lv = 11;
hg_imgproc::antiInflow(ImagePrc_pHandle_, lv); hg_imgproc::antiInflow(ImagePrc_pHandle_, lv);
(this->*dump_img_)(ImagePrc_pHandle_, "antiInflow"); (this->*dump_img_)(ImagePrc_pHandle_, "antiInflow");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
#include "image_process.h" #include "image_process.h"
#include "../wrapper/hg_log.h" #include "../wrapper/hg_log.h"
#include <vector> #include <vector>
#include <string.h> #include <string.h>
@ -977,7 +977,7 @@ namespace hg_imgproc
std::vector<cv::Mat> mats(mats_); std::vector<cv::Mat> mats(mats_);
mats_.clear(); mats_.clear();
CImageApplyRefuseInflow Inflow(permeate_lv); CImageApplyRefuseInflow Inflow(permeate_lv, 200, 200);
for (size_t i = 0; i < mats.size(); ++i) for (size_t i = 0; i < mats.size(); ++i)
{ {
Inflow.apply(mats[i],img_conf_.is_duplex); Inflow.apply(mats[i],img_conf_.is_duplex);