|
Science Forum Index » Image Processing Forum » Extracting a region from a Jpeg
Page 1 of 1
|
| Author |
Message |
| Jeff |
Posted: Wed Apr 30, 2008 12:54 pm |
|
|
|
Guest
|
Hi
Does anyone know if it would be possible in principle to extract a
rectangular region from a Jpeg file without decoding the pixels - or put
another way could a jpeg file be cropped without first decoding it? I'd be
prepared to accept that the width and height of the rectangle had to be
aligned multiples of 8.
My sketchy understanding of Jpeg suggests that the entropy encoding scheme
would prevent this. If that is the case, would it at least be possible to
crop a jpeg without inverting the DCT?
Thanks
Jeff |
|
|
| Back to top |
|
| Thomas Richter |
Posted: Wed Apr 30, 2008 5:01 pm |
|
|
|
Guest
|
Jeff wrote:
Quote: Hi
Does anyone know if it would be possible in principle to extract a
rectangular region from a Jpeg file without decoding the pixels - or put
another way could a jpeg file be cropped without first decoding it? I'd be
prepared to accept that the width and height of the rectangle had to be
aligned multiples of 8.
It is surely possible to do that. The anchor point hat to be a multiple
of eight, the width and height can be arbitrary. You would have to
re-encode parts of the DC coefficients, or at least decode parts of the
DC coefficients.
Quote: My sketchy understanding of Jpeg suggests that the entropy encoding scheme
would prevent this.
Not really. Blocks are almost coded independently, i.e. up to the DC
part, which you would have to decode separately.
Quote: If that is the case, would it at least be possible to
crop a jpeg without inverting the DCT?
Sure.
So long,
Thomas |
|
|
| Back to top |
|
| bugbear |
Posted: Thu May 01, 2008 3:24 am |
|
|
|
Guest
|
Jeff wrote:
Quote: Hi
Does anyone know if it would be possible in principle to extract a
rectangular region from a Jpeg file without decoding the pixels - or put
another way could a jpeg file be cropped without first decoding it? I'd be
prepared to accept that the width and height of the rectangle had to be
aligned multiples of 8.
Try looking at jpegtran. Does (in the latest version)
what you want, and the source is available.
http://sylvana.net/jpegcrop/
BugBear |
|
|
| Back to top |
|
| Jeff |
Posted: Thu May 01, 2008 4:14 pm |
|
|
|
Guest
|
"Thomas Richter" <thor@math.tu-berlin.de> wrote in message
news:fvaq3j$de5$1@infosun2.rus.uni-stuttgart.de...
Quote: Jeff wrote:
Hi
Does anyone know if it would be possible in principle to extract a
rectangular region from a Jpeg file without decoding the pixels - or put
another way could a jpeg file be cropped without first decoding it? I'd
be prepared to accept that the width and height of the rectangle had to
be aligned multiples of 8.
It is surely possible to do that. The anchor point hat to be a multiple of
eight, the width and height can be arbitrary. You would have to re-encode
parts of the DC coefficients, or at least decode parts of the DC
coefficients.
My sketchy understanding of Jpeg suggests that the entropy encoding
scheme would prevent this.
Not really. Blocks are almost coded independently, i.e. up to the DC part,
which you would have to decode separately.
If that is the case, would it at least be possible to crop a jpeg without
inverting the DCT?
Sure.
So long,
Thomas
Thanks a million - that's really useful.
Would these comments apply to both the baseline and progressive encodings?
Also, would it be straightforward to index the 8x8 blocks within the file so
that they could quickly be extracted without even expanding them - or are
you saying that can be done with the existing structure anyway?
Thanks again.
Jeff |
|
|
| Back to top |
|
| Jeff |
Posted: Thu May 01, 2008 4:33 pm |
|
|
|
Guest
|
"bugbear" <bugbear@trim_papermule.co.uk_trim> wrote in message
news:IrednVtpCN_J44TVnZ2dnUVZ8rKdnZ2d@plusnet...
Quote: Jeff wrote:
Hi
Does anyone know if it would be possible in principle to extract a
rectangular region from a Jpeg file without decoding the pixels - or put
another way could a jpeg file be cropped without first decoding it? I'd
be prepared to accept that the width and height of the rectangle had to
be aligned multiples of 8.
Try looking at jpegtran. Does (in the latest version)
what you want, and the source is available.
http://sylvana.net/jpegcrop/
BugBear
Thanks a lot.
I downloaded the windows version of this softwarw including the executable
with the GUI .
The supplied command line executables work fine, but when I build them
myself in VS2005 I get a crash reading the source file header at line 550 of
jpegtran.c = (void) jpeg_read_header(.....). Has anyone else come across
this?
Thanks again
Jeff |
|
|
| Back to top |
|
| |