Home > Archive > Compression > September 2004 > JPEG Transcoding - Lossless Rotate and Mirror
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
JPEG Transcoding - Lossless Rotate and Mirror
|
|
| Korejwa 2004-09-18, 8:55 am |
|
JPEG Group has a utility called "jpegtran" which can rotate and mirror JPG
pictures without quality loss. An online version of this application can
be found here:
http://sylvana.net/jpeg-lab.html
I know how to arrange the quantization tables and DCTs in a JPG file to
swap the top-right and lower-left corner of a picture, but I can not
figure out how to do any other lossless rotate and mirror functions.
I am looking for the algorithms that make these other manipulations
possible. I do not know C well enough to understand JPEG Group's source
code, and would prefer an explanation in plain english.
Any help would be appreciated. Thanks.
-korejwa
| |
| Sebastian Gesemann 2004-09-18, 8:55 am |
| On Sat, 18 Sep 2004, Korejwa wrote:
> I know how to arrange the quantization tables and DCTs in a JPG file to
> swap the top-right and lower-left corner of a picture, but I can not
> figure out how to do any other lossless rotate and mirror functions.
>
> I am looking for the algorithms that make these other manipulations
> possible. I do not know C well enough to understand JPEG Group's source
> code, and would prefer an explanation in plain english.
If you know how you mirror horizontally, vertically and across the
diagonal axis you can also rotate in 90° steps.
Suppose that you have the DCT coefficients available as
coeff(i,j) for i,j=0..7, i being "the x frequency" and
j being the "y frequency"
Mirroring at the diagonal axis:
new_coeffs(i,j) = coeff(j,i)
Swapping left/right:
new_coeffs(i,j) = coeffs(i,j) * sign_adjust1(i,j)
where sign_adjust(i,j) is 1 for even i and -1 for odd i
Swapping up/down
is similar to swapping left/right except that sign_adjust
depends on j
90° clockwise rotation would be
- swap at diagonal axis
- swap left/right
90° counter clockwise rotation would be
- swap at diagonal axis
- swap up/down
The elements of the quantization tables have to be swapped in
the same way. Now the only thing left is to encode your file.
> Any help would be appreciated. Thanks.
>
> -korejwa
HTH,
Sebastian
--
PGP-Key-ID (long): 572B1778A4CA0707
| |
| Korejwa 2004-09-22, 8:55 am |
|
Thanks a million Sebastian!
I've put quite a few hours into this, and I'm now able to do all the
possible transforms based on the information you've given me. I can't
thank you enough!
-korejwa
On Sat, 18 Sep 2004 14:37:35 +0200, Sebastian Gesemann <isnt@valid.net>
wrote:
> On Sat, 18 Sep 2004, Korejwa wrote:
>
>
> If you know how you mirror horizontally, vertically and across the
> diagonal axis you can also rotate in 90° steps.
>
> Suppose that you have the DCT coefficients available as
> coeff(i,j) for i,j=0..7, i being "the x frequency" and
> j being the "y frequency"
>
> Mirroring at the diagonal axis:
> new_coeffs(i,j) = coeff(j,i)
>
> Swapping left/right:
> new_coeffs(i,j) = coeffs(i,j) * sign_adjust1(i,j)
> where sign_adjust(i,j) is 1 for even i and -1 for odd i
>
> Swapping up/down
> is similar to swapping left/right except that sign_adjust
> depends on j
>
> 90° clockwise rotation would be
> - swap at diagonal axis
> - swap left/right
>
> 90° counter clockwise rotation would be
> - swap at diagonal axis
> - swap up/down
>
> The elements of the quantization tables have to be swapped in
> the same way. Now the only thing left is to encode your file.
>
>
>
>
> HTH,
> Sebastian
>
> --
> PGP-Key-ID (long): 572B1778A4CA0707
>
|
|
|
|
|