private ImageMatrix MultiplyImageToMask(ImageMatrix p, HaarMask masks) { var res = new ImageMatrix(p.Width, p.Height); var wid = p.Width / 2; var height = p.Height / 2; int i, j; try { for (i = 0; i < p.Width / 2; i++) { for (j = 0; j < p.Height / 2; j++) { res[i, j] = ApplyFilterToPixel(2 * i, 2 * j, p, masks.A); res[i + wid, j] = ApplyFilterToPixel(2 * i + 1, 2 * j, p, masks.B); res[i, j + height] = ApplyFilterToPixel(2 * i, 2 * j + 1, p, masks.C); res[i + wid, j + height] = ApplyFilterToPixel(2 * i + 1, 2 * j + 1, p, masks.D); } } } catch (Exception ex) { throw new Exception("Помилка при проведенні згортки:\n\n" + ex.Message); } return(res); }
public ImageMatrix Visit(HaarMask mask) { return(MultiplyImageToMask(_image, mask)); }