Exemple #1
0
        /// <summary>
        /// 將Emgu.Image.Data設定至PixelBitmap.Pixel
        /// </summary>
        /// <param name="bgraData"><see cref="Emgu"/>.<see cref="Image"/>.Data</param>
        /// <remarks>以三維陣列設定圖像像素陣列,像素深度按B,G,R,A排列</remarks>
        public static PixelBitmap ToPixelBitmap(this byte[,,] bgraData)
        {
            var pixel3      = bgraData.Clone() as byte[, , ];
            var height      = pixel3.GetLength(0);
            var width       = pixel3.GetLength(1);
            var depth       = pixel3.GetLength(2);                      //iptImage depth
            var stride      = depth * width;                            //iptImage stride
            var pixelBitmap = new PixelBitmap(new Size(width, height)); //不更新pixel
            var pixel       = new byte[width * height * pixelBitmap.Depth];
            int idx;

            for (int row = 0; row < height; row++)
            {
                for (int col = 0; col < width; col++)
                {
                    idx            = col * pixelBitmap.Depth + row * pixelBitmap.Stride;
                    pixel[idx + 0] = pixel3[row, col, 0]; //B
                    pixel[idx + 1] = pixel3[row, col, 1]; //G
                    pixel[idx + 2] = pixel3[row, col, 2]; //R
                    pixel[idx + 3] = pixel3[row, col, 3]; //A
                }
            }
            pixelBitmap.Pixel = pixel; // Update Bitmap
            return(pixelBitmap);
        }
Exemple #2
0
        public void GetAxisTest()
        {
            var imageFilterW = new PixelBitmap(pixelBitmap.Size)
            {
                Pixel = ImageProcessing.FilterW(pixelBitmap)
            };

            var(actualAxis, axisType) = ImageProcessing.GetAxis(imageFilterW);
            var expectedAxis = new Rect(87, 20, 747, 547);

            Assert.AreEqual(expectedAxis, actualAxis);
        }
Exemple #3
0
 public ImageProcessingTests()
 {
     pixelBitmap = new Bitmap(@"C:\Users\alex\Desktop\WPF\WpfPlotDigitizer\WpfPlotDigitizerTests\data.png").ToPixelBitmap();
     imageBGRA   = pixelBitmap.ToImage <Bgra, byte>();
     mat         = imageBGRA.Mat;
 }
Exemple #4
0
 public static Image <TColor, TDepth> ToImage <TColor, TDepth>(this PixelBitmap pixelBitmap)
     where TColor : struct, IColor
     where TDepth : new()
 {
     return(pixelBitmap.Bitmap.ToImage <TColor, TDepth>());
 }
Exemple #5
0
 public static Mat ToMat(this PixelBitmap pixelBitmap) => pixelBitmap.Bitmap.ToMat();