예제 #1
0
 public Complex[,] ToComplex(Bitmap image)
 {
     if (!Grayscale.IsGrayscale(image))
     {
         throw new Exception("Source image must not be color");
     }
     int[,] array2d = ToInteger(image);
     return(ToComplex(array2d));
 }
예제 #2
0
    public int[,] ToInteger(Bitmap input)
    {
        if (!Grayscale.IsGrayscale(input))
        {
            throw new Exception("Source image must not be color");
        }
        int Width  = input.Width;
        int Height = input.Height;

        int[,] array2d = new int[Width, Height];
        for (int y = 0; y < Height; y++)
        {
            for (int x = 0; x < Width; x++)
            {
                Color cl   = input.GetPixel(x, y);
                int   gray = (int)Convert.ChangeType(cl.R * 0.3 + cl.G * 0.59 + cl.B * 0.11, typeof(int));
                array2d[x, y] = gray;
            }
        }
        return(array2d);
    }