public override LearningImage Project(LearningImage i) { List<double> results = new List<double>(); int scaledH = 0; int scaledW = 0; for (int h = -Height / 2; h < i.Height - Height / 2; h += this.Scale) { scaledW = 0; for (int w = -Width / 2; w < i.Width - Width / 2; w += this.Scale) { var trimed = i.Trim(new Rectangle(w, h, Width, Height)); var projected = base.Project(trimed); results.AddRange(projected.Data); scaledW++; } scaledH++; } return new LearningImage(scaledH, scaledW, this.FrameOut.Plane, results.ToArray()); }
public override LearningImage BackProject(LearningImage i) { int Scale = this.Scale; ListImage li = new ListImage(i.Height * Scale + Height, i.Width * Scale + Width); for (int h = 0; h < i.Height; h++) { for (int w = 0; w < i.Width; w++) { LearningImage trimed = i.Trim(new Rectangle(w, h, 1, 1)); LearningImage pasting = base.BackProject(trimed); for (int hh = 0; hh < pasting.Height; hh++) for (int ww = 0; ww < pasting.Width; ww++) li.Add(h * Scale + hh, w * Scale + ww, pasting.GetPlane(hh, ww)); } } LearningImage o = new LearningImage(i.Height * Scale, i.Width * Scale, this.FrameIn.Plane); for (int h = 0; h < o.Height; h++) for (int w = 0; w < o.Width; w++) o.SetPlane(h, w, li.Median(h + Height / 2, w + Width / 2)); return o; }