소스 검색

optimize the CVRemoveBG method.

gsp 1 년 전
부모
커밋
186d13617b
3개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제
  1. 7 7
      OTSCPP/OTSImagePro/BaseFunction.cpp
  2. 1 1
      OTSCPP/OTSImagePro/BaseFunction.h
  3. 2 2
      OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

+ 7 - 7
OTSCPP/OTSImagePro/BaseFunction.cpp

@@ -261,7 +261,7 @@ Mat AdjustContrastY(const Mat& img)
 }
 
 
-void CVRemoveBG(const cv::Mat& img, cv::Mat& dst,int bgstart,int bgend, long& nNumParticle)
+void CVRemoveBG(const cv::Mat& img, cv::Mat& dst,int bgstart,int bgend/*, long& nNumParticle*/)
 {
 	int min_gray = bgstart;
 	int max_gray = bgend;
@@ -279,10 +279,10 @@ void CVRemoveBG(const cv::Mat& img, cv::Mat& dst,int bgstart,int bgend, long& nN
 	uchar lutvalues[256];
 	for (int i = 0; i < 256; i++)
 	{
-		if (i < min_gray || i > max_gray)
+		if (i <= min_gray || i >= max_gray)
 		{
-			lutvalues[i] = i;
-			nNumParticle++;
+			lutvalues[i] = 255;
+			/*nNumParticle++;*/
 		}
 		else
 		{
@@ -380,9 +380,9 @@ void AutoRemove_background_OTS(const cv::Mat& img, cv::Mat& dst, int black_thing
 	}
 	else
 	{
-		/*cv::GaussianBlur(image, temp1, cv::Size(3, 3), 1.0, 1.0);
-		pAdaptiveManifoldFilter->filter(temp1, dst_adapt, image);*/
-		dst_adapt = image;
+		cv::GaussianBlur(image, temp1, cv::Size(3, 3), 1.0, 1.0);
+		pAdaptiveManifoldFilter->filter(temp1, dst_adapt, image);
+		//dst_adapt = image;
 		cv::ThresholdTypes img_ThresholdTypes = cv::ThresholdTypes::THRESH_BINARY_INV;
 		cv::Mat image_Negate;
 		if (both_black_bright)

+ 1 - 1
OTSCPP/OTSImagePro/BaseFunction.h

@@ -30,7 +30,7 @@ void ImageStretchByHistogram(const Mat& src, Mat& dst);
 
 Mat AdjustContrastY(const Mat& img);
 
-void CVRemoveBG(const cv::Mat& img, cv::Mat& dst, int bgstart, int bgend, long& nNumParticle);
+void CVRemoveBG(const cv::Mat& img, cv::Mat& dst, int bgstart, int bgend/*, long& nNumParticle*/);
 
 void RemoveBG_old(const cv::Mat& img, cv::Mat& dst, int nBGStart, int nBGEnd, long& nNumParticle);
 /// <summary>

+ 2 - 2
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -44,8 +44,8 @@ namespace OTSModelSharp
       
         protected Queue<COTSField> fieldQueue=new Queue<COTSField>();
       
-        protected IClassifyEngine m_classifyEngine;
-       
+        protected IClassifyEngine m_classifyEngine; 
+
 
         public CSmplMeasure( string a_strWorkingFolder, COTSSample a_pSample)
         {