Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: access 8x8 blocks in JPG



Francesco Gallarotti:

>is anybody aware of a library (in C/C++) or a method that allows to extract
>color information for a block of pixels (say 8x8) inside a JPG file WITHOUT
>having to spend time decompressing the entire image? Is it possible to do
>that?

Random access to any 8x8 block is not possible.

There are restart markers so that you may not have to decompress
everything before the block that you want to read, but I'm not sure
how easy it is to find out how many restart markers one can skip.

>My program is interested in querying single pixels (or 8x8 blocks of pixels
>if single is not possible) inside a JPG file but I really need speed and
>also to save space in memory, therefore I am looking for a method that
>doesn't require blowing up the entire image in memory to get a single pixel
>out of it...

The IJG library lets you handle decompressed blocks. So you could
write a handler function that throws away everything before the block
you want instead of loading it all into memory. This saves memory, but
isn't faster.

Maybe the library gives you exact control of the decoding process.
Then you could avoid doing IDCT, dequantization, color space
conversion etc. for blocks that you want to throw away anyway. This
would be a certain speed-up.

If a different file format is an option, you may want to consider one
that stores images as tiles which are compressed independently. TIFF
can do this and it supports JPEG style compression. Then you will only
have to decompress and load into memory the tile corresponding to
position (x, y).

Or you could split a large image into smaller ones and save them as
different JPEG files. Then you would pick the right one and could load
that small image.

Regards,
Marco



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.