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
oldbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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).
oldbAuthor Commented:
WelkinMaze

How?
show me some example code
WelkinMazeCommented:
Try to write something by yourself (it's better this way) and post it here if it doesn't work.
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.