更新渗透算法,调整纸张尺寸

This commit is contained in:
mo1027728827@qq.com 2022-05-04 17:19:32 +08:00
parent e7db4bdf16
commit 93a39d30ac
3 changed files with 55 additions and 182 deletions

View File

@ -1,192 +1,64 @@
#include "ImageApplyRefuseInflow.h" #include "ImageApplyRefuseInflow.h"
#include "ImageApplyAdjustColors.h"
static unsigned char table_very_light[] = { CImageApplyRefuseInflow::CImageApplyRefuseInflow(int constrast)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, : m_adjustColor(new CImageApplyAdjustColors(0, constrast, 1.0f))
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, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 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 };
static unsigned char table_light[] = {
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, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 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 };
static unsigned char table_medium[] = {
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, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 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 };
static unsigned char table_strong[] = {
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 unsigned char table_very_strong[] = {
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, 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, 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, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255 };
CImageApplyRefuseInflow::CImageApplyRefuseInflow(int level)
{ {
m_level = level;
} }
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; (void)side;
static cv::Mat mat_table; #if 0
switch(m_level) static unsigned char table_contrast[] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
case 1: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
mat_table = cv::Mat(1, 256, CV_8UC1, table_very_light); 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
break; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
case 2: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
mat_table = cv::Mat(1, 256, CV_8UC1, table_light); 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
break; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
case 3: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
mat_table = cv::Mat(1, 256, CV_8UC1, table_medium); 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
break; 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
case 4: 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
mat_table = cv::Mat(1, 256, CV_8UC1, table_strong); 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
break; 50, 51, 52, 53, 54, 55, 56, 57, 198, 199,
case 5: 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
mat_table = cv::Mat(1, 256, CV_8UC1, table_very_strong); 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
break; 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
default: 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
mat_table = cv::Mat(1, 256, CV_8UC1, table_medium); 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
break; 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); 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)
{ {
(void)isTwoSide; (void)isTwoSide;
int i = 0; int i = 0;
for (cv::Mat& var : mats) { for (cv::Mat& var : mats) {
if (i != 0 && isTwoSide == false) if (i != 0 && isTwoSide == false)
break; break;
if (!var.empty()) if (!var.empty())
apply(var, 0); apply(var, 0);
i++; i++;
} }
} }

View File

@ -1,11 +1,12 @@
/* /*
* ==================================================== * ====================================================
* 1¤71¤71¤7<EFBFBD>1ť11¤71¤71¤71¤71¤7<EFBFBD>0Č61¤71¤7<EFBFBD>0č91¤71¤7<EFBFBD>0Ë21¤7<EFBFBD>0»21¤7 *
* 1¤71¤71¤7<EFBFBD>1°31¤71¤71¤71¤71¤7<EFBFBD>0Ë4 *
* 1¤71¤71¤71¤7<EFBFBD>0µ21¤74Ź22020/4/21 * 2020/4/21
* 1¤71¤71¤71¤7<EFBFBD>1¬01¤7<EFBFBD>0µ21¤74Ź22020/4/21 * v1.0 2020/04/21
* 1¤7·Ú1¤7<EFBFBD>001¤7v1.0 * v1.1 2022/05/04
* v1.1
* ==================================================== * ====================================================
*/ */
@ -15,10 +16,11 @@
#include "ImageApply.h" #include "ImageApply.h"
class CImageApplyAdjustColors;
class CImageApplyRefuseInflow : public CImageApply class CImageApplyRefuseInflow : public CImageApply
{ {
public: public:
CImageApplyRefuseInflow(int level); CImageApplyRefuseInflow(int constrast = 15);
virtual ~CImageApplyRefuseInflow(); virtual ~CImageApplyRefuseInflow();
@ -27,6 +29,6 @@ public:
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide); virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private: private:
int m_level = 3; CImageApplyAdjustColors* m_adjustColor;
}; };
#endif // !IMAGE_APPLY_REFUSE_INFLOW_H #endif // !IMAGE_APPLY_REFUSE_INFLOW_H

View File

@ -4,7 +4,7 @@ using namespace std;
namespace Device { namespace Device {
PaperSize::PaperSize() PaperSize::PaperSize(int pid):pid_(pid)
{ {
InitPaperMap(); InitPaperMap();
} }
@ -30,7 +30,6 @@ namespace Device {
else else
papersize.insert({ MaxSize,SIZE{297,420 * 2} }); papersize.insert({ MaxSize,SIZE{297,420 * 2} });
if(pid_ == 0x300) if(pid_ == 0x300)
papersize.insert({ USStatement,SIZE{210,(long)(297 * 1.5)} }); papersize.insert({ USStatement,SIZE{210,(long)(297 * 1.5)} });
else else