Encoding method and device therefor

Abstract: The invention is to exactly select an enconding method with satisfactory encoding efficiency, by comparing the final predicted code lengths for plural encoding methods, prior to the actual encoding operation. This object can be attained by an encoding device comprising generation means for generating difference data between an encoding target pixel and another pixel in each of the predetermined plural difference encoding methods, first prediction means for predicting the code length in case the difference data generated by the generation means are encoded, second prediction means for predicting the data length of additional data, other than the difference data generated by the generation means, selection means for selecting one of the difference encoding methods based on the code length predicted by the first prediction means and the data length predicted by the second prediction means, and difference encoding means for effecting difference encoding according to the result of selection by the selection means.

Description: The present invention relates to an encoding device for encoding data, and a method therefor. As reversible encoding method, there is conventionally known DPCM + entropy encoding which is the internationally standardized JPEG method. This method consists of calculating a predicted value for an encoding target pixel, utilizing pixels therearound, then generating difference data between the predicted value and the actual pixel value of the encoding target pixel, and effecting variable-length encoding such as Huffman encoding on the difference data. Fig. 3A shows an example of the predicting method for generating the above-mentioned predicted value. There are illustrated a target pixel X, and surrounding pixels a, b, c used for prediction. There are provided 7 equations for generating the difference between the predicted value and the target pixel X, and one of the equations is suitably selected. Also among the blockwise difference encoding methods, there is known a method for encoding the difference data between an encoding target block and a reference block obtained from the already encoded area. In case of selecting an efficient encoding method from plural difference encoding methods by predicting the encoding efficiency, the efficiency has conventionally been compared by the code length of the difference data, but, in the blockwise difference encoding methods, the code length may eventually become longer since other data (such as vector information in the embodiments of the present invention) have to be added in a larger amount, in comparison with the encoding methods utilizing the correlation of nearby pixels. Also in case of selecting an efficient encoding method from plural difference encoding methods by predicting the encoding efficiency in succession, there is required a long time for such prediction because other encoding methods have to still be evaluated even if an encoding method satisfying the required encoding efficiency is identified in the course of such prediction. Also in the conventional DPCM encoding mentioned above, since only one prediction mode (method of difference generation utilizing the target pixel X and the nearby pixels a, b, c) can be selected for each image, the encoding efficiency cannot be improved if the character of the image varies locally within the image. Also there is only utilized the correlation between the encoding target pixel and the nearby pixels, the correlation with other pixels cannot be utilized. Also in the blockwise difference encoding methods, the reference block can only be selected from the already encoded area, and there cannot be utilized even the correlation with the nearby pixels. Furthermore, in the blockwise difference encoding methods mentioned above, even if the reference block and the encoding target block are similar in the frequency characteristics, the encoding efficiency cannot be improved if these blocks are generally difference in luminosity or in density. Furthermore, the adaptive Huffman encoding or the dynamic arithmetic encoding is utilized for the conventional variable-length encoding mentioned above, but these encoding methods have been associated with the following drawbacks: (i) In Huffman encoding, in which a code is assigned to a difference data, the shortest code for a pixel cannot be less than 1 bit; (ii) Also in case the difference between the most frequently appearing difference data and the next most frequently appearing difference data is small, the code for a pixel becomes two bits or longer; (iii) On the other hand, the arithmetic encoding, being capable of encoding without partition in the difference data, can dispense with the above-mentioned fixed bit length for each difference data; (iv) However, in case of applying the arithmetic encoding to the encoding of multi-value data, the difference data are encoded bit by bit, and the statistical model of conditions for such bit encoding is difficult to prepare; and (v) Also the number of levels of such multi-value data is large, the encoding efficiency cannot be better in comparison with that of the Huffman encoding. Also in case plural encoding methods are simultaneously employed within an image, there is required positional information indicating the image area in which each encoding method is used, but such information has to be prepared separately from the difference data encoded by such plural encoding methods, so that the entire data amount after encoding becomes inevitably large. EP-A-0 615 384 discloses an encoding device for encoding image information in a selected one of a number of encoding modes. The results of compression without motion compensation (PCM) and motion compensation format compression (DPCM), in which the difference data between a predicted signal and based on the data for a previous frame and an actual signal is compressed and encoded on individual blocks of data, are compared to determine which method offers the most efficient compression over a region of the image. EP-A-0 444 918 discloses a data compression apparatus in which the compression is performed using discrete cosine transform (DCT) processing followed by quantization and Huffman encoding. The number of quantization levels is varied in order to reduce variations in the amount of output data from frame to frame. An object of the present invention is to resolve at least one of the above-mentioned drawbacks of the prior art. Another object of one aspect of the present invention is to enable, prior to the encoding, selection of an encoding method with satisfactory encoding efficiency in precise manner from plural encoding methods, by making comparison with the predicted final code length for each of the plural encoding methods. One aspect of the present invention provides an encoding method for encoding a block of image data represented by a plurality of pixels using one of a plurality of encoding modes wherein the number of bits needed to represent the encoded data obtained when the block of image data is encoded in each mode is predicted, said method being characterised by comprising the steps of: a first prediction step of generating a first pixel average value from a block of image data at least partially surrounded by further data by encoding the block of image data in a first encoding mode, outputting a first number of bits needed to represent the first pixel average value, and multiplying said first number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the first encoding mode; a second prediction step of generating a second pixel average value from said block of image data by encoding the block of image data in a second encoding mode, outputting a second number of bits needed to represent the second pixel average value, and multiplying said second number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the second encoding mode; a third prediction step of predicting the number of bits representing additional data required to decode the encoded data when the block of image data is encoded in the first encoding mode; and a fourth prediction step of predicting the number of bits representing additional data required to decode the encoded data when the block of image data is encoded in the second encoding mode; wherein the first or second encoding modes is selected based on the smaller of the sums of the number of bits predicted at the first and third prediction steps and at the second and fourth prediction steps, or where said sum for the first and third prediction steps is less than a predetermined value, the first encoding mode is selected. An object of another aspect of the present invention is, in the course of predicting the encoding efficiency in succession for selecting an encoding method of satisfactory encoding efficiency from plural encoding methods, to reduce the entire process time for the prediction of the encoding efficiency, by not effecting the prediction of the encoding efficiency for other encoding methods in case an encoding method satisfying the required encoding efficiency is identified in the above-mentioned plural encoding methods. Another aspect of the present invention provides an encoding device for encoding a block of image data represented by a plurality of pixels using one of a plurality of encoding modes wherein the number of bits needed to represent the encoded data obtained when the block of image data is encoded in each mode is predicted, said device being characterised by comprising: means for generating a first pixel average value from a block of image data at least partially surrounded by further data by encoding the block of image data in a first encoding mode, means for outputting a first number of bits needed to represent the first pixel average value, and means for multiplying said first number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the first encoding mode; means for generating a second pixel average value from said block of image data by encoding the block of image data in a second encoding mode, means for outputting a second number of bits needed to represent the second pixel average value, and means for multiplying said second number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the second encoding mode; means for predicting the quantity of additional data required to decode the encoded data generated when the block of image data is encoded in the first encoding mode; means for predicting the quantity of additional data required to decode the encoded data generated when the block of image data is encoded in the second encoding mode; and means for comparing the sums of said numbers of bits predicted by the first and third prediction means and by the second and fourth prediction means, and selecting the first or second encoding method corresponding to the smaller of the sums, or where the sum predicted by the first and third prediction means is less than a predetermined value, selecting the first encoding means. An object of a further aspect of the present invention is to enable encoding adaptive to the local property of the image. An object of still another aspect of the present invention is to enable selection from a larger number of reference blocks, by using not only those within the already encoded pixels but also those including the unencoded pixels, thereby improving the encoding efficiency. An object of a further aspect of the present invention is to improve the encoding efficiency by considering the frequency characteristics of each block. An object of another aspect of the present invention is to provide a difference generating method capable of improving the encoding efficiency, even in case the difference between the above-mentioned reference block and the encoding target block does not become small. An object of another aspect of the present invention is to enable, among said plural encoding methods, selection of an encoding method with satisfactory encoding efficiency according to the magnitude of the data to be encoded. An object of a further aspect of the present invention is to selectively prepare positional information and encoded data from the data to be encoded, thereby reducing the entire data amount after the encoding and improving the encoding efficiency. An object of another aspect of the present invention is to enable selection, from plural statistical probability tables employed in the arithmetic encoding, of a suitable table according to the situation of the pixels around the encoding target pixel. Embodiments of the present invention will now be described with reference to the accompanying drawings in which: Fig. 1 is a block diagram of a DPCM encoding mode judgment unit; Fig. 2 is a block diagram of an encoding control device; Fig. 3A is a view showing an example of the difference generating method corresponding to an encoding mode; Fig. 3B is a view showing a variation of the difference generating method shown in Fig. 3A; Fig. 4 is a view showing the manner of encoding by the DPCM encoding mode; Fig. 5 is a block diagram of an encoding unit 3; Fig. 6 is a view showing an example of encoded data format in a first comparative example; Fig. 7 is a view showing an example of Huffman code employed in the first comparative example; Fig. 8 is a block diagram showing an example of an encoding mode judgment unit 2 in a second comparative example; Fig. 9 is a block diagram of an analogous block mode judgment unit 81; Fig. 10 is a view showing the manner of search for an analogous block or an analogous wave form block; Fig. 11 is a view showing an example of encoded data format in the second comparative example; Fig. 12 is a view showing an example of the encoding mode judgment unit 2 in a third comparative example; Fig. 13 is a view showing sequence components of Hadamard transformation; Fig. 14 is a block diagram of an analogous wave form block mode judgment unit 84; Fig. 15 is a view showing an example of analogous wave form blocks; Fig. 16 is a view showing an example of encoded data format in the third comparative example; Fig. 17 is a view showing the manner of determining an absolute difference sum in the DPCM encoding mode; Fig. 18 is a view showing an encoding target block suitable for analogous block mode; Fig. 19 is a view showing the manner of determining an absolute difference sum in the analogous block mode and in the analogous wave form block mode; Fig. 20 is a view showing the assignment of encoding order in 4 × 4 block data; Fig. 21A is a view showing the mode of use of a reference block in rotated states; Fig. 21B is a view showing a variation in obtaining the difference between a reference block and an encoding target block; Fig. 22 is a view showing an example of relationship between the encoding device of a comparative example and other peripheral devices; Fig. 23 is an internal block diagram of an encoding unit 51 in a fourth comparative example; Fig. 24 is a histogram of difference data; Fig. 25 is a view showing a judgment method by a judgment tree in a difference level judgment unit 300; Fig. 26A is a block diagram for controlling statistical tables for arithmetic encoding in an embodiment 5; Fig. 26B is a view showing the relationship between an encoding target pixel X and surrounding pixels in Fig. 26A; Fig. 27 is a view showing encoded data format in the fourth comparative example; Fig. 28 is a correspondence table of Huffman codes employed in the fourth comparative example; Fig. 29 is an internal block diagram of an encoding mode judgment unit 2 in a first embodiment of the invention; Fig. 30 is a flow chart showing the control sequence in a second embodiment of the invention; and Fig. 31 is a block diagram for realizing the process of the second embodiment. [Comparative Example 1] Fig. 2 is a block diagram of an encoding control device constituting a first comparative example 1. In Fig. 2, there are provided an image memory 1; an encoding mode judgment circuit 2; an encoding unit 3 capable of switching the encoding method according to an encoding mode signal 101; and a compression memory 4 for storing encoded data 102. Image data 100, entered from the image memory 1, are supplied to the encoding mode judgment unit 2 and the encoding unit 3. The encoding mode judgment unit 2 selects an encoding mode which is anticipated to provide a short code length in the DPCM encoding of the image data 100, and generates a corresponding encoding mode signal 101. Now the encoding mode judgment circuit 2 will be explained with reference to Fig. 1. Encoding mode arithmetic units 10a - 10g, in response to the image data 100, generate difference data 200a - 200g with respect to a pixel X in an encoding target block shown in Fig. 4, respectively utilizing predetermined difference generation formulas corresponding to seven encoding modes (hereinafter called DPCM encoding modes) as shown in Figs. 3A and 3B. Fig. 4 shows the manner of encoding of an image. In Fig. 4, a block of 4 × 4 pixels is extracted from the image, and the encoding mode is switched for each encoding target block. In the first example, among the pixels adjacent to the encoding target block of 4 × 4 pixels and the nearby pixels within the block, reference is made to a hatched area. In-block calculation units 11a - 11g respectively calculate the difference data 200a - 200g of each encoding target block as the total sum of absolute values of each block (hereinafter called block absolute difference sum, to be explained in relation to Fig. 17), and release block absolute difference sum data 201a - 201g. A minimum value judgment circuit 12 identifies the minimum of the block absolute difference sum data 201a - 201g and selects the encoding method showing the minimum. A mode signal generation unit 13 releases an encoding mode signal 101 corresponding to the mode selected by the minimum value judgment circuit 12. In Fig. 1, the seven formulas shown in Figs. 3A and 3B are assigned as the seven encoding modes, but there may also be employed other suitable formulas for generating the difference, and the number of encoding modes is not limited to seven. In the present example, the encoding mode arithmetic unit 10a calculates the difference between each target pixel X within the encoding target block and a pixel A adjacent to the left. The encoding mode arithmetic unit 10b calculates the difference between the target pixel X and a pixel B adjacent immediately above. The encoding unit 3 switches the DPCM encoding method according to the encoding mode signal 101. Fig. 17 shows the manner of calculation of the block absolute difference sum for an encoding mode number 2 and an encoding mode number 4. In case of the encoding mode number 2, for all the pixels M(1, 1) to M(4, 4) within the encoding target block M(i, j), the difference from a pixel adjacent immediately above is calculated, and the differences for all the pixels mentioned above are set as N(1, 1) to N(4, 4). The block absolute difference sum is the sum of the absolute values of N(1, 1) to N(4, 4). Similar operations are conducted also for the encoding mode number 4. Fig. 5 is a block diagram of the encoding unit 3. A difference generator 50 switches the difference generating formula according to the encoding mode signal 101, and generates, in succession, the difference data 103 of the encoding target blocks shown in Fig. 4, utilizing the image data 100. A code generator 51 generates encoded data 102 by adding the encoding mode signal 101 to the difference data 103. Fig. 6 shows an example of the data format employed in the encoded data 102 generated in the code generator 51. At the top of the encoded data 102 of each encoding target block, there are provided block encoding mode number data, indicating the encoding mode employed for each encoding target block. Thereafter provided are Huffman codes and additional bits, assigned as shown in Fig. 7 to the 16 difference data within the 4 × 4 pixel block as shown in Fig. 20. Fig. 7 shows an example of Huffman encoding employed in the present example. The difference data are divided into plural groups, in the decreasing order of magnitude of the difference data, and a Huffman code is assigned to each group, and additional bits are added for identifying the difference values within the group. For example, for a group 2, additional bits '00', '01', '10' and '11' are employed for identifying four differences -3, -2, 2 and 3. The first example, being capable of switching the encoding mode for each block, can achieve adaptive encoding according to the local image quality, for example an image area showing strong horizontal correlation or an image area showing strong vertical correlation, within an image. [Comparative Example 2] In case the encoding target block contains an image with a screen dot pattern, the mere calculation of the difference between the longitudinally or laterally positioned nearby pixels as in the first example, where the highest uniform correlation is anticipated to exist, may not be able to sufficiently reduce the difference between the blocks, and may not achieve sufficiently high compression. An example of such image pattern is shown in Fig. 18. Although the present invention contemplates a multivalue image, three density levels are illustrated in Fig. 18 for the ease of explanation. In case the encoding target block has a pattern as shown in Fig. 18, the difference data obtained from every pixel by the DPCM encoding mode in the first embodiment do not become very small as the data are obtained by calculating the differences with the adjacent pixels. However, the encoded data can be shortened by determining the difference between the blocks by employing a block present in the already encoded area and analogous to the encoding target block and encoding such difference data. Thus, in such case, there is adopted a method of searching an analogous block area within the already encoded area and encoding the difference between such analogous block and the encoding target block. Fig. 8 is a block diagram showing an example of the encoding mode judgment unit 2 for realizing such encoding mode (hereinafter called analogous block mode). A DPCM encoding mode judgment unit 80 is a block of the encoding mode judgment circuit 2 shown in Fig. 1, composed of the encoding mode arithmetic units 10, the in-block calculation unit 11 and the minimum value judgment circuit 12, and releases data 110 including an encoding mode signal 110a and difference data 110b providing the minimum value from the minimum value judgment circuit 12. An analogous block mode judgment unit 81 releases data 111 including vector information 111a indicating the position of the analogous block and difference data 111b between the analogous block and the encoding target block. A minimum value judgment circuit 82 compares the difference data 110b and 111b contained in the data 110 and 111, and selects the smaller one. According to the result of this selection, there is judged whether the encoding in a mode signal generator 83 is to be conducted by the DPCM encoding mode in the comparative example 1 or by the analogous block mode, and an encoding mode signal 101a is released instead of the encoding mode 101 in the comparative example 1. Fig. 9 is a block diagram of a portion for generating the difference from the analogous block. At the search of the analogous block area, a control unit 90 sends vector information (x, y) 120a of the encoded area to an image memory 1 and a minimum value judgment circuit 95, and also sends position information (x, y) 120b of the encoding target block to the image memory 1. The image memory 1 release the image data of the encoding target block and those of a reference block, indicated by the vector information 120a in the course of the analogous block, and these image data are respectively stored in block memories 92, 93. Then a block absolute difference sum arithmetic unit 94 calculates the block absolute difference sum 150 of the block memories 92, 93, for supply to a minimum value judgment circuit 95. Fig. 19 shows the manner of determination of the block absolute difference sum in the analogous block mode. Difference data N(i, j) indicates the difference of the encoding target block M(i, j) with respect to the reference block P(i, j). The block absolute difference sum is the sum of all the absolute values of N(1, 1) to N(4, 4). The minimum value judgment circuit 95 judges, within a preselected area, the position of the reference block and the difference between the blocks when the block absolute difference sum 150 becomes minimum and releases data 111 including the vector information 111a and the difference data 111b. Fig. 10 shows the manner of reference to the analogous block. In the illustrated example, the search area for the 4 × 4 pixel block is from +8 to -8 pixels in the main scanning direction, and from 0 to -8 lines in the sub scanning direction. An area from (1, -1) to (8, -1), from (1, -2) to (8, -2) and from (1, -3) to (8, -3), marked with X, is an inhibited area for reference, as an unencoded pixel will be contained in the reference block. The (x, y) vector information 120a of the reference block moves in succession to the right from (-8, -8), and, after reaching (8, -8), moves from (-8, -7) to (8, -7). Thereafter the referencing movement is continued in a similar manner. Fig. 11 shows an example of the encoded data 102 generated by the code generator 51 of the comparative example 2. At the head of the encoded data 102 for each encoding target block, there are provided block encoding mode number data, indicating the encoding mode employed in each encoding target block. Thereafter provided, in case the analogous block mode is selected, is the (x, y) vector information 120a of the reference block, and the Huffman codes and the additional bits assigned as shown in Fig. 7, for the differences corresponding to the pixels within the 4 × 4 pixel block as shown in Fig. 20. As explained in the foregoing, the comparative example 2 is provided with the DPCM encoding mode in which judgment is made as to whether uniform correlation exists in the nearby pixels in the longitudinal or transversal direction in the encoding target block and a state of minimum block absolute difference sum is selected, and the analogous block mode for searching an analogous block in the unit of each pixel block and encoding the difference between such analogous block and the encoding target block. Thus efficient encoding can be attained even in the absence of uniform correlation within the nearby pixels to each of the pixels in the encoding target block. Also the analogous block mode of the present example, being also capable of searching the correlation of the nearby pixels in the unit of a block, can improve the accuracy of search and the encoding efficiency, in comparison with the conventional method in which the search can only be made within the already encoded pixels. [Comparative Example 3] In the comparative example 2, there may be encountered a case in which the encoding target block and the reference block are analogous in the print pattern, though they are different in the density or luminosity. For coping with such situation, there is conceived a method of identifying a block with an analogous waveform by comparing each encoding target block with blocks within a predetermined area based on the frequency distribution, and encoding the difference data between the pixels of the encoding target block and those of such analogous waveform block. Fig. 12 shows an example of the encoding mode judgment circuit 2 for realizing such encoding method (hereinafter called analogous waveform block mode). A DPCM encoding mode judgment unit 80 and an analogous block mode judgment unit 81 are similar to those in the comparative example 2. An analogous waveform block mode judgment unit 84 generates data 112 including vector information 112a and difference data 112b of an analogous waveform block, which provides a minimum block absolute difference sum between the analogous waveform block and the encoding target block. The method of generation of the absolute difference sum will be explained later. In the following there will be explained, with reference to Fig. 14, the block configuration of the analogous waveform mode judgment unit and the method of generating the block absolute difference sum. At the search of the analogous waveform block, a control unit 90 sends (x, y) vector information 120a of the already encoded area to an image memory 1 and a minimum value judgment circuit 95. It also sends (x, y) positional information 120b of the encoding target block to the image memory 1. Pixel block data 92a, 93a, read from an encoding target block memory 92 and a reference block memory 93 similar to the memories in Fig. 9, are respectively converted into coefficient components 400, 401 in Hadamard converters 96a, 96b, which will be explained further in the following. Arithmetic units 97a, 97b calculate square sum of the pixels within the respective blocks and release square sum data A, B. Then an arithmetic unit 99 calculates a gain B/A, and a multiplier 98 releases a value 98a obtained by multiplying the output 400 of the Hadamard converter 96a with the gain B/A. The value 98a is inverse converted by an inverse Hadamard converter 100 to generate reference block data 100a having a density level matching that of the encoding target block. A block absolute difference sub arithmetic unit 94 generates a block absolute difference sum 94a by processing the encoding target block data 92a and the reference block data 100a of a density level matching that of the encoding target block, in the same manner as in Fig. 19 for the encoding target block and the reference block. A minimum value judgment circuit 95 generates data 112 including vector information 112a of the reference block and the difference data 112b between the blocks, when the block absolute difference sum data 94a become minimum. Then a minimum value judgment circuit 85 in Fig. 12 compares the difference data 110b, 111b, 112b contained in the data 110, 111, 112 and selects the smallest data. Then a mode signal generator 86 judges whether the encoding is to be executed in the DPCM encoding mode, the analogous block mode or the analogous waveform block mode, and generates an encoding mode signal 101b instead of the encoding mode signal 101 in the comparative example 1. The Hadamard conversion employed in the present example is a method for converting an image into frequency components, and there may also be employed other frequency converting methods. The Hadamard conversion is defined as follows: (y) ij → (Y) ij y = (y11, y12, ...y44) Y = (Y11, Y12, ...Y44) Y = (H4) 2 y wherein wherein (H4) 2 is a Cronecker product of H4 and H4. Fig. 13 shows the sequence of Hadamard conversion, in which the frequency becomes higher toward the lower right corner. Fig. 15 illustrates the method of judging an analogous waveform. Two blocks illustrated in Fig. 15 represent a case where the images in these blocks have a same waveform but are different in the amplitude. If the difference data are generated in the method of the comparative example 2, these blocks will generate very large difference data, indicating a low similarity. However the comparison of the coefficients before and after the Hadamard conversion reveals that the positions of the pixels with effective coefficients (non-zero pixels) are same and the ratio of the coefficients (2040/80) is also same in both blocks. It is therefore possible to reproduce the values of the other block, as already explained in Fig. 14, by calculating the ratio of the coefficients, correcting the coefficients of a block with thus calculated ratio and effecting inverse conversion. In the present example, the gain or the ratio of the coefficients is calculated by the ratio of the square sum of all the coefficients. Based on this method, it is possible, in the decoding side, upon receiving the (x, y) positional information of the analogous waveform block, gain information and gain information of the encoding target block, to reproduce the pixel values of the encoding or decoding target block by effecting Hadamard conversion on the analogous waveform block obtained from the already decoded area, then multiplying with the coefficient values and the gain, then effecting inverse conversion to obtain pixel data, and adding thereto the difference data. Fig. 16 shows an example of the encoded data 102 generated by a code generator 51 of the comparative example 3. At the head of the data of each encoding target block, there are provided block encoding mode number data, indicating the encoding mode for each block. In case the analogous waveform block mode is selected, there are then provided (x, y) vector information of the reference block, gain component information for waveform correction and Huffman codes and additional bits assigned as shown in Fig. 7 for 16 differences within the 4 × 4 pixel block shown in Fig. 20. In case an image analogous to the encoding target block in the pattern but different in the density or luminosity exists in the already encoded area, the present comparative example 3 allows to reduce the difference data between the corresponding pixels of the reference block and the encoding target block by matching the density level of the former with that of the latter. It is thus rendered possible to achieve even more efficient encoding, in comparison with the foregoing comparative examples 1 and 2. The comparative examples 1 to 3 explained above allow to select an efficient encoding mode from predetermined plural difference encoding modes, for each encoding target block, prior to the encoding operation. Consequently it is possible to select an efficient encoding, without effecting plural encoding operations corresponding to such plural encoding modes. As a result, it is made possible to select one of the plural encoding modes, without utilizing plural independent encoding means. Also the present example enables high-speed encoding as it requires only one encoding, whereas the conventional configuration has to effect plural encodings if there is provided only one encoding means. [Variation of Comparative Example 1] The above-mentioned search for the analogous waveform may also be applied for the search of movement in the encoding of a moving image. The conventional method of movement search is based on a parallel displacement of a rigid member and is not effective in case the luminosity varies for example by the illumination, but the method of the present invention is sufficiently applicable to the case where the luminosity varies. [Variation of Comparative Examples 2 and 3] As a variation of the comparative examples 2 and 3, the difference calculation of the encoding target block in the analogous block mode or in the analogous waveform block mode may also be made by rotating the reference block as will be explained in the following with reference to Figs. 21A and 21B. Thus, in comparison with the comparative examples 2 and 3, it becomes possible to extract a further analogous block. In the following there will be briefly explained an example of such method. Fig. 21A shows four patterns obtained by rotating a reference block. The comparison with such rotated reference block can be achieved, in transferring the 4 × 4 pixel block data from the image memory 1 to the encoding target block memory 92 or the reference block memory 93, by varying the sequence of reading the pixels in the block. In case of using 4 patterns of the reference block for each of the analogous block mode and the analogous waveform block mode, minimum difference data are generated for each pattern. Thus, there are generated 8 difference data in total, for the analogous block mode and the analogous waveform block mode. A minimum value judgment circuit, constructed similar to the minimum value judgment circuit 85 in Fig. 12, selects the smallest one among the minimum value data from the DPCM encoding mode judgment unit and the eight minimum value data mentioned above. The subsequent process is similar to that in the foregoing examples. In the present example, if similarity to the encoding target block is obtained by an exchange of the in-block pixel positions of a non-analogous reference block, there may be applied the method of varying the sequence of transferring the 4 × 4 pixel block data to the encoding target block memory 92 or to the reference block memory 93, as in the above-mentioned rotation of the reference block. This method will be explained in the following. In Fig. 21B, the illustrated reference block has very low similarity to the encoding target block. However, a new reference block can be generated by reading the pixels of the reference block in the illustrated order, in transferring these pixels into the reference block memory 93. Thus there can be obtained a reference block which is very analogous to the encoding target block. (A similar result can also be obtained by modifying the order of reading the pixels of the encoding target block.) Also in such reading of the pixels of the reference block, a same pixel may be read plural times, if within the 4 × 4 pixel block. It is therefore possible to generate various reference block patterns from a reference block, by arbitrarily varying the sequence of transferring the pixels of the reference block or the encoding target block to the respective block memories. The foregoing explanation has been limited to the encoding side, but inverse operations are conducted in the decoding side. The first process from the image memory 1 to the compression memory 4 in Fig. 2, explained in the foregoing example, is included in a codec 500 shown in Fig. 22. Fig. 22 shows a system including the encoding part and the decoding part of the present example. The codec 500 is provided with an encoding part having the first process shown in Fig. 2 and a decoding part having a process (second process) inverse to the first process. A CPU 501 controls the entire system. There are also provided a RAM 502, ROM 503, communication means 504 capable of data exchange through a wired or wireless communication line, a handwriting input equipment 505, a video camera 506, and an image scanner 507. A memory controller 508 is provided for data exchange with an external memory device 509 such as a hard disk or a CD-ROM. There are also provided a printer 510, and a display 511. In encoding, the codec 500 fetches the image data into the memory 1 from input means as shown in Fig. 22. At the output of the encoded data, the data are read from the compression memory 4 shown in Fig. 2. In decoding, compressed data are fetched in a compression memory used in the second process, from a device for example the communication means 504 shown in Fig. 22. Such input and output of the data are controlled by the CPU 501. Also at the output of the decoded data, the data are read from an image memory which stores a decoded image obtained by the second process. The foregoing comparative examples 1 to 3 employ Huffman encoding which is a reversible encoding, but there may also be employed arithmetic encoding or non-reversible encoding. The configuration shown in Fig. 12 employs a combination of three encoding mode judgment units, but it is also possible to combine the analogous block mode judgment unit 81 and the analogous waveform block mode judgment unit 84 or to prepare a new combination by setting another encoding mode. Also the difference calculation in the comparative examples 1 to 3 may be made, instead of between the encoding target pixel X and the reference pixel A, B or C as shown in Fig. 3A, between the pixel X and a non-adjacent pixel as shown in Fig. 3B. [Comparative Example 4] In the foregoing comparative examples 1 to 3, the Huffman encoding is singly used for encoding the difference data of the encoding target block, but, in such case, the shortest code for a pixel does not become less than 1 bit because the Huffman encoding assigns a code to the difference data of each pixel. On the other hand, arithmetic encoding, being capable of encoding the difference data without division into each pixel, can avoid fixed bit length and is anticipated to achieve efficient encoding. However, if the arithmetic encoding is applied to the encoding of multi-value data, it becomes difficult to prepare a model of statistical level divisions for encoding, since the arithmetic encoding effects encoding by each bit of the data. Also in case the multi-value data have a large value, it is difficult to achieve a higher encoding efficiency than in the Huffman encoding. For this reason, the arithmetic encoding is employed when the difference data are small, and the Huffman encoding is employed when the difference data are large. Also in case plural encoding methods are used within an image, it is necessary to generate information on the division of areas, but independent generation of such information is inefficient. Consequently there is adopted a method of including the information on the division of areas within the encoded data. Fig. 23 is a block diagram of an encoding unit for the difference data 103, in the code generator 51 in Fig. 5. The magnitude of the difference data 103 is judged by a difference level judgment unit 300. The histogram of the difference data assumes the form of a Laplacian distribution with a peak at 0, as shown in Fig. 24. This histogram indicates that the frequency of emergence of difference is high in the levels 0, ±1, ±2 and ±3 in this descending order, but is low in other levels. Again referring to Fig. 23, if the difference data 103 are small, there is generated layout information to be explained later, for encoding of the difference data without division into each pixel, and this layout information is supplied to the arithmetic encoding unit 301, which effects arithmetic encoding of the layout information. If the difference data are large, the layout information is generated in the same manner as in the case of small difference data, but the difference data 103 are separately supplied to the Huffman encoding unit 302, in order to effect the Huffman encoding which is easier in the preparation of the encoding model. Fig. 25 illustrates a judgment tree, employed in the difference level judgment unit 300 for judging the magnitude of the difference data 103. In the following there will be given a detailed explanation, with reference to Fig. 25, on an example of such judgment tree. In the following explanation, YES and NO are respectively assumed as 1 and 0, but this assumption may naturally be inversed. At first there is judged whether the difference data 103 is equal to or larger than 4 or equal to or smaller than -4, and, if YES, a signal "1" is supplied to the arithmetic encoding unit 301 as a signal indicating the partition of data of a pixel. In case of NO, a signal "0" is sent to the arithmetic encoding unit 301 and the judgment is continued. Then there is judged whether the difference data 103 is 3, and a signal "1" or "0" is released respectively in case of YES or NO. The judgment is thereafter continued in a similar manner, in the sequence of -3, 2, -2, 1 and -1. If the judgments to -1 are all NO, the output signal becomes "0000000", which indicates that the difference data is 0. These output signals are called layout information. Based on this layout information, the decoding side can identify, upon receiving a signal "1" in succession, the second "1" not as a difference data but as a pixel position where a Huffman code, to be explained later, is to be inserted. In this manner the layout information contains the positional information on the division of areas in case of using plural encoding methods. The magnitude of the difference data is judged in succession on each pixel of the difference data 103, and the released layout information is consecutively supplied, in the unit of a bit, to the arithmetic encoding unit 301. The arithmetic encoding unit 301 effects encoding of the layout information, in continuous manner in the unit of a bit, independently from the partition of the data by the pixels. The difference level judgment unit 300, upon selecting YES in a state A in the judgment tree in Fig. 25, sends the value of the difference data 103 for a pixel under current judgment, to the Huffman encoding unit 302. The Huffman encoding unit 302 effects, in succession, Huffman encoding of the difference data 103 of a pixel, only for the data 103 identified as large by the difference level judgment unit 300. An example of assignment of the Huffman codes to the difference data is shown in Fig. 28. The difference data equal to or larger than 128, or equal to or smaller than -128 are encoded with special (ESC) codes, as they only appear rarely. For example a difference of 200 is represented by ESC and a Huffman code corresponding to 76 (= 200 - 124). The list of such Huffman codes may be prepared according to the measured frequency of appearance of the difference data for each image, or may be prepared from a representative image. Fig. 27 shows the format of the encoded data 102, finally released from the code generator 51 in the comparative example 4. The code data shown in Fig. 6, 11 or 16 are classified and regrouped, in the present example, according to each form of the information. Thus there is at first generated block information, including the block encoding mode number, the (x, y) vector information, the gain information etc. Secondly generated is the layout information obtained by the arithmetic encoding. This layout information mixedly contains the difference of pixels with small difference data, and the in-image position information of pixels with large difference data. Thirdly generated are Huffman encoded data indicating the magnitude of the large difference data. Thus efficient encoding is rendered possible, as the encoding method can be suitably switched for each pixel, according to the magnitude of the difference data thereof. It is also rendered possible to insert, in the arithmetic encoded data, the position information of the pixels where the difference data are Huffman encoded. It is thus no longer necessary to generate the positional information independently, and a decrease in the number of bits can be expected. Also instead of the above-explained combination of two encoding methods (arithmetic encoding and Huffman encoding), there may be adopted another encoding method or a combination of three or more encoding methods. [Comparative Example 5] For improving the efficiency of arithmetic encoding, there is conceived an encoding method of referring to the difference data of surrounding pixels and accordingly switching the statistical tables for the arithmetic encoding. Fig. 26A shows a variation of the block diagram shown in Fig. 23, for realizing the above-mentioned method. A difference level judgment unit 300 generates state information 602, indicating the states A - G under judgment. A judgment result generation circuit 600 rewrites the layout information of the already judged pixels into 3-bit data indicating 0, ±1, ±2, ±3 or another value. A memory 601 stores the above-mentioned 3-bit data, as the information indicating the magnitude of the difference data in the encoded pixels, in correspondence to the image. Registers 200, 201, 202 receive the difference data of surrounding pixels a, b, c of the pixel X under current judgment, as shown in Fig. 26B, and respectively release magnitude information 200a, 201a, 202a of the difference data of the pixels a, b, c. An arithmetic code prediction circuit 203, provided with a RAM, can read and write data from or into the RAM, utilizing the 3-bit data 200, 201, 202 and the difference data of the encoding target pixel as addresses. The above-mentioned arithmetic code prediction circuit 203 releases data 203a of the reference position number, to be referred to a probability estimation table 604 and corresponding to the combinations of the 3-bit data 200, 201, 202 and the judgment states A to G of the difference data 103 of the encoding target pixel. The reference position of the probability estimation table of the arithmetic encoding unit 301a is reset for each bit of the input layout information. The state setting is made by reading, from the arithmetic code prediction circuit 203, the reference position number data 203a corresponding to the combinations (7 × 2 3 × 2 3 × 2 3 ) of the judgment states A to G when this bit is released as the layout information and the surrounding pixels a, b, c of the currently judged pixel X. Then the arithmetic encoding is conducted, and the reference position for the next encoding moves according to the coincidence or non-coincidence of the prevalent symbol and the encoding target bit. Reference position number data 603, indicating thus moved reference position, is stored in the address of the original reference position number data 203a and is used instead of the original position number data. The arithmetic code prediction circuit 203 is provided in advance with the set values (reference position numbers of the probability estimation table) for all the combinations of the surrounding pixel data (3 bits × 3) and the judged states A to G. Each set value is read out for arithmetic encoding, then, after the encoding, is converted into the reference position number data to be referred to next time, and stored again in the arithmetic code prediction circuit 203. By repeating the above-explained process, there can be achieved independent arithmetic encoding for each of all the combinations of the difference data of the surrounding pixels a, b, c and the judged states A to G. In the following there will be explained a specific example. In a state where the surrounding pixels a, b, c are (3, 3, 2) and the judged state is A (represented as state (3, 3, 2, A)), the set value (reference position number data) of the state (3, 3, 2, A) is supplied to the arithmetic encoding unit 301, and the arithmetic encoding is conducted with the prevalent symbol and skew (probability that the prevalent symbol does not appear) at the reference position of the probability estimation table indicated by the above-mentioned set value. After the arithmetic encoding, the reference position to be referred to next time varies according to the coincidence or non-coincidence of the prevalent symbol and the encoding target bit. Thus, the reference position is supplied to the arithmetic code prediction circuit 203, as the reference position data 603 to be used when the state (3, 3, 2, A) is encountered next time. This reference position data 603 is also used next time instead of the original set value (reference position number data). The process explained above is repeated thereafter. The arithmetically encoded layout information is released as the layout information data 301a. Also the large difference data, released from the difference level judgment unit 300, are released, by the Huffman encoding unit 302, as Huffman encoded data 302a. The present example, in the arithmetic encoding of the difference data of the encoding target pixel, can achieve efficient encoding since an appropriate arithmetic code statistical table is used for each combination of the difference data (a, b, c) of the surrounding pixels and the judged states A to G. Also as the layout information data 301a are decoded prior to the Huffman encoded data 302a, it is rendered possible to recognize, from the layout information data 301a subjected to the first encoding (arithmetic encoding in the present example), the position information for the pixels in which the second encoding (Huffman encoding in the present example) is applied to the difference data. Thus, it is no longer necessary to have the information on the image areas subjected to the first and second encodings separately from the data 301a, 302a, smooth area division can be achieved regardless of the shape of the image areas (rectangular, non-rectangular, dot or mixtures thereof). Also in the present example, the arithmetic encoding unit 301 may selectively utilize plural probability estimation tables 604 in the unit of each bit, according to the combination of the surrounding pixels a, b, c and the judged states A to G of the currently judged pixel. [Embodiment 6] In the comparative examples 1 to 5, the DPCM encoding mode requires limited additional information and can be achieved with a limited amount of calculation. On the other hand, the analogous block mode and the analogous waveform block mode requires a larger amount of additional information and a larger amount of calculation. Consequently, if the DPCM encoding mode and other two block modes are not much different in the absolute difference sum, the DPCM encoding mode will probably provide a smaller amount of encoded data, in consideration of the data amount of the additional information. Fig. 29 is a block diagram of the encoding mode judgment unit 2 of the present embodiment, attained in consideration of the above-mentioned fact. An arithmetic unit 200 calculates the pixel average value of the block absolute difference, by dividing the block absolute difference sum, obtained in the DPCM encoding mode unit, by the number of pixels (16 pixels in the present embodiment) within the block. An arithmetic unit 204 similarly calculates the pixel average value of the block absolute difference on the analogous block mode and the analogous waveform block mode. Then the predicted code lengths, indicating the number of bits of the pixel average values, are released by referring to the Huffman code tables 201a, 201b. For small difference data (from -3 to 3), not present in the Huffman code tables, there are given predicted code lengths of about 2 bits. Additional information tables 202a, 202b investigate and release the number of bits of the additional information (block encoding mode number data in Fig. 6, 11 or 16, or the vector information indicating the block position, or the gain information). There may also be included various other additional information, such as data indicating the block size. Block conversion units 203a, 203b multiply the outputs, from the Huffman code tables 201a, 201b by the number (16) of pixels within the block and add the outputs of the additional information tables 202a, 202b to obtain predicted data code lengths 207, 208. A comparator compares the predicted code lengths 207, 208 and selects the smaller one. A mode signal generator 206 releases an encoding mode signal 101c, selected by the comparator 205, instead of the encoding mode signal 101 in Fig. 2. In this manner it is rendered possible to prevent selection of a mode which has a larger weight of the additional information within the encoded data and provides a code length, including the additional information, longer than that in other encoding modes.. [Embodiment 7] In case, among the seven DPCM encoding modes shown in Figs. 3A and 3B, the smallest block absolute difference sum (or the predicted code length in the DPCM encoding mode, determined according to the embodiment 6) becomes less than a preset value, the entire process can be executed at a higher speed by passing the process of the judgment unit for other encoding modes (for example analogous block mode and analogous waveform block mode) and the process of comparing the encoding efficiency of the DPCM encoding mode and other encoding modes. Fig. 30 is a flow chart of a judgment circuit for enabling such process. A step 210 generates data enabling prediction of the encoding efficiency. In case of Fig. 30, a DPCM encoding mode process is executed to generate the block absolute difference sum. Instead of the block absolute difference sum, there may also be employed, for example, the predicted code length generated by the Huffman code table 201a and the additional information table 202a of the embodiment 6 shown in Fig. 29. A step 211 judges whether thus generated value is larger than a preset value. If not, it is ensured that the encoding by the DPCM encoding mode can sufficiently reduce the amount of the codes, so that the sequence proceeds to a step 213 for variable-length encoding. On the other hand, if the block absolute difference sum is larger than the preset value, a step 212 executes the processes by the analogous block mode and the analogous waveform block mode, then the minimum value of the block absolute difference sum is compared with that of the block absolute difference sum obtained by the DPCM encoding mode, and the encoding mode providing the smaller one is selected. Fig. 31 is a block diagram showing a variation of the encoding mode judgment circuit 2 capable of realizing the above-explained flow chart. An image memory 1 and a DPCM encoding mode judgment unit 80a respectively correspond to and are same in configuration as the image memory 1 and the DPCM encoding mode judgment unit 80 in Fig. 12. A minimum value judgment circuit 12a selects the smallest value 900 among the block absolute difference sums released from the DPCM encoding mode judgment unit 80a, for supply to a comparator 700. The comparator 700 compares the minimum data 900 with a preset value, and, if the former is smaller, releases a start signal 901. It releases a signal 903 if the former is larger. An analogous block/analogous waveform block mode judgment unit 81a is activated by the entry of the start signal 900, and is same in configuration as the analogous block mode judgment unit 81 and the analogous waveform block mode judgment unit 84 in Fig. 12. The block mode judgment unit 81a releases minimum data 902 of the absolute difference sum, obtained by the analogous block mode and the analogous waveform block mode. A minimum value judgment circuit 85a, in response to the entry of the minimum value data 900, selects the minimum value data 900 if the output signal 903 from the comparator 700 is then received, and a mode signal generator 86a releases an encoding mode signal 101c indicating the selected encoding mode. On the other hand, if minimum value data 902 is entered next to the minimum value data 900, the smaller data is selected and the encoding mode signal 101c is similarly generated. The present embodiment can achieve encoding with a higher speed, by dispensing with the unnecessary process time. The embodiments of the present invention have been described with reference to the encoding of image information data. Image information is however only a common type of a two dimensional data array and the present invention can thus be used for any such two dimensional data array. Thus reference to a pixel hereinabove can be generalised to reference to a datum in the two-dimensional data array. The present invention is not limited to the foregoing embodiments but is subject to various modifications within the scope of the appended claims.

Claims: An encoding method for encoding a block of image data represented by a plurality of pixels using one of a plurality of encoding modes wherein the number of bits needed to represent the encoded data obtained when the block of image data is encoded in each mode is predicted, said method being characterised by comprising the steps of: a first prediction step (210) of generating a first pixel average value from a block of image data at least partially surrounded by further data by encoding the block of image data in a first encoding mode, outputting a first number of bits needed to represent the first pixel average value, and multiplying said first number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the first encoding mode; a second prediction step (212) of generating a second pixel average value from said block of image data by encoding the block of image data in a second encoding mode, outputting a second number of bits needed to represent the second pixel average value, and multiplying said second number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the second encoding mode; a third prediction step (210) of predicting the number of bits representing additional data required to decode the encoded data when the block of image data is encoded in the first encoding mode; and a fourth prediction step (212) of predicting the number of bits representing additional data required to decode the encoded data when the block of image data is encoded in the second encoding mode; wherein the first or second encoding modes is selected based on the smaller of the sums of the number of bits predicted at the first and third prediction steps and at the second and fourth prediction steps (213), or where said sum for the first and third prediction steps is less than a predetermined value, the first encoding mode is selected. A method according to claim 1, wherein the pixel average value is the pixel average of the block absolute difference value of the block of data. A method according to claim 1, wherein the block of data is a square block of pixels. A method according to claim 1, wherein when the sum of the number of bits predicted at the first and third prediction steps (210) is below said predetermined value, the second and fourth prediction steps (212) are not executed (211). An encoding device for encoding a block of image data represented by a plurality of pixels using one of a plurality of encoding modes wherein the number of bits needed to represent the encoded data obtained when the block of image data is encoded in each mode is predicted, said device being characterised by comprising: means (200) for generating a first pixel average value from a block of image data at least partially surrounded by further data by encoding the block of image data in a first encoding mode, means (201-a) for outputting a first number of bits needed to represent the first pixel average value, and means (203a) for multiplying said first number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the first encoding mode; means (204) for generating a second pixel average value from said block of image data by encoding the block of image data in a second encoding mode, means (201-b) for outputting a second number of bits needed to represent the second pixel average value, and means (203b) for multiplying said second number of bits by the number of pixels in the block to predict the number of bits needed to represent the encoded data obtained when all the block of image data is encoded in the second encoding mode; means (202-a) for predicting the quantity of additional data required to decode the encoded data generated when the block of image data is encoded in the first encoding mode; means (202-b) for predicting the quantity of additional data required to decode the encoded data generated when the block of image data is encoded in the second encoding mode; and means (205) for comparing the sums of said numbers of bits predicted by the first and third prediction means (201-a, 202-a) and by the second and fourth prediction means (202-a, 202-b), and selecting the first or second encoding method corresponding to the smaller of the sums, or where the sum predicted by the first and third prediction means is less than a predetermined value, selecting the first encoding means. A device according to claim 5, wherein the pixel average value is the pixel average of the block absolute difference value of the block of data. A device according to claim 5, wherein the block of data is a square block of pixels. A device according to claim 5, wherein if the sum of the number of bits predicted the number of bits predicted by the first (200) and third (202-a) prediction means is below said predetermined value, the second (201-b) and fourth (202-b) prediction means do not operate.

Inventors: OHSAWA HIDEFUMI, OHSAWA, HIDEFUMI
Applicants: CANON KK, CANON KABUSHIKI KAISHA
Application year: 1995
Main classification: H04N7
IPC codes: H04N7, G06T9