PV6093.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using PaintDotNet.Base.DedicatedAnalysis.Porosity.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.Porosity.PorositysGlobalSettings;
  9. namespace PaintDotNet.Base.DedicatedAnalysis.Porosity.Standard
  10. {
  11. public class PV6093 : PorositysStandard
  12. {
  13. public PV6093(double pxPerUnit)
  14. {
  15. this.globalSettings.binaryThreshold = 175;
  16. this.globalSettings.pxPerUnit = pxPerUnit;
  17. this.globalSettings.minimumLength = 3;
  18. this.globalSettings.minimumWidth = 2;
  19. string[] types = { "A" };
  20. for (int i = 0; i < types.Length; i++)
  21. {
  22. TypesOfPorositys typesOfInclusion = new TypesOfPorositys(types[i]);
  23. typesOfInclusion.showColor = PorositysStandard.RAINBOW_COLORS[i].ToArgb();
  24. this.globalSettings.typeDics.Add(types[i], typesOfInclusion);
  25. }
  26. this.globalSettings.colorOfPorositys.Add("Black", new ColorOfPorositys("Black", new TypesOfPorositys[] { this.globalSettings.typeDics["A"] }, Color.Black));
  27. }
  28. public override void determineType(Porositys porosity)
  29. {
  30. Dictionary<TypesOfPorositys, int> typeCount = new Dictionary<TypesOfPorositys, int>();
  31. foreach (var type in this.globalSettings.typeDics)
  32. {
  33. typeCount.Add(type.Value, 0);
  34. }
  35. if (porosity.color != null)
  36. {
  37. foreach (TypesOfPorositys item in porosity.color.ofTypes)
  38. {
  39. typeCount[this.globalSettings.typeDics[item.type]]++;
  40. }
  41. }
  42. porosity.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key;
  43. }
  44. public override void edgeErrorsCorrection(List<Porositys> porositys)
  45. {
  46. throw new NotImplementedException();
  47. }
  48. }
  49. }