Example #1
0
        public void InitYUVFromRGB()
        {
            var matrixMapY = new double[Height, Width];
            var matrixMapU = new double[Height, Width];
            var matrixMapV = new double[Height, Width];

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    matrixMapY[i, j] = +RGBConverstionMatrix[0, 0] * RGBMatrix.R[i, j]
                                       + RGBConverstionMatrix[1, 0] * RGBMatrix.G[i, j]
                                       + RGBConverstionMatrix[2, 0] * RGBMatrix.B[i, j];

                    matrixMapU[i, j] = 128 + RGBConverstionMatrix[0, 1] * RGBMatrix.R[i, j]
                                       + RGBConverstionMatrix[1, 1] * RGBMatrix.G[i, j]
                                       + RGBConverstionMatrix[2, 1] * RGBMatrix.B[i, j];

                    matrixMapV[i, j] = 128 + RGBConverstionMatrix[0, 2] * RGBMatrix.R[i, j]
                                       + RGBConverstionMatrix[1, 2] * RGBMatrix.G[i, j]
                                       + RGBConverstionMatrix[2, 2] * RGBMatrix.B[i, j];
                }
            }

            YUVMatrix = new YUVColors()
            {
                Y = matrixMapY,
                U = matrixMapU,
                V = matrixMapV,
            };
        }
Example #2
0
 public PPM(string filename, int width, int height, int maxValue)
 {
     FileName  = filename;
     Width     = width;
     Height    = height;
     MaxValue  = maxValue;
     YUVMatrix = new YUVColors();
     RGBMatrix = new RGBColors();
 }