I want to iterate over each pixel color in a jpg
format image,
which library should I refer to to do this so that the code can be as short as possible?
I want to iterate over each pixel color in a jpg
format image,
which library should I refer to to do this so that the code can be as short as possible?
I can think of either ImageMagick or CImg. Here is a CImg tutorial for you. They abstract away a lot of the decompression details and just give you a grid to work with.
If you go with CImg, you only need to use the data call. You can probably do something like:
CImg<unsigned char> src("image.jpg");
int width = src.width();
int height = src.height();
unsigned char* ptr = src.data(10,10); // get pointer to pixel @ 10,10
unsigned char pixel = *ptr;
For access to pixel level information. libjpeg & JAI Image I/O Tools should be sufficient. JAI provide advance image processing framework more than this. All options allow you to read/write pixels to an image file.
libjpeg In C/C++. It is available for Linux and Window. I have used it in Linux before and it works well. However, if you would like to process other image type, you may need to get other package and learn another API interface.
Java Advanced Imaging(JAI) Image I/O Tools Remember to download the platform specific java package because there is specific optimization for different system. It covers not only JPG but other image format too with exact same API interface.
Java Advanced Imaging(JAI) If you plan to do more advance level of processing such as using image operator and filter, you can use this. This is a package provide higher level functionality than JAI Image I/O Tools.
EDIT: to remove the 1, 2 & 3 as suggested
I would use Allegro Game Library http://alleg.sourceforge.net/latestdocs/en/alleg010.html it's simple / open source / free / multiplatform, and you can iterate pixel by pixel if you want