Explorar o código

change the xray position calculation method.

gsp %!s(int64=3) %!d(string=hai) anos
pai
achega
7e1c69e901

+ 6 - 0
OTSCPP/OTSData/OTSParticle.h

@@ -57,6 +57,10 @@ const double Pi = 3.14159;
 		// area
 		double GetArea() { return m_dArea; }
 		void SetArea(double a_nArea) { m_dArea = a_nArea; }
+
+		// Pixel area
+		double GetPixelArea() { return m_dPixelArea; }
+		void SetPixelArea(double a_nArea) { m_dPixelArea = a_nArea; }
 		
 		// rectangle
 		CRect GetParticleRect() { return m_rectParticle; }
@@ -174,6 +178,8 @@ protected:
 		// area
 		double m_dArea;
 
+		double m_dPixelArea;
+
 		// rectangle
 		CRect m_rectParticle;
 

+ 30 - 18
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -1334,9 +1334,9 @@ namespace OTSIMGPROC
 				  int h = stats.at<int>(i, CC_STAT_HEIGHT);
 				  int area = stats.at<int>(i, CC_STAT_AREA);
 
-				  double dArea = area * a_pixelSize * a_pixelSize;
+				  double actualArea = area * a_pixelSize * a_pixelSize;
 
-				  if (dArea >= partAreaMin && dArea < partAreaMax)
+				  if (actualArea >= partAreaMin && actualArea < partAreaMax)
 				  {
 				 
 				
@@ -1364,8 +1364,18 @@ namespace OTSIMGPROC
 						}
 
 					}
-				
-					GetParticles(rectMax.x, rectMax.y, rectMax.width, rectMax.height, imageROI.data, listParticleOut);
+					COTSParticleList roiParts;
+					if (GetParticles(rectMax.x, rectMax.y, rectMax.width, rectMax.height, imageROI.data, roiParts))
+					{
+						COTSParticlePtr roiPart = roiParts[0];//normally ,we will find only one part in the roi.
+						roiPart->SetXRayPos(CPoint(center_x, center_y));
+						CRect r = CRect(x, y, x + w, y + h);
+						roiPart->SetParticleRect(r);
+						roiPart->SetArea(actualArea);
+						roiPart->SetPixelArea(area);
+						listParticleOut.push_back(roiPart);
+					}
+
 
 
 				  
@@ -1521,10 +1531,17 @@ namespace OTSIMGPROC
 
 					}
 
-
-
-		
-					GetParticles(rectMax.x, rectMax.y, rectMax.width, rectMax.height, imageROI.data, listParticleOut);//We will find more than one particle in one ROI. and We cann't decide which are the valid and not valid.So we will do another filter again later.
+					COTSParticleList roiParts;
+					if (GetParticles(rectMax.x, rectMax.y, rectMax.width, rectMax.height, imageROI.data, roiParts))
+					{
+						COTSParticlePtr roiPart = roiParts[0];//normally ,we will find only one part in the roi.
+						roiPart->SetXRayPos(CPoint(center_x, center_y));
+						CRect r = CRect(x, y, x + w, y + h);
+						roiPart->SetParticleRect(r);
+						roiPart->SetArea(actualArea);
+						roiPart->SetPixelArea(area);
+						listParticleOut.push_back(roiPart);
+					}
 					
 				}
 				
@@ -1561,8 +1578,6 @@ namespace OTSIMGPROC
 
 						for (unsigned int i = 0; i < nLengthS; i++)
 						{
-
-
 							long nValueTemp = (long)*(pSrcImg + nHeightS * nWidthImg + nStartS + i);
 							nPixelAll += nValueTemp;
 						}
@@ -1570,12 +1585,9 @@ namespace OTSIMGPROC
 					BYTE nAveGray = (BYTE)(nPixelAll / nPixelNum);
 					pParticle->SetAveGray(nAveGray);
 
-					
-				
-				
-				
 
 			}
+
 			m_pFieldData->SetParticleList(listParticleOut);
 		}
 
@@ -2074,12 +2086,12 @@ namespace OTSIMGPROC
 		{
 			COTSParticlePtr pParticle = COTSParticlePtr(new COTSParticle());
 			pParticle->SetFeature(pFeature);
-			if (!pParticle->CalCoverRect())
+			/*if (!pParticle->CalCoverRect())
 			{
 				return FALSE;
-			}
+			}*/
 		
-			COTSSegmentsList listSegment = pFeature->GetSegmentsList();
+			/*COTSSegmentsList listSegment = pFeature->GetSegmentsList();
 
 			long nPixelNum = 0;
 
@@ -2092,7 +2104,7 @@ namespace OTSIMGPROC
 
 			}
 			
-			pParticle->SetArea(nPixelNum);
+			pParticle->SetArea(nPixelNum);*/
 			a_listParticle.push_back(pParticle);
 		}
 

+ 0 - 2
OTSIncAMeasureApp/0-OTSModel/Measure/1-OTSInclution/SmplMeasureInclution.cs

@@ -139,8 +139,6 @@ namespace OTSModelSharp
             COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
             curFldData.InitParticles(pImgProcessParam,dPixelSize);
 
-         
-     
             // make sure the particles list is not empty
             if (curFldData.NoAnalysisParticle())
             {

+ 1 - 5
OTSIncAMeasureApp/0-OTSModel/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -740,11 +740,7 @@ namespace OTSModelSharp
                     MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(poiFieldCentre.Y);
 
                     m_pMsrThread.SendMessageToMeasureApp(MsgFieldEnd);
-                    //while (bSaveThreadWorking )//wait untill all the field data has been saved.
-                    //{
-                    //    Thread.Sleep(100);
-                    //    log.Info("db saving!");
-                    //}
+           
 
                 }
                 while (bSaveThreadWorking)//wait untill all the field data has been saved.

+ 11 - 21
OTSIncAMeasureApp/0-OTSModel/Measure/BSEPicData/COTSFieldData.cs

@@ -166,9 +166,9 @@ namespace OTSModelSharp
             CDoubleRange oAreaRange = a_pImageProcessParam.GetIncAreaRange();
             double rMin = oAreaRange.GetStart() / 2.0;
             double rMax = oAreaRange.GetEnd() / 2.0;
-            double dAreaLow = rMin*rMin * 3.14159;
-            double dAreaHigh = rMax*rMax * 3.14159;
-    
+            double dAreaLow = rMin * rMin * 3.14159;
+            double dAreaHigh = rMax * rMax * 3.14159;
+
 
             int nTagId = 0;
             //int nAnalysisPartId = 0;
@@ -176,18 +176,10 @@ namespace OTSModelSharp
          
             int overSizenum = 0;
             log.Info("Total Particles: " + m_listAllParticles.Count);
-            foreach (COTSParticleClr pParticle in m_listAllParticles)
+            foreach (COTSParticleClr pParticle in m_listAllParticles)//m_listAllParticles memorize all the particles .
             {
                
-             
-                double dPartArea = pParticle.GetArea();
-                dPartArea = dPartArea * a_dPixelSize * a_dPixelSize;
-                pParticle.SetArea(dPartArea);
-            
-                int nAveGrayLevel = pParticle.GetAveGray();
-
-
-
+      
 
                 pParticle.SetTagId(nTagId);//give all the conforming particles a unified sequence no.
               
@@ -204,29 +196,27 @@ namespace OTSModelSharp
             log.Info("Normal Particles (>"+ dAreaLow .ToString("f2") + "): "+ "<" + dAreaHigh.ToString("f2") + "): " + m_listAnalysisParticles.Count);
            
 
-            List<COTSParticleClr> sizeConformingXrayParts = new List<COTSParticleClr>();
-            foreach (var p in m_listXrayParticles)
+            List<COTSParticleClr> xrayParts = new List<COTSParticleClr>();
+            foreach (var p in m_listXrayParticles)//m_listXrayParticles memorize all the particles which needs xray analysis.
             {
                 if (p.GetTagId() > -1)//it has been initialized and it's a valid particle.
                 {
-                    sizeConformingXrayParts.Add(p);
+                    xrayParts.Add(p);
 
 
                 }
             
             }
-            m_listXrayParticles = sizeConformingXrayParts;
+            m_listXrayParticles = xrayParts;
 
         }
        
         public bool CreateXrayList(List<COTSParticleClr> a_listParticles)
         {
-            // go through particles list
-            //a_listPosXRay.Clear();
-            //int nXrayIndex = 0;
+      ;
             foreach (COTSParticleClr pPart in a_listParticles)
             {
-                pPart.CalXrayPos();
+             
          
                 // get xray position
                 System.Drawing.Point poi = (System.Drawing.Point)pPart.GetXRayPos();