Bug 695597 - Look at the output from the pdfwrite Bicubic image downsampler
Summary: Look at the output from the pdfwrite Bicubic image downsampler
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: master
Hardware: PC Windows 7
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-13 07:37 UTC by Ken Sharp
Modified: 2015-05-14 04:20 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
specimen files and output (2.02 MB, application/zip)
2014-10-13 07:37 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Sharp 2014-10-13 07:37:44 UTC
Created attachment 11241 [details]
specimen files and output

The user in bug #695579 was complaining that we were ignoring Bicubic downsampling in more recent versions. This turns out not to be the case. In fact we were ignoring it in earlier versions, and now we do honour it :-)

I tried the attached file with both GS and Acrobat Distiller 3 ways; once each with the Subsample, Average and Bicubic filters. The Distiller output for Subsample and average more or less match the GS output, but the GS Bicubic output is quite unlike the Distiller output, and more closely matches the Subsample result. (it is possible that some bug in pdfwrite is causing this to be broken, but I don;t think so).

The Ghostscript command line is:
-sDEVICE=pdfwrite -dColorImageDownsampleType=/Bicubic -dColorImageResolution=56 -dDownsampleColorImages=true -sOutputFile=\temp\out.pdf

obviously substituting /Average and /Subsample for the DownsampleType. I sued 56 dpi because if the downsample factor is not approximately integer, pdfwrite will substitute the Bicubic filter.

The attached zip has the reduced PDF file, the PostScript file made from it (You can't run PDF to Distiller) and the various outputs from GS and Distiller. I notice that the Bicubic and Average output from Distiller are almost, but not quite, identical.....
Comment 1 Robin Watts 2015-05-08 12:08:40 UTC
It makes no sense to use Bicubic interpolation for downscaling (for anything beyond a factor of 2 at least). That is why we get artifacts.

Options to improve this would be to:

1) subsample by factors of 2 until we reach 'just' higher than we need (i.e. apply a box filter), and then bicubicly downscale the last step.

2) just use the mitchell filter when bicubic is requested for a downscale factor larger than 2.

I'd opt for 2 personally.
Comment 2 Ken Sharp 2015-05-09 01:50:06 UTC
(In reply to Robin Watts from comment #1)
> It makes no sense to use Bicubic interpolation for downscaling (for anything
> beyond a factor of 2 at least). That is why we get artifacts.

Acrobat Distiller sets the default downsampling for all image types to be Bicubic, so are Adobe incorrect then ?

Or does Distiller do something akin to '1' ? I notice that the 'bicubic' and 'average' results in Distiller are very similar.
Comment 3 Ken Sharp 2015-05-09 01:55:57 UTC
Is it possible that when Distiller says 'Bicubic' they simply mean a Mitchell filter ?
Comment 4 Robin Watts 2015-05-09 03:37:48 UTC
(In reply to Ken Sharp from comment #3)
> Is it possible that when Distiller says 'Bicubic' they simply mean a
> Mitchell filter ?

I suspect that if they are asked to downscale by more than a factor of 2, they use the mitchell filter. I am inclined to think that's what we should do.
Comment 5 Ken Sharp 2015-05-11 04:04:30 UTC
Re-assigning to me to look at either just using the Mitchell filter (I_scale) or Robin's option 2, use the bicubic filter up to downsampling of 2, and Mitchell thereafter.
Comment 6 Ken Sharp 2015-05-14 04:20:38 UTC
I believe this is 'fixed' with ab45751e7b38c7f9b28b090af52649f19355115d

When 'bicubic' downsampling is requested we now use the Mitchell filter. If we revert to bicubic downsampling (because the downsample factor isn't an integer) we still use bicubic filter.

Changed a few defaults and updated the documentation (which was wrong anyway).