#include "StdAfx.h" #include "ImageApplyThreshold.h" CImageApplyThreshold::CImageApplyThreshold(float thre) :m_thresh(thre) { } CImageApplyThreshold::~CImageApplyThreshold() { } void CImageApplyThreshold::apply(cv::Mat& pDib, int side) { #ifdef LOG FileTools::write_log("imgprc.txt", "enter CImageApplyThreshold apply"); #endif // LOG if (pDib.channels() >= 3) return; if (m_thresh == 0.0f) m_thresh = 140.0; cv::threshold(pDib, pDib, m_thresh, 255.0,cv::THRESH_OTSU); #ifdef LOG FileTools::write_log("imgprc.txt", "exit CImageApplyThreshold apply"); #endif // LOG } void CImageApplyThreshold::apply(std::vector& mats, bool isTwoSide) { if (mats.empty()) return; apply(mats[0], 0); if (isTwoSide && mats.size() > 1) apply(mats[1], 1); }