protected override SectionedLabCounts CalcImageData(IEnumerable <PixelPoint> pixels, Point start) { /*int leftCount = 0; * int rightCount = 0; * int topCount = 0; * int bottomCount = 0; * int centerCount = 0; * int allCount = 0;*/ SectionedDouble counts = new SectionedDouble(); SectionedLab area = new SectionedLab(); foreach (PixelPoint p in pixels) { ColorLab color = LabConverter.ToLab(p.Color); if (p.X < left) { area.Left += color; counts.Left++; //leftCount++; } else if (p.X >= right) { area.Right += color; counts.Right++; //rightCount++; } if (p.Y < top) { area.Top += color; counts.Top++; //topCount++; } else if (p.Y >= bottom) { area.Bottom += color; counts.Bottom++; //bottomCount++; } if (p.X >= left && p.X < right && p.Y >= top && p.Y < bottom) { area.Center += color; counts.Center++; //centerCount++; } area.All += color; counts.All++; //allCount++; } return(new SectionedLabCounts(area, counts)); }
protected override SectionedLab CalcFontData(IEnumerable <PixelPoint> pixels) { SectionedDouble counts = new SectionedDouble(); SectionedLab area = new SectionedLab(); double inc = 1; foreach (PixelPoint p in pixels) { inc = p.Color.A / 255d; ColorLab color = LabConverter.ToLab(p.Color) * inc; if (p.X < left) { area.Left += color; counts.Left += inc; //leftCount++; } else if (p.X >= right) { area.Right += color; counts.Right += inc; //rightCount++; } if (p.Y < top) { area.Top += color; counts.Top += inc; //topCount++; } else if (p.Y >= bottom) { area.Bottom += color; counts.Bottom += inc; //bottomCount++; } if (p.X >= left && p.X < right && p.Y >= top && p.Y < bottom) { area.Center += color; counts.Center += inc; //centerCount++; } area.All += color; counts.All += inc; //allCount++; } return((area / counts).ZeroNaNs); }
public static SectionedDouble Abs(SectionedDouble a, SectionedDouble b) => new SectionedDouble( Math.Abs(a.Left - b.Left), Math.Abs(a.Right - b.Right), Math.Abs(a.Top - b.Top), Math.Abs(a.Bottom - b.Bottom), Math.Abs(a.Center - b.Center), Math.Abs(a.All - b.All));
public static SectionedDouble Min(SectionedDouble a, SectionedDouble b) => new SectionedDouble( Math.Min(a.Left, b.Left), Math.Min(a.Right, b.Right), Math.Min(a.Top, b.Top), Math.Min(a.Bottom, b.Bottom), Math.Min(a.Center, b.Center), Math.Min(a.All, b.All));
public SectionedDoubleCounts(SectionedDouble area, SectionedDouble counts) { Double = (area / (counts * 100)).ZeroNaNs; Counts = counts; }
public SectionedLabCounts(SectionedLab area, SectionedDouble counts) { Lab = (area / counts).ZeroNaNs; Counts = counts; }