public static DataRectangle <RGB> GetRGB(this Bitmap image) { if (image == null) { throw new ArgumentNullException(nameof(image)); } var imageColours = image.GetColourData(); var values = new RGB[image.Width, image.Height]; for (var x = 0; x < image.Width; x++) { for (var y = 0; y < image.Height; y++) { var imageColour = imageColours[x, y]; values[x, y] = new RGB(imageColour.R, imageColour.G, imageColour.B); } } return(DataRectangle.For(values)); }