1)修改二值化参数为 51 10 30 235

2黑白默认红色增强
This commit is contained in:
masayume 2020-12-29 21:33:26 +08:00
parent 9eceba0f96
commit 3d939f21e2
8 changed files with 26 additions and 16 deletions

View File

@ -79,6 +79,7 @@ void CImageProcPage::ImageProcPageUpdate(int val,bool is_Crop)
if (val == 2) if (val == 2)
{ {
((CButton*)GetDlgItem(IDC_CHECKDETACHNOISE))->EnableWindow(true); ((CButton*)GetDlgItem(IDC_CHECKDETACHNOISE))->EnableWindow(true);
//m_temp->SetCurSel(4);
} }
else else
{ {

View File

@ -518,7 +518,12 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
#else // REAL300DPI #else // REAL300DPI
settings->resolution_native = 200.0f; settings->resolution_native = 200.0f;
#endif #endif
//if (settings->pixtype == TWPT_BW)
//{
// settings->pixtype = TWPT_RGB;
// settings->enhance_color = Enchace_Color::Enhance_Red;
// settings->filter = 3;//none
//}
UpdateUi(); UpdateUi();
} }

View File

@ -215,7 +215,7 @@ void ImageMatQueue::setparam(const GScanCap& param)
if (param.filter != 3 || param.enhance_color) { if (param.filter != 3 || param.enhance_color) {
int channel = 0; //filter none r g b enhance none r g b int channel = 0; //filter none r g b enhance none r g b
if (param.filter != 3) { channel = param.filter; } if (param.filter != 3) { channel = param.filter; }
else { channel = param.enhance_color + 3; } else { channel = param.enhance_color + 4; }
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyChannel(static_cast<CImageApplyChannel::Channel>(channel)))); m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyChannel(static_cast<CImageApplyChannel::Channel>(channel))));
} }

View File

@ -103,7 +103,7 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
cv::Point(thre_dst.cols - 1, thre_dst.rows - 1), cv::Point(0, thre_dst.rows - 1) }; cv::Point(thre_dst.cols - 1, thre_dst.rows - 1), cv::Point(0, thre_dst.rows - 1) };
std::vector<std::vector<cv::Point>> rectEdges{ rectEdge }; std::vector<std::vector<cv::Point>> rectEdges{ rectEdge };
cv::drawContours(thre_dst, rectEdges, 0, cv::Scalar::all(0)); cv::drawContours(thre_dst, rectEdges, 0, cv::Scalar::all(0));
cv::Mat element = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(m_indent, m_indent)); cv::Mat element = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(m_indent*2, m_indent*2));
cv::erode(thre_dst, thre_dst, element, cv::Point(-1, -1), 1); cv::erode(thre_dst, thre_dst, element, cv::Point(-1, -1), 1);
} }
hierarchy.clear(); hierarchy.clear();

View File

@ -36,8 +36,8 @@ void CImageApplyBWBinaray::apply(cv::Mat& pDib, int side)
cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY); cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY);
cv::Mat integ; cv::Mat integ;
int blockSize = 25;//ÁÚÓò³ß´ç int blockSize = 51;//ÁÚÓò³ß´ç
int threshold = 1; int threshold = 10;
int low = 30; int low = 30;
int up = 235; int up = 235;
int halfSize = blockSize / 2; int halfSize = blockSize / 2;

View File

@ -116,7 +116,7 @@ cv::Mat CImageApplyDiscardBlank::getRoiMat(const cv::Mat& image)
processRectR(image, rect, contour, scale, thresh, blobSize); processRectR(image, rect, contour, scale, thresh, blobSize);
cv::Rect rect2 = rect.boundingRect(); cv::Rect rect2 = rect.boundingRect();
cv::Rect inRect = rect2 & cv::Rect(0, 0, image.cols, image.rows); cv::Rect inRect = rect2 & cv::Rect(0, 0, image.cols, image.rows);
gap = cv::max(inRect.width - rect.size.width, inRect.height - rect.size.height) + 100; gap = cv::max(inRect.width - rect.size.width, inRect.height - rect.size.height) + 20;
inRect = cv::Rect(inRect.x + gap, inRect.y + gap, inRect.width - gap * 2, inRect.height - gap * 2); inRect = cv::Rect(inRect.x + gap, inRect.y + gap, inRect.width - gap * 2, inRect.height - gap * 2);
if (inRect.width <= 0 || inRect.height <= 0) if (inRect.width <= 0 || inRect.height <= 0)

View File

@ -762,17 +762,20 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
if (mech == PixelType::Rgb || mech == PixelType::Gray || mech == PixelType::BlackWhite) if (mech == PixelType::Rgb || mech == PixelType::Gray || mech == PixelType::BlackWhite)
{ {
m_scanparam->pixtype = (int)mech; m_scanparam->pixtype = (int)mech;
if (m_scanparam->pixtype == (int)PixelType::Rgb) if (m_scanparam->pixtype == (int)PixelType::Rgb){
{
m_scanparam->filter = (byte)Filter::None; m_scanparam->filter = (byte)Filter::None;
m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_None; m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_None;
m_scanparam->automaticcolor = FALSE; m_scanparam->automaticcolor = FALSE;
} }
else else{
{
m_scanparam->multi_output_red = 0;//非彩色模式下多流输出不可用 m_scanparam->multi_output_red = 0;//非彩色模式下多流输出不可用
//if (m_scanparam->pixtype == (int)PixelType::BlackWhite) //if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
// m_scanparam->sharpen = SharpenBlur::Sharpen_None; // m_scanparam->sharpen = SharpenBlur::Sharpen_None;
if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
{
m_scanparam->filter = (byte)Filter::None;
m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_Red;
}
} }
m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1); m_iBitdepth = mech == PixelType::Rgb ? 24 : (mech == PixelType::Gray ? 8 : 1);
return success(); return success();
@ -786,8 +789,7 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::IAutomaticColorEnabled] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticColorEnabled] = [this](Msg msg, Capability& data)->Result {
if (Msg::Set == msg) { if (Msg::Set == msg) {
auto mech = data.currentItem<CapType::IAutomaticColorEnabled>(); auto mech = data.currentItem<CapType::IAutomaticColorEnabled>();
if (mech) if (mech){
{
m_scanparam->automaticcolor = TRUE; m_scanparam->automaticcolor = TRUE;
m_scanparam->filter = (byte)Filter::None; m_scanparam->filter = (byte)Filter::None;
m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_None; m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_None;
@ -805,10 +807,8 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_caps[CapType::IAutomaticColorNonColorPixelType] = [this](Msg msg, Capability& data)->Result { m_caps[CapType::IAutomaticColorNonColorPixelType] = [this](Msg msg, Capability& data)->Result {
if (msg == Msg::Set) { if (msg == Msg::Set) {
auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>(); auto mech = data.currentItem<CapType::IAutomaticColorNonColorPixelType>();
if (m_scanparam->automaticcolor == TRUE) if (m_scanparam->automaticcolor == TRUE){
{ if ((UInt16)mech == 0 || (UInt16)mech == 1){
if ((UInt16)mech == 0 || (UInt16)mech == 1)
{
m_scanparam->automaticcolortype = (UInt16)mech; m_scanparam->automaticcolortype = (UInt16)mech;
return success(); return success();
} }
@ -1373,6 +1373,10 @@ Result HuagaoDs::identityOpenDs(const Identity&) {
m_scanparam->enhance_color = (byte)mech; m_scanparam->enhance_color = (byte)mech;
if (mech != (byte)Enchace_Color::Enhance_None) if (mech != (byte)Enchace_Color::Enhance_None)
m_scanparam->filter = (byte)Filter::None; m_scanparam->filter = (byte)Filter::None;
if (m_scanparam->pixtype == (int)PixelType::BlackWhite)
m_scanparam->enhance_color = (byte)Enchace_Color::Enhance_Red;
return success(); return success();
} }
} }

Binary file not shown.