Exemple #1
0
        public static Mat ImageToMat(Bitmap image)
        {
            var mat = new Mat(image.Width, image.Height);

            for (var x = 0; x < mat.Width; x++)
            {
                for (var y = 0; y < mat.Height; y++)
                {
                    mat.Set(x, y, ColorConverter.RgbToGreyscale(image.GetPixel(x, y)));
                }
            }

            return(mat);
        }
Exemple #2
0
        public static Bitmap MatToImage(Mat img)
        {
            img.Normalize();

            var image = new Bitmap(img.Width, img.Height);

            for (var x = 0; x < image.Width; x++)
            {
                for (var y = 0; y < image.Height; y++)
                {
                    image.SetPixel(x, y, ColorConverter.GreyscaleToRgb(img.GetAt(x, y)));
                }
            }

            return(image);
        }