|
|
@@ -6,6 +6,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Drawing.Imaging;
|
|
|
+using System.Reflection;
|
|
|
using System.Xml;
|
|
|
|
|
|
namespace OTSDataType
|
|
|
@@ -483,10 +484,10 @@ namespace OTSDataType
|
|
|
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 (Math.Abs(pcenter.X - p1Center.X) < 1 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 1 * overlap)
|
|
|
{
|
|
|
- var sim = p.CalculateSimilarity(p1);
|
|
|
- if (sim > 0.95)
|
|
|
+ double sim = 0;
|
|
|
+ if (judgeParticlesAreDuplicate(p, pcenter, p1, p1Center, out sim))
|
|
|
{
|
|
|
log.Warn("remove left side duplicate particle,similarity:" + sim.ToString("F3"));
|
|
|
log.Warn("P1:" + p.GetImgPortraitString());
|
|
|
@@ -526,10 +527,10 @@ namespace OTSDataType
|
|
|
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 (Math.Abs(pcenter.X - p1Center.X) < 1 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 1 * overlap)
|
|
|
{
|
|
|
- var sim = p.CalculateSimilarity(p1);
|
|
|
- if (sim > 0.95)
|
|
|
+ double sim = 0;
|
|
|
+ if (judgeParticlesAreDuplicate(p, pcenter, p1, p1Center, out sim))
|
|
|
{
|
|
|
log.Warn("remove upside duplicate particle,similarity:" + sim.ToString("F3"));
|
|
|
log.Warn("P1:" + p.GetImgPortraitString());
|
|
|
@@ -579,10 +580,10 @@ namespace OTSDataType
|
|
|
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 (Math.Abs(pcenter.X - p1Center.X) < 1 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 1 * overlap)
|
|
|
{
|
|
|
- var sim = p.CalculateSimilarity(p1);
|
|
|
- if (sim > 0.95)
|
|
|
+ double sim = 0;
|
|
|
+ if (judgeParticlesAreDuplicate(p, pcenter, p1, p1Center, out sim))
|
|
|
{
|
|
|
log.Warn("remove right side duplicate particle,similarity:" + sim.ToString("F3"));
|
|
|
log.Warn("P1:" + p.GetImgPortraitString());
|
|
|
@@ -621,16 +622,16 @@ namespace OTSDataType
|
|
|
PointF p1Center = p1rec.GetCenterPoint();
|
|
|
if (Math.Abs(pcenter.X - p1Center.X) < 1 * overlap && Math.Abs(pcenter.Y - p1Center.Y) < 1 * overlap)
|
|
|
{
|
|
|
- var sim = p.CalculateSimilarity(p1);
|
|
|
- if (sim > 0.90)
|
|
|
+ double sim = 0;
|
|
|
+ if(judgeParticlesAreDuplicate(p, pcenter, p1, p1Center,out sim))
|
|
|
{
|
|
|
log.Warn("remove down side duplicate particle,similarity:" + sim.ToString("F3"));
|
|
|
log.Warn("P1:" + p.GetImgPortraitString());
|
|
|
log.Warn("P2:" + p1.GetImgPortraitString());
|
|
|
duplicateparts.Add(p);
|
|
|
-
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -696,6 +697,23 @@ namespace OTSDataType
|
|
|
this.SetListAnalysisParticles(finalparts);
|
|
|
log.Info("removing duplicate particles result:" + finalparts.Count);
|
|
|
}
|
|
|
+ private bool judgeParticlesAreDuplicate( COTSParticleClr p,PointF pCenter,COTSParticleClr p1,PointF p1Center,out double sim)
|
|
|
+ {
|
|
|
+ sim = p.CalculateSimilarity(p1);
|
|
|
+ double d = Math.Sqrt(Math.Pow(pCenter.X - p1Center.X, 2) + Math.Pow(pCenter.Y - p1Center.Y, 2));
|
|
|
+ double d1 = p.GetFeretDiameter() / 2;
|
|
|
+ double d2 = p1.GetFeretDiameter() / 2;
|
|
|
+ if (d <= (d1 + d2) && sim > 0.90)
|
|
|
+ {
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (d > (d1 + d2) && sim > 0.97)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
private List<COTSParticleClr> GetSideParticlesByOverlap(SORTING_DIRECTION direction, int overlap)
|
|
|
{
|
|
|
List<COTSParticleClr> sideparts = new List<COTSParticleClr>();
|