views:

157

answers:

2

I want to process an image in C++. How can I access the 3D array representing the JPEG image as is done in MATLAB?

+3  A: 

Well, I've never used MATLAB for such a task, but in C++ you will need some JPEG loader library like OpenIL or FreeImage. These will allow you to access the picture as byte arrays.

FreeImage's FreeImage_GetBits function has a detailed example in the documentation on how to access per pixel per channel data.

BTW, if you plan to do image processing in C/C++, I'd suggest you to check out the Insight Segmentation and Registration Toolkit and OpenCV.

shinjin
+4  A: 

I'd suggest using OpenCV for the task; C++ documentation is available here. The relevant (I believe) data structure which you'd have to use is the Point3_ class, which represents a 3D point in the image.

welp
I... don't think he's looking for computer vision. Or is OpenCV a good library just for decoding JPEG?
Matti Virkkunen
OpenCV's a perfectly good library for decoding various image formats. I believe its cvLoadImage function is capable of opening the following image formats: BMP, DIB, JPEG, JPG, JPE, PNG, PBM, PGM, PPM, SR, RAS, TIFF, TIF.For what it's worth, Wikipedia states that OpenCV "focuses mainly on real-time image processing."
welp
All right, it seems OpenCV comes up with a good set of image format decoders :)
Matti Virkkunen