Exemplo n.º 1
0
 private void median_filter(IImageMatrix<IRGB> matrix, int x, int y)
 {
     byte[] pixelsR = new byte[m_workingAreaCapacity];
     byte[] pixelsB = new byte[m_workingAreaCapacity];
     byte[] pixelsG = new byte[m_workingAreaCapacity];
     int pixelOrder = 0;
     for (int i = x - radius; i < x + radius + 1; i++)
     {
         for (int j = y - radius; j < y + radius + 1; j++)
         {
             IRGB rgb = matrix[i, j];
             pixelsR[pixelOrder] = rgb.R;
             pixelsG[pixelOrder] = rgb.G;
             pixelsB[pixelOrder] = rgb.B;
             pixelOrder++;
         }
     }
     Array.Sort(pixelsR);
     Array.Sort(pixelsG);
     Array.Sort(pixelsB);
     IRGB targetRGB = matrix[x, y];
     targetRGB.R = pixelsR[m_medianPixel];
     targetRGB.G = pixelsG[m_medianPixel];
     targetRGB.B = pixelsB[m_medianPixel];
 }
Exemplo n.º 2
0
		/// <summary>
		/// Обновляет свойства InputMatrix и OutputMatrix новыми значениями, полученными из colorMatrix. 
		/// </summary>
		public void UpdateImages(IImageMatrix colorMatrix)
		{
			if(colorMatrix != null)
			{
				InputMatrix = colorMatrix.ToMat();
				OutputMatrix = InputMatrix.Clone();
			}
		}
        public static Mat ToMat(this IImageMatrix colorMatrix)
        {
            var result = new Mat(new Size(colorMatrix.Width, colorMatrix.Height), MatType.CV_8UC3);

            using (var matrixData = colorMatrix.LockData())
            {
                Native
                .Kernel32
                .CopyMemory(result.Data, matrixData.Scan0, matrixData.Stride * matrixData.Height);
            }
            return(result);
        }
Exemplo n.º 4
0
        private void InitializeVideoSource()
        {
            _videoSourceProvider = _container.Resolve <IVideoSourceProvider>();
            _videoSource         = _videoSourceProvider.CreateVideoSource();

            _matrix = new ColorMatrix();

            _frameImage.Matrix = _matrix;
            _frameImage.ManualUpdateRendererCache = true;
            _frameImage.SizeMode = ImageSizeMode.Zoom;

            StartVideoSource();
        }
Exemplo n.º 5
0
 public Image<Bgr, Byte> CreateImage(IImageMatrix<IRGB> matrix, int startx, int starty, int width, int height)
 {
     Bitmap bitmap = new Bitmap(width, height);
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             IRGB pixel = matrix[startx + i,starty + j];
             bitmap.SetPixel(i, j, Color.FromArgb(pixel.R, pixel.G, pixel.B));
         }
     }
     return new Image<Bgr,byte>(bitmap);
 }
 public static byte[,] GetGrey(IImageMatrix<IRGB> matrix)
 {
     byte[,] result = new byte[matrix.Width, matrix.Height];
     for (int i = 0; i < matrix.Width; i++)
     {
         for (int j = 0; j < matrix.Height; j++)
         {
             IRGB pix = matrix[i, j];
             result[i, j] = (byte)(0.3 * pix.R + 0.59 * pix.G + 0.11 * pix.B);
         }
     }
     return result;
 }
Exemplo n.º 7
0
 public Barchart(IImageMatrix<IRGB> sampleImage)
 {
     this.sampleImage = sampleImage;
     this.foundObject = new FoundObject();
 }
 void ToGrey(IImageMatrix<IRGB> matrix)
 {
     for (int i = 0; i < matrix.Width; i++)
     {
         for (int j = 0; j < matrix.Height; j++)
         {
             IRGB pix = matrix[i, j];
             byte temp = (byte)(0.3 * pix.R + 0.59 * pix.G + 0.11 * pix.B);
             pix.B = temp;
             pix.G = temp;
             pix.R = temp;
         }
     }
 }