BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention generally relates to the field of computer graphics and, more particularly, to error diffusion screening with parallel processing.
2. Description of the Related Art
Digital halftone screening is a mechanism for reproducing an image based on the use of less bits per pixel than available in an original image.
Very often only one bit will be available in an output image. That is, each pixel can only be either colored or not colored. In contrast, the original image will typically be continuous tone with eight or more bits per pixel, though often at a lower resolution than the output.
Screening utilizes the eye's natural tendency to integrate small dots over an area. In general, a person will perceive a tone (a shade of gray) from the screened image approximately according to the ratio of colored dots to the total number of dots over an area.
When more than two, but still a small number of tonal values is available, the eye of a viewer still perceives the tone from a group of adjacent dots and white space. However, the values that are implicitly integrated vary from point-to-point.
In principle, there are many possible arrangements of dots that can achieve the same visual result. In a perfect system, this is because the perceived tone depends on the ratio of colored dots and their densities, and not on the actual arrangement of the dots. There are many different classes of screening algorithms and these can be characterized by the way in which they arrange the dots.
A conventional halftone screen clusters colored pixels together in discrete areas called cells. This has the effect of making the dots more noticeable to the human eye. As a result, conventional halftone screens require the ability to reproduce small pixels at high resolutions to achieve high quality images. On the other hand, the ability of such screens to pre-compute and tessellate cells (i.e., group together cells) over an area is efficient; the clumping of dots allows for optional control over printing processes. In addition, the earlier and familiar physical manifestations produced using glass gratings and film are approximated by computational halftoning.
More recently, stochastic methods have been used with some success. These methods distribute the colored pixels more randomly, with a greater or lesser control over dot placement according to the particular algorithm. The key feature, here, is that the correct ratio of colored dots to white space should be achieved. Because smaller dot clusters are used, such methods can be used on lower resolution devices, such as ink-jet printers. However, they have the disadvantage of yielding an image that appears grainy.
Another method is error diffusion screening. Error diffusion screening has been more successful when applied at lower resolutions. It is also easy to apply where more than one-bit per pixel is available in the resultant image. Error diffusion screening involves choosing the tone value of a result such that the tone value is the closest available from among the smaller number of levels in the output to the tone value indicated by the corresponding input pixel. This applies whether the result chosen is 0 or 1 in a bi-level system, or whether the result is chosen from a larger number of possible tone values.
The difference between the original input value and the output result at some pixel is an error term that can be either positive or negative. For example, for a 3-level output, the possible output values (normalized in the range 0 to 1) are 0, 0.5 and 1. An input value of 0.8 would select 1 as the output with an error of −0.2. An input of 0.6 would select 0.5 in the output with an error of +0.1.
Usually, a resultant value for a pixel that is larger or smaller than the corresponding input is selected to compensate for a positive or a negative error value. The error is then apportioned between one or more neighboring pixels and added to the input pixel value at each of the one or more neighboring pixels. The nearest available output value is later chosen for these pixels, taking into account the error acquired from all of the neighbors that contribute to the pixel. In practice, the error values or sums are usually stored, and pixels are obtained across scan lines and down the page.
In principle, distribution of the error to immediate neighbors is not required. This is true as long as the effect is not so far distant that the perception of the tone over a small area is lost.
In practice, the error from a pixel is passed to neighbors in the direction in which the pixels are being computed (usually to the right and downwards) to avoid revisiting pixels whose output values were previously computed. Errors that cannot be forwarded to a neighboring pixel are discarded because they are off the edge of the page or image.
A method for error diffusion screening is disclosed by R. W. Floyd and L. Steinberg in “Adaptive Algorithm for Spatial Grey Scale” [SID Int. Sym. Digest of Technical Papers, pg. 36-37, 1975]. As shown in FIG. 1, the error from a pixel is distributed to the four immediate neighbors to the right, below-right, below, and below-left of the pixel being considered in the proportions of 7/16, 1/16, 5/16, and 3/16 respectively.
In accordance with the Floyd-Steinberg method, input and output values are both represented in the same (integer) number ranges, by the arrays input and output indexed by pixel co-ordinates x, y. The output values are constrained such that they only utilize a small number of those values, evenly spaced (by output_step) to the extent possible using integer numbers. As a result, the small number of levels permitted in the output is represented by the integer numbers.
This is represented by the following sequence of steps, in which:
| || |
| || |
| ||remainder = input (x,y) MODULUS output_step |
| ||if remainder >=output_step / 2 then |
| ||error_term = remainder − output_step |
| ||else |
| ||error_term = remainder |
| ||output (x, y) = input (x, y) − error_term |
| ||input (x+1, y)=input (x+1, y) + error_term * 7/16 |
| ||input (x+1, y+1) = input (x+1, y+1) + error_term * 1/16 |
| ||input (x, y+1) = input (x, y+1) + error_term * 5/16 |
| ||input (x−1, y+1) = input (x−1, y+1) + error_term * 3/16 |
| ||where |
| ||output_step = ( input_levels / (output_levels − 1)) − 1 |
| || |
As an example, for an 8-bit per pixel original, there are 256 input levels. As a result, for a 3 level output, the step (i.e., the output_step) is 127 from one permitted output value to the next when scaled to match the range of the input values.
Many variations of error diffusion screening based on the Floyd-Steinberg method are possible. For example, different distributions of error terms can be used. In addition, distribution patterns may be varied according to content or by way of a controlled random selection.
Error diffusion screening can produce excellent results. However, it is computationally expensive. The calculation of the nearest output value that approximates the corresponding input value is costly because it involves a modulus operation (in effect, a division).
Furthermore, while conventional clustered-dot screening can be applied simultaneously to different areas of the picture, it is not possible to do so in the Floyd-Steinberg method, as well as in other error diffusion techniques. This is because each pixel depends on the error terms that arise from all its predecessors. Therefore, all of the pixels must be calculated first. As a result, it is not possible to make optimal usage of multiple, parallel processors when computing the screening for an error-diffused page, where each processor is working on a different part of the image.
For the same reason, small changes made to the picture require the whole picture to be re-screened rather than simply re-screening the affected region, such as where a small element is to be moved across a fixed background, such as a character in a video game.
It is therefore apparent that there is a need for an improved error diffusion screening method that advantageously utilizes parallel processing architectures, and with which small modifications can be made to an image without the requirement to re-screen an entire image.
The invention is a system and method for error diffusion screening with parallel processing. In accordance with the invention, the calculation of an error diffused output image is divided into two distinct processes. The first process is used to calculate the tone value for an output pixel based only on a corresponding input pixel value. The error term arising for that pixel based on the difference between input and output pixel values is also computed and stored using only the first process. An array of output pixels whose values are simply the permitted output values closest to the corresponding inputs and an array of error terms for those pixels are produced.
The second process is used to manage distribution and application of the error terms to output values. The error arising from each pixel is apportioned among its neighbors entirely within the error array. As a result, the two processes run simultaneously, provided that the second process does not start to use the error term for any particular pixel until the first process has complete the calculation of the error term.
In certain cases, it is not necessary to use an array for the error terms that have an element for every pixel on the entire image or page. This is because the effect of the error propagation is very small beyond a few neighboring pixels. Here, the absolute value of the maximum error arising from any input value is half of the amount represented by a level. For example, in a 3-level system, where the normalized outputs are 0, 0.5 and 1, the maximum error is half of 0.5 (i.e. 0.25). The error contributed to any pixel (when applied in accordance with Floyd Steinberg's proportions) is 1/16 from the upper left neighbor, 5/16 from the pixel above, 3/16 from the pixel above and to the right, and 7/16 from the left. (see FIG. 2). These errors are all accumulated by a pixel and add up to 1. Therefore, the maximum error from all neighbors transferred into a pixel is also half of the amount represented by a level.
If on its own an input value would be rounded up, then the maximum effect that a positive total incoming error can have on the error is to select the same output value but pass on a positive rather than negative error. Here, the error is still only as much as one half a level of error. If an input value would round down, then the most a positive error can do is to move the level up by one and then propagate a negative error. Similarly for negative errors, the most change that can occur is that the output value is one level less than it would have been without any contributed error. So in all cases the output will always be at most one level different from the input, and whatever the input value and accumulated error, the absolute value of the error transferred out of a pixel even when the accumulated error is taken into account is half a level. Taking accumulated error into account does not cause the maximum possible error passed on to increase.
FIG. 3 is an illustration of how the error arising at a pixel P can be propagated both directly and indirectly to the neighboring pixel that is positioned down and to the right, i.e., pixel Q. The error arising from P propagated via A and B to Q will be 7/16×3/16, or approximately 0.082. Adding the results of similar calculations for all the error paths, and then considering that the error is at most initially half a level, permits the conclusion that 3607/32768 (approximately 11%) of a level is the maximum error that Q will receive from P. By the time the error is propagated to pixel R in FIG. 3, the maximum error contributed by P is less than 10% of the error level. In accordance with the invention, error levels of this level are ignored.
When screening a complete page or image, discarding small errors in this way permits the storage and later propagation of an error array for each independently calculated area that is no larger than one pixel more than a scan line. It also permits the recalculation and reapplication of the error that arises from a small part of a scene to a specific small area as well as the immediate neighboring pixels.
In particular, for a common case where an image page is divided into horizontal sections (e.g., bands), the unadjusted values for each band can be computed independently, and therefore in parallel. In this case, the initial error array is computed at the same time. Once the computation is performed, the error is diffused through the band by way of an independent process that can lag behind the first process by an amount that is equal to the maximum error size permitted by the error array.
Furthermore, by discarding small errors, the effect of the error array is limited to a little more than a single line. As a result, storage of the accumulated errors at the band boundaries is all that is required to determine the error. In certain embodiments of the invention, the effects of neighboring bands are applied at a later point in time based on the stored accumulated errors at the band boundaries. As a result, the independent processing of a majority of screening bands is permitted.