|
@@ -389,7 +389,7 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
return points;
|
|
|
}
|
|
|
|
|
|
- public bool RepeatedParticleTreatment(List<COTSFieldData> allFields, ref Dictionary<COTSParticleClr, COTSParticleClr> combinBorderParts, COTSSample theSample, string stdPath)
|
|
|
+ public bool RepeatedParticleTreatment(List<COTSFieldData> allFields, COTSSample theSample, string stdPath)
|
|
|
{
|
|
|
int maxPartCount = theSample.GetMsrParams().GetXRayParam().GetXrayLimit();
|
|
|
int overlap = theSample.GetMsrParams().GetImageProcessParam().GetOverlapParam();
|
|
@@ -400,6 +400,9 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
int offsetX = scanFieldSizeX - (int)(overlap * pixelSize);
|
|
|
int offsetY = scanFieldSizeY - (int)(overlap * pixelSize);
|
|
|
List<COTSParticleClr> deletePartList = new List<COTSParticleClr>();
|
|
|
+ List<COTSParticleClr> updatePartList= new List<COTSParticleClr>();
|
|
|
+ Dictionary<COTSParticleClr, COTSParticleClr> combinBorderParts = new Dictionary<COTSParticleClr, COTSParticleClr>();
|
|
|
+ List<string> combinBorderParts_style = new List<string>();
|
|
|
|
|
|
foreach (var item in allFields)
|
|
|
{
|
|
@@ -418,7 +421,7 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
if (leftField[0].GetIsMeasureComplete() == true)//存在测量帧图
|
|
|
{
|
|
|
//寻找重叠颗粒
|
|
|
- deletePartList.AddRange(FieldFun(leftField[0], item, "left_right", resolutionSize, overlap, ref combinBorderParts));
|
|
|
+ deletePartList.AddRange(FieldFun(leftField[0], item, "left_right", resolutionSize, overlap, ref combinBorderParts, ref combinBorderParts_style));
|
|
|
}
|
|
|
}
|
|
|
if (rightField.Count() == 1)//包含右帧图
|
|
@@ -426,7 +429,7 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
if (rightField[0].GetIsMeasureComplete() == true)//存在测量帧图
|
|
|
{
|
|
|
//寻找重叠颗粒
|
|
|
- deletePartList.AddRange(FieldFun(item, rightField[0], "left_right", resolutionSize, overlap, ref combinBorderParts));
|
|
|
+ deletePartList.AddRange(FieldFun(item, rightField[0], "left_right", resolutionSize, overlap, ref combinBorderParts, ref combinBorderParts_style));
|
|
|
}
|
|
|
}
|
|
|
if (upField.Count() == 1)//包含上帧图
|
|
@@ -434,7 +437,7 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
if (upField[0].GetIsMeasureComplete() == true)//存在测量帧图
|
|
|
{
|
|
|
//寻找重叠颗粒
|
|
|
- deletePartList.AddRange(FieldFun(upField[0], item, "up_down", resolutionSize, overlap, ref combinBorderParts));
|
|
|
+ deletePartList.AddRange(FieldFun(upField[0], item, "up_down", resolutionSize, overlap, ref combinBorderParts, ref combinBorderParts_style));
|
|
|
}
|
|
|
}
|
|
|
if (downField.Count() == 1)//包含下帧图
|
|
@@ -442,7 +445,7 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
if (downField[0].GetIsMeasureComplete() == true)//存在测量帧图
|
|
|
{
|
|
|
//寻找重叠颗粒
|
|
|
- deletePartList.AddRange(FieldFun(item, downField[0], "up_down", resolutionSize, overlap, ref combinBorderParts));
|
|
|
+ deletePartList.AddRange(FieldFun(item, downField[0], "up_down", resolutionSize, overlap, ref combinBorderParts, ref combinBorderParts_style));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -454,17 +457,28 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
|
|
|
deletePartList = deletePartList.Distinct().ToList();//去重
|
|
|
|
|
|
- if (!sQLiteHelper.DeletePartForTransaction(deletePartList))
|
|
|
+ if (!sQLiteHelper.DeletePartForTransaction(deletePartList))//删除重复颗粒
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if (!sQLiteHelper.CombinPartForTransaction(allFields, combinBorderParts, updatePartList, combinBorderParts_style, resolutionSize))//合并大颗粒
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!sQLiteHelper.UpdatePartForTransaction(updatePartList))//修改Segment
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
sQLiteHelper.CommitTransaction();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private List<COTSParticleClr> FieldFun(COTSFieldData left_upField, COTSFieldData right_downField, string style, System.Drawing.Size resolutionSize, int overlap, ref Dictionary<COTSParticleClr, COTSParticleClr> combinBorderParts)
|
|
|
+ private List<COTSParticleClr> FieldFun(COTSFieldData left_upField, COTSFieldData right_downField, string style, System.Drawing.Size resolutionSize, int overlap, ref Dictionary<COTSParticleClr, COTSParticleClr> combinBorderParts, ref List<string> combinBorderParts_style)
|
|
|
{
|
|
|
List<COTSParticleClr> particleClrs = new List<COTSParticleClr>();
|
|
|
combinBorderParts = new Dictionary<COTSParticleClr, COTSParticleClr>();
|
|
@@ -512,6 +526,7 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
if (i > rightRectangle.Y && i < rightRectangle.Y + rightRectangle.Height)
|
|
|
{
|
|
|
combinBorderParts.Add(leftBorder, rightBorder);
|
|
|
+ combinBorderParts_style.Add("left");
|
|
|
isTrue = true;
|
|
|
break;
|
|
|
}
|
|
@@ -530,7 +545,10 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
Rectangle leftRectangle = (Rectangle)leftParticles.GetParticleRect();
|
|
|
if (leftRectangle.Left > resolutionSize.Width - overlap)//未跨界
|
|
|
{
|
|
|
- particleClrs.Add(leftParticles);
|
|
|
+ if (!combinBorderParts.ContainsKey(leftParticles))
|
|
|
+ {
|
|
|
+ particleClrs.Add(leftParticles);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -541,7 +559,10 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
Rectangle downRectangle = (Rectangle)downParticles.GetParticleRect();
|
|
|
if (downRectangle.Right < overlap / 2)//未跨界
|
|
|
{
|
|
|
- particleClrs.Add(downParticles);
|
|
|
+ if (!combinBorderParts.ContainsValue(downParticles))
|
|
|
+ {
|
|
|
+ particleClrs.Add(downParticles);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -551,6 +572,8 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
//寻找上帧图的下侧区域颗粒
|
|
|
double left_upField_sum = 0;
|
|
|
double right_downField_sum = 0;
|
|
|
+ List<COTSParticleClr> upBorderParts = new List<COTSParticleClr>();
|
|
|
+ List<COTSParticleClr> downBorderParts = new List<COTSParticleClr>();
|
|
|
foreach (var upParticles in left_upField.GetListAnalysisParticles())
|
|
|
{
|
|
|
Rectangle upRectangle = (Rectangle)upParticles.GetParticleRect();
|
|
@@ -558,6 +581,10 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
{
|
|
|
left_upField_sum += upParticles.GetActualArea();
|
|
|
}
|
|
|
+ if (upRectangle.Bottom == resolutionSize.Height || upRectangle.Bottom == resolutionSize.Height - 1)//边界
|
|
|
+ {
|
|
|
+ upBorderParts.Add(upParticles);
|
|
|
+ }
|
|
|
}
|
|
|
foreach (var downParticles in right_downField.GetListAnalysisParticles())
|
|
|
{
|
|
@@ -566,6 +593,38 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
{
|
|
|
right_downField_sum += downParticles.GetActualArea();
|
|
|
}
|
|
|
+ if (downRectangle.Top == 0)//边界
|
|
|
+ {
|
|
|
+ downBorderParts.Add(downParticles);
|
|
|
+ }
|
|
|
+ else if (downRectangle.Top == 1)//边界
|
|
|
+ {
|
|
|
+ downBorderParts.Add(downParticles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var upBorder in upBorderParts)
|
|
|
+ {
|
|
|
+ Rectangle upRectangle = (Rectangle)upBorder.GetParticleRect();
|
|
|
+ foreach (var downBorder in downBorderParts)
|
|
|
+ {
|
|
|
+ Rectangle downRectangle = (Rectangle)downBorder.GetParticleRect();
|
|
|
+ bool isTrue = false;
|
|
|
+ for (int i = upRectangle.X; i < upRectangle.X + upRectangle.Width; i++)
|
|
|
+ {
|
|
|
+ if (i > downRectangle.X && i < downRectangle.X + downRectangle.Width)
|
|
|
+ {
|
|
|
+ combinBorderParts.Add(upBorder, downBorder);
|
|
|
+ combinBorderParts_style.Add("up");
|
|
|
+ isTrue = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isTrue)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (left_upField_sum < right_downField_sum)
|
|
@@ -575,7 +634,10 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
Rectangle upRectangle = (Rectangle)upParticles.GetParticleRect();
|
|
|
if (upRectangle.Top > resolutionSize.Height - overlap / 2)//未跨界
|
|
|
{
|
|
|
- particleClrs.Add(upParticles);
|
|
|
+ if (!combinBorderParts.ContainsKey(upParticles))
|
|
|
+ {
|
|
|
+ particleClrs.Add(upParticles);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -586,7 +648,10 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
Rectangle downRectangle = (Rectangle)downParticles.GetParticleRect();
|
|
|
if (downRectangle.Bottom < overlap / 2)//未跨界
|
|
|
{
|
|
|
- particleClrs.Add(downParticles);
|
|
|
+ if (!combinBorderParts.ContainsValue(downParticles))
|
|
|
+ {
|
|
|
+ particleClrs.Add(downParticles);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -740,9 +805,9 @@ namespace OTSModelSharp.ServiceInterface
|
|
|
MStitch mStitch = new MStitch();
|
|
|
mStitch.Pwidth = newImg1.Width;
|
|
|
mStitch.Pheight = newImg1.Height;
|
|
|
- mStitch.W_min = min_w - 100;
|
|
|
- mStitch.W_max = min_w + 100;
|
|
|
- mStitch.H_min = newImg1.Height;
|
|
|
+ mStitch.W_min = min_w - 50;
|
|
|
+ mStitch.W_max = min_w - 50;
|
|
|
+ mStitch.H_min = newImg1.Height - 20;
|
|
|
mStitch.minval = 255;
|
|
|
mStitch.im = newImg1;
|
|
|
|