I am referring to whether an image could be described as a matrix in the form:
(Image) => (x1, x2, ... , x61, x62);
where xa is a positive integer.
Gam
You want to convert an nxm image to a 1xnm matrix Most people wouldn't call that a matrix; a list or a vector is much more specific. (This is most definitely not a matrix of "high dimensions" though, unless you consider 1 dimension high).
TonoGam, I don't know if this is what you mean, but you can convert a bitmap to an array of bytes. What follows is a slightly modified version of an example on the MSDN (for the full example, see Bitmap.LockBits):
private byte [] GetImageBytes (Bitmap bmp) { Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits (rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); IntPtr ptr = bmpData.Scan0; // This code is specific to a bitmap with 24 bits per pixels. int bytes = bmp.Width * bmp.Height * 3; byte [] rgbValues = new byte [bytes]; System.Runtime.InteropServices.Marshal.Copy (ptr, rgbValues, 0, bytes); bmp.UnlockBits (bmpData); return rgbValues; }
The above works for 24bpp, but it's not difficult to adapt to other pixel formats.
Converting images to matrix form
IntMain
You want to convert an nxm image to a 1xnm matrix Most people wouldn't call that a matrix; a list or a vector is much more specific. (This is most definitely not a matrix of "high dimensions" though, unless you consider 1 dimension high).
SanthaMind
I am referring to whether an image could be described as a matrix in the form:
(Image) => (x1, x2, ... , x61, x62);
where xa is a positive integer.
Gam
Matt Tolhurst
You can certainly use this declaration:
int[ ] image = { x0, x1, x2, … };
but I think this could get a little tedious. A little more detail in your question would provoke a more accurate response.
VAD214
TonoGam,
private byte [] GetImageBytes (Bitmap bmp) {I don't know if this is what you mean, but you can convert a bitmap to an array of bytes. What follows is a slightly modified version of an example on the MSDN (for the full example, see Bitmap.LockBits):
Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits (rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
IntPtr ptr = bmpData.Scan0;
// This code is specific to a bitmap with 24 bits per pixels.
int bytes = bmp.Width * bmp.Height * 3;
byte [] rgbValues = new byte [bytes];
System.Runtime.InteropServices.Marshal.Copy (ptr, rgbValues, 0, bytes);
bmp.UnlockBits (bmpData);
return rgbValues;
}
The above works for 24bpp, but it's not difficult to adapt to other pixel formats.
HTH
--mc
Simon FERQUEL
What would you expect the obstacles to be
How high is ‘high’, in ‘high dimensions’
< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
What do you mean by ‘unique’