private void blur_ItemClick(object sender, ItemClickEventArgs e) { try { var bitmap = pictureEdit1.Image as Bitmap; if (bitmap == null) { return; } var size = bitmap.Size; using (var blinderDialog = new BlinderDialog(new Size(size.Width * 3 / 4, size.Height * 3 / 4))) { if (blinderDialog.ShowDialog() != DialogResult.OK) { return; } var blinderSize = blinderDialog.BlinderSize; using (var builder = new BlurBuilder(blinderSize)) pictureEdit1.Image = builder.Blur(bitmap); } } catch (Exception exception) { XtraMessageBox.Show(exception.Message); } }
private void blurToolStripMenuItem_Click(object sender, EventArgs e) { try { var bitmap = pictureEdit1.Image as Bitmap; if (bitmap == null) { throw new Exception("Нет изображения"); } var size = bitmap.Size; var blinderDialog = new BlinderDialog(new Size(size.Width / 2, size.Height / 2)); if (blinderDialog.ShowDialog() != DialogResult.OK) { return; } var filterSize = blinderDialog.BlinderSize; using (var builder = new BlurBuilder(filterSize)) { pictureEdit1.Image = builder.Blur(bitmap); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public void BlurTestMethod() { const int width = 100; const int height = 100; const int filterStep = 1; var image = new Image <Gray, byte>(height, width); var bytes = new byte[image.Data.Length]; Rng.GetBytes(bytes); var handle = GCHandle.Alloc(image.Data, GCHandleType.Pinned); Marshal.Copy(bytes, 0, handle.AddrOfPinnedObject(), bytes.Length); handle.Free(); var average = bytes.Average(x => (double)x); var delta = Math.Sqrt(bytes.Average(x => (double)x * x) - average * average); var minValue = bytes.Min(x => (double)x); var maxValue = bytes.Max(x => (double)x); var sb = new StringBuilder(); sb.AppendLine(string.Format("Length {0}", bytes.Length)); sb.AppendLine(string.Format("Average {0}", average)); sb.AppendLine(string.Format("Delta {0}", delta)); sb.AppendLine(string.Format("minValue {0}", minValue)); sb.AppendLine(string.Format("maxValue {0}", maxValue)); Console.WriteLine(sb.ToString()); using (var blurBuilder = new BlurBuilder(filterStep)) image = blurBuilder.Blur(image); handle = GCHandle.Alloc(image.Data, GCHandleType.Pinned); Marshal.Copy(handle.AddrOfPinnedObject(), bytes, 0, bytes.Length); handle.Free(); var average1 = bytes.Average(x => (double)x); var delta1 = Math.Sqrt(bytes.Average(x => (double)x * x) - average1 * average1); var minValue1 = bytes.Min(x => (double)x); var maxValue1 = bytes.Max(x => (double)x); var sb1 = new StringBuilder(); sb1.AppendLine(string.Format("Length {0}", bytes.Length)); sb1.AppendLine(string.Format("Average {0}", average1)); sb1.AppendLine(string.Format("Delta {0}", delta1)); sb1.AppendLine(string.Format("minValue {0}", minValue1)); sb1.AppendLine(string.Format("maxValue {0}", maxValue1)); Console.WriteLine(sb1.ToString()); Assert.IsTrue(delta1 < delta); }
public void BlurTestMethod() { const int width = 100; const int height = 100; const int filterStep = 1; var image = new Image<Gray, byte>(height, width); var bytes = new byte[image.Data.Length]; Rng.GetBytes(bytes); var handle = GCHandle.Alloc(image.Data, GCHandleType.Pinned); Marshal.Copy(bytes, 0, handle.AddrOfPinnedObject(), bytes.Length); handle.Free(); var average = bytes.Average(x => (double) x); var delta = Math.Sqrt(bytes.Average(x => (double) x*x) - average*average); var minValue = bytes.Min(x => (double) x); var maxValue = bytes.Max(x => (double) x); var sb = new StringBuilder(); sb.AppendLine(string.Format("Length {0}", bytes.Length)); sb.AppendLine(string.Format("Average {0}", average)); sb.AppendLine(string.Format("Delta {0}", delta)); sb.AppendLine(string.Format("minValue {0}", minValue)); sb.AppendLine(string.Format("maxValue {0}", maxValue)); Console.WriteLine(sb.ToString()); using (var blurBuilder = new BlurBuilder(filterStep)) image = blurBuilder.Blur(image); handle = GCHandle.Alloc(image.Data, GCHandleType.Pinned); Marshal.Copy(handle.AddrOfPinnedObject(), bytes, 0, bytes.Length); handle.Free(); var average1 = bytes.Average(x => (double) x); var delta1 = Math.Sqrt(bytes.Average(x => (double) x*x) - average1*average1); var minValue1 = bytes.Min(x => (double) x); var maxValue1 = bytes.Max(x => (double) x); var sb1 = new StringBuilder(); sb1.AppendLine(string.Format("Length {0}", bytes.Length)); sb1.AppendLine(string.Format("Average {0}", average1)); sb1.AppendLine(string.Format("Delta {0}", delta1)); sb1.AppendLine(string.Format("minValue {0}", minValue1)); sb1.AppendLine(string.Format("maxValue {0}", maxValue1)); Console.WriteLine(sb1.ToString()); Assert.IsTrue(delta1 < delta); }
public void BlurTestMethod() { const int width = 100; const int height = 100; const int filterStep = 1; var image = new Image <Bgr, byte>(width, height); var bytes = new byte[image.Data.Length]; Rng.GetBytes(bytes); Buffer.BlockCopy(bytes, 0, image.Data, 0, bytes.Length); double average = bytes.Average(x => (double)x); double delta = Math.Sqrt(bytes.Average(x => (double)x * x) - average * average); double minValue = bytes.Min(x => (double)x); double maxValue = bytes.Max(x => (double)x); var sb = new StringBuilder(); sb.AppendLine(string.Format("Length {0}", image.Data.Length)); sb.AppendLine(string.Format("Average {0}", average)); sb.AppendLine(string.Format("Delta {0}", delta)); sb.AppendLine(string.Format("minValue {0}", minValue)); sb.AppendLine(string.Format("maxValue {0}", maxValue)); Console.WriteLine(sb.ToString()); using (var blurBuilder = new BlurBuilder(filterStep)) image = blurBuilder.Blur(image); Buffer.BlockCopy(image.Data, 0, bytes, 0, bytes.Length); double average1 = bytes.Average(x => (double)x); double delta1 = Math.Sqrt(bytes.Average(x => (double)x * x) - average1 * average1); double minValue1 = bytes.Min(x => (double)x); double maxValue1 = bytes.Max(x => (double)x); var sb1 = new StringBuilder(); sb1.AppendLine(string.Format("Length {0}", image.Data.Length)); sb1.AppendLine(string.Format("Average {0}", average1)); sb1.AppendLine(string.Format("Delta {0}", delta1)); sb1.AppendLine(string.Format("minValue {0}", minValue1)); sb1.AppendLine(string.Format("maxValue {0}", maxValue1)); Console.WriteLine(sb1.ToString()); Assert.IsTrue(delta1 < delta); }
public void BlurTestMethod() { const int width = 100; const int height = 100; const int filterStep = 1; var image = new Image<Bgr, byte>(width, height); var bytes = new byte[image.Data.Length]; Rng.GetBytes(bytes); Buffer.BlockCopy(bytes, 0, image.Data, 0, bytes.Length); double average = bytes.Average(x => (double) x); double delta = Math.Sqrt(bytes.Average(x => (double) x*x) - average*average); double minValue = bytes.Min(x => (double) x); double maxValue = bytes.Max(x => (double) x); var sb = new StringBuilder(); sb.AppendLine(string.Format("Length {0}", image.Data.Length)); sb.AppendLine(string.Format("Average {0}", average)); sb.AppendLine(string.Format("Delta {0}", delta)); sb.AppendLine(string.Format("minValue {0}", minValue)); sb.AppendLine(string.Format("maxValue {0}", maxValue)); Console.WriteLine(sb.ToString()); using (var blurBuilder = new BlurBuilder(filterStep)) image = blurBuilder.Blur(image); Buffer.BlockCopy(image.Data, 0, bytes, 0, bytes.Length); double average1 = bytes.Average(x => (double) x); double delta1 = Math.Sqrt(bytes.Average(x => (double) x*x) - average1*average1); double minValue1 = bytes.Min(x => (double) x); double maxValue1 = bytes.Max(x => (double) x); var sb1 = new StringBuilder(); sb1.AppendLine(string.Format("Length {0}", image.Data.Length)); sb1.AppendLine(string.Format("Average {0}", average1)); sb1.AppendLine(string.Format("Delta {0}", delta1)); sb1.AppendLine(string.Format("minValue {0}", minValue1)); sb1.AppendLine(string.Format("maxValue {0}", maxValue1)); Console.WriteLine(sb1.ToString()); Assert.IsTrue(delta1 < delta); }
/// <summary> /// Blur bitmap with the Fastest Fourier Transform /// </summary> public CvBitmap(CvBitmap input, BlurBuilder builder) : base(builder.Blur(input).Data) { }