Browse Source

edit overlap measure mode.

gsp 1 year ago
parent
commit
f13d9c0951

+ 1 - 1
OTSCPP/OTSClrInterface/CommonClr/OTSFieldDataClr.cpp

@@ -59,7 +59,7 @@ namespace OTSCLRINTERFACE {
 	{
 		COTSRect rec(left, top, right, bottom);
 
-		mFieldData->get()->SetRect(rec);
+		mFieldData->get()->SetOTSRect(rec);
 	}
 
 	COTSParticleListClr ^ COTSFieldDataClr::GetParticleList()

+ 5 - 0
OTSCPP/OTSClrInterface/ImageProClr/ImageProForClr.cpp

@@ -14,6 +14,11 @@ namespace OTSCLRINTERFACE
 	{
 		imgProEngine->UpdateImageProcessParam(perameter->GetImgPrcPrmPtr());
 		bool ret = imgProEngine->RemoveBGByCVconnectivities(bseImg->GetBSEImgPtr(), a_PixelSize, fieldData->GetOTSFieldDataPtr());
+		if (perameter->GetImgPrcPrmPtr()->GetOverlapParam() > 0)
+		{
+			imgProEngine->FilterParticlesByOverlap(fieldData->GetOTSFieldDataPtr());
+		}
+		
 		return ret;
 
 	}

+ 4 - 4
OTSCPP/OTSData/OTSFieldData.cpp

@@ -89,7 +89,7 @@ namespace OTSDATA {
 		{
 			xnID = m_nID;
 			xpoiPos = m_poiPos;
-			//xstrFieldFileFolder = m_strFieldFileFolder;
+			
 			parts.Clear();
 			for (auto pParticle : m_listParticles)
 			{
@@ -103,7 +103,7 @@ namespace OTSDATA {
 
 			m_nID = xnID.value();
 			m_poiPos = xpoiPos.value();
-			//m_strFieldFileFolder = xstrFieldFileFolder.value().c_str();
+			
 			m_listParticles.clear();
 			for (unsigned int i=0; i < parts.size(); i++)
 			{
@@ -229,7 +229,7 @@ namespace OTSDATA {
 		// initialization
 		m_nID = -1;
 		m_poiPos = CPoint(0, 0);
-		//m_strFieldFileFolder = _T("");
+		
 		m_listParticles.clear();
 	}
 
@@ -241,7 +241,7 @@ namespace OTSDATA {
 
 		m_nID = a_oSource.m_nID;
 		m_poiPos =  a_oSource.m_poiPos;
-		//m_strFieldFileFolder = a_oSource.m_strFieldFileFolder;
+	
 
 		// copy data over
 		for (auto pParticle : a_oSource.m_listParticles)

+ 3 - 3
OTSCPP/OTSData/OTSFieldData.h

@@ -28,8 +28,8 @@ namespace OTSDATA {
 		CPoint GetPosition() { return m_poiPos; }
 		void SetPosition(CPoint a_poiPos) { m_poiPos.x = a_poiPos.x;m_poiPos.y=a_poiPos.y; }
 
-		COTSRect GetRect() { return m_rect; }
-		void SetRect(COTSRect r) { m_rect = r; }
+		COTSRect GetOTSRect() { return m_rect; }
+		void SetOTSRect(COTSRect r) { m_rect = r; }
 
 	
 		// particle list
@@ -93,7 +93,7 @@ namespace OTSDATA {
 		//valid big particles
 		COTSParticleList m_listBigParticles;//used for  merging with other field later.
 
-		bool leftBorderParticlesBias=true;//true means that when there is a overlap to process field image the particles on the leftBorder will be included.
+		bool leftBorderParticlesBias=true;//true means the particles on the leftBorder will be included.
 		bool rightBorderParticlesBias=true;
 		bool upBorderParticlesBias=true;
 		bool downBorderParticlesBias=true;

+ 60 - 10
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -205,8 +205,15 @@ namespace OTSIMGPROC
 				}
 				BYTE nAveGray = (BYTE)(nPixelAll / nPixelNum);
 				pParticle->SetAveGray(nAveGray);
-			
+				auto fieldOTSRect = m_pFieldData->GetOTSRect();
+				CPoint leftTop = fieldOTSRect.GetTopLeft();
+				
+				CRect rectInSinglefld = pParticle->GetParticleRect();
+				CPoint OTSLeftTop = CPoint(leftTop.x + rectInSinglefld.left * a_pixelSize, leftTop.y - rectInSinglefld.top * a_pixelSize);
+				CPoint OTSRightBottom = CPoint(leftTop.x + rectInSinglefld.right * a_pixelSize, leftTop.y - rectInSinglefld.bottom * a_pixelSize);
 
+				COTSRect recInOTSCord = COTSRect(OTSLeftTop, OTSRightBottom);
+				pParticle->SetOTSRect(recInOTSCord);
 
 			}
 			m_pFieldData->SetParticleList(listParticleOut);
@@ -380,7 +387,15 @@ namespace OTSIMGPROC
 					}
 					BYTE nAveGray = (BYTE)(nPixelAll / nPixelNum);
 					pParticle->SetAveGray(nAveGray);
+					auto fieldOTSRect = m_pFieldData->GetOTSRect();
+					CPoint leftTop = fieldOTSRect.GetTopLeft();
 
+					CRect rectInSinglefld = pParticle->GetParticleRect();
+					CPoint OTSLeftTop = CPoint(leftTop.x + rectInSinglefld.left * a_pixelSize, leftTop.y - rectInSinglefld.top * a_pixelSize);
+					CPoint OTSRightBottom = CPoint(leftTop.x + rectInSinglefld.right * a_pixelSize, leftTop.y - rectInSinglefld.bottom * a_pixelSize);
+
+					COTSRect recInOTSCord = COTSRect(OTSLeftTop, OTSRightBottom);
+					pParticle->SetOTSRect(recInOTSCord);
 
 			}
 
@@ -393,25 +408,62 @@ namespace OTSIMGPROC
 
 		return TRUE;
 	}
-	BOOL COTSImageProcess::FilterParticlesByOverlap(COTSFieldDataPtr m_pFieldData)
+	void COTSImageProcess::FilterParticlesByOverlap(COTSFieldDataPtr m_pFieldData)
 	{
 		int overlap = m_imageProcessParam->GetOverlapParam();
 
-		COTSRect outBorderRect = m_pFieldData->GetRect();
+		COTSRect outBorderRect = m_pFieldData->GetOTSRect();
 		CPoint p1 = outBorderRect.GetTopLeft();
 		CPoint p2 = outBorderRect.GetBottomRight();
 		COTSRect inBorderRect = COTSRect(p1.x + overlap, p1.y - overlap, p2.x - overlap, p2.y + overlap);
+		CPoint inRecLt = inBorderRect.GetTopLeft();
+		CPoint inRecRb = inBorderRect.GetBottomRight();
 		COTSParticleList allparts = m_pFieldData->GetParticleList();
-
+		
+		COTSParticleList finalparts;
 		for (auto p : allparts)
 		{
 			auto partRec = p->GetOTSRect();
-
+			CPoint lt = partRec.GetTopLeft();
+			CPoint rb = partRec.GetBottomRight();
+			if (inBorderRect.PointInRect(lt) && inBorderRect.PointInRect(rb))//totally inside
+			{
+				finalparts.push_back(p);
+			}
+			if (inBorderRect.PointInRect(rb) && (lt.x<inRecLt.x))//on left side
+			{
+				if (m_pFieldData->GetLeftBorderParticlesBiasDefine())
+				{
+					finalparts.push_back(p);
+				}
+			}
+			if (inBorderRect.PointInRect(rb) && ( lt.y>inRecLt.y))//on top side
+			{
+				if (m_pFieldData->GetUpBorderParticlesBiasDefine())
+				{
+					finalparts.push_back(p);
+				}
+			}
+			if (inBorderRect.PointInRect(lt) && (rb.x > inRecRb.x) )//on right side
+			{
+				if (m_pFieldData->GetRightBorderParticlesBiasDefine())
+				{
+					finalparts.push_back(p);
+				}
+			}
+			if (inBorderRect.PointInRect(lt) && (rb.y < inRecRb.y) )//on bottom side
+			{
+				if (m_pFieldData->GetDownBorderParticlesBiasDefine())
+				{
+					finalparts.push_back(p);
+				}
+			}
+			
 		}
 
-
+		m_pFieldData->SetParticleList(finalparts);
+		
 		
-		return 0;
 	}
 	CIntRangePtr COTSImageProcess::CalBackground(CBSEImgPtr m_pBSEImg)
 	{
@@ -434,9 +486,7 @@ namespace OTSIMGPROC
 
 		linearSmooth5(originChartData, firstSmoothChart, MAXBYTE);
 		linearSmooth5(firstSmoothChart, secondSmooth, MAXBYTE);
-		//linearSmooth5(secondSmooth, secondSmooth, MAXBYTE);
-		/*linearSmooth5(secondSmooth, secondSmooth, MAXBYTE);
-		linearSmooth5(secondSmooth, secondSmooth, MAXBYTE);*/
+		
 		
 		//2. get down edge		
 		int nLengthEdge = MAXBYTE + 2;

+ 1 - 1
OTSCPP/OTSImagePro/OTSImageProcess.h

@@ -18,7 +18,7 @@ namespace OTSIMGPROC {
 
 		 BOOL GetParticlesBySpecialGrayRange(CBSEImgPtr m_pBSEImg, CIntRangePtr a_grayRange, CDoubleRangePtr a_diameterRange, double a_pixelSize, COTSFieldDataPtr m_pFieldData);
 	
-		 BOOL FilterParticlesByOverlap(COTSFieldDataPtr m_pFieldData);
+		 void FilterParticlesByOverlap(COTSFieldDataPtr m_pFieldData);
 
 		 CIntRangePtr CalBackground(CBSEImgPtr m_pBSEImg);
 		 std::vector<CIntRangePtr> CalcuGrayLevelRange(CBSEImgPtr m_pBSEImg);

+ 2 - 2
OTSCPP/OTSRptCalculate/GBCal/CGBCalculate.cpp

@@ -985,7 +985,7 @@ namespace OTSGBCalculate
 		
 
 			
-				(*itr)->SetRect(fldRec);
+				(*itr)->SetOTSRect(fldRec);
 				myOTSFields.push_back(*itr);
 
 			
@@ -1032,7 +1032,7 @@ namespace OTSGBCalculate
 			{
 				CPoint fieldPos = OTSField->GetPosition();
 			
-				CPoint fieldTopLeft = OTSField->GetRect().GetTopLeft();
+				CPoint fieldTopLeft = OTSField->GetOTSRect().GetTopLeft();
 				double fwidth = nFieldWidth;
 				double pixelsize = fwidth / a_sizePixelImage.cx;
 				CPoint xrayPosInFieldByPixel= part->GetXRayPos();

+ 2 - 0
OTSIncAMeasureApp/1-OTSMeasure/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -499,7 +499,9 @@ namespace OTSModelSharp
 
         string ConvertFormatOfDateString(string Time)
         {
+            
             string[] str1 = Time.Split(' ');
+           
             string[] str2 = str1[0].Split('/');
             return str2[2] + "/" + str2[1] + "/" + str2[0] +" "+ str1[1];
         }

+ 12 - 9
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CFieldPositionMgr.cs

@@ -36,6 +36,8 @@ namespace OTSModelSharp
         // SEM data (measurement)
         CSEMDataMsr m_poSEMDataMsr;
 
+        int overLap;
+
         // unmeasured field centre points list
         List<System.Drawing.Point> m_listUnmeasuredFieldCentrePoints;
         CFieldMgrClr fieldmgrclr;
@@ -45,7 +47,7 @@ namespace OTSModelSharp
             m_pMeasureArea = a_pMeasureArea;
             m_poImageScanParam = a_poImageScanParam;
             m_poSEMDataMsr = a_poSEMDataMsr;
-            
+            overLap = overlap;
 
             if (m_listFieldCentrePoints == null)
             {
@@ -101,7 +103,7 @@ namespace OTSModelSharp
         }
 
         // field centre points list
-        public bool GetFieldRectByIndex(int a_nIndex,ref System.Drawing.Rectangle a_rectField)
+        public bool GetFieldRectByIndex(int a_nIndex, ref System.Drawing.Rectangle a_rectField)
         {
             // check input
             if (a_nIndex < 0 || a_nIndex > (int)m_listFieldCentrePoints.Count)
@@ -115,15 +117,16 @@ namespace OTSModelSharp
             int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId;
             System.Drawing.Size sizePixelImage = RESOLUTION_VALUE[nResulotionId];
             // scan field size (x, y)
-            System.Drawing.Size sizeImage = new System.Drawing.Size
-            {
-                Width = m_poSEMDataMsr.GetScanFieldSize()
-            };
-            sizeImage.Height = sizeImage.Width * sizePixelImage.Height/ sizePixelImage.Width;
+            System.Drawing.Size sizeImage = new System.Drawing.Size();
+            
+            sizeImage.Width = m_poSEMDataMsr.GetScanFieldSize() - overLap;
+             
+            sizeImage.Height = m_poSEMDataMsr.GetScanFieldSize() * sizePixelImage.Height/ sizePixelImage.Width-overLap;
             // get left top
-            System.Drawing.Point ptLeftTop = m_listFieldCentrePoints[a_nIndex];
+            System.Drawing.Point ptcenter = m_listFieldCentrePoints[a_nIndex];
+            Point ptLt = new Point(ptcenter.X - sizeImage.Width / 2, ptcenter.Y + sizeImage.Height / 2);
             // get field rectangle
-            a_rectField =new System.Drawing.Rectangle(ptLeftTop, sizeImage);
+            a_rectField =new System.Drawing.Rectangle(ptLt, sizeImage);
 
             return true;
         }

+ 4 - 2
OTSIncAMeasureApp/ServiceCenter/CImageHandler.cs

@@ -221,7 +221,8 @@ namespace OTSModelSharp.ServiceCenter
             List<COTSParticleClr> parts = new List<COTSParticleClr>();
             List<COTSParticleClr> specialGreyparts = new List<COTSParticleClr>();
             var ecdrange = a_pImgProcessParam.GetIncAreaRange();
-            if (!RemoveBGAndGetParts(a_pImgIn, a_pImgProcessParam, a_pixelSize, ref parts))
+            var tempFld = new COTSField();
+            if (!RemoveBGAndGetParts(tempFld,a_pImgIn, a_pImgProcessParam, a_pixelSize, ref parts))
             {
                 return;
             }
@@ -300,7 +301,8 @@ namespace OTSModelSharp.ServiceCenter
             List<COTSParticleClr> parts = new List<COTSParticleClr>();
             List<COTSParticleClr> specialGreyparts = new List<COTSParticleClr>();
             var ecdrange = a_pImgProcessParam.GetIncAreaRange();
-            if (!RemoveBGAndGetParts(a_pImgIn, a_pImgProcessParam, a_pixelSize, ref parts))
+            var tempFld = new COTSField();
+            if (!RemoveBGAndGetParts(tempFld,a_pImgIn, a_pImgProcessParam, a_pixelSize, ref parts))
             {
                 return;
             }