Bug 692236

Summary: Add option to downscaled devices to use halftoning rather than error diffusion.
Product: Ghostscript Reporter: Eric <ericw>
Component: GeneralAssignee: Robin Watts <robin.watts>
Status: CONFIRMED ---    
Severity: enhancement CC: robin.watts, sphinx.pinastri
Priority: P4 Keywords: bountiable
Version: 9.02   
Hardware: Macintosh   
OS: MacOS X   
Customer: Word Size: ---
Attachments: The rendered file demonstrating the artifact.
The source PDF file.

Description Eric 2011-05-26 18:43:51 UTC
Created attachment 7538 [details]
The rendered file demonstrating the artifact.

The error diffusion algorithm used in tiffscaled can generate large, unsightly artifacts when large images of flat color are rendered. This is reminiscent to the little bugs in the "Life" computer game, or the automata in Wolfram's ego-inflating tome "A New Kind of Science".

Attached are two files. One is the source PDF, the other is the 1-bit TIFF output file. The command used was:

/opt/local/bin/gs -sDEVICE=tiffscaled -sOutputFile=/scaled.tif -dMinFeatureSize=4 -r600 /Users/eric/Desktop/PDF\ Analyzer/CMYK\ Square.pdf 

The artifact can be seen in the grey rectangle in the upper left-hand corner.
Comment 1 Eric 2011-05-26 18:44:48 UTC
Created attachment 7539 [details]
The source PDF file.
Comment 2 Ray Johnston 2011-05-26 20:04:10 UTC
I recommend either changing tiffscaled to use a stochastic threshold array.
We can generate one using my 'genpat' function of any dimension, or use
the 167x167 array in 'ht_ccsto.ps'. Note that gx_ht_construct_threshold
can be used to get a threshold array from whatever halftone is set in the
graphics state so that "normal" methods (like PS) can be used to set up
the threshold array.

If better error diffusion is needed, then we should take advantage of the
Even Toned Screening that is in the 'rinkj' directory.

I've changed this to 'enhancement' and marked it bountiable.
Comment 3 Robin Watts 2011-05-28 17:40:59 UTC
That's exactly typical of using error diffusion. I disagree with Ray about 'changing to use stochastic thresholding'. There may be a case to be made for having stochastic thresholding as an option, but there are cases where error diffusion does a better job.
Comment 4 Ray Johnston 2011-05-28 21:43:44 UTC
I agree that an option for ETS (Even Tone Screening) _or_ threshold array
based screening (for when performance in important, or when the technology
cannot image dispersed individual dots).

Deriving the threshold array from the 'order' using gx_ht_construct_threshold
lets the user choose the screening.

I suppose the selection of threshold array vs. ETS would be a parameter for
this device.

This is bountiable, and an enhancement, but I'll assign it to Robin since
he wrote the device in question and can guide any outside developer seeking
the bounty or maybe get to it himself.
Comment 5 Robin Watts 2011-07-22 11:03:33 UTC
Rename bug.
Comment 6 Peter Cherepanov 2017-07-28 12:55:21 UTC
I'm wondering what the scope of this enhancement request is, now that ETS halftoning is implemented.
Comment 7 Ray Johnston 2017-07-28 15:15:04 UTC
Supporting thresold array based haltoning would provide for either ordered
or blue noise (stochastic) to be used. Ghostscript is distributed with both
gen_ordered and gen_stochastic programs to generate threshold arrays.

Threshold array based halftoning is much faster than error diffusion, and is
amenable to using SIMD (SSE2 or other) for even more acceleration.