An exemplary embodiment of the present invention will be described in detail based on the following figures, wherein:
[Background and Outline]
First, the background of the present invention will be described to facilitate its understanding.
The run-length encoding system is an encoding system by which, where the same data elements appear consecutively in a data file, this group of data elements (runs) is expressed in data element values and the length of consecution (run-length). The following description will refer to encoding of image data as a specific example.
The predictive encoding system (in the narrow sense) is an encoding system by which pixel values are predicted and the resultant prediction errors are used as codes. The predictive encoding system is extensively used by virtue of its simplicity of processing, and the international standard JPEG-LS may be classified as a kind of this system. Incidentally, though the run-length encoding system is also considered a predictive encoding system in a broader sense, in the following description, the run-length encoding system will be distinguished from the predictive encoding system in the narrow sense.
While both the run-length encoding system and the predictive encoding system are extensively used, their basis of pixel-by-pixel processing makes it difficult to achieve higher speed.
In view of this problem, an image processing device 2 in this exemplary embodiment of the present invention, an inputted image is divided into blocks of a predetermined size, and each block is subjected to run-length conversion or predictive processing. Each pixel in the block is so configured as to permit processing independent of others. Since short feedbacks and branching are eliminated in this way and this arrangement may be used for parallel processing, raising the speed of encoding is facilitated.
Incidentally, while various shapes are conceivable for the block, data may be put into blocks in the sequence of encoding. Thus, when image data are to be encoded, pixel groups arrayed in the fast-scanning direction is treated as blocks. This is because, if a block containing multiple pixels in the slow-scanning direction is created, the size of the memory for buffering pixel values will have to be made greater.
[Hardware Configuration]
Next, the hardware configuration of the image processing device 2 in this exemplary embodiment will be described.
As illustrated in
The image processing device 2 is disposed within a printer 3, and an encoding program 5 (to be described afterwards) and a decoding program 6 (to be described afterwards) are installed therein.
[Encoding Program]
As illustrated in
In the encoding program 5, the block dividing section 500 divides an inputted data file into blocks including multiple data elements arrayed in the sequence of encoding, and outputs the blocks resulting from the division to the substitution determining section 510.
The block dividing section 500 in this example, as illustrated in
The substitution determining section 510 (a predicted data creating unit), when creating predicted data of a noted block, creates predicted data on the basis of data elements (pixel values) contained in other blocks.
The substitution determining section 510 in this example, as illustrated in
Incidentally the substitution determining section 510, as illustrated in
The substitution determining section 510 compares the created predicted data with each of the data elements (pixel values) contained in the noted block; if all the data elements are found identical with the predicted data, the substitution determining section 510 notifies the run counter 520 of the rightness of the prediction or, if any of the data elements is not found identical with the predicted data, notifies the run counter 520 of the wrongness of the prediction, and outputs the pixel values contained in this noted block as they are to the entropy encoding section 530 as symbols to be encoded.
The substitution determining section 510 in this example, as shown in
The run counter 520, when notified by the substitution determining section 510 of the rightness of the prediction, counts up the run-length (the number of consecutive right predictions) or, when the prediction is wrong, outputs the current count (the number of runs) to the substitution determining section 510. The substitution determining section 510, having received the input of the number of runs from the run counter 520, outputs the predicted data of this run count (the immediately preceding pixel value) and the number of runs as symbols to be encoded to the entropy encoding section 530.
The entropy encoding section 530 encodes, with variable-length codes, the predicted data and the number of runs inputted from the substitution determining section 510 or the pixel values of the noted block.
The entropy encoding section 530 in this example, when the predicted data and the number of runs are inputted from the substitution determining section 510, encodes the input predicted data and the number of runs or, when the bit string (32 bits) of the pixel group of the noted block are inputted, encodes this bit string.
As charted in
At step 110 (S110), the substitution determining section 510, which is holding the final pixel value of the immediately preceding block (namely the pixel immediately preceding the noted block), compares in parallel the immediately preceding pixel value that is held with each pixel value of the noted block inputted from the block dividing section 500. More specifically, the substitution determining section 510 creates a bit string in which four immediately preceding pixels are arrayed (the bit string of a predicted block) as illustrated in
At step 120 (S120), in the case of complete identification of the immediately preceding pixel value and every pixel value of the noted block (namely the rightness of the prediction), the encoding program 5 shifts to processing at S130 or, in the case of non-identification of the immediately preceding pixel value and any pixel value of the noted block, shifts to processing at S140.
At step 130 (S130) the run counter 520, when notified by the substitution determining section 510 of the rightness of the prediction, increases the run count by one. Incidentally, the initial run count is 0.
The encoding program 5, returning to processing at S100, cuts the next noted block out of the inputted image data. In the absence of the next noted block, exceptional processing is executed.
At step 140 (S140) the run counter 520, notified by the substitution determining section 510 of the wrongness of the prediction, outputs the run count to the substitution determining section 510 to initialize the count.
The substitution determining section 510 outputs to the entropy encoding section 530 the count (the number of runs) inputted from the run counter 520 and the predicted pixel value at the time (the immediately preceding pixel value) as symbols to be encoded.
The entropy encoding section 530 encodes with variable-length codes the number of runs and immediately preceding pixel value inputted from the substitution determining section 510.
At step 150 (S150), the substitution determining section 510, after outputting the number of runs and immediately preceding pixel value to the entropy encoding section 530, outputs the pixel group of the noted block to the entropy encoding section 530.
The entropy encoding section 530 encodes with variable-length codes the pixel group of the noted block inputted from the substitution determining section 510.
At step 160 (S160), the encoding program 5 judges whether or not all the inputted image data has been encoded and, if there is any unprocessed pixel, returns to processing at S100 or, if every pixel has been encoded, ends the encoding (S10).
[Decoding Program]
Next, the method of decoding the code data encoded as described above will be described.
As illustrated in
In the decoding program 6, the block decoding section 600 decodes the input encoded data to create the decoded values of each block. Decoded values in this example are the pixel values (immediately preceding values), the number of runs for correctly predicted blocks and the pixel values of all the pixels contained in blocks for wrongly predicted blocks.
The block decoding section 600 in this example outputs the pixel values and the number of runs to the run elongating section 610, and the pixel values of all the pixels contained in blocks to the image output section 620.
The run elongating section 610 produces, according to the number of runs, copies of the pixel values inputted from the block decoding section 600, and outputs these pixels to the image output section 620 as the pixel values of the block.
The run elongating section 610 in this example produces as many copies of the inputted pixel values as (the number of runs)×(the number of pixels in the block), and outputs the copied pixel values to the image output section 620.
Incidentally, where the whole immediately preceding block and the whole noted block are directly compared and encoded as illustrated in
The image output section 620 divides the pixel group of the block inputted from the block decoding section 600 or the run elongating section 610 into individual pixels.
The image output section 620 in this example externally outputs the block inputted from the block decoding section 600 as four pixels.
As charted in
At step 210 (S210), the decoding program 6, if the decoded symbols are runs and pixel values, shifts to processing at S220 or, if the decoded symbols are the pixel values of the pixel group contained in the block, shifts to processing at S230.
At step 220 (S220), when the number of runs and the pixel values are inputted from the block decoding section 600, the run elongating section 610 produces as many copies of the pixel values as (the number of runs)×(the number of pixels in the block), and outputs the copied pixel values to the image output section 620.
The image output section 620 externally outputs as they are the multiple pixel values inputted from the run elongating section 610.
At step 230 (S230), when the pixel values of the pixel group contained in the block are inputted from the block decoding section 600, the image output section 620 externally outputs the pixel values of the inputted pixel group as the values of four pixels.
At step 240 (S240), the decoding program 6 judges whether or not all the encoded data has been decoded and, if there is any unprocessed code, returns to processing at S200 or, if all the encoded data has been decoded, ends the decoding (S20).
As described above the image processing device 2 in this exemplary embodiment, as it processes run-length encoding on a block-by-block basis, can increase the speed of encoding.
Incidentally, while in the foregoing exemplary embodiment the pixel values of the pixel group contained in the block are encoded as a single bit string in the event of run interruption (wrong prediction), these pixel values of the pixel group may as well be encoded pixel by pixel in parallel, and in this case the decoding of the values of the pixels can also be accomplished in parallel.
[First Variation]
Next, variations of this exemplary embodiment will be described.
In the exemplary embodiment described above, since runs are counted on a block-by-block basis, the runs have to be elongated in decoding by using (the number of runs)×(the number of pixels in the block), (the count)×(the number of pixels in the block) may as well be used as the number of runs in encoding. This would enable decoding to be accomplished by a pixel-by-pixel run-length system.
As charted in
At S110, the substitution determining section 510, which is holding the final pixel value of the immediately preceding block (the immediately preceding pixel value), compares in parallel the immediately preceding pixel value that is held with each pixel value of the noted block.
At S120, in the case of complete identification of the immediately preceding pixel value and every pixel value of the noted block, the encoding program 5 shifts to processing at S132 or, in the case of non-identification of the immediately preceding pixel value and any pixel value of the noted block, shifts to processing at S140.
At step 132 (S132) the run counter 520, notified by the substitution determining section 510 of the rightness of the prediction, increases the run count by the number of pixels in the block. In this example, as four pixels are contained in a block, it increases the count by four each time.
At S140, the run counter 520, notified by the substitution determining section 510 of the wrongness of the prediction, outputs the run count to the substitution determining section 510 to initialize the count.
The substitution determining section 510 outputs to the entropy encoding section 530 the count (the number of runs) inputted from the run counter 520 and the predicted pixel value at the time (the immediately preceding pixel value) as symbols to be encoded.
The entropy encoding section 530 encodes with variable-length codes the number of runs and immediately preceding pixel value inputted from the substitution determining section 510.
At step 152 (S152) the substitution determining section 510, after outputting the number of runs and immediately preceding pixel value to the entropy encoding section 530, outputs the pixel value group of the noted block to the entropy encoding section 530.
The entropy encoding section 530 encodes in parallel the pixel values of the noted block inputted from the substitution determining section 510.
At S160, the encoding program 5 judges whether or not all the inputted image data has been encoded and, if there is any unprocessed pixel, returns to processing at S100 or, if every pixel has been encoded, ends the encoding (S10).
The encoded data created in this way can be decoded by a conventional run-length decoding system.
[Variation 2]
While the foregoing exemplary embodiment is described with reference to a form in which run-length encoding is processed on a block-by-block basis, a second variation will be described with reference to a form in which predictive encoding is processed on a block-by-block basis.
In predictive encoding, as illustrated in
When this encoding is to be done block by block as illustrated in
Also, as illustrated in
The prediction method of
As shown in
The predicting section 540 creates predicted data of the noted block on the basis of individual blocks created by the block dividing section 500, and outputs the created predicted data to the prediction error computing section 550. Creation of the predicted data uses data elements contained in other blocks than the noted block.
The predicting section 540 of this example computes the predicted data pieces (X0 through X3) of the noted block from the pixel values of the blocks of the reference position A (A0 through A3), those of the reference position B (B0 through B3) and those of the reference position C (C0 through C3) by using the equation shown in
The prediction error computing section 550 computes the prediction error of the noted block for individual blocks created by the block dividing section 500.
The prediction error computing section 550 in this example computes the differences between the noted block inputted from the block dividing section 500 and the predicted data (X0 through X3) of the noted block inputted from the predicting section 540, and outputs the computed differences (prediction errors) to the entropy encoding section 530 as symbols to be encoded.
The prediction error computing section 550 in this example, as illustrated in
Incidentally, the prediction error computing section 550, regarding the predicted data pieces (the predicted value X0 through the predicted value X3) inputted from the predicting section 540 as a bit string of a single block (predicted block) as shown in
The second encoding program 52, as its processes predictive encoding on a block-by-block basis in this way, may realize predictive encoding at high speed.
[Variation 3]
In a third variation, the run-length encoding system and the predictive encoding system are combined. When combining the run-length encoding system and the predictive encoding system, the blocks of the two systems need not be identical. For instance, as the run-length encoding system is subject to a lighter processing load than the predictive encoding system, it can be balanced at a lower level of parallelism (namely a smaller block size) than the predictive encoding system.
As illustrated in
The 4×1 block dividing section 502 divides the input image data into four-pixel blocks in the fast-scanning direction and into one-pixel blocks in the slow-scanning direction.
The 2×1 block dividing section 504 divides the input image data into two-pixel blocks in the fast-scanning direction and into one-pixel blocks in the slow-scanning direction.
Thus, when the run-length encoding system is applied, smaller blocks (½ size in this example) are used than when the predictive encoding system is applied.
The 2×1 block dividing section 504 creates 2×1 blocks of prediction errors by putting together two-pixel equivalents, arranged in the fast-scanning direction, of the prediction errors of the pixel computed by the prediction error computing section 550.
The run creating section 560 counts runs with respect to prediction errors for every 2×1 blocks. Thus, the run creating section 560 has the functions of the substitution determining section 510 and the run counter 520 of
The entropy encoding section 532 encodes with variable-length codes the run data of prediction errors (the number of runs and prediction errors or all the prediction errors in the block) created by the run creating section 560.
The entropy encoding section 532 in this example is supposed to use Huffman codes, for which the information source is enlarged by using two symbols as one new symbol, in variable-length encoding. More specifically, as illustrated in
[Other Variations]
To add, though symbols to be encoded are entropy-encoded with variable-length codes in every case of the foregoing exemplary embodiment and variations, the applicable encoding systems are not limited to them, for instance, these symbols (runs, pixel values, prediction errors and so forth) may as well be outputted as codes.
The foregoing description of the exemplary embodiment of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the present invention to the precise forms disclosed. Obviously, many modifications and variations will be apparent to practitioners skilled in the art. The embodiment was chosen and described in order to best explain the principles of the invention and its practical applications, thereby enabling others skilled in the art to understand the invention for various embodiments and with the various modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
2006-163453 | Jun 2006 | JP | national |