浏览代码

improve RemoveDuplicateOverlapParticles class.

gsp 1 年之前
父节点
当前提交
4a307f49ee

+ 0 - 8
OTSCPP/OTSClrInterface/CommonClr/OTSFieldDataClr.h

@@ -37,14 +37,6 @@ namespace OTSCLRINTERFACE {
 
 
 
-		//bool GetLeftBorderParticlesBiasDefine() { return mFieldData->get()->GetLeftBorderParticlesBiasDefine(); }
-		//void SetLeftBorderParticlesBiasDefine(bool ifSelect) { mFieldData->get()->SetLeftBorderParticlesBiasDefine( ifSelect); }
-		//bool GetRightBorderParticlesBiasDefine() { return mFieldData->get()->GetRightBorderParticlesBiasDefine(); }
-		//void SetRightBorderParticlesBiasDefine(bool ifSelect) { mFieldData->get()->SetRightBorderParticlesBiasDefine(  ifSelect); }
-		//bool GetUpBorderParticlesBiasDefine() { return mFieldData->get()->GetUpBorderParticlesBiasDefine(); }
-		//void SetUpBorderParticlesBiasDefine(bool ifSelect) { mFieldData->get()->SetUpBorderParticlesBiasDefine( ifSelect); }
-		//bool GetDownBorderParticlesBiasDefine() { return mFieldData->get()->GetDownBorderParticlesBiasDefine(); }
-		//void SetDownBorderParticlesBiasDefine(bool ifSelect) { mFieldData->get()->SetDownBorderParticlesBiasDefine(ifSelect); }
 	protected:
 		COTSFieldDataPtr* mFieldData;
 		

+ 1 - 14
OTSCPP/OTSData/OTSFieldData.h

@@ -57,16 +57,6 @@ namespace OTSDATA {
 		BOOL IsEmpty() { return m_listParticles.empty(); }
 		long Width;
 		long Height;
-
-
-		/*bool GetLeftBorderParticlesBiasDefine() { return leftBorderParticlesBias; }
-		void SetLeftBorderParticlesBiasDefine(bool ifSelect) { leftBorderParticlesBias = ifSelect; }
-		bool GetRightBorderParticlesBiasDefine() { return rightBorderParticlesBias; }
-		void SetRightBorderParticlesBiasDefine(bool ifSelect) { rightBorderParticlesBias = ifSelect; }
-		bool GetUpBorderParticlesBiasDefine() { return upBorderParticlesBias; }
-		void SetUpBorderParticlesBiasDefine(bool ifSelect) { upBorderParticlesBias = ifSelect; }
-		bool GetDownBorderParticlesBiasDefine() { return downBorderParticlesBias; }
-		void SetDownBorderParticlesBiasDefine(bool ifSelect) { downBorderParticlesBias = ifSelect; }*/
 	protected:
 
 		// cleanup
@@ -91,10 +81,7 @@ namespace OTSDATA {
 		//valid big particles
 		COTSParticleList m_listBigParticles;//used for  merging with other field later.
 
-		bool leftBorderParticlesBias=true;//true means the particles on the leftBorder will be included.
-		bool rightBorderParticlesBias=true;
-		bool upBorderParticlesBias=true;
-		bool downBorderParticlesBias=true;
+
 	};
 
 	typedef std::shared_ptr<COTSFieldData> __declspec(dllexport) COTSFieldDataPtr;

+ 2 - 2
OTSCPP/OTSData/OTSParticle.h

@@ -146,8 +146,8 @@ const double Pi = 3.14159;
 		void SetOrientation(double Orien) { m_Orientation = Orien; }
 		double GetDElong() { return m_De; }
 		void SetDElong(double de) { m_De = de; }
-		double GetAspectElong() { return m_De/m_Dm; }
-		double GetAspectRatio() { return m_DMax / m_Dm; }
+		double GetAspectElong() { return m_De/ m_DMin; }
+		double GetAspectRatio() { return m_DMax / m_DMin; }
 		
 		double GetVideo() {return m_cAveGray;}
 		double GetEqualCircleDiameter()

+ 18 - 23
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSField.cs

@@ -37,11 +37,6 @@ namespace OTSDataType
 
        protected   CImageHandler m_ImagePro;
 
-        //bool leftBorderParticlesBias = true;//true means that when there is overlap to process image the particles on the leftBorder will be included.
-        //bool rightBorderParticlesBias = true;
-        //bool upBorderParticlesBias = true;
-        //bool downBorderParticlesBias = true;
-
         protected List<COTSParticleClr> m_listAllParticles = new List<COTSParticleClr>();//hold up all the particles abstracted from bse image;
 
        protected  List<COTSParticleClr> m_listAnalysisParticles = new List<COTSParticleClr>();// according to xraylimit constraint,pick out the first big particles.
@@ -76,14 +71,6 @@ namespace OTSDataType
             m_otsRect = value;
         }
 
-        //public bool GetLeftBorderParticlesBiasDefine() { return leftBorderParticlesBias; }
-        //public void SetLeftBorderParticlesBiasDefine(bool ifSelect) { leftBorderParticlesBias = ifSelect; }
-        //public bool GetRightBorderParticlesBiasDefine() { return rightBorderParticlesBias; }
-        //public void SetRightBorderParticlesBiasDefine(bool ifSelect) { rightBorderParticlesBias = ifSelect; }
-        //public bool GetUpBorderParticlesBiasDefine() { return upBorderParticlesBias; }
-        //public void SetUpBorderParticlesBiasDefine(bool ifSelect) { upBorderParticlesBias = ifSelect; }
-        //public bool GetDownBorderParticlesBiasDefine() { return downBorderParticlesBias; }
-        //public void SetDownBorderParticlesBiasDefine(bool ifSelect) { downBorderParticlesBias = ifSelect; }
          public int GetMeasureSequence()
         {
             return measureSequence;
@@ -237,13 +224,15 @@ namespace OTSDataType
                     foreach (var p1 in rightsideparts)
                     {
                         int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
-                        p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
+                        p1.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
                         COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
                         PointF p1Center = p1rec.GetCenterPoint();
                         if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
                         {
-                            if (p.CalculateSimilarity(p1) > 0.95)
+                            var sim = p.CalculateSimilarity(p1);
+                            if ( sim> 0.95)
                             {
+                                log.Warn("remove left side duplicate particle,similarity:" + sim.ToString("F3"));
                                 findsimilar = true;
                                 break;
                             }
@@ -278,13 +267,15 @@ namespace OTSDataType
                     foreach (var p1 in othersideparts)
                     {
                         int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
-                        p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
+                        p1.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
                         COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
                         PointF p1Center = p1rec.GetCenterPoint();
                         if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
                         {
-                            if (p.CalculateSimilarity(p1) > 0.95)
+                            var sim = p.CalculateSimilarity(p1);
+                            if (sim > 0.95)
                             {
+                                log.Warn("remove upside duplicate particle,similarity:" + sim.ToString("F3"));
                                 findsimilar = true;
                                 break;
                             }
@@ -319,13 +310,15 @@ namespace OTSDataType
                     foreach (var p1 in othersideparts)
                     {
                         int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
-                        p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
+                        p1.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
                         COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
                         PointF p1Center = p1rec.GetCenterPoint();
                         if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
                         {
-                            if (p.CalculateSimilarity(p1) > 0.95)
+                            var sim = p.CalculateSimilarity(p1);
+                            if (sim > 0.95)
                             {
+                                log.Warn("remove right side duplicate particle,similarity:" + sim.ToString("F3"));
                                 findsimilar = true;
                                 break;
                             }
@@ -356,17 +349,19 @@ namespace OTSDataType
                     COTSRect prec = new COTSRect(pleft, ptop, pright, pbottom);
                     PointF pcenter = prec.GetCenterPoint();
                     bool findsimilar = false;
-                    var othersideparts = rightField.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap);
+                    var othersideparts = downField.GetSideParticlesByOverlap(SORTING_DIRECTION.UP, overlap);
                     foreach (var p1 in othersideparts)
                     {
                         int p1left = 0, p1right = 0, p1top = 0, p1bottom = 0;
-                        p.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
+                        p1.GetOTSRect(ref p1left, ref p1top, ref p1right, ref p1bottom);
                         COTSRect p1rec = new COTSRect(p1left, p1top, p1right, p1bottom);
                         PointF p1Center = p1rec.GetCenterPoint();
                         if (Math.Abs(pcenter.X - p1Center.X) < 2 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 2 * overlap)
                         {
-                            if (p.CalculateSimilarity(p1) > 0.95)
+                            var sim = p.CalculateSimilarity(p1);
+                            if (sim > 0.95)
                             {
+                                log.Warn("remove down side duplicate particle,similarity:" + sim.ToString("F3"));
                                 findsimilar = true;
                                 break;
                             }
@@ -479,7 +474,7 @@ namespace OTSDataType
                     int fldright = (int)fldrec.GetBottomRight().X;
                     int fldtop = (int)fldrec.GetTopLeft().Y;
                     int fldbottom = (int)fldrec.GetBottomRight().Y;
-                    if ((top - fldtop > 2 * overlap) && (fldbottom-bottom>2*overlap) && (left-fldleft>2*overlap) && (fldright-right>2*overlap))
+                    if ((Math.Abs(top - fldtop) > 2 * overlap) && (Math.Abs(fldbottom-bottom)>2*overlap) && (Math.Abs(left-fldleft)>2*overlap) && (Math.Abs(fldright-right)>2*overlap))
                     {
                         sideparts.Add(p);
                     }

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

@@ -833,18 +833,16 @@ namespace OTSModelSharp
             log.Info("Begin to process image and get all particles!");
             GetOriginalParticles(ref curFldData);
 
-            // second step :filter the finded particles.
-            log.Info("Begin to filter particles!");
-
-            FilterParticles(ref curFldData);
-
-            CalculateParticleAbsolutPos(ref curFldData);
-
             log.Info("Begin to Calculate the image property of every particle!");
             var analysisparts = curFldData.GetListAnalysisParticles();
             curFldData.CalParticleImageProp(analysisparts);//calculate particle image property such as feret diameter, DMAX etc.
+            CSampleParam pMsrParam = m_Sample.GetMsrParams();
+            COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
+            curFldData.RemoveDuplicateOverlapParticles(pImgProcessParam.GetOverlapParam());
+            log.Info("Begin to filter particles!");
+            FilterParticles(ref curFldData);
 
-          
+            CalculateParticleAbsolutPos(ref curFldData);
             return ;
 
         }
@@ -897,7 +895,7 @@ namespace OTSModelSharp
             var ifCollectxray = pMsrParam.GetXRayParam().GetUsingXray();
             // remove BES image background
             curFldData.RemoveImgBGAndGetParticles(pImgProcessParam, pixelsize, ifCollectxray);
-            curFldData.RemoveDuplicateOverlapParticles(pImgProcessParam.GetOverlapParam());
+           
 
             // check if this is an empty image
             if (curFldData.NoParticle())

+ 5 - 17
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CFieldPositionHelper.cs

@@ -138,7 +138,7 @@ namespace OTSModelSharp
             return m_listUnmeasuredFieldCentrePoints;
         }
 
-        public void CalculateBorderParticleBias(List<COTSField> previousFields, COTSField currentfld)
+        public void CalculateFieldNeighbour(List<COTSField> previousFields, COTSField currentfld)
         {
             List<Point> allFldPoints = new List<Point>();
             Dictionary<Point, COTSField> allflds = new Dictionary<Point, COTSField>();
@@ -154,36 +154,24 @@ namespace OTSModelSharp
             Point neighbor = new Point();
             if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, ref neighbor, (int)SORTING_DIRECTION.LEFT))
             {
-                //if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence())
-                //{
-                //    currentfld.SetLeftBorderParticlesBiasDefine(false);
                     currentfld.leftField = allflds[neighbor];
-                //}
+                
 
             }
             if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, ref neighbor, (int)SORTING_DIRECTION.RIGHT))
             {
-                //if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence())
-                //{
-                    //currentfld.SetRightBorderParticlesBiasDefine(false);
                     currentfld.rightField = allflds[neighbor];
-                //}
+               
             }
             if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, ref neighbor, (int)SORTING_DIRECTION.UP))
             {
-                //if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence())
-                //{
-                //    currentfld.SetUpBorderParticlesBiasDefine(false);
                     currentfld.upField = allflds[neighbor];
-                //}
+               
             }
             if (fieldmgrclr.FindNeighborField(allFldPoints, curFld, ref neighbor, (int)SORTING_DIRECTION.DOWN))
             {
-                //if (allflds[neighbor].GetMeasureSequence() < currentfld.GetMeasureSequence())
-                //{
-                //    currentfld.SetDownBorderParticlesBiasDefine(false);
                     currentfld.downField = allflds[neighbor];
-                //}
+               
             }
 
         }

+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -2783,7 +2783,7 @@ namespace OTSMeasureApp
                  sample.pFieldMgr.GetOTSRectByIndex(i,ref r);//get this field's global position(in the whole ots coordination)
                 newfld.SetOTSRect(r);
                 newfld.SetMeasureSequence(f.SequenceNum);
-                sample.pFieldMgr.CalculateBorderParticleBias(sample.GetFieldsData(), newfld);
+                sample.pFieldMgr.CalculateFieldNeighbour(sample.GetFieldsData(), newfld);
                 newfld.Sample = sample;
                 sample.AddNewField(newfld);
             }