//-----------------------------------------------------------------------------------------------
        //Матрица интенсивностей серого
        public RealMatrix GetGrayScaleMatrix()
        {
            int        rowCount        = this.Image.PixelHeight;
            int        columnCount     = this.Image.PixelWidth;
            RealMatrix grayScaleMatrix = new RealMatrix(rowCount, columnCount);

            for (int y = 0; y < rowCount; y++)
            {
                for (int x = 0; x < columnCount; x++)
                {
                    media.Color pixelColor    = this.GetPixelColor(x, y);
                    int         grayIntensity = ColorWrapper.GetGrayIntensity(pixelColor);
                    grayScaleMatrix[y, x] = grayIntensity;
                }
            }
            return(grayScaleMatrix);
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------------------------------
        //Матрица интенсивностей серого из изображения
        public static RealMatrix GetGrayScaleMatrixFromBitmap(Bitmap bitmap)
        {
            int        sizeX           = bitmap.Width;
            int        sizeY           = bitmap.Height;
            RealMatrix grayScaleMatrix = new RealMatrix(sizeY, sizeX);

            for (int x = 0; x < sizeX; x++)
            {
                for (int y = 0; y < sizeY; y++)
                {
                    System.Drawing.Color pixelColor = bitmap.GetPixel(x, y);
                    double grayIntensity            = ColorWrapper.GetGrayIntensity(pixelColor);
                    grayScaleMatrix[y, x] = grayIntensity;
                }
            }

            return(grayScaleMatrix);
        }