|
@@ -33,6 +33,11 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
/// </summary>
|
|
|
public int GridLength { get; set; }
|
|
|
public int type = 0;
|
|
|
+
|
|
|
+ private double picYmin = 0;
|
|
|
+ private double picGBYmin = 0;
|
|
|
+ private int imgeH = 0;
|
|
|
+ private int imgeW = 0;
|
|
|
/// <summary>
|
|
|
/// 获取每行图片的位置配合opencv方法使用
|
|
|
/// </summary>
|
|
@@ -49,12 +54,8 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
dr["X"] = f.OTSCoordinatePos.X;
|
|
|
dr["Y"] = f.OTSCoordinatePos.Y;
|
|
|
- //dr["X"] = f.GetShowRect().X;
|
|
|
- //dr["Y"] = f.GetShowRect().Y;
|
|
|
picDatat.Rows.Add(dr);
|
|
|
}
|
|
|
- //int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
|
|
|
- //int y_min = Convert.ToInt32(picDatat.Compute("Min(Y)", "true"));
|
|
|
DataTable total_dt_X = picDatat.Copy();
|
|
|
DataView dv_x = total_dt_X.DefaultView;
|
|
|
DataView dv_x_2 = dv_x.ToTable(true, "X").DefaultView;
|
|
@@ -81,13 +82,11 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
DataRow dr2 = data.NewRow();
|
|
|
Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].OriginalImage.Width, (int)m_list_allDfield[0].OriginalImage.Height);
|
|
|
|
|
|
- //Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].GetShowRect().Width, (int)m_list_allDfield[0].GetShowRect().Height);
|
|
|
Graphics g = Graphics.FromImage(bitmap);
|
|
|
g.Clear(Color.White);
|
|
|
g.Dispose();
|
|
|
dr2["mat"] = bitmap;
|
|
|
dr2["X"] = total_dt_X.Rows[a]["X"];
|
|
|
- //dr2["Y"] = total_dt_X.Rows[a]["Y"];
|
|
|
data.Rows.Add(dr2);
|
|
|
}
|
|
|
foreach (var f in m_list_allDfield)
|
|
@@ -118,6 +117,123 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
return list_dt_picdata;
|
|
|
}
|
|
|
+
|
|
|
+ private List<DataTable> color_piclist()
|
|
|
+ {
|
|
|
+ List<DataTable> list_dt_picdata = new List<DataTable>();
|
|
|
+ DataTable picDatat = new DataTable();
|
|
|
+ List<Field> fieldlist = resultFile.List_OTSField;
|
|
|
+ picDatat.Columns.Add("X", typeof(double));
|
|
|
+ picDatat.Columns.Add("Y", typeof(double));
|
|
|
+ foreach (var f in m_list_allDfield)
|
|
|
+ {
|
|
|
+ DataRow dr = picDatat.NewRow();
|
|
|
+ dr["X"] = f.OTSCoordinatePos.X;
|
|
|
+ dr["Y"] = f.OTSCoordinatePos.Y;
|
|
|
+ picDatat.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ DataTable total_dt_X = picDatat.Copy();
|
|
|
+ DataView dv_x = total_dt_X.DefaultView;
|
|
|
+ DataView dv_x_2 = dv_x.ToTable(true, "X").DefaultView;
|
|
|
+ dv_x_2.Sort = "X ASC";
|
|
|
+ total_dt_X = dv_x_2.ToTable();
|
|
|
+
|
|
|
+
|
|
|
+ DataTable total_dt_Y = picDatat.Copy();
|
|
|
+ DataView dv_Y = total_dt_Y.DefaultView;
|
|
|
+ DataView dv_Y_2 = dv_Y.ToTable(true, "Y").DefaultView;
|
|
|
+ dv_Y_2.Sort = "Y ASC";
|
|
|
+ total_dt_Y = dv_Y_2.ToTable();
|
|
|
+ picYmin = Convert.ToDouble(total_dt_Y.Rows[0]["Y"]);
|
|
|
+
|
|
|
+ for (int i = 0; i < total_dt_Y.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ NLog.LogManager.GetCurrentClassLogger().Info("Splice line" + i + 1.ToString() + "of" + total_dt_Y.Rows.Count.ToString() + ".....");
|
|
|
+ DataTable data = new DataTable();
|
|
|
+ data.Columns.Add("mat", typeof(Bitmap));
|
|
|
+ data.Columns.Add("X", typeof(double));
|
|
|
+ data.Columns.Add("Y", typeof(double));
|
|
|
+ imgeH = (int)m_list_allDfield[0].OriginalImage.Height;
|
|
|
+ imgeW = (int)m_list_allDfield[0].OriginalImage.Width;
|
|
|
+ Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].OriginalImage.Width, (int)m_list_allDfield[0].OriginalImage.Height);
|
|
|
+ for (int a = 0; a < total_dt_X.Rows.Count; a++)
|
|
|
+ {
|
|
|
+ DataRow dr2 = data.NewRow();
|
|
|
+ Graphics g = Graphics.FromImage(bitmap);
|
|
|
+
|
|
|
+ g.Clear(Color.White);
|
|
|
+ g.Dispose();
|
|
|
+ dr2["mat"] = bitmap;
|
|
|
+ dr2["X"] = total_dt_X.Rows[a]["X"];
|
|
|
+ data.Rows.Add(dr2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ foreach (var f in m_list_allDfield)
|
|
|
+ {
|
|
|
+ if (total_dt_Y.Rows[i]["Y"].ToString() == f.OTSCoordinatePos.Y.ToString())
|
|
|
+ {
|
|
|
+ for (int c = 0; c < data.Rows.Count; c++)
|
|
|
+ {
|
|
|
+ if (data.Rows[c]["X"].ToString() == f.OTSCoordinatePos.X.ToString())
|
|
|
+ {
|
|
|
+
|
|
|
+ Bitmap image = new Bitmap(bitmap.Width, bitmap.Height);
|
|
|
+ Graphics graph_2 = Graphics.FromImage(image);
|
|
|
+
|
|
|
+ for (int a = 0; a < fieldlist.Count; a++)
|
|
|
+ {
|
|
|
+ if (fieldlist[a].FieldID.ToString() == f.FieldID.ToString())
|
|
|
+ {
|
|
|
+ //先获取该Field中的所有Particle
|
|
|
+ List<Particle> list_particle;
|
|
|
+ list_particle = fieldlist[a].ParticleList;
|
|
|
+ //再循环计算所有的Particle对象
|
|
|
+ foreach (Particle particle in list_particle)
|
|
|
+ {
|
|
|
+ List<Segment> list_seg;
|
|
|
+ list_seg = particle.SegmentList;
|
|
|
+ //创建颗粒分布图对应的类对象
|
|
|
+ List<DisplaySegment> list_dsegment = new List<DisplaySegment>();
|
|
|
+ //再循环取出里面所有的segment
|
|
|
+ foreach (Segment seg in list_seg)
|
|
|
+ {
|
|
|
+ #region 创建DSegment对象,并将STD分析出的化合物颜色保存到DSegment对象中
|
|
|
+
|
|
|
+ System.Drawing.Point on_p = new System.Drawing.Point() { X = seg.Start, Y = seg.Height };
|
|
|
+ System.Drawing.Point off_p = new System.Drawing.Point() { X = seg.Start + seg.Length, Y = seg.Height };
|
|
|
+ var color = DrawFunction.GetColorBySTDTypeIDForBSEAndSorImage(particle.TypeColor, particle.TypeId);
|
|
|
+ Pen npen = new Pen(color);
|
|
|
+ graph_2.DrawLine(npen, on_p, off_p);
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ data.Rows[c]["mat"] = image;
|
|
|
+ data.Rows[c]["X"] = f.OTSCoordinatePos.X;
|
|
|
+ data.Rows[c]["Y"] = f.OTSCoordinatePos.Y;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ DataView dataView1 = data.DefaultView;
|
|
|
+ dataView1.Sort = "X ASC";
|
|
|
+ data = dataView1.ToTable();
|
|
|
+
|
|
|
+
|
|
|
+ list_dt_picdata.Add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list_dt_picdata;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void opencv_outpic()
|
|
|
{
|
|
|
|
|
@@ -134,9 +250,14 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
list_dt_picdata = opencv_piclist_Render();
|
|
|
list_mats = new OpenCvSharp.Mat[list_dt_picdata.Count + 1];
|
|
|
}
|
|
|
- if (type == (int)Outpic_enum.GBOne)
|
|
|
+ else if (type == (int)Outpic_enum.GBOne)
|
|
|
{
|
|
|
- list_dt_picdata = opencv_piclist();
|
|
|
+ list_dt_picdata = color_piclist();
|
|
|
+ list_mats = new OpenCvSharp.Mat[list_dt_picdata.Count];
|
|
|
+ }
|
|
|
+ else if (type == (int)Outpic_enum.ColoredParticles)
|
|
|
+ {
|
|
|
+ list_dt_picdata = color_piclist();
|
|
|
list_mats = new OpenCvSharp.Mat[list_dt_picdata.Count];
|
|
|
}
|
|
|
else
|
|
@@ -145,7 +266,7 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
list_mats = new OpenCvSharp.Mat[list_dt_picdata.Count];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
NLog.LogManager.GetCurrentClassLogger().Info("Organize and splice all pictures......");
|
|
|
|
|
|
List<OpenCvSharp.Mat> list_pano = new List<OpenCvSharp.Mat>();
|
|
@@ -160,7 +281,6 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
mats[a] = OpenCvSharp.Extensions.BitmapConverter.ToMat((Bitmap)list_dt_picdata[i].Rows[a]["mat"]);
|
|
|
}
|
|
|
OpenCvSharp.Mat pano = new OpenCvSharp.Mat();
|
|
|
-
|
|
|
|
|
|
OpenCvSharp.Cv2.HConcat(mats, pano);
|
|
|
list_pano.Add(pano);
|
|
@@ -170,7 +290,7 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
|
|
|
//导出原图(渲染图)在下方增加每种颜色的标注和面积占比
|
|
|
- if (type == (int)Outpic_enum.Render_pic)
|
|
|
+ if (type == (int)Outpic_enum.Render_pic && type == (int)Outpic_enum.GBOne)
|
|
|
{
|
|
|
DataTable particleData = ParticleDataIntegration(ParticleData, ParticleClassData);
|
|
|
int NumberOfRows = getPICstringLong(particleData, list_pano);
|
|
@@ -182,10 +302,6 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
g.Clear(Color.White);
|
|
|
int rowData = 10;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//矩形格子宽500
|
|
|
|
|
|
SolidBrush mysbrush1 = new SolidBrush(ColorTranslator.FromHtml("#000000"));
|
|
@@ -195,7 +311,6 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
int Color_Y = 10; int TypeName_Y = 40; int Prozentsatz_Y = 100;int Area_Y = 70;
|
|
|
int Gitter_X = 10;
|
|
|
picKopfzeile(mypen, myFont, sbrush, g, 10, rowData);
|
|
|
-
|
|
|
|
|
|
Gitter_X = Gitter_X + 350;
|
|
|
for (int i = 0; i < particleData.Rows.Count; i++)
|
|
@@ -224,17 +339,11 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
Gitter_X = Gitter_X + 350;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
g.Dispose();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
OpenCvSharp.Mat pano = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
|
|
|
list_pano.Add(pano);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
for (int i = 0; i < list_pano.Count; i++)
|
|
|
{
|
|
|
list_mats[i] = list_pano[i];
|
|
@@ -256,19 +365,19 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
distinctValuesY.Add(Convert.ToInt32(GBDatatableOne.Rows[i]["fieldY"]));
|
|
|
distinctValuesX.Add(Convert.ToInt32(GBDatatableOne.Rows[i]["fieldX"]));
|
|
|
}
|
|
|
- int picdataYmin = Convert.ToInt32(list_dt_picdata[0].Rows[0]["Y"]);
|
|
|
- int picdataXmin = Convert.ToInt32(list_dt_picdata[0].Rows[0]["X"]);
|
|
|
+ //int picdataYmin = Convert.ToInt32(list_dt_picdata[0].Rows[0]["Y"]);
|
|
|
+ //int picdataXmin = Convert.ToInt32(list_dt_picdata[0].Rows[0]["X"]);
|
|
|
var distinctY = distinctValuesY.ToList();
|
|
|
distinctY.Sort((a, b) => b.CompareTo(a));
|
|
|
var distinctX = distinctValuesX.ToList();
|
|
|
distinctX.Sort();
|
|
|
|
|
|
- //int Yzhou = (distinctY[0] - picdataYmin);
|
|
|
- int Yzhou = 0;
|
|
|
+ //int Yzhou = 0;
|
|
|
+ int Yzhou = (int)picYmin- distinctY.Min();
|
|
|
+ Yzhou = Yzhou + (GridLength / 2)+(imgeH/2);
|
|
|
for (int i = 0; i < distinctY.Count; i++)
|
|
|
{
|
|
|
- //int Xzhou = (distinctX[0] - picdataXmin);
|
|
|
- int Xzhou = 0;
|
|
|
+ int Xzhou = +(GridLength / 2) + (imgeW / 2);
|
|
|
DataTable number = CountTheNumberOfX_axes(GBDatatableOne, "fieldY", distinctY[i].ToString());
|
|
|
for (int j = 0; j < number.Rows.Count; j++)
|
|
|
{
|
|
@@ -283,7 +392,7 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
// 定义矩形的颜色(BGR)和线宽
|
|
|
OpenCvSharp.Scalar color = new OpenCvSharp.Scalar(0, 0, 255, 255); // 蓝色
|
|
|
- int thickness = 10;
|
|
|
+ int thickness = 2;
|
|
|
// 在图像上绘制矩形
|
|
|
OpenCvSharp.Cv2.Rectangle(save_pano, topLeft, bottomRight, color, thickness);
|
|
|
|
|
@@ -292,20 +401,16 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
|
|
|
string input = number.Rows[j]["data"].ToString();
|
|
|
- int chunkSize = 40; // 分割长度
|
|
|
-
|
|
|
+ double fontScale = 1; // 字体大小缩放因子
|
|
|
+ int thickness2 = 1; // 字体粗细
|
|
|
+ // 获取文字的大小,以便我们可以更好地定位它
|
|
|
+ OpenCvSharp.Size textSize = OpenCvSharp.Cv2.GetTextSize(input, HersheyFonts.HersheySimplex, fontScale, thickness2, out int baseline);
|
|
|
+ int chunkSize = GridLength / textSize.Height; // 分割长度
|
|
|
// 使用LINQ的Enumerable.Chunk扩展方法分割字符串
|
|
|
var chunks = Enumerable.Range(0, input.Length / chunkSize + (input.Length % chunkSize > 0 ? 1 : 0))
|
|
|
.Select(x => input.Substring(x * chunkSize, Math.Min(chunkSize, input.Length - x * chunkSize)))
|
|
|
.ToList();
|
|
|
-
|
|
|
- // 输出分割后的子字符串
|
|
|
- //foreach (var chunk in chunks)
|
|
|
- //{
|
|
|
- // Console.WriteLine(chunk);
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
int topgrade = Convert.ToInt32(number.Rows[j]["color"]);
|
|
|
// 设置字体样式和大小
|
|
|
Color color1 = new Color();
|
|
@@ -335,39 +440,23 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
}
|
|
|
OpenCvSharp.Scalar fontColor = new OpenCvSharp.Scalar(color1.B, color1.G, color1.R, 255); // 文字颜色:黑色
|
|
|
- double fontScale = 2.5; // 字体大小缩放因子
|
|
|
- //int thickness = 2; // 字体粗细
|
|
|
OpenCvSharp.LineTypes lineType = OpenCvSharp.LineTypes.AntiAlias; // 线条类型
|
|
|
|
|
|
- int thickness2 = 1; // 字体粗细
|
|
|
-
|
|
|
foreach (var chunk in chunks)
|
|
|
{
|
|
|
- // 获取文字的大小,以便我们可以更好地定位它
|
|
|
- OpenCvSharp.Size textSize = OpenCvSharp.Cv2.GetTextSize(chunk, HersheyFonts.HersheySimplex, fontScale, thickness2, out int baseline);
|
|
|
// 使用PutText方法在图像上绘制文字
|
|
|
OpenCvSharp.Cv2.PutText(save_pano, chunk, textOrg, HersheyFonts.HersheySimplex, fontScale, fontColor, thickness, lineType);
|
|
|
- textOrg.Y = textOrg.Y + 100;
|
|
|
+ textOrg.Y = textOrg.Y + 70;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
Yzhou = Yzhou + GridLength;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
OpenCvSharp.Cv2.ImWrite(sfd.FileName, save_pano);
|
|
|
NLog.LogManager.GetCurrentClassLogger().Info("Save complete.");
|
|
|
-
|
|
|
Control_DrawDistrbutionImageAndBSE v = m_ReportApp.im_Control_DrawDistrbutionImageAndBSE;
|
|
|
MyEvent += new MyEntrust(v.msgInform);
|
|
|
-
|
|
|
-
|
|
|
v.Invoke(MyEvent);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private DataTable CountTheNumberOfX_axes(DataTable dataTable, string ColumnName, string name)
|
|
@@ -509,16 +598,10 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
data.Columns.Add("X", typeof(double));
|
|
|
//循环每行图片进行拼接
|
|
|
Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].OriginalImage.Width, (int)m_list_allDfield[0].OriginalImage.Height);
|
|
|
-
|
|
|
-
|
|
|
|
|
|
for (int a = 0; a < total_dt_X.Rows.Count; a++)
|
|
|
{
|
|
|
DataRow dr2 = data.NewRow();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].GetShowRect().Width, (int)m_list_allDfield[0].GetShowRect().Height);
|
|
|
Graphics g = Graphics.FromImage(bitmap);
|
|
|
|
|
|
g.Clear(Color.White);
|
|
@@ -555,8 +638,6 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
//再循环计算所有的Particle对象
|
|
|
foreach (Particle particle in list_particle)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
List<Segment> list_seg;
|
|
|
list_seg = particle.SegmentList;
|
|
|
//创建颗粒分布图对应的类对象
|
|
@@ -568,8 +649,6 @@ namespace OTSIncAReportApp._3_ServiceCenter
|
|
|
|
|
|
System.Drawing.Point on_p = new System.Drawing.Point() { X = seg.Start, Y = seg.Height };
|
|
|
System.Drawing.Point off_p = new System.Drawing.Point() { X = seg.Start + seg.Length, Y = seg.Height };
|
|
|
- //var color = DrawFunction.GetColorBySTDTypeIDForBSEAndSorImage("#434343", particle.TypeId);
|
|
|
-
|
|
|
Pen npen = new Pen(Color.FromArgb(255-particle.AveGray, 0, 0, 0));
|
|
|
graph_2.DrawLine(npen, on_p, off_p);
|
|
|
|