コード例 #1
0
ファイル: GrayWorldTest.cs プロジェクト: sami1971/framework
        public void ProcessImageTest()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;

            new MatrixToImage()
            {
                Format = PixelFormat.Format24bppRgb
            }.Convert(diag, out input);

            GrayWorld gabor = new GrayWorld();

            // Apply the filter
            Bitmap output = gabor.Apply(input);

            double[,] actual;

            new ImageToMatrix().Convert(output, out actual);

            string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture);

            double[,] expected =
            {
                { 0.309803921568627, 0.301960784313725, 0.333333333333333,  0.32156862745098, 0.313725490196078 },
                { 0.301960784313725, 0.325490196078431, 0.325490196078431, 0.313725490196078, 0.313725490196078 },
                { 0.329411764705882, 0.325490196078431, 0.317647058823529, 0.305882352941176, 0.305882352941176 },
                {  0.32156862745098, 0.317647058823529, 0.309803921568627, 0.305882352941176, 0.329411764705882 },
                { 0.317647058823529, 0.309803921568627, 0.301960784313725, 0.329411764705882,  0.32156862745098 }
            };

            Assert.IsTrue(expected.IsEqual(actual, 1e-6));
        }
コード例 #2
0
ファイル: GrayWorldTest.cs プロジェクト: sami1971/framework
        public void ApplyTest1()
        {
            Bitmap image = Properties.Resources.lena_color;

            // Create the Gray World filter
            var grayWorld = new GrayWorld();

            // Apply the filter
            Bitmap result = grayWorld.Apply(image);

            // ImageBox.Show(result);
            Assert.IsNotNull(result);
        }
コード例 #3
0
ファイル: GrayWorldTest.cs プロジェクト: haf/Accord.Net
        public void ProcessImageTest2()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;

            new MatrixToImage()
            {
                Format = PixelFormat.Format32bppArgb
            }.Convert(diag, out input);

            Assert.AreEqual(PixelFormat.Format32bppArgb, input.PixelFormat);

            GrayWorld gabor = new GrayWorld();

            // Apply the filter
            Bitmap output = gabor.Apply(input);

            Assert.AreEqual(PixelFormat.Format32bppArgb, output.PixelFormat);

            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));
        }