1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using PaintDotNet.Base.DedicatedAnalysis.Inclusions.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.Inclusions.InclusionsGlobalSettings;
- namespace PaintDotNet.Base.DedicatedAnalysis.Inclusions.Standard.ASTME45
- {
- public class ASTME45 : InclusionsStandard
- {
- public ASTME45(double pxPerUnit)
- {
- this.globalSettings.binaryThreshold = 175;
- this.globalSettings.pxPerUnit = pxPerUnit;
- this.globalSettings.distancesBetweenParticlesE = 40;
- this.globalSettings.distancesBetweenParticlesT = 15;
- this.globalSettings.distancesBetweenStringersE = 40;
- this.globalSettings.distancesBetweenStringersT = 15;
- this.globalSettings.minimumLength = 3;
- this.globalSettings.minimumWidth = 2;
- this.globalSettings.lwRatioLimit = 2f;
- string[] types = { "A", "B", "C", "D"};
- for (int i = 0; i < types.Length; i++)
- {
- TypesOfInclusions typesOfInclusion = new TypesOfInclusions(types[i]);
- typesOfInclusion.showColor = InclusionsStandard.RAINBOW_COLORS[i].ToArgb();
- this.globalSettings.typeDics.Add(types[i], typesOfInclusion);
- }
- this.globalSettings.colorOfInclusions.Add("Black", new ColorOfInclusions("Black", new TypesOfInclusions[] { this.globalSettings.typeDics["C"] }, Color.Black));
- this.globalSettings.colorOfInclusions.Add("Gray", new ColorOfInclusions("Gray", new TypesOfInclusions[] { this.globalSettings.typeDics["A"] }, Color.DarkGray));
- this.globalSettings.colorOfInclusions.Add("DarkGray", new ColorOfInclusions("DarkGray", new TypesOfInclusions[] { this.globalSettings.typeDics["B"] }, Color.Gray));
- this.globalSettings.colorOfInclusions.Add("LightBlue", new ColorOfInclusions("LightBlue", new TypesOfInclusions[] { this.globalSettings.typeDics["D"] }, Color.LightBlue));
- }
- public override void determineType(Inclusion inclusion)
- {
- Dictionary<TypesOfInclusions, int> typeCount = new Dictionary<TypesOfInclusions, int>();
- foreach (var type in this.globalSettings.typeDics)
- {
- typeCount.Add(type.Value, 0);
- }
- switch (inclusion.classes)
- {
- case ClassesOfInclusions.α:
- typeCount[this.globalSettings.typeDics["A"]] = typeCount[this.globalSettings.typeDics["A"]] + 2;
- typeCount[this.globalSettings.typeDics["C"]] = typeCount[this.globalSettings.typeDics["C"]] + 2;
- break;
- case ClassesOfInclusions.β:
- typeCount[this.globalSettings.typeDics["B"]] = typeCount[this.globalSettings.typeDics["B"]] + 2;
- break;
- case ClassesOfInclusions.γ:
- typeCount[this.globalSettings.typeDics["A"]] = typeCount[this.globalSettings.typeDics["A"]] + 2;
- typeCount[this.globalSettings.typeDics["C"]] = typeCount[this.globalSettings.typeDics["C"]] + 2;
- break;
- case ClassesOfInclusions.δ:
- typeCount[this.globalSettings.typeDics["D"]] = typeCount[this.globalSettings.typeDics["D"]] + 2;
- break;
- }
- if (inclusion.color != null)
- {
- foreach (TypesOfInclusions item in inclusion.color.ofTypes)
- {
- typeCount[this.globalSettings.typeDics[item.type]]++;
- }
- }
- inclusion.type = typeCount.First(r => r.Value == typeCount.Max(t => t.Value)).Key;
- }
- public override void edgeErrorsCorrection(List<Inclusion> inclusions)
- {
- throw new NotImplementedException();
- }
- }
- }
|