using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PaintDotNet.Base.DedicatedAnalysis.Porosity { /// /// 孔隙抽象全局设置 /// public class PorositysGlobalSettings: DedicatedAnalysisGlobalSettings { public bool autoThreshold = true; public int binaryThreshold; /// /// 轧制方向 /// public RollingDirection rollingDirection; /// /// 系统纳米标尺每像素长度 /// public double pxPerUnit; /// /// 微粒之间的距离(distances between particles) 垂直距离 /// public int distancesBetweenParticlesE; /// /// 微粒之间的距离(distances between particles) 水平距离 /// public int distancesBetweenParticlesT; /// /// 条串之间的距离(distances between stringers) 垂直距离 /// public int distancesBetweenStringersE; /// /// 条串之间的距离(distances between stringers) 水平距离 /// public int distancesBetweenStringersT; /// /// 判定微粒最小长度尺寸 /// public int minimumLength; /// /// 判定微粒最小宽度尺寸 /// public int minimumWidth; /// /// 长宽比界限,用于判断球型孔隙 /// public double lwRatioLimit; public Dictionary typeDics = new Dictionary(); public Dictionary colorOfPorositys = new Dictionary(); public enum RollingDirection { [Description("纵向")] PORTRAIT, [Description("横向")] HORIZONTAL } /// /// 孔隙类型 /// public class TypesOfPorositys { public TypesOfPorositys(string type) { this.type = type; } /// /// 展示颜色 /// public int showColor; /// /// 孔隙类型字符串 /// public string type; } public class ColorOfPorositys { public string colorName; public TypesOfPorositys[] ofTypes; /// /// 判断孔隙rgb /// rgb 上下限 /// public byte ru; public byte rd; public byte gu; public byte gd; public byte bu; public byte bd; public ColorOfPorositys(string colorName, TypesOfPorositys[] ofTypes, Color color) { this.colorName = colorName; this.ofTypes = ofTypes; this.rd = (byte)(color.R - 10 < 0 ? 0 : color.R - 10); this.ru = (byte)(color.R + 10 > 255 ? 255 : color.R + 10); this.gd = (byte)(color.G - 10 < 0 ? 0 : color.G - 10); this.gu = (byte)(color.G + 10 > 255 ? 255 : color.G + 10); this.bd = (byte)(color.B - 10 < 0 ? 0 : color.B - 10); this.bu = (byte)(color.B + 10 > 255 ? 255 : color.B + 10); } public ColorOfPorositys(string colorName, TypesOfPorositys[] ofTypes, byte ru, byte rd, byte gu, byte gd, byte bu, byte bd) { this.colorName = colorName; this.ofTypes = ofTypes; this.ru = ru; this.rd = rd; this.gu = gu; this.gd = gd; this.bu = bu; this.bd = bd; } public void setColor(Color color) { this.rd = (byte)(color.R - 10 < 0 ? 0 : color.R - 10); this.ru = (byte)(color.R + 10 > 255 ? 255 : color.R + 10); this.gd = (byte)(color.G - 10 < 0 ? 0 : color.G - 10); this.gu = (byte)(color.G + 10 > 255 ? 255 : color.G + 10); this.bd = (byte)(color.B - 10 < 0 ? 0 : color.B - 10); this.bu = (byte)(color.B + 10 > 255 ? 255 : color.B + 10); } } } }