private void MedianFilter_Click(object sender, EventArgs e) { var bitmap = GetPictureBox().Image; var medianFilter = new MedianFilter(); pictureBox5.Image = medianFilter.Filter((Bitmap)bitmap, trackBar1.Value); }
private void medianButton_Click(object sender, EventArgs e) { var inputBitmap = new Bitmap(otherFiltersInputImgBox.Image); var medianFilterMaskClient = new MedianFilter(inputBitmap, Settings.Default.StoreAsColorWherePossible); otherFiltersOutputImgBox.Image = medianFilterMaskClient.Filter(); }
/// <summary> /// Set value /// </summary> private void SetValue() { var w = Colors.GetLength(0); var h = Colors.GetLength(1); var tempData = new byte[w + 2, h + 2, 1]; Data = new byte[w, h, 1]; Image = new bool[w, h]; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { var argb = Colors[i, j].ToArgb(); if (argb == Constant.ArgbWhite || argb == Constant.ArgbTunnel || argb == Constant.ArgbYellow) { tempData[i + 1, j + 1, 0] = 255; } else { tempData[i + 1, j + 1, 0] = 0; } } } MedianFilter.Filter(tempData); for (int i = 0; i < 5; i++) { ZhangSuen.ZhangSuenThinning(tempData); } MedianFilter.CorrosiveHit(tempData); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { Data[i, j, 0] = tempData[i + 1, j + 1, 0]; Image[i, j] = Data[i, j, 0] == 255 ? true : false; if (Image[i, j]) { Colors[i, j] = Color.Black; } else { Colors[i, j] = Color.White; } } } }
private void button1_Click(object sender, EventArgs e) { Bitmap img = new Bitmap(picBarcode.Image); picBarcode.Image = MedianFilter.Filter(img, 3, 0, false); }
public override float Filter(float value) { return(filter.Filter(value)); }