InclusionsGlobalSettings.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace PaintDotNet.Base.DedicatedAnalysis.Inclusions
  9. {
  10. /// <summary>
  11. /// 夹杂物抽象全局设置
  12. /// </summary>
  13. public class InclusionsGlobalSettings: DedicatedAnalysisGlobalSettings
  14. {
  15. public bool autoThreshold = true;
  16. public int binaryThreshold;
  17. /// <summary>
  18. /// 轧制方向
  19. /// </summary>
  20. public RollingDirection rollingDirection;
  21. /// <summary>
  22. /// 系统纳米标尺每像素长度
  23. /// </summary>
  24. public double pxPerUnit;
  25. /// <summary>
  26. /// 微粒之间的距离(distances between particles) 垂直距离
  27. /// </summary>
  28. public int distancesBetweenParticlesE;
  29. /// <summary>
  30. /// 微粒之间的距离(distances between particles) 水平距离
  31. /// </summary>
  32. public int distancesBetweenParticlesT;
  33. /// <summary>
  34. /// 条串之间的距离(distances between stringers) 垂直距离
  35. /// </summary>
  36. public int distancesBetweenStringersE;
  37. /// <summary>
  38. /// 条串之间的距离(distances between stringers) 水平距离
  39. /// </summary>
  40. public int distancesBetweenStringersT;
  41. /// <summary>
  42. /// 判定微粒最小长度尺寸
  43. /// </summary>
  44. public int minimumLength;
  45. /// <summary>
  46. /// 判定微粒最小宽度尺寸
  47. /// </summary>
  48. public int minimumWidth;
  49. /// <summary>
  50. /// 长宽比界限,用于判断球型夹杂物
  51. /// </summary>
  52. public double lwRatioLimit;
  53. public Dictionary<String, TypesOfInclusions> typeDics = new Dictionary<string, TypesOfInclusions>();
  54. public Dictionary<String, ColorOfInclusions> colorOfInclusions = new Dictionary<string, ColorOfInclusions>();
  55. public enum RollingDirection
  56. {
  57. [Description("纵向")]
  58. PORTRAIT,
  59. [Description("横向")]
  60. HORIZONTAL
  61. }
  62. /// <summary>
  63. /// 夹杂物类型
  64. /// </summary>
  65. public class TypesOfInclusions
  66. {
  67. public TypesOfInclusions(string type)
  68. {
  69. this.type = type;
  70. }
  71. /// <summary>
  72. /// 展示颜色
  73. /// </summary>
  74. public int showColor;
  75. /// <summary>
  76. /// 夹杂物类型字符串
  77. /// </summary>
  78. public string type;
  79. }
  80. public class ColorOfInclusions
  81. {
  82. public string colorName;
  83. public TypesOfInclusions[] ofTypes;
  84. /// <summary>
  85. /// 判断夹杂物rgb
  86. /// rgb 上下限
  87. /// </summary>
  88. public byte ru;
  89. public byte rd;
  90. public byte gu;
  91. public byte gd;
  92. public byte bu;
  93. public byte bd;
  94. public ColorOfInclusions(string colorName, TypesOfInclusions[] ofTypes, Color color)
  95. {
  96. this.colorName = colorName;
  97. this.ofTypes = ofTypes;
  98. this.rd = (byte)(color.R - 10 < 0 ? 0 : color.R - 10);
  99. this.ru = (byte)(color.R + 10 > 255 ? 255 : color.R + 10);
  100. this.gd = (byte)(color.G - 10 < 0 ? 0 : color.G - 10);
  101. this.gu = (byte)(color.G + 10 > 255 ? 255 : color.G + 10);
  102. this.bd = (byte)(color.B - 10 < 0 ? 0 : color.B - 10);
  103. this.bu = (byte)(color.B + 10 > 255 ? 255 : color.B + 10);
  104. }
  105. public ColorOfInclusions(string colorName, TypesOfInclusions[] ofTypes, byte ru, byte rd, byte gu, byte gd, byte bu, byte bd)
  106. {
  107. this.colorName = colorName;
  108. this.ofTypes = ofTypes;
  109. this.ru = ru;
  110. this.rd = rd;
  111. this.gu = gu;
  112. this.gd = gd;
  113. this.bu = bu;
  114. this.bd = bd;
  115. }
  116. public void setColor(Color color)
  117. {
  118. this.rd = (byte)(color.R - 10 < 0 ? 0 : color.R - 10);
  119. this.ru = (byte)(color.R + 10 > 255 ? 255 : color.R + 10);
  120. this.gd = (byte)(color.G - 10 < 0 ? 0 : color.G - 10);
  121. this.gu = (byte)(color.G + 10 > 255 ? 255 : color.G + 10);
  122. this.bd = (byte)(color.B - 10 < 0 ? 0 : color.B - 10);
  123. this.bu = (byte)(color.B + 10 > 255 ? 255 : color.B + 10);
  124. }
  125. }
  126. }
  127. }