Bug 694850 - Threshold tables are not generated entirely evenly.
Summary: Threshold tables are not generated entirely evenly.
Status: RESOLVED WONTFIX
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Images (show other bugs)
Version: master
Hardware: All All
: P4 enhancement
Assignee: Michael Vrhel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-17 06:59 UTC by Robin Watts
Modified: 2023-05-23 16:41 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Test case (332 bytes, application/postscript)
2021-01-03 00:20 UTC, Peter Cherepanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Watts 2013-12-17 06:59:30 UTC
This is a spin off from bug 694842.

In order to do halftoning we build threshold tables. These are then used to map contone values to dithered values, such that if contone(x,y) < threshold(x,y), we set the pixel at (x,y).

For an n pixel area, there are n+1 possible levels (ranging from 0 to n pixels set). As such we'd expect the threshold table to map roughly equal divisions of the source contone range into each level of dither.

The existing code fails to do this. For a source range of 0..255 it divides the range into n 256/n sized blocks (for the middle cases) and two 512/n sized blocks (for the 0 and n cases). We should fix this.

Also, we should check the behaviour of the code in the case where we are dithering with more than simple black and white.
Comment 1 Robin Watts 2013-12-17 07:00:55 UTC
Assigning to Michael, as requested.
Comment 2 Peter Cherepanov 2021-01-03 00:20:02 UTC
Created attachment 20415 [details]
Test case

I don't know how to observe any effects of this in rendering. When the test case is rendered as:
 ~/ghostpdl/debugbin/gs -r1000 -o a.tiff -sDEVICE=tiffg4 a.ps

it produced a few steps of a tint ramp. These steps occur due to internal rounding to 8 bit. The width of every step is about the same. IMHO Ghostscript works fine.