Method to convert bitmaps to monochrome data

Abstract: A peripheral unit converts source color image data to a rasterized monochrome bit map and includes a random access memory, a storage memory containing a gray scale conversion table, dithering matrices, procedures for determining destination image dithering tiling locations, scaling conversion procedures and sub routines for establishing a gray scale value array index to a bit mask array. The peripheral unit performs a method of converting color source image data to a rasterized compressed monochrome bit map which involves a conversion cycle for converting source pixels to gray scale value and output position bits within the two arrays. Testing is performed to determine all of the source pixels converted to the same gray scale value, and if so, a read ahead cycle commences, reading ahead in the source pixel row for as long as the unconverted source image color data bytes are the same as for those converted in the conversion cycle. The converted output position bits of the converted source pixels are dithered, and an attempt is made to generate a compressed data repeated run entry with a default to a literal run entry based upon dithering of only the converted source pixel output position bits and a count of repeating source pixels.

Description: BACKGROUND OF THE INVENTION Technical Field. This invention relates to a process for converting color bit map data to compressed monochrome data, and more particularly to convert color bit map data to resolution scaled monochrome data in Printer Control Language Method Two compressed data without explicit processing of all repeating source color data. Background Art. Prior art processes for converting source color images to monochrome rasterized bit maps typically require examination of each pixel of the source bit map and conversion of the color information for each pixel to a gray scale value. After conversion, the correct dithering matrix is retrieved and scaled output pixels are generated. This is a slow, cumbersome process involving a large number of computations. This is especially so when converting visual color image data to high resolution raster bit maps, such as those utilized by laser printers having print engines capable of 300 or even 600 dots per inch (1 inch = 2,54 cm). The rasterized bit map for monochrome image at 300 dots per inch resolution requires approximately a megabyte of raster memory for each letter-size page. At 600 dots per inch, 3.8 megabytes of memory are required. If the conversion process converts each individual source pixel, one at a time, and dithers each scaled group of output pixels resulting from each source pixel, processing 3.8 megabytes of rasterized bits of output image results in 30 million conversion computations and 30 million dithering operations which can take a considerable amount of time. Laser printers typically include an on board or internal memory capable of receiving rasterized data bit map information from a host processor. This bit map is used to construct page intermediate strips of rasterized data. The page intermediate strips of rasterized data are delivered to the laser print engine which operates at a constant speed. If new rasterized data is not available at a rate that keeps up with the engine's operation, a print "overrun" occurs and the page is not printable. To prevent this from occurring, page intermediate formatting must occur at a high enough rate to keep up with the print engine. This can only be accomplished if the host processor is sending formatted data at a high enough rate of speed, or the printer contains sufficient internal memory to hold the entire destination image bit map which has been delivered to it at perhaps a slower rate of speed from the host processor. To maintain the cost of laser printers at a low level, substantial efforts have been directed to reducing the amount of required, on board, raster memory, such that it is not possible to hold a complete rasterized bit map of an image. In such cases, if the conversion, dithering and rasterization execution time, either in the random access memory (RAM) of the printer, or the host processor, is greater than the time within which page intermediate strips must be constructed for delivery to the print engine, print overruns will occur. Execution time for prior art conversion procedures is oftentimes too slow to keep up with the construction times needed for the construction of page intermediate strips for delivery to the print engine. As a result, a number of data conversion and compression techniques are employed, usually executed in the host processor, prior to transmission of data to the printer memory to increase the rate of data transfer from the host processor to the on board memory, such that page intermediate construction can commence during the transfer while at the same time minimizing the amount of required internal printer RAM for raster memory. One of the most common compression methods is known as Printer Control Language (PCL) Method Two compression. PCL is a trademark of the assignee of this Application, Hewlett-Packard Co. PCL Method Two compression compares each byte of data to be sent, testing for whether it is "same" or "different" from a reference byte read. If it is "same", Method Two continues to read ahead in a rasterized row of data until the test indicates either "end of line" or "different". From this information is constructed a two byte PCL compressed run, wherein the first byte indicates the number of times that the second byte is to be repeated in the rasterized row. In the event that the next byte read tests different from the previous byte read, then a literal run data string is constructed, wherein the first byte of the literal run indicates that the following bytes are to be printed in proper sequence. Method Two compression is an effective compression technique which is particularly useful for images which include numerous strings of repeated data. Thus, in the prior art, conversion of the source color image to a rasterized bit map monochrome image has usually been completed and stored in the host processor RAM, and the compression procedure conducted prior to transmission of the bit map image data to the on-board RAM of the printer. What is needed is a process which speeds up the conversion process by eliminating the need to convert each individual pixel's color data information to a gray scale value where there are strings of repeating color data. Also, to increase the speed of execution time, what is needed is a process by which the requirement to dither the scaled output pixels derived from the conversion of repeating source pixels is eliminated, particularly when upscaling to a higher resolution image than the original source image. Accordingly, it is an object of this invention to provide a process by which strings of repeating source pixels need not all be converted to gray scale values, and wherein all of the scaled output pixels resulting from the scaling of the source pixels need not all be individually dithered to produce a complete rasterized bit map. It is another object of this invention to provide a process by which the source image data can be converted directly into Printer Control Language Method Two compressed data, thus eliminating the need for processing the source image into a complete monochrome rasterized bit map prior to compression. DISCLOSURE OF INVENTION A peripheral unit is used to convert color source image data to a rasterized, Printer Control Language Method Two compressed, monochrome bit map and includes a random access memory, a processor and a control memory that holds a plurality of procedures necessary to convert the color source code image to the rasterized, Printer Control Language Method Two compressed, monochrome bit map, including a storage memory containing a gray scale conversion table, dithering matrices, procedures for determining destination image dither tiling locations, scaling conversion calculations, PCL Method Two conversion code, and sub routines for establishing two arrays, a gray scale value array, and a bit mask array, each containing a number of elements equal to the dither pattern width of the output image dither tiles. The peripheral unit is used in conjunction with a three part conversion process, including an initial conversion cycle, a read-ahead cycle, and a compressed data dithering cycle. The process begins with the initial conversion cycle, wherein color data information for source pixels are converted to gray scale values which are entered in elements of the gray scale value array. Appropriately scaled output position bits are then entered into corresponding bit mask elements. Conversion of source pixels and entry of output position bits into the same or additional bit mask array elements continues until a counter determines that there are sufficient output position bits to fill a dither pattern tile width or row within the output image. The first element of the bit mask array is then tested to determine whether it contains all of the output position bits, which if it does, it indicates that repeating color data is present. If the test indicates repeating color data in the source image, then the read ahead cycle is initiated, wherein the unconverted color data information for additional source pixels is read and directly compared to the unconverted original color data for the already converted source pixels and continues until either the end of the source row is reached, or until source color data of different value is encountered. Upon reading ahead to the end of the row, or encountering a source pixel of different color data value, the read ahead cycle ends and the dithering cycle begins. The read ahead cycle is skipped if the first bit mask array element test indicates that not all output position bits are located within the first bit mask element, and the process proceeds directly with the dithering cycle. The dithering cycle begins with selection of the appropriate dithering matrix for the first element of the gray scale value array. The selected dithering matrix is rotated or repositioned so that the first bit in the dithering matrix corresponds in both its X and Y position, to the actual X and Y position within the destination image dithering tile for the first output position bit to be dithered. Then, the entire first element of the bit mask array is ANDed to the rotated dither matrix to generate output bits. Each bit mask element corresponds in size to the output image dithering tile width and, for purposes of data compression is divisible, in the X axis, by eight so as to facilitate direct data compression. In the event repeating data has been encountered, the dithering process calculates the number of scaled output bits in the repeating string, attempts to compress the dithered output signal from the ANDing of the first bit mask element to the dithering matrix to a single byte and, if successful, generates a PCL Method Two repeating run compressed data signal for transmission to an output buffer. In the event that a compressed repeating run string cannot be generated, a literal run PCL Method Two compressed data signal is generated and transmitted to the output buffer. In the event that reading ahead did not occur, essentially the same process is used, ANDing successive bit mask array elements to the appropriate, rotated dithering matrices and ORing the outputs together to form an output signal. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a high level block diagram of a peripheral unit that is adapted to carry out the invention. Fig. 2 is a global flow diagram illustrating the overall procedure of the invention hereof. Fig. 3 illustrates the conversion process employed in accordance with the procedures of Fig. 2. Fig. 4 illustrates the conversion process employed in accordance with the procedures of Fig. 2. BEST MODE FOR CARRYING OUT INVENTION Hereafter, the invention will be described in the context of converting color video image data to PCL Method Two compressed data for transmission to a laser printer. However, it should be understood that any source color data and other devices, such as plotters, facsimile units, etc., can also make use of the procedures embodied within this invention. In Fig. 1, peripheral unit 10 includes processor 12, input port 18, random access memory (RAM) 14, storage memory 16, output port 20, all connected by bus 22 and contains all of the procedures necessary to assure the conversion of color image data bit maps compressed monochrome bit maps for devices that use TIFF or pack bit data compression. In this example, the printer connected to output port 20 accepts Printer Control Language (PCL) Method Two compressed data format. Image data from the host processor is received via input port 18 and read into RAM 20. The image data may take one of several forms. It may include sub-images or pixels wherein the descriptors are contiguous with each sub-image and are processed along with each sub-image or wherein the sub-image or pixel descriptors are received separately from (but linked to) the actual sub-image data. In both versions, when peripheral unit 10 receives image data, it is parsed and commands and data are processed to derive raster graphics data that includes source image color data and location descriptors for each pixel of the source image. Storage memory 16 contains the sub routines that carry out the conversion procedure which include gray scale conversion table 28, dithering matrices 30, PCL Method Two conversion code 32, procedures for determining destination dither tiling locations 34, scaling conversion procedures 36 and two arrays, gray scale value array 24 and bit mask array 26. The two arrays, gray scale value array 24 and bit mask array 26, each contain a number of elements equal to-the dither pattern width of the output image dither tiles. Each are, in the preferred embodiment, evenly divisible by eight to facilitate PCL Method Two compression. In the preferred embodiment, the gray scale monochrome data is contained in a single eight bit byte, thus providing an availability of 254 shades of gray between pure white, represented by the binary number for 255, and solid black, represented by the binary number for 0. In all cases, regardless of whether the color data is contained in a single byte format, or where the color data format is four bits per pixel or twenty four bits per pixel, the source color data must be normalized during conversion to an appropriate monochrome gray shade, as for example the sixteen available colors in four bits per pixel color data format are spread across the spectrum of the 256 available shades of monochrome data. The bit mask array 26 is intended to hold information indicating the relative positions of the output pixels that will be generated for each associated gray value. Like the gray scale value array, it contains the number of elements equal to the dither pattern matrix width and, in the preferred embodiment is evenly divisible by eight for purposes of eventual data compression. Each element of the bit mask array contains a bit block of sufficient size to hold the number of output position bits equal to the dither pattern tile width of the output image, so that in the event all of the output pixels are of the same gray scale value, they can be contained within a single bit mask element. The elements of gray scale value array 24 and bit mask array 26 correspond to each other by their element indexes. For purposes of example, and for demonstrating the preferred embodiment, the following parameters will be used: the source color image is a video image with rasterized pixels at a resolution of seventy four per inch; the source color data for each pixel is contained in one eight bit byte which corresponds to 256 available colors including white and black; the dithering pattern matrices for the output image tiles are sixteen pixels by sixteen pixels; the device to which the output pixel data will be sent is a laser printer having a laser engine with a resolution of 600 dots per inch (DPI) and is compatible with Printer Control Language Method Two compression procedures; and finally, the source image, as is usually the case, contains a significant amount of repeating data. Turning to Fig. 2, a flow diagram, illustrates the actions taken in the peripheral unit to convert the pixels of the source color image to a PCL Method Two compressed data monochrome bit map. In the first step, as is shown in box 50, source image data is received through input port 18 and is converted to a raster graphic bit map, the source color data format is identified, and the scaling format to be used is calculated using scaling conversion procedures 36. With regard to the scaling format, the source format in this example is seventy four pixels per inch, and the output format or resolution is 600 DPI, which will result in scaling ratio of approximately 8.1 output pixels in both the horizontal, or X direction, and the vertical Y direction, for each input pixel, thus requiring the necessity of periodic rounded scaling so as to provide an output of 600 output pixels for each seventy four input pixels. Since the number of destination or output pixels to be generated by each source pixel is proportional to the ratio of the number of output pixels in one raster row divided by the number of source pixels in the corresponding source row, it is essential for accurate conversion that extra output pixels be added to the image in identical locations within each row. For that reason all scaling calculations and the addition of extra output pixels begins anew at the beginning of each row, and is measured, for each row, from the beginning of each row of the output image. It should also be pointed out that in addition to scaling because of varying resolutions, scaling can also occur by reason of image sizing, both upsizing and downsizing. In any event, the principles embodied within this method are the same. As shown in Fig. 2, once the color data format has been identified, and in this example it is an eight bit byte of color information, and the scaling format identified, the first byte of source color data information is converted to a monochrome gray scale value as determined from gray scale conversion table 28 as shown in Fig. 1, and as shown in Fig. 2 as box 52. This gray scale value is then entered, in the first element of the gray scale value array, as representationally shown in Fig. 3 as element 200 and as box 54 in Fig. 2. Next, scaled output position bits, which, in this example, for the first source pixel, would be eight output position bits, are entered, one at a time, in the first bit mask array element 201 of Fig. 3 in their proper locations within the sixteen bits of bit mask element 201, and as shown in box 56 of Fig. 2. As shown in Fig. 2, before each output position bit is entered in any bit mask element, it is tested at decision box 58 to determine whether the end of the raster row of the output image has been reached. In addition, as each output position bit is entered into a bit mask element it is counted in decision box 60 to determine when the bit mask array contains enough output position bits to exactly fill one dither pattern tile width of the output image, which in this example is sixteen bits wide. Since decision box 60, at this point in time, only counts eight output position bits in the first bit mask element, the color data byte for the next source pixel is retrieved and converted to its gray scale value as shown in box 62. It is then tested at decision box 64 to determine whether or not it is equal to the gray scale value of the first source pixel in box 54. If the test results indicate that the gray scale value is of a different value from that determined in box 52 and stored in box 54 for the first source pixel, then the second gray scale value is then entered into second element 202 of the gray scale value array as shown in Fig. 3 and as shown in box 68 of Fig. 2, and the appropriate number of scaled output position bits are entered into the corresponding second element 203 of bit mask array 26, as shown in Fig. 3, and box 70 of Fig. 2. The number of output position bits representing eventual output pixels are continuously counted in decision box 60 as they are entered into any element of bit mask array 26 until the appropriate number have been entered, which equals the width of the dither pattern tiles for the monochrome output image. If the scaling ratio were lower, for example four output position bits per source pixel, conversion of source pixels would continue until a full dither pattern tile width of output position bits had been generated, with each new gray scale value encountered being entered into a new gray scale value array element and scaled output position bits being entered into the corresponding element of the bit mask array. Also, as the color data for each source pixel is converted to a gray scale value, that value is tested in decision box 64 to determine whether that gray scale value has been encountered before in the current conversion cycle. If it has, then the gray scale value is not re-entered into the next element of the gray scale value array, but instead the associated output position bits for the converted source pixel are entered into the proper relative locations within the bit mask element already associated with the previously encountered gray scale value as shown in box 66. At this point in time, the process of conversion of source color data into gray scale value stops. It stops even if the scaling process were to call for additional output position bits for the particular source pixel being converted. In the event scaling results in unused output position bits for the last source pixel converted, and no reading ahead occurs, this source pixel is reused, for the remaining scaled output position bits, as the first new source pixel converted when the conversion process begins anew in the conversion cycle. If scaling were not to occur, that is to say that the ratio of input to output pixels were to be one to one, and each source pixel were of a different color, and converted to a different gray scale, then sixteen elements would be needed in both gray scale value array 24 and bit mask array 26. For this reason, each array contains a sufficient number of elements to match the output dither pattern tile width. However, it is unlikely that all elements would be used in any given conversion and fill of the arrays. Similarly, each bit mask element has a bit block large enough to hold a full dither pattern tile width, since it is much more likely that only one or two gray scale values will be encountered in any given conversion cycle. Once the bit mask elements of the array contain the correct number of output position bits, as shown in Fig. 3, the first bit mask element 201 is tested to see if all of its sixteen bits are on, as shown in decision box 72 of Fig. 2. If they were all on, which in this first example of the conversion cycle they are not, it would indicate that the first two source pixels examined in this example were of the same color. Since not all bits in element 201 are on, the conversion process proceeds to dithering of the output position bits for eventual transmission to the output buffer of a PCL Method Two compressed data literal run entry. This begins with the selection of the correct dithering matrix for the first element 200 from the gray scale value array as shown in box 74. Once the correct dither pattern matrix has been selected, the Y position within the output image dither pattern tile for the particular output position bits to be dithered is determined as shown in box 76 so that the same Y position line within the dither pattern matrix can be selected. In a like manner, as shown in box 78, the X position, or the bit offset within the destination bit map dithering tile for the first output position bit to be dithered is calculated and the selected Y row of the dithering pattern matrix is rotated, in box 80, to match the X position of the first output position bit from dithering matrix to the X position of the first output bit in the destination dithering tile. Thereafter, as shown in box 82, the bit mask element that corresponds to the particular gray scale value element, which in this example is bit mask element 201 is ANDed to the rotated dither pattern matrix row to generate what eventually will become output pixels. Bit mask element 201 is then ORed into a test flag to determine whether all sixteen output position bits are on as shown in decision box 84. If not, the process is repeated for the next gray scale array element 202 for the next gray scale value and associated output position bits. It would continue sequentially with the next elements of the gray scale value array and bit mask array until all sixteen bits in the test flag are on, thus generating sixteen bits of output data which is then divided by eight in box 86 so as to calculate the number of output bytes that will eventually be used to form a compressed data signal to be sent to the output buffer. Provision is made to save any leftover output bits or pixels, but there will be none for this group of output pixels since all of them originated only from the bit mask elements of the converted source color data which, as stated earlier in this disclosure, was always divisible by eight. The next step is an attempt to compress the output data. This is accomplished, as shown in box 88 by grouping the sixteen output pixels into output bytes, and comparing the bytes to each other to determine if they are of the same value as shown in decision box 90. In this particular instance the output bytes will be of differing values since they were derived from different dithering pattern matrices. As a result, in box 94, a literal run PCL Method Two compressed data string is constructed which is sent to the output buffer where it will be used in the construction of a complete PCL Method Two raster row command as shown in box 96. Once the complete command has been constructed it is sent to the printer through output port 98. Since there are no remaining output pixels, no remainder from box 122 is sent to the first bit mask element 201, box 56 in Fig. 2, and all the elements of both the gray scale value array 24 and the bit mask array 26 are reset to zero. In practice, the use of the above-described conversion process using both gray scale value array 24, and the bit mask array 26 to scale output position bits without any repeating data, will typically result in a thirty percent time savings over the prior art. In the case of repeating source data, even more significant time savings are achieved by use of the present invention. In these situations, the requirement to convert all the source color data for repeating pixels is eliminated, as is the requirement for dithering the output pixels associated with each repeating source pixel. In the first conversion cycle the color data for two source pixels was converted which resulted in two elements of the bit mask array being used to construct a complete sixteen bit output position map. In the next conversion cycle of this example the next source pixel, the third one, begins a string of repeating pixels of the same color which extends across the raster line of the source image. The conversion of source data into gray scale data cycle begins anew as shown in Fig. 4, with the next source pixel (namely the third pixel) becoming the first source pixel, which in box 52 of Fig. 2 is converted to a gray scale value, and in box 54 is entered into element 200 of gray scale value array 24 as shown in Fig. 4. After entry of the gray scale value into element 200, scaled output position bits are entered into bit mask element 201. The process is repeated with the next pixel, in this example source pixel number four, being converted to gray scale value in box 62 and tested in decision box 64 against the gray scale value entered in element 200, box 54. If the same value, which it will be if it has the same color data, then the appropriate number of scaled output position bits for source pixel four are also entered into bit mask element 201, thus filling bit mask element 201. The count in decision box 60 having determined that a full dither pattern width of output position bits are present, initiates a test, as shown in decision box 72, to determine whether all of the bits in the first bit mask element are on. If so, all of the eventual output bits will of the same gray scale. At this point in the process, instead of proceeding to dither the scaled output position bits, as was described in the first conversion cycle of this example, a check procedure is initiated to determine if the remaining unconverted source color data can be used to confirm whether or not additional pixels in the source row are the same color, and hence would be converted to the same gray scale value if the conversion process were to continue. By using the original source color data the need for conversion of each source pixel to a gray scale value is eliminated, thus saving considerable computing time. Additionally scaling operations and dithering, as will be explained later in this disclosure, are consolidated resulting in additional time savings. The check procedure starts in decision box 100 with a determination of whether a single byte of source color data contains color information for more than one source pixel. If it does not, a 'No' decision in box 100, or if the source color information for each source pixel is contained in more than one byte, also a 'No' decision in box 100, then the byte values of the unconverted source color data for the next source pixels in the source row can be compared to the unconverted source color data for the last converted source pixel to determine if they are the same. If they are the same value, then the source pixels are the same color. The color data is compared byte for byte if the color data format is a single byte, or in the case of three byte or other multiple byte color data formats, then all multiple bytes are compared. If the decision in box 100 is 'Yes' then each source byte of color data contains color information for more than one source pixel. If this occurs, a second test is made in decision box 102 to determine whether all pixels within the byte are the same color. This is done by comparing the color data values for each source pixel within the byte. If they are the same value, then the source pixels are the same color. If the decision is 'Yes', they are of the same color, then the process can proceed with a source byte comparison the same as in the case where this data is contained in one source byte. If the decision in box 102 is 'No', the source pixels are of different color and conversion to gray scale value and dithering proceeds as previously set forth in box 74. Once it has been determined that the dither pattern width of output position bits generated from conversion of source pixels are all the same gray scale value, and that unconverted color data can be compared, rather than directly proceeding with the dithering process, the source address and the source color value of the last source pixel converted are saved in save boxes 106 and 104 as shown in Fig. 2. Once saved, the process reads ahead in the source pixel row, testing each new source pixel color data value in decision box 108 to determine if it is the same as the saved source color value in save box 104. If it is the same, the address of the source pixel tested in decision box 108 is saved in save box 110, which is continuously updated with the address of the last source pixel which tested 'same' in decision box 108. This process continues until the end of the source image row is reached as determined in decision box 112 or until a source pixel tests 'different' in decision box 108. Once the test in decision box 108 indicates 'different' source color values or end of line is reached in decision box 112, then a test is made in decision box 114 to determine whether the address of the last converted source pixel saved in save box 106 is the same as the address of the source pixel for which the color data was last tested and saved in save box 110. If they are the same then there was no reading ahead in the source image row. If they are different then the process has read ahead in the source image row without conversion and dithering of each source pixel that is the same color as the source pixels originally converted in this cycle of operation. Next, in box 116, the process calculates the number of source pixels from the beginning of the source image row to the address of the last saved source pixel in box 110 so as to determine the total number of scaled output pixels that need to be generated in the scaling process from the beginning of the output image row to the same relative position in the destination image as shown in box 118. From this total, in box 120, the total number of output pixels generated from skipping ahead can be computed by subtracting the number of output pixels already sent to the output buffer. It is necessary to compute the number of output pixels generated from the source pixels that were skipped by reading ahead in this manner because the scaling process may involve scaling of source pixels to output pixels in non integer ratios and as a result an extra output pixel will be added periodically whenever the accumulation of fractional output pixels total to a complete output pixel. Also, computing the number of output pixels in this manner eliminates any potential scaling problems in the initial conversion and scaling process at the beginning of the cycle where only a dither pattern width of output position bits are accumulated in the bit mask array before being tested in decision box 72 to determine if all of the output position bits are located in the bit mask element and hence are of the same color. If they are not all in the same bit mask element, then the dither pattern width of output position bits will be dithered seriatim and any carry over of additional scaled output bits from the last read source pixel will be reentered in the next conversion cycle as the first source pixel gray scale value and output position bits. If the test result in decision box 72 is 'yes', these same leftover output position bits are accounted for in the calculation of the total number of output bits needed to reach the same relative position in the output image as computed in box 118. After the total number of output bits of the same color has been determined, the gray scale value from gray scale value array element 200 is selected in box 74 and it, and the Y position in the output image dither pattern tile, are used to select the correct row of the correct dither pattern matrix as shown in box 76 in the same manner as in the dithering process for output pixels generated from first bit mask array element 201 in a cycle wherein there was no reading ahead. In a like manner the selected dither pattern row is rotated in box 80 so that the first dither matrix bit in the Y row corresponds to the same X position for the first output, position bit in bit mask element 201 as it will be printed in the dither tile of the output image. Bit mask element 201 is then ANDed in box 82 to the rotated row of the dither pattern matrix to generate actual output pixels and Ored to insure that a complete dither pattern tile width has been generated. At this point the calculation of the number of output bytes is performed in box 86 by dividing the number of output bits from box 120, plus the dither pattern width from bit mask array element 201, by eight. Because of the reading ahead and scaling which has occurred, the number of eventual output bytes may be substantial and there will likely be a remainder of output bits insufficient to create a final full byte. This remainder is saved in save box 122, along with the gray scale value in box 54 for inclusion in the next cycle of conversion unless the end of the row has been reached, in which case a final partial output byte will be constructed. At this point in time the first complete dither pattern width of output bits has been divided into two repeating bytes of output data. It is also known, at this point, how many repeating bytes are required in the output string of data generated in this cycle. The dither pattern matrices that are used with the present invention are empirically determined, and wherever possible, each row of the matrix has a symmetrical pattern such that even if the row is rotated, when it is divided into output bytes, the bytes may likely be of equal value, such that the output can be constructed into repeating pairs of output bytes, or preferably into a repeating run PCL Method 2 compressed string entry as shown in box 92. Regardless of whether the data string is constructed in box 92 or 94, it is sent to output buffer 96 where a complete PCL Method 2 command for a destination image raster row is constructed for eventual transmission through output port 98 to the printer or other device. Concurrent with transmission of the repeating run PCL Method 2 entry in box 92, in box 124 a command is sent to zero out the gray scale and bit mask arrays. The only exception is if there is a remainder in box 122, then the gray scale value for the remainder bits in save box 122 will be the same as that found in box 54, element 200, and therefore this element is not reset to zero. Instead, the remainder bits are reentered as the first output position bit entries in bit mask element 201 as shown in box 56. Once a complete raster row of output image pixels has been assembled in the output buffer for transmission to the printer or other device, all of scaled pixels in the X direction will have been accounted for, but the scaling in the Y direction remains to be accomplished. For this reason, the same row of source image pixels will be reused in the process a sufficient number of times to accomplish scaling in the Y direction, which in this example is eight rows with a periodic inclusion of a ninth row, when the accumulating scaling fractions total one additional row. The process is identical, but will not necessarily result in identical output raster rows since the Y position in the output image tiles will change, resulting in the selection of different rows within the dithering matrices, which may or may not contain different dither patterns. While this example involved scaling up from lower resolution to higher resolution, exactly the same process can be used for scaling down from higher resolution to lower resolution. For example, scaling down from a 600 DPI rasterized source image to a video monochrome image. In such cases the scaling is reversed, and only selected source image pixels are examined and included in the process. For example, if scaling were to occur from the 600 DPI rasterized source color image to a 300 DPI monochrome image, only every other source pixel would be converted in the conversion cycle, and/or read in the repeated data reading ahead cycle. In a like manner, this process can be used in situations where image clipping occurs, merely by modifying the identification of the beginning of each source line and the end of line tests. Similarly, it can be used for up or down sizing scaling. And finally, this process can be used to read and scale a monochrome source image.

Claims: Method for converting source color image data to rows of a monochrome rasterized bit map in a peripheral unit that converts source pixel color image data to rows of a monochrome rasterized bit map, said peripheral unit including random access memory, a processor, an output buffer and a control memory containing a gray scale value conversion table, a plurality of dithering matrices, procedures for determining the location of an output pixel within an output image dither tile for the monochrome rasterized bit map, scaling conversion procedures for generating factored, scaled, output position bits in both an X and a Y direction, and data compression procedures, said method comprising, a. establishing in the random access memory an array of elements for storing gray scale values; b. establishing in the random access memory an array of bit mask elements, each having a bit block for storing output position bits, each of said elements being indexed to a corresponding gray scale value element, and each being sized to hold a plurality of output position bits equal to the number of bits in a row of an output image dither pattern tile; c. converting the color data information of a source pixel into a corresponding gray scale value; d. generating a single row of scaled output position bits for the converted source pixel; e. storing each different gray scale value obtained from conversion of said color data information in a separate element of the gray scale value array; f. storing said output position bits in the bit mask array element indexed to the gray scale array element for the source pixel from which output position bits were generated, said output position bits being stored within the bit mask element in the same relative location, relative to the other output position bits, as the relative position of the source pixel relative to the other converted source pixels; g. repeating steps (c) through (f), seriatim, until a sufficient number of source pixels have been converted to generate a plurality of output position bits equal to the number of bits in one row of an output image dither pattern tile; h. testing to determine whether all of the output position bits are stored in one bit mask element; i. if the test indicates all of the output position bits are stored in one bit mask element, then comparing unconverted source pixel color data information for the next source pixel, seriatim, to the unconverted color data information for the last converted source pixel until either the end of the source row is encountered or until color data information of unequal value is encountered; j. saving the address of the last source pixel having color data information of the same value as the color data information of the last converted source pixel; k. calculating the number of output position bits that would be generated from the tested and counted source pixels having the same value of color data information; l. dithering the stored output position bits stored in the bit mask element to generate bits of output data; m. compressing the bits of output data and the calculated number of output position bits from step (k) into a compressed data output signal; n. if the test result indicates that output position bits are stored in more than one bit mask element, then sequentially dithering the stored output position bits in each element of the bit mask array holding stored output position bits to generate unassembled bits of output data; o. assembling an output signal from the unassembled bits of output data to form an output signal; p. sending the output signal to the output buffer; q. storing output signals in the output buffer; r. assembling, within the output buffer, a row of a monochrome rasterized bit map from the output signals stored in the output buffer; and s. repeating steps (c) through (r) for the source pixels converted in steps (c) through (g) to generate a number of additional rows of monochrome rasterized bit map equal to the Y scaling factor. The method as recited in Claim 1 wherein the number of bits in the bit block of each bit mask element is evenly divisible by eight. The method as recited in Claim 1 wherein step (q) further comprises counting the number of output signal bits for each monochrome rasterized bit map row stored in the output buffer. The method as recited in Claim 3 wherein step (k) further comprises: k(1) calculating the number of source pixels from the beginning of the source row to the last compared source pixel having color data information of equal value to the last converted source pixel; k(2) calculating the number of scaled output position bits to be generated from the beginning of the monochrome bit map row for the number of source pixels calculated in step k(1); k(3) subtracting from the number calculated in step k(2) the number of output signals for the row stored in the output buffer. The method as recited in Claim 1 wherein step (l) further comprises: l(1) calculating the Y position within the dither pattern tile for the output position bit in the first position within the filled bit mask element; l(2) calculating the X position within the dither pattern tile for the output position bit in the first position within the filled bit mask element; l(3) using the gray scale value stored in the element corresponding to the element of the bit mask array filled with output position bits, selecting a dither pattern matrix; l(4) rotating the dither pattern matrix to reposition to the first position within said dither pattern matrix the dither pattern matrix bit having a location corresponding to the X and Y positions calculated in steps l(1) and l(2); l(5) ANDing the output position bits of the bit mask element to the rotated dither pattern matrix to generate bits of output data. The method as recited in Claim 1 wherein step (m) further comprises: (m)(1) calculate the number of output bytes by dividing the number of output position bits calculated in step (k) by eight; (m)(2) group the output position bits into bytes of eight bits each; (m)(3) save any remainder output position bits; (m)(4) group the bits of output data from step (l) into bytes of output signal; (m)(5) compare the output signal bytes generated in step (m)(4) to determine if they are the same or if they are different; (m)(6) if the comparison conducted in step (m)(5) indicated that the output signal bytes are different, then construct a literal run of output signal bytes using the bytes of output signal generated in step (m)(4) and the number of output bytes determined in step (m)(1); (m)(7) if the comparison conducted in step (m)(5) indicated that the output signal bytes are the same, then construct a repeating run compressed data output signal; (m)(8) rewrite the first element of the bit mask array to include a number of output position bits equal to the remainder of output position bits determined in step (m)(3). The method as recited in Claim 1 wherein step (n) further comprises: n(1) calculating the Y position within the dither pattern tile for the first output position bit within the first bit mask element; n(2) calculating the X position within the dither pattern tile for the first output position bit within the first bit mask element; n(3) using the gray scale value stored in the element of the gray scale value array corresponding to the first bit mask element, selecting a dither pattern matrix; n(4) rotating the dither pattern matrix to reposition to the first position within said dither pattern matrix, the dither pattern matrix bit having a location corresponding to the X and Y positions calculated in steps n(1) and n(2); n(5) ANDing the output position bits of the bit mask element to the rotated dither pattern matrix to generate bits of output data; and n(6) repeating steps n(1) ) through n(5), seriatim, until all output position bits generated and stored in steps (f) and (g) have been ANDed to a dither pattern matrix. The method as recited in Claim 1 wherein step (o) further comprises: o(1) ORing the unassembled bits of output data generated in step (n) into a test array to generate an assemblage of output data bits; o(2) dividing the assemblage of output data bits into groups of eight to form bytes of output signal. The method as recited in Claim 1 wherein step (i) further comprises: (i)(1) testing to determine whether a byte of source image color data contains color information for more than one source pixel; (i)(2) if the test conducted in step (i)(1) ) indicates that color data is present in each source image color data byte for more than one source pixel, then testing the color data for each source pixel contained within each byte to determine whether they are equal; (i)(3) if the test conducted in step (i)(2) indicates that the color data for each source pixel contained within a byte of source image color data are the same, then comparing unconverted bytes of unconverted color data information for the next source pixels, seriatim, to the unconverted byte of color data information for the last converted source pixels until either the end of the source row is encountered or until a byte of color data information of unequal value is encountered; (i)(4) if the test conducted in step (i)(2) indicates that the color data for each source pixel contained within a byte of source image color data are different, then skip steps (j) through (m); (i)(5) if the test conducted in step (i)(1) indicates that the color data is not present for more than one source pixel contained within each byte of source image color data, then compare unconverted bytes of unconverted color data information for the next source pixels, seriatim, to the unconverted bytes of color data information for the last converted source pixels until either the end of the source row is encountered or until bytes of color data information of unequal value are encountered.

Inventors: SHANNON TERRENCE M, SHANNON, TERRENCE M.
Applicants: HEWLETT PACKARD CO, HEWLETT-PACKARD COMPANY
Application year: 1993
Main classification: G06K15
IPC codes: H04N1, G06T1, G06K15, G06T5