quality of downsampled images once JPEG compressed
Posted: 2011-04-12T18:41:57-07:00
Another reason I like -distort resize:
If you care about the overall quality of a destructively
compressed jpeg, a reasonable thing to do is to compare the visual
quality for a fixed final image size. In the following, I omitted the
final sharpening step. The lanczoses are pretty sharp to start with,
and sharpening makes the final file larger and also introduces more
"JPEG ringing" around sharp interfaces.
If you now visually compare the results of -resize and -distort resize (the two methods that give, in my opinion, the best results overall), you will see that the "JPEG ringing" is less obstrusive with -distort resize, and the -distort resize result's sharpness is more natural (which, arguably, means "softer"). Yet, the distort lanczos file is smaller.
Again, although this is subjective, it is my opinion that when combined with JPEG compression, distort lanczos (and variants) give slightly better results than their resize counterparts. (IMHO, this is also the case when no compression is used.)
There is a theoretical reason for this: EWA Jinc-windowed Jinc appears to be a better >>2D<< low-pass filter than tensor Sinc-windowed Sinc. It is, after all, a windowed version of the "ideal" (isotropic) 2D low-pass filter.
-filter lanczossharp does really well too.
P.S.
When I have a minute I'll fix the virtual pixel policy in the code. This may be skewing the results.
If you care about the overall quality of a destructively
compressed jpeg, a reasonable thing to do is to compare the visual
quality for a fixed final image size. In the following, I omitted the
final sharpening step. The lanczoses are pretty sharp to start with,
and sharpening makes the final file larger and also introduces more
"JPEG ringing" around sharp interfaces.
Code: Select all
# quality levels producing about the same size file:
# resize lanczos: 75 (size: 72916)
# distort lanczos: 76 (size: 71746)
# distort lanczossharp: 76 (size: 72361)
# resize lanczos2: 76 (size: 71928)
# distort lanczos2: 78 (size: 72990)
# distort lanczos2sharp: 76 (size: 72499)
# resize triangle: 80 (size: 72780)
# distort triangle: 79 (size: 72249)
# test image from http://www.pbase.com/konascott/image/69543104/original
infile="69543104.bHSz3aSK.Downsampletestimage.jpg"
filt="lanczos"
fact=25
# IM compiled with --enable-hdri
# Note: I'd rather use LAB instead of YCbCr but I can't seem to make
# it work right.
filtering="-filter $filt -distort resize"
convert $infile \
-colorspace YCbCr \
$filtering $fact% \
-colorspace sRGB \
-sampling-factor 4:2:0 -quality 76 -strip distort$filt.jpg
filtering="-filter $filt -resize"
convert $infile \
-colorspace YCbCr \
$filtering $fact% \
-colorspace sRGB \
-sampling-factor 4:2:0 -quality 75 -strip resize$filt.jpg
Again, although this is subjective, it is my opinion that when combined with JPEG compression, distort lanczos (and variants) give slightly better results than their resize counterparts. (IMHO, this is also the case when no compression is used.)
There is a theoretical reason for this: EWA Jinc-windowed Jinc appears to be a better >>2D<< low-pass filter than tensor Sinc-windowed Sinc. It is, after all, a windowed version of the "ideal" (isotropic) 2D low-pass filter.
-filter lanczossharp does really well too.
P.S.
When I have a minute I'll fix the virtual pixel policy in the code. This may be skewing the results.