123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using PaintDotNet.Base.DedicatedAnalysis.Porosity.Model;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using static PaintDotNet.Base.DedicatedAnalysis.Porosity.PorositysGlobalSettings;
- namespace PaintDotNet.Base.DedicatedAnalysis.Porosity.Standard
- {
- public class GBT37787 : PorositysStandard
- {
- public GBT37787(double pxPerUnit)
- {
- this.globalSettings.binaryThreshold = 175;
- this.globalSettings.pxPerUnit = pxPerUnit;
- this.globalSettings.minimumLength = 3;
- this.globalSettings.minimumWidth = 2;
- string[] types = { "A" };
- for (int i = 0; i < types.Length; i++)
- {
- TypesOfPorositys typesOfInclusion = new TypesOfPorositys(types[i]);
- typesOfInclusion.showColor = PorositysStandard.RAINBOW_COLORS[i].ToArgb();
- this.globalSettings.typeDics.Add(types[i], typesOfInclusion);
- }
- this.globalSettings.colorOfPorositys.Add("Black", new ColorOfPorositys("Black", new TypesOfPorositys[] { this.globalSettings.typeDics["A"] }, Color.Black));
- }
- public override void determineType(Porositys porosity)
- {
- Dictionary<TypesOfPorositys, int> typeCount = new Dictionary<TypesOfPorositys, int>();
- foreach (var type in this.globalSettings.typeDics)
- {
- typeCount.Add(type.Value, 0);
- }
- if (porosity.color != null)
- {
- foreach (TypesOfPorositys item in porosity.color.ofTypes)
- {
- typeCount[this.globalSettings.typeDics[item.type]]++;
- }
- }
- porosity.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key;
- }
- public override void edgeErrorsCorrection(List<Porositys> porositys)
- {
- throw new NotImplementedException();
- }
- }
- }
|