ASTME45.cs 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.InclusionsGlobalSettings;
  9. namespace PaintDotNet.Base.DedicatedAnalysis.Inclusions.Standard.ASTME45
  10. {
  11. public class ASTME45 : InclusionsStandard
  12. {
  13. public ASTME45(double pxPerUnit)
  14. {
  15. this.globalSettings.binaryThreshold = 175;
  16. this.globalSettings.pxPerUnit = pxPerUnit;
  17. this.globalSettings.distancesBetweenParticlesE = 40;
  18. this.globalSettings.distancesBetweenParticlesT = 15;
  19. this.globalSettings.distancesBetweenStringersE = 40;
  20. this.globalSettings.distancesBetweenStringersT = 15;
  21. this.globalSettings.minimumLength = 3;
  22. this.globalSettings.minimumWidth = 2;
  23. this.globalSettings.lwRatioLimit = 2f;
  24. string[] types = { "A", "B", "C", "D"};
  25. for (int i = 0; i < types.Length; i++)
  26. {
  27. TypesOfInclusions typesOfInclusion = new TypesOfInclusions(types[i]);
  28. typesOfInclusion.showColor = InclusionsStandard.RAINBOW_COLORS[i].ToArgb();
  29. this.globalSettings.typeDics.Add(types[i], typesOfInclusion);
  30. }
  31. this.globalSettings.colorOfInclusions.Add("Black", new ColorOfInclusions("Black", new TypesOfInclusions[] { this.globalSettings.typeDics["C"] }, Color.Black));
  32. this.globalSettings.colorOfInclusions.Add("Gray", new ColorOfInclusions("Gray", new TypesOfInclusions[] { this.globalSettings.typeDics["A"] }, Color.DarkGray));
  33. this.globalSettings.colorOfInclusions.Add("DarkGray", new ColorOfInclusions("DarkGray", new TypesOfInclusions[] { this.globalSettings.typeDics["B"] }, Color.Gray));
  34. this.globalSettings.colorOfInclusions.Add("LightBlue", new ColorOfInclusions("LightBlue", new TypesOfInclusions[] { this.globalSettings.typeDics["D"] }, Color.LightBlue));
  35. }
  36. public override void determineType(Inclusion inclusion)
  37. {
  38. Dictionary<TypesOfInclusions, int> typeCount = new Dictionary<TypesOfInclusions, int>();
  39. foreach (var type in this.globalSettings.typeDics)
  40. {
  41. typeCount.Add(type.Value, 0);
  42. }
  43. switch (inclusion.classes)
  44. {
  45. case ClassesOfInclusions.α:
  46. typeCount[this.globalSettings.typeDics["A"]] = typeCount[this.globalSettings.typeDics["A"]] + 2;
  47. typeCount[this.globalSettings.typeDics["C"]] = typeCount[this.globalSettings.typeDics["C"]] + 2;
  48. break;
  49. case ClassesOfInclusions.β:
  50. typeCount[this.globalSettings.typeDics["B"]] = typeCount[this.globalSettings.typeDics["B"]] + 2;
  51. break;
  52. case ClassesOfInclusions.γ:
  53. typeCount[this.globalSettings.typeDics["A"]] = typeCount[this.globalSettings.typeDics["A"]] + 2;
  54. typeCount[this.globalSettings.typeDics["C"]] = typeCount[this.globalSettings.typeDics["C"]] + 2;
  55. break;
  56. case ClassesOfInclusions.δ:
  57. typeCount[this.globalSettings.typeDics["D"]] = typeCount[this.globalSettings.typeDics["D"]] + 2;
  58. break;
  59. }
  60. if (inclusion.color != null)
  61. {
  62. foreach (TypesOfInclusions item in inclusion.color.ofTypes)
  63. {
  64. typeCount[this.globalSettings.typeDics[item.type]]++;
  65. }
  66. }
  67. inclusion.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key;
  68. }
  69. public override void edgeErrorsCorrection(List<Inclusion> inclusions)
  70. {
  71. throw new NotImplementedException();
  72. }
  73. }
  74. }