Browse Source

Merge branch 'OTSRelease3_0' into cxs

cxs 1 year ago
parent
commit
c31fa17e6d

+ 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
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -590,7 +590,7 @@ namespace OTSIMGPROC
 		long nBGEnd;
 		long nPartStart;
 		long nPartEnd;
-		long nNumParticle = 0;
+		//long nNumParticle = 0;
 		if (a_pImageProcessParam->GetBGRemoveType() == OTS_BGREMOVE_TYPE::MANUAL)
 		{
 			nBGStart = a_pImageProcessParam->GetBGGray().GetStart();
@@ -601,7 +601,7 @@ namespace OTSIMGPROC
 			
 			
 			
-			CVRemoveBG(srcImgMat, rstMat, nBGStart, nBGEnd,nNumParticle);
+			CVRemoveBG(srcImgMat, rstMat, nBGStart, nBGEnd);
 			//RemoveBG_old(srcImgMat, rstMat, nBGStart, nBGEnd, nNumParticle);
 
 			pPixel = rstMat.data;

+ 38 - 32
OTSCPP/OTSRptCalculate/GBCal/GBFieldData.cpp

@@ -300,7 +300,7 @@ namespace OTSGBCalculate
 
 		
 		// get all the all particles for each level			
-		//mapAllParticles.clear();
+	
 		for (auto pParticle : m_listOTSParticles)
 		{	// compute length width ratio
 			if (pParticle->GetType() == OTS_PARTICLE_TYPE::INVALID)//here we take all the particles except Invalid.
@@ -340,14 +340,14 @@ namespace OTSGBCalculate
 					listAparts.push_back(pParticle);
 					
 					
-					//mapAllParticles[pParticle] = GBParticle(pParticle, GB_CLASSIFY_TYPE::A_TYPE, wt);
+					
 				}
 				else if (nChemicalType == GB_CHEMICAL_TYPE::CHE_O || nChemicalType== GB_CHEMICAL_TYPE::CHE_Si || nChemicalType == GB_CHEMICAL_TYPE::CHE_Al)
 				{
 					// C
 					listCparts.push_back(pParticle);
 					
-					//mapAllParticles[pParticle] = GBParticle(pParticle, GB_CLASSIFY_TYPE::C_TYPE, wt);
+					
 				}
 
 			}
@@ -355,34 +355,23 @@ namespace OTSGBCalculate
 			{
 				
 				// B, or D or DS				
-				double dFeretDiameter = pParticle->GetFeretDiameter();
-				if (dFeretDiameter >= 13)
+				
+				
+				if (nChemicalType == GB_CHEMICAL_TYPE::CHE_S)//if it contains sulfide then it is a A particle.
 				{
-					// DS		
-					CGBParticlePtr gbp = CGBParticlePtr(new GBParticle());
-					gbp->myType = GB_CLASSIFY_TYPE::DS_TYPE;
-					gbp->myOTSParts.push_back(pParticle);
-					listDSParticles.push_back(gbp);
-
-					
+					listAparts.push_back(pParticle);
+						
 				}
 				else
 				{
-					if (nChemicalType == GB_CHEMICAL_TYPE::CHE_S)//if it contains sulfide then it is a A particle.
-					{
-						listAparts.push_back(pParticle);
-						
-					}
-					else
-					{
-						// B or D
+					// B or D
 						
-							listBAndDParticles.push_back(pParticle);
+						listBAndDParticles.push_back(pParticle);
 						
-					}
+				}
 					
 
-				}
+				
 			}
 
 
@@ -463,8 +452,17 @@ namespace OTSGBCalculate
 							listDSuperParticles.push_back(pGBParticle);
 							break;
 						}
-						//mapAllParticles[pGBParticle.myPart] = GBParticle(pGBParticle.myPart, GB_CLASSIFY_TYPE::D_TYPE, wt);
-					//}
+
+						double dFeretDiameter = pGBParticle->GetFeretDiameter();
+						if (dFeretDiameter >= 13)
+						{
+							// DS		
+							
+							listDSParticles.push_back(pGBParticle);
+
+
+						}
+						
 					
 				}
 				else if (pGBParticle->myOTSParts.size() == 2)//there's only two parts,it's still  D part
@@ -489,6 +487,15 @@ namespace OTSGBCalculate
 							listDSuperParticles.push_back(gbp);
 							break;
 						}
+						double dFeretDiameter = gbp->GetFeretDiameter();
+						if (dFeretDiameter >= 13)
+						{
+							// DS		
+
+							listDSParticles.push_back(gbp);
+
+
+						}
 					}
 				}
 				else if(pGBParticle->myOTSParts.size()>= 3)
@@ -816,7 +823,7 @@ namespace OTSGBCalculate
 		COTSParticleList listBAndDParticles;//
 		listBAndDParticles.clear();
 		// get all the all particles for each level			
-		//mapAllParticles.clear();
+		
 		for (auto pParticle : listParticle)
 		{	// compute length width ratio
 			if (pParticle->GetType() == OTS_PARTICLE_TYPE::INVALID)//here we take all the particles except Invalid.
@@ -855,7 +862,7 @@ namespace OTSGBCalculate
 						listAThinParticles.push_back(gbp);
 					}
 
-					//mapAllParticles[pParticle] = GBParticle(pParticle, GB_CLASSIFY_TYPE::A_TYPE, wt);
+					
 				}
 				else if (nChemicalType == GB_CHEMICAL_TYPE::CHE_O)
 				{
@@ -866,13 +873,13 @@ namespace OTSGBCalculate
 					{
 						listAThinParticles.push_back(gbp);
 					}
-					//mapAllParticles[pParticle] = GBParticle(pParticle, GB_CLASSIFY_TYPE::C_TYPE, wt);
+					
 				}
 			}
 			else//长宽比小于3的颗粒,有3种情况,一种是串条状的B类颗粒,一种是单独的D类颗粒,如果费雷特直径大于13则为DS类颗粒
 			{
 				// B, or D or DS
-				// compute Feret's diameter	
+				
 				double dFeretDiameter = pParticle->GetFeretDiameter();
 				if (dFeretDiameter >= 13)
 				{
@@ -884,8 +891,7 @@ namespace OTSGBCalculate
 				else
 				{
 					// B or D
-					//GBParticle gbP = GBParticle(pParticle, GB_CLASSIFY_TYPE::INVALID, GB_WIDTH_TYPE::INVALID);
-					//不能确定是B或D,先设为INVALID
+					
 					listBAndDParticles.push_back(pParticle);
 
 				}
@@ -909,7 +915,7 @@ namespace OTSGBCalculate
 					{
 						listDThinParticles.push_back(pGBParticle);
 					}
-					//mapAllParticles[pGBParticle.myPart] = GBParticle(pGBParticle.myPart, GB_CLASSIFY_TYPE::D_TYPE, wt);
+					
 				}
 				else//找到了相邻接的颗粒,不是孤立的则为B类
 				{

+ 3 - 5
OTSCPP/OTSRptCalculate/GBCal/GBFieldData.h

@@ -71,8 +71,7 @@ namespace OTSGBCalculate
 		
 		COTSFieldDataList myReleventOTSFlds;
 		COTSParticleList m_listOTSParticles;
-		//std::map<COTSParticlePtr, GBParticle> mapAllParticles;
-		//std::vector <GBParticle> allMyParticles;
+	
 		void CategoryByMethod1();
 
 		// caculate Level by method 2
@@ -100,12 +99,11 @@ namespace OTSGBCalculate
 		// duplication
 		void Duplicate(const CGBFieldData& a_oSource);
 
-		// caculate Level by method 1
-
+	
 
 		// caculate Level Width
 		BOOL CaculateLevelThinWidth(COTSParticleList& a_listParticles, GB_CLASSIFY_TYPE a_nLevel);
-		//GB_WIDTH_TYPE CaculateLevelWidth(COTSParticlePtr Particle, GB_CLASSIFY_TYPE a_nLevel);
+		
 
 		BOOL CaculateLevelFatWidth(COTSParticleList& a_listParticles, GB_CLASSIFY_TYPE a_nLevel);
 		BOOL CaculateSuper(COTSParticleList& a_listParticles, GB_CLASSIFY_TYPE a_nLevel);

+ 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)
         {