Method and apparatus for filling an image

Abstract: A method and apparatus (20) for performing hidden surface removal of an object based rasterised image is disclosed. The apparatus (20) receives pixel edge data (21) which is compared with a pixel position (22) in the rasterised seam line. The result is used to toggle an array of latches (26) which are input (25) with a decoder (30) arrangement of fill level data (24). Only those levels (25) that are active are output therefrom to be priority encoded (28) thereby outputting (29) only the highest active level.

Description: The present invention relates to graphics systems, and, in particular to a method and apparatus for providing hidden surface removal by filling an object based rasterised image prior to displaying that image either on a video display or by means of printing, or recording the image. Most object based graphics systems utilise a frame store or page buffer to hold a pixel based image of the page or screen. The outlines of the objects are calculated, filled and written into the frame store. For two-dimensional graphics, objects which appear in front of other objects are simply written into the frame store after the background object, thereby replacing the background on a pixel-by-pixel basis. This is commonly known in the art as "Painter's algorithm". Images are calculated in object order, from the rearmost object to the foremost object However, real-time image generation for raster displays requires the calculation of images in raster order. This means that each scan-line must be calculated as it is reached, thus requiring that the intersection points of each scan line with each object outline are calculated and then subsequently filled. Although it is possible, with a line buffer rather than a page buffer, to use the Painter's algorithm within a scan-line to fill the objects, image generation in real-time, at video data rates is expensive using this method. In the field of three dimensional computer graphics, "Computer Graphics Principles and Practice" by Foley, van Dam, Feiner and Hughes, Addison-Wesley Publishing Company Inc. discloses in chapter 15.6 the use of scan-line algorithms to create an image one scan line at a time. An edge table is created for all non-horizontal edges of all polygons projected on the view plane, and each polygon is assigned an in-out Boolean flag, initialised to "false". The algorithm processes edges from left to right along a scan line. When an edge of a given polygon is encountered, the flag for the polygon becomes "true" indicating that the scan is "in" the polygon, and the shading for that polygon is applied unit the next edge of the polygon is encountered when the flag is invited to "false". When the scan is in two polygons, the plane equations of both polygons are evaluated to determine which polygon is closer to the viewer and hence which shading to use. Also in the field of three-dimensional computer graphics, "The Edge Flag Algorithm - A Fill Method for Raster Scan Displays" by Ackland and Weste in IEEE Transactions on Computers, vol. C-30, no. 1 describes contour filling algorithms and examines their suitability in terms of various frame-store architectures. The paper discloses that much of the processing associated with ordered edge list algorithms can be eliminated by allowing the computer to use the frame store as a working memory. The present invention aims to provide a means by which overlying two-dimensional objects in an image can be filled on a line-by-line basis, without the need for a frame or line store. According to the present invention, there is provided a method of generating image data by filling an object-based rasterised image as set out in claim 1. The invention also provides an apparatus for generating image data by filling an object-based rasterised image as set out in claim 5. Optional features are set out in claims 2 to 4 and 6 to 11. Embodiments of the present invention will now be described with reference to the drawings in which: Fig. 1 is a schematic block diagram representation of an object based graphics system which includes the embodiment. Fig. 2 illustrates the outlines of an image formed of a number of objects; Fig. 3 illustrates the image of Fig. 2 when viewed in priority order; Fig. 4 is a view similar to Fig. 3, in which each of the objects is fully coloured; Fig. 5 is a view similar to Fig. 4 after hidden surfaces are removed; Fig. 6 is a view of the image of Fig. 5; Fig. 7 shows a first embodiment; and Fig. 8 shows a second embodiment configured for use in an object based graphic system. Referring firstly to Fig. 1, a data flow diagram of a real time object based graphic system 1 is shown which is characterised by the absence of an image frame store. The system 1 generally includes an image creation workstation 2 which permits a user to select various images either using a drawing tablet, image scanner, database of images, or the like. The user can input specific commands via a command console 3 to a processor 4 which acts to divide the images into objects and to create a page display list of those objects. As indicated earlier, where an image frame store is available, the objects need only be stored in the frame store on a one-by-one basis so to form the entire image. However, in real time image generation, the processing required to calculate, store, as well as overwrite pixel data within such a memory is excessive and therefore not suitable for low cost systems. Specifically, each of the objects of the final image is processed on a line-by-line basis. This is performed initially by forming, translating and scaling of portions of the objects (object fragments) 5 for each object of the image. The various subobjects are then sorted 6 into the order into which they will appear in each raster line of the display. Edge calculation 7 then occurs which determines the intersection between all object fragments of the image such that the image need only be represented by edge pixel data, and the colour level into which the image changes after crossing each edge. This data is then output to a fill calculator 8 which, using the edge pixel data and the colour level, and in synchronisation with a display 10, outputs pixel level data for each pixel of the raster line for the image. This pixel level data is then input to a colouring device 9 which outputs specific colour information either in RGB (red, green, blue) or CYMK (cyan, magenta, yellow and black) or other colour data formats to an image display 10 such as a video display or a printer respectively. As illustrated in Fig. 1, the data flow stages 5, 6, 7, and 8 can be combined into a single real time objects graphics processor 11 such as that disclosed in post-published EP-A-0568359. Figs. 2 to 6 show the image generation process, termed "rasterisation" just described. In this case, an image 12 is formed by a background 13 which acts as a first object, a character "A" 14 which acts as a second object, a rectangle 16 which acts as a third object, and a circle 15 which acts as a fourth object. Fig. 2 shows the outline information of the image 12 which is a series of numbers which describe each fragment of the outline of the curves and the priority level of each curve fragment. The priority level is analogous to the level each object takes in the resultant image and the manner in which the objects overlie each other. This complements the arrangement obtained through the use of Painter's algorithm. Also seen in Fig. 2 is a sectional line 18-18 representing a single scan-line which is used with reference to Figs. 3, 4 and 5. As seen in Fig. 3, edge calculation of the intersection of each scan line with the outline fragments to be rendered is involved. This results in a sorted list of the pixel position of each fragment intersection, along with the priority level. Fig. 3 shows a cross-section through the line 18-18 of Fig. 2 which represents a single scan line of the image and in which the priority level is represented by the height of each of the layers in Fig. 3. In Fig. 4, the regions to be filled are generated. These regions are filled by the "even/ odd rule". This involves, where the first intersection encountered turns the fill of colour ON, the second intersection turns the fill OFF, and third turns the fill ON and so on. This fill method allows holes in objects, such as in the character A 14, to allow the background 13 to appear there through. Next, as seen in Fig. 5, hidden surfaces are removed. Objects that are obscured by other objects of a higher priority order are removed thereby creating a string of data for a single scan line which is divided by blocks of varying pixel colour level. Fig. 6 shows the resultant image 12 as printed or displayed in which the circle 15 has the highest priority and the background 13 the lowest. The following description is concerned specifically with a method and apparatus by which the results of Figs. 4 and 5 are achieved. Referring now to Fig. 7, a fill calculator 20 is shown which receives pixel edge position data 21 and colour level data 24 from an edge calculator 7 such as that seen in Fig. 1. A further input relating to the pixel position in the raster line 22 arrives synchronously from the display, such as the display 10 in Fig. 1, such that pixel data can be output in a synchronous fashion thereto. The level data 24 for each edge is fully decoded using a decoder 30 to output individual bit level data 25 to the inputs of a plurality of toggle latches 26, one latch for each value of decoded level data 25. A comparator 23 is provided to compare the pixel edge position 21 with the pixel position in the line 22. If the pixel edge value is negative or if it is less than or equal to the value of the pixel position in the line, the toggle latches 26 are clocked simultaneously. This causes the toggle latch corresponding to the particular object's level to toggle, whilst all the other latches remain unaffected. This implements the even/odd rule as previously stated. The outputs of the toggle latches 26 correspond to all of the currently active objects in the display. This operation is equivalent to the level fill provided in Fig. 4. A priority encoder 28 connects to the output of the toggle latches 26 and selects the highest level output that is asserted. This is then encoded and output as the fill level 29. Accordingly, the priority encoder 28 performs hidden surface removal as seen in Fig. 5. For example, if the priority level of the just clocked level is less than that being output by the priority encoder 28, the colour level output 29 remains unchanged. Alternatively, if the just clocked level is higher than that being output by the priority encoder, the level output 29 is changed to that of the just clocked level. Also, if the just clocked level is the same as the current highest priority level, the output will change to the highest active level below the current level. This causes the output image to change in accordance with the transition of an edge between two objects in which it is intended that the second object have higher priority and overlie the first. The output level data 29 is then used to select a colour which is displayed in the pixel position in the raster line on the display. Referring now to Fig. 8, the second embodiment of a fill calculator 40 is shown in which the pixel position of object edges in the current line are input and comprise 16 bits of edge position data (EP) 41 and 6 bits of fill level (FL) 49. A pixel clock (PCLK) 43 in synchronism with the display, inputs to a pixel counter 45, which, together with an initialised number of pixels 44, output from the pixel counter 45 the current pixel position in the present raster line which is input to an "A" input of a comparator 46. The edge position data (EP) 41 is provided to a "B" input of the comparator 46 which has an output 47 connected to one input of a NOR gate 48. The NOR gate 48 is also input with the most significant bit (EP15) 42 of the pixel data 41. The NOR gate 48 outputs to a clock input 52 of a bank of 64 J-K flip-flops 51 connected as toggle latches. Each of the flip-flops 51 is enabled with a single decoded fill level 49 supplied via a 6-to-64 decoder 50. When the flip-flops 51 are clocked via the clock input 52, those flip-flops corresponding to enabled levels change state (toggle) to implement the even/odd rule. The toggle flip-flops 51 are reset at the beginning of each line by a line sync 56. The output of the toggle flip-flops 51 are connected to a priority circuit 53, which only allows the highest of the 64 input states to be represented on its output states. This "highest state" is then encoded into a 6- bit binary number by the encoder 54, providing the output level 55. The output level data 55 can then be input to a colour look-up table (not illustrated but known in the art) to output a 24-bit block of actual colour data for the pixel being displayed. The fill calculators of Figs. 7 and 8 provide a means by which a result equivalent to painter's algorithm can be achieved without incurring the necessary expense and time loss found with a full page store. In specific implementations, graphic objects are processed as quadratic polynomial fragments which, in view of their simpler mathematical representation when compared to (Bezier) spline based object data, permit rapid processing up to and including edge calculation 7. However, the present invention is not limited to graphics systems which operate on quadratic polynomial fragments. The foregoing describes a number of embodiments of the present invention, and modifications obvious to those skilled in the art can be made thereto without departing from the scope of the present invention.

Claims: A method of generating image data by filling an object-based rasterised image comprising a plurality of two-dimensional graphic objects on a line-by-line basis, each object lying in a two-dimensional plane, the planes containing the objects being parallel and at least some of the objects being at different depths and overlying in the rasterised image, said method comprising the steps of: pre-ordering the graphic objects by assigning a respective constant priority level to each object; and for each raster line of the image: sequentially testing pixel positions along the raster line against data defining the edges of the graphic objects to determine if an edge exists at a pixel position and: if it is determined that an edge exists at the pixel position, changing the setting of an ON/OFF flag, initially set to OFF for the scan line, for each object having an edge which exists at the pixel position; or if it is determined that no edge exists at the pixel position, maintaining the current flag setting for each object; and generating image data for the current pixel by examining the flag of each object and selecting fill data for the current pixel corresponding to the object having the highest assigned constant priority level of those objects having said flag set ON. A method according to claim 1, wherein the image data generation step includes substantially simultaneously examining the flags of each object for the current pixel. A method according to any preceding claim, wherein the data defining the edges of the graphic objects comprises data derived by processing the objects as quadratic polynomial fragments. A method according to any preceding claim, further comprising the step of printing or recording the generated image data. Apparatus for generating image data by filling an object-based rasterised image comprising a plurality of two-dimensional graphic objects on a line-by-line basis, each object lying in a two-dimensional plane, the planes containing the objects being parallel and at least some of the objects being at different depths and overlying in the rasterised image, said apparatus comprising: means (6) for pre-ordering the graphic objects to assign a respective constant priority level to each object; testing means (23; 46, 48) for sequentially testing pixel positions along a raster line of the image against data defining the edges of the graphic objects to determine if an edge exists at a pixel position; flag setting means (26; 51) arranged to set an ON/OFF flag for each object such that: the flag for each object is initially set to OFF for each scan line; if it is determined that an edge exists at the pixel position, the setting of the ON/OFF flag for each object having an edge which exists at the pixel position is changed; if it is determined that no edge exists at the pixel position, the current flag setting for each object is maintained; and generating means (9; 28; 53, 54) for generating image data for the current pixel by examining the flag of each object and selecting fill data for the current pixel corresponding to the object having the highest assigned constant priority level of those objects having said flag set ON. Apparatus according to claim 5, wherein said generation means (9; 28; 53, 54) is arranged to examine substantially simultaneously the flags of each object for the current pixel. Apparatus according to claim 5 or claim 6, wherein said flag setting means includes a toggle latch (26; 51) for each priority level. Apparatus according to any of claims 5 to 7, further comprising means (45) for producing a pixel position value defining a current pixel position or a pixel start position along the raster line, and wherein: the testing means (46; 48) comprises: comparator means (46) for comparing the pixel position value with an edge position value for an object and for outputting an edge display signal when the edge position value is greater than or equal to the current pixel value or the start pixel value; and combination means (48) for combining the edge display signal with an edge start signal to produce a flag signal; and the flag setting means (51) is operable in response to the flag signal. Apparatus according to claim 8 when dependent on claim 7, wherein: said means for producing a pixel position value comprises a pixel counter (45) configured to receive an initialisation number of pixels and a pixel clock and to output a pixel position value to the comparator means (46); said combination means comprises a NOR gate (48); and each toggle latch of the flag setting means is arranged to receive a common clock signal output from the NOR gate and a corresponding priority level. Apparatus according to any of claims 5 to 9, wherein the generating means includes an encoder (28; 53, 54) for outputting a value corresponding to the determined highest priority level for each pixel. Apparatus according to any of claims 5 to 10, further comprising means (7) for processing the graphic objects as quadratic polynomial fragments to generate the data defining the edges of the graphic objects.

Inventors: SILVERBOORK KIA, SILVERBROOK, KIA, Silverboork, Kia, c/o Canon Info. Systems Research
Applicants: CANON KK, CANON KABUSHIKI KAISHA
Application year: 1993
Main classification: G06T11
IPC codes: G09G5, G06T11, G06T15