A device for use in the digital processing of a graphic image containing a straight line

Abstract: A device (Fig 1) for generating the approximate coordinates (X,Y) of a straight line together with an error signal (R), for use in computer graphics, is modified to enable coordinate values to be obtained to greater accuracy. The error signal (R) and values of one coordinate (Y) to which the error signal relates are processed (13-16) by multiplication and addition (21) to bring both values to the same scale and to obtain values proportional to the true values of the one coordinate (Y). The said proportional values are then converted to actual values in an iterative process wherein a comparison (24) is made between a proportional value when multiplied (23) by a first number (T), and a second number (S) multiplied (19,20) to the same scale as the proportional value. One of the two numbers (T) is incremented until a valid comparison is obtained and the true value of the coordinate is expressed as the relationship between the two numbers (S/T).

Description: This invention concerns a device for use in the digital processing of a graphic image containing a straight line, and has particular applications in computer graphics and television image processing. In one embodiment it is a device which will construct a straight line between any two points in a picture area, and which will report correctly, for any point described by rational number coordinates in the picture area, which side of the line the point lies on, or if the line passes through the point. In the process of generating a straight line in a graphics image, it is known to provide means for generating approximate two dimensional coordinates of the straight line, said generating means including first means for providing, in correspondence with regularly incremented values of one coordinate, the approximate values of the second coordinate together with, for each said approximate value, an error signal comprising a scaled value of the difference between the said approximate value and the actual second coordinate value of the required point on the line. Such an arrangement is illustrated in Fig.1 and can be utilised to draw a line between points (X0,Y0) and (X1,Y1) on a plane as shown in Fig.2. Before drawing a line the registers 1-4 of Fig.1 are loaded with the following values: Let: Yinc = (Y1-Y0)/(X1-X0) rounded towards minus infinity A = Y0 - Y1 + ( X1 - X0 ) * Yinc B = Y0 - Y1 + ( X1 - X0 ) * ( Yinc + 1 ) C = Yinc D = Yinc + 1 the accumulator 7 is set to zero and the accumulator 8 is loaded with Y0. Then for successive values of X from X0 to X1 the following operation is performed. The data selectors 5 are set in response to the sign of the number in R such that if it is zero or positive then data is taken from 1 and 3, if it is negative then data is taken from 2 and 4. Since the number in 1 will be zero or negative, and that 2 will be positive, the number in R will tend to oscillate around zero, advancing Y in the accumulator 8 by Yinc or Yinc=1 in appropriate proportions to draw a fair approximation to the required line. The values of R and Y are presented at the outputs 9 and 10. This is illustrated in Figure 2 where 11 is the required line, and 12 is the sequence of values of Y generated by the arrangement in Figure 1. As will be well understood by one skilled in the art, the number R comprises a running error term that is derived according to Bresenham's Algorithm and comprises a number that is used to store the actual distance between the line to be drawn and the point selected, taken in a direction perpendicular to the axis of greatest movement (see EP 0334600 A2 para 3 lines 13-15). Thus, in the case illustrated in Figure 2, since the line to be drawn extends at an angle of less than 45° to the X axis which is therefore the axis of greatest movement, the number R represents the error comprising the distance on the Y axis between the selected value of Y and the true point on the line to be drawn. Since the actual value of the error will be a fractional value and the application of Bresenham's Algorithm to the apparatus of Figure 1 requires the use of whole numbers, the error term R comprises the actual error value scaled such that all possible values of R comprise whole numbers. In the illustrated example R comprises the actual error value multiplied by (X1-X0) units. However, as may be seen from the diagram the standard technique is not sufficiently accurate for many purposes since division of the error term R to obtain the actual error value cannot be performed accurately in a digital process. Also the position of the required line relative to intermediate points cannot be determined. EP-A-0,314,289 describes a system for generating multiple pixels in a single machine cycle, by employing a method of parallel processing. The system enables simultaneous rather than incremental generation of coordinate values, but also relies upon Bresenham's Algorithm and thus suffers from the same drawbacks as outlined above. It is accordingly an object of the present invention to provide a means enabling an increase in the accuracy of the above described technique to enable calculations to be performed in relation to the true coordinate value of a point on the line, using rational numbers. This object is achieved by the features of Claims 1 and 5. It is a preferred object of the invention also to enable such calculations for intermediate points on the line. This object is achieved by the features of Claims 2 and 6. Further preferred features and advantages of the invention will become apparent from the following description and the subordinate claims, taken in conjunction with the accompanying drawings, in which: Fig.1 is a block circuit diagram of a known device used in computer graphics; Fig.2 is a diagram illustrating the operation of the device of Fig.1; Fig.3 is a block diagram of a device in accordance with the present invention, and Fig.4 is a view of a detail of the device of Fig.3 Referring to the drawings, there is shown in Fig.3 an additional circuit in accordance with the invention that may be added to the arrangement of Fig.1 in order to obtain more accurate information about the coordinate value Y. Referring to Figure 3, it may be assumed that this invention is being used as part of a larger system, such as a computer graphics system, which wishes to draw a straight line to a high accuracy, and which therefore requires the test described to be performed a large number of times, but which is capable of performing simple calculations and presenting the results to the equipment described, but is not capable, in software, of performing the calculation performed here at a sufficient speed. The values of R and Y are passed through the delays 13 in order to obtain two consecutive values of each. These values are then multiplied at 14 by integers P and Q, and the results added at 15. This produces values for R and Y at a fractional position which is P/(P+Q) of the way between the successive values from the accumulators, and is scaled by (P+Q). For example if P=5 and Q=3 then the values at the outputs of 15 are eight times the value which is five eighths of the way between the successive values of Y and R. Note that this calculation is performed exactly, and that there is no rounding error involved. The number R represents the difference between the value of Y and the Y coordinate of a point with the given value of X which lies exactly on a line joining (X0,Y0) to (X1,Y1). A value of R of (X1-X0) would indicate a departure of +1, and in general the error in Y is R/(X1-X0) units. Performing this division would lead to loss of accuracy, as the quotient could not be expressed exactly in many cases. This invention, however, allows a test to be performed which will determine unambiguously on which side of a value of Y expressed as S/T, where S and T are integers, the true value of Y lies, and hence on which side of a point, the coordinates of which are expressed as rational numbers (such as 3/7 by 9/17), the line passes. If the number at the outputs of the adders are denoted by Rs and Ys, then the true Y coordinate at the fractional X position which is represented by P and Q is ( Ys + Rs / ( X1 - X0 ) ) / ( P + Q ) once again we avoid doing the division, and work out ( X1 - X0 ) * Ys + Rs using the multiplier 16 and adder 21. Note that if this calculation is done using integer arithmetic then there is no loss of accuracy, and all the input data has still been preserved. The result is then multiplied by the integer T in multiplier 23. Simultaneously we work out (X1 - X0 ) * S * ( P + Q ) using the multipliers 19 and 20, and compare the results at 24. The result of this comparison can indicate that Y is greater than, equal to or less than S/T. The numerical quantities P,Q, (X1-X0), S,P+Q and T are input to the device at 14, 17, 18, 22 and 27 from an external device, commonly a microprocessor. An approximate value of Y can be derived at 26. This can be used to derive a first guess value of S as shown in the arrangement of figure 4. Here a lookup table is used to find values of Y/T rounded towards minus infinity, Y entering at 27 and the quotient S0 being produced at 29. This value of S can be used as input to the main part of the invention, being fed back in at 18, and the result of the comparison being used to increment S0 until a value of S which makes S/T >= Y is found. This method can be used to determine the value of S for a given T which is on, or lies as closely as possible to a desired side of, the value of Y.

Claims: A device for use in the digital processing of a graphic image containing a straight line and having means for generating approximate two dimensional coordinates (X,Y) of the straight line, said generating means including first means (10) for providing, in correspondence with regularly incremented values of one coordinate (X), the approximate values of the second coordinate (Y), second means (9) for providing for each said approximate value (Y), an error signal(R)generated according to Bresenham's Algorithm and comprising the difference between the said approximate value and the actual second coordinate value (Y) of the required point on the line according to a predetermined scale such that all possible values of the error signal comprise whole numbers, characterised in that said device comprises third means (16) for multiplying values derived from said first providing means (10)by the said predetermined scale (X1-X0), fourth means (21) for adding values derived from said third means (16) and said second means (9), fifth means (23) for multiplying values derived from said fourth means (21) by an integer T, sixth means (19) for multiplying an integer S by said predetermined scale (X1-X0) and seventh means (24) for comparing values derived from said fifth and sixth means and providing an output signal, for incrementing one of said integers S and T until the first and second values are substantially equal whereby the coordinates of the point on said line are expressed as the digital value of the one coordinate (X) and the second coordinate (Y) expressed as the rational number S/T. A device according to Claim 1, further comprising eighth means (13-15) coupled between said first means (10) and said sixth means (19), ninth means (13-15) coupled between second means (9) and said fourth means (21) and tenth means (20) coupled between said sixth means (19) and said seventh means (24), each of said eighth and ninth means comprising a delay means (13), multipliers (14) respectively connected at an input and an output of said delay means and arranged to multiply received signals by integers P and Q and means (15) for summing output signals from said multipliers (14), and said tenth means (20) comprising a multiplier arranged to multiply received signals by the sum of the integers P and Q. A device according to Claim 1 or 2 further comprising means for incrementing one of said integers S and T in a direction determined by the output signal of said seventh means (24) to reduce the difference between the compared values to a minimum. A device according to Claim 3, wherein the arrangement is such that it is the integer S that is incremented and said device further includes, for providing an initial trial value of S, a memory means (÷S) providing a look up table and means (27,28) for addressing said look up table with values derived from said first means (10) and with said integer T. A process for the digital calculation of the coordinates of a point on a straight line from the values of one coordinate (X) the approximate value of a second coordinate (Y) and an error term (R) generated according to Bresenham's Algorithm and comprising the value of the error between the approximate value of the second coordinate (y) and the exact value of the second coordinate of the point on the line, to a predetermined scale (X1-X0) such that all possible values of the error term (R) comprise whole numbers, characterised in that it comprises the steps of multiplying the said approximate value of the second coordinate (y) by the said predetermined scale (X1-X0), adding the scaled approximate value (y)and the scaled error term (R), to provide an output value, multiplying a first trial integer S by said predetermined scale (X1-X0), to provide a first value for comparison, multiplying said output value by a second trial integer T to obtain a second value for comparison, comparing said first and second values and incrementing one of said integers S and T until the first and second values are substantially equal whereby the coordinates of the point on said line are expressed as the digital value of the one coordinate (X) and the value of the second coordinate (Y) expressed as the rational number S/T. A process according to Claim 5, wherein the approximate value of said second coordinate (Y) and the value of said error term (R) are in each case values intermediate two consecutive digitally calculated values and derived by multiplying said consecutive values by integers P and Q respectively and summing the multiplied consecutive values, and wherein said trial integer S is further multiplied by the sum of the integers P and Q prior to said comparison. A process according to Claim 5 or 6, wherein said first trial integer is obtained by addressing a look-up table with the integer T and the approximate value of said second coordinate (Y).

Inventors: BILLING ROBERT, BILLING, ROBERT
Applicants: QUESTECH LTD, QUESTECH LIMITED
Application year: 1994
Main classification: G06T11
IPC codes: G06T11