• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

image processing

Hi experts,

How do I convert an image to a matrix of numbers?

eg)
I have a image file image.bmp
I would like to convert it to a matrix of numbers,
say red = 255, lighter red = 252, white = 0........
I want to pixel the image into a matirx and then get a matrix of numbers.
Please show me some simple example codes that i can write

eg) int main( file image......)

thanx
0
oldb
Asked:
oldb
  • 2
1 Solution
 
WelkinMazeCommented:
You can simply read the whole data from the bmp file in one dimensional array. And since this is C language after that just index the array as two dimensional (matrix).
0
 
oldbAuthor Commented:
WelkinMaze

How?
show me some example code
0
 
WelkinMazeCommented:
Try to write something by yourself (it's better this way) and post it here if it doesn't work.
0
 
itsmeandnobodyelseCommented:
If you are on a Windows platform you should check the struct BITMAPINFO

typedef struct tagBITMAPINFO { // bmi
    BITMAPINFOHEADER bmiHeader;
    RGBQUAD          bmiColors[1];
} BITMAPINFO;

which has a header and a variable number of RGB values. The biSize member of the header struct tells you the size of the bitmap (file).

So, you might first read the header, get the size and read the rest to an appropriate buffer (you might allocate a properly sized array of RGBQUAD words).

Regards, Alex
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now