public void ProcessImageTest2() { double[,] diag = Matrix.Magic(5); Bitmap input; new MatrixToImage().Convert(diag, out input); // Create a new Kuwahara filter Kuwahara filter = new Kuwahara(); // Apply the filter Bitmap output = filter.Apply(input); double[,] actual; new ImageToMatrix().Convert(output, out actual); string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture); double[,] expected = { { 0.937254901960784, 0.909803921568627, 1, 0.972549019607843, 0.945098039215686 }, { 0.913725490196078, 0.984313725490196, 0.976470588235294, 0.949019607843137, 0.941176470588235 }, { 0.988235294117647, 0.980392156862745, 0.952941176470588, 0.925490196078431, 0.917647058823529 }, { 0.964705882352941, 0.956862745098039, 0.929411764705882, 0.92156862745098, 0.992156862745098 }, { 0.96078431372549, 0.933333333333333, 0.905882352941176, 0.996078431372549, 0.968627450980392 } }; Assert.IsTrue(expected.IsEqual(actual, 1e-6)); }
private void SetFilter() { ImageType = ImageTypes.GrayscaleBT709; Af.Kuwahara newFilter = new Af.Kuwahara(); newFilter.Size = makeOdd(); imageFilter = newFilter; }
public void KuwaharaTest1() { Bitmap image = Accord.Imaging.Image.Clone(Properties.Resources.lena512); Kuwahara kuwahara = new Kuwahara(); Bitmap result = kuwahara.Apply(image); //ImageBox.Show(result); Assert.IsNotNull(result); }
/// <summary> /// Kuwahara filter. /// <para>Accord.NET internal call. See: <see cref="Accord.Imaging.Filters.Kuwahara"/> for details.</para> /// </summary> /// <param name="img">Image.</param> /// <param name="size">the size of the kernel used in the Kuwahara filter. This should be odd and greater than or equal to five</param> /// <param name="blockSize">the size of each of the four inner blocks used in the Kuwahara filter. This is always half the <paramref name="size"/> minus one.</param> /// <param name="inPlace">Apply in place or not. If it is set to true return value can be omitted.</param> /// <returns>Processed image.</returns> public static Gray<byte>[,] Kuwahara(this Gray<byte>[,] img, int size = 5, int blockSize = 2, bool inPlace = false) { Kuwahara k = new Kuwahara(); return img.ApplyFilter(k, inPlace); }
/// <summary> /// Kuwahara filter. /// <para>Accord.NET internal call. See: <see cref="Accord.Imaging.Filters.Kuwahara"/> for details.</para> /// </summary> /// <param name="img">Image.</param> /// <param name="size">the size of the kernel used in the Kuwahara filter. This should be odd and greater than or equal to five</param> /// <param name="blockSize">the size of each of the four inner blocks used in the Kuwahara filter. This is always half the <paramref name="size"/> minus one.</param> /// <param name="inPlace">Apply in place or not. If it is set to true return value can be omitted.</param> /// <returns>Processed image.</returns> public static Image<Gray, byte> Kuwahara(this Image<Gray, byte> img, int size = 5, int blockSize = 2, bool inPlace = false) { Kuwahara k = new Kuwahara(); return img.ApplyFilter(k, inPlace); }