Image encoding apparatus and method, computer program, and computer-readable storage medium

According to this invention, encoded data of a target data amount is generated by one image input operation while both lossless encoding and lossy encoding are adopted. For this purpose, an encoding sequence control unit controls a first encoding unit for lossy (JPEG) encoding, a second encoding unit for lossless (JPEG-LS) encoding, first and second memories, and a re-encoding unit, and stores, in a first memory, encoded data of a target data amount or less that contains both losslessly and lossily encoded data. A correction unit corrects, of encoded data stored in the first memory, encoded data of an isolated type to the type of neighboring encoded data, and outputs the corrected data.

FIELD OF THE INVENTION

The present invention relates to a technique of encoding image data.

BACKGROUND OF THE INVENTION

Conventionally, still image data is often compressed by either a method using discrete cosine transformation or a method using Wavelet transformation. Encoding of this type is variable-length encoding, and hence the code amount changes for each image to be encoded.

According to JPEG encoding as an international standardization scheme, only one quantization matrix can be defined for an image, and it is difficult to make encoded data of one image (document) fall within a target code amount without a prescan. When JPEG encoding is used in a system which stores data in a limited memory, an overflow of memory may occur.

In order to prevent this, conventional schemes use, for example, a method of re-reading the same document upon changing the compression ratio parameter when the actual code amount exceeds an expected code amount, or a method of estimating a code amount in advance by prescan and re-setting quantization parameters to adjust the code amount.

As described above, prescan and actual scan are generally executed, but a document must be read at least two times, at poor efficiency.

Especially when a copying machine encodes a document of a plurality of sheets (pages) while successively reading it page by page by an ADF (Auto Document Feeder), it is impossible in terms of the process time to read the same document twice.

The assignee of the present invention has proposed a technique of eliminating these two, prescan and actual scan operations, and encoding one entire image using a common encoding parameter to compress the encoded data into a target encoded data amount (Japanese Patent Laid-Open No. 2003-8903). According to this technique, encoded data are sequentially stored in two memories during one image input operation (for one page). When the amount of encoded data in a predetermined memory exceeds a predetermined size during this operation, the data in the predetermined memory is discarded, the current encoding parameter is updated to a new encoding parameter for increasing the compression ratio, and encoding of image data of an unencoded part continues (encoded data obtained at this time is defined as the first encoded data). At this time, encoded data obtained by encoding before the compression ratio is increased are stored in the other memory, and the encoded data are re-encoded in accordance with the updated parameter. As a result, encoded data identical to those obtained by encoding data at the new parameter from the beginning can be attained (encoded data obtained by re-encoding is defined as the second encoded data). The first and second encoded data are concatenated to obtain data (complying with JPEG encoding) which is encoded at a common encoding parameter (updated encoding parameter) for one entire image (of one page). In addition, the encoded data amount can be suppressed to a target encoded data amount.

Unlike the technique of executing re-encoding in accordance with the encoded data amount in the process of encoding, as described in the above reference (Japanese Patent Laid-Open No. 2003-8903), a technique of keeping an entire image at a predetermined code amount while selectively applying either of lossless encoding and lossy encoding to a plurality of areas in an image is also available (Japanese Patent Laid-Open No. 10-224640).

Compression encoding in the conventional technique disclosed in Japanese Patent Laid-Open No. 2003-8903 adopts only a lossy compression technique such as JPEG.

According to the code amount control technique disclosed in Japanese Patent Laid-Open No. 2003-8903, when an encoded data amount generated during encoding of a 1-page image exceeds a predetermined size, a process equivalent to uniquely increasing the compression ratio for the entire page is executed, and the image quality may partially degrade more than expected. This problem becomes more serious in compressing an image containing a character/line image.

There is known a lossless encoding technique “JPEG-LS”. “JPEG” is prefixed to this technique, but its encoding algorithm is completely different from general lossy JPEG. JPEG-LS is known to be lower in compression ratio for natural pictures than JPEG, but be able to losslessly encode character/line images and computer graphics at a higher compression ratio.

Considering this, when a document image containing both photographic and character/line images in one page is to be compressed, it is preferable to use lossless compression with a character/line image part.

Hence, demands for a technique using both lossy compression and lossless compression arise in order to make an encoded data amount fall within a target data amount by one image data input operation, i.e., without inputting image data again, similar to Japanese Patent Laid-Open No. 2003-8903, when a document is to be compressed. In an application of lossy encoding to part or all of an image, a common encoding parameter needs to be used for the image.

A case wherein lossless encoding or lossy encoding is performed for each predetermined pixel block of one page will be examined.

Either a lossy encoding process or lossless encoding process is executed for a predetermined pixel block size in an original image.

Assume that a given area of a document image has a character/line image and another area has a natural picture (or photographic image), and lossless encoding is performed for the character/line image area and lossy encoding is performed for the natural picture area. If these encoding processes are switched for each relatively large area, the boundary between the areas is less conspicuous as far as the user understands that a small difference in image quality is generated by a difference in encoding because encoding processes suitable for respective areas are performed.

When, however, encoding is switched by automatically determining the type of area of each small block on the basis of a predetermined criterion, lossily encoded data or losslessly encoded data may be isolatedly generated. In this situation, the image quality changes for each small block (small area), and the difference in image quality may be recognized as visual noise.

SUMMARY OF THE INVENTION

The present invention has been made to overcome the conventional drawbacks, and has as its object to generate encoded data of a target data amount by one image data input operation while using both lossy and lossless encoding techniques, use a common encoding parameter for an image by applying lossy encoding to part or all of the image, and suppress generation of block noise.

In order to solve the conventional problems, an image encoding apparatus according to the present invention has, for example, the following arrangement.

That is, there is provided an image encoding apparatus which receives image data and encodes the image data, comprising

first encoding means for lossily encoding input image data for each predetermined pixel block in accordance with a first parameter to generate lossily encoded data,

second encoding means for losslessly encoding input image data for the predetermined pixel block to generate losslessly encoded data,

first storage means for storing, of the encoded data generated by the first encoding means and the second encoding means, encoded data of a shorter encode length in a predetermined first memory, second storage means for storing the losslessly encoded data generated by the second encoding means in a predetermined second memory,

re-encoding means for decoding the losslessly encoded data in the second memory, re-encoding the decoded data in accordance with a second parameter to generate lossily encoded data, and storing, of the lossily encoded data obtained after re-encoding and the losslessly encoded data before re-encoding, encoded data of a shorter encode length in the first memory,

monitoring means for monitoring an encoded data amount in the first memory and determining whether the encoded data amount has exceeded a predetermined data amount,

parameter update means for, when the monitoring means determines that the encoded data amount has exceeded the predetermined data amount, (a) discarding the encoded data in the first memory, (b) updating the first parameter set for the first encoding means to a parameter having a high compression ratio, and causing the first encoding means to continue encoding of the image data, and (c) setting, as the second parameter, the same parameter as the updated first parameter for the re-encoding means, and causing the re-encoding means to re-encode losslessly encoded data obtained before the encoded data amount exceeds the predetermined data amount, and

correction means for, when an encoding process for one page is completed, correcting, of encoded data of pixel blocks that are stored in the first memory, isolated encoded data of a type different from a type of neighboring encoded data to the type of the neighboring encoded data.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Description of the Outline of Apparatus

FIG. 22is a block diagram showing a copying machine to which an embodiment is applied.

InFIG. 22, reference numeral1denotes a control unit which controls the overall apparatus, and is made up of a CPU, ROM, RAM, and the like. Reference numeral2denotes an operation unit which is made up of an LCD display, various switches, buttons, and the like. Reference numeral3denotes a document reading unit (image scanner unit) which includes an ADF (Auto Document Feeder). The document reading unit3outputs a read image as digital data of 8 bits (256 gray levels) for each of R, G, and B color components. Reference numeral4denotes a rendering unit which renders a print image on the basis of PDL print data received via an interface (including a network interface: not shown). Reference numeral5denotes a selector which selects and outputs one of bitmap images output from the document reading unit3and rendering unit4in accordance with an instruction from the control unit1.

Reference numeral6denotes an encoding unit which is a feature of the embodiment. Although details of the encoding unit6will be described later, the encoding unit6encodes image data.

Reference numeral7denotes a secondary storage device (in the embodiment, a hard disk drive) which sequentially stores encoded data output from the encoding unit6.

Reference numeral8denotes a decoding unit which reads out and decodes, in the storage order, compression-encoded image data that are stored in the secondary storage device7. Reference numeral9denotes an image processing unit which receives a decoded image from the decoding unit8, and performs conversion from an RGB color space into a YMC print color space, a UCR (Under Color Removal) process, and in addition an image data correction process.

Reference numeral10denotes a printer engine unit whose printing mechanism is a laser beam printer engine, but can be of an arbitrary type for, e.g., discharging liquid ink.

In the above arrangement, for example, the user operates the operation unit2to select a copy mode, sets a document on (the ADF of) the document reading unit3, and presses a copy start key. Then, document image data read by the document reading unit3are transferred in the raster order to the encoding unit6via the selector5, compression-encoded by the encoding unit6, and stored in the secondary storage device7.

When print data is externally received, the selector5selects the rendering unit4, an image based on print data generated by the rendering unit4is compression-encoded, and the encoded data is stored in the secondary storage device7.

The decoding unit8reads out compression-encoded data from the secondary storage device7, and decodes the readout data in accordance with the print speed of the printer engine10. The image processing unit9generates print image data of Y, M, C, and K (Black) components from the decoded image data. The image processing unit9outputs the process result to the printer engine unit10to print.

As described above, a compression-encoded data storage process to the secondary storage device7and a read process for decoding and printing are asynchronous. That is, the secondary storage device7functions as a buffer interposed between an image compression process and a decoding process. Since a document reading/encoding process is independent of a decoding/printing process, many documents can be read at a high speed, and the process can quickly shift to document reading of the next job.

FIG. 23is a flowchart for explaining a process by the encoding unit6.

The encoding unit6reads image data of several lines in step S1, and performs an encoding process in step S2. In step S3, the encoding unit6continues input of the image and the encoding process until it is determined that the encoding process for one page is completed. Upon the completion of the encoding process for one page, the flow advances to step S4, and the encoding unit6performs a correction process of correcting the generated encoded data, and outputs the corrected data to the secondary storage device7. If it is determined in step S5that the next page exists, the process from step S1is executed.

A feature of the embodiment lies in steps S2and S4. The arrangement of the encoding unit6according to the embodiment and the process of step S2based on the arrangement will be explained first, and then the process of step S4will be explained.

Description of Encoding Unit 6

FIG. 1is a block diagram showing the encoding unit6according to the embodiment. Each unit inFIG. 1will be briefly explained.

An input unit101incorporates a line buffer memory for a plurality of lines. As described above, the input unit101receives image data from the document reading unit3or rendering unit4via the selector5in the raster order, stores the image data in the internal line buffer, and outputs it by a block of N×M pixels (in the embodiment, a block of 8×8 pixels).

A first encoding unit102is a lossy encoding unit which compression-encodes each pixel block input from the input unit101in accordance with a parameter which influences the compression ratio, and outputs the result (encoded data). An identification bit representing that data has been encoded by the first encoding unit102is added at the start of the encoded data.

The image encoding unit102according to the embodiment adopts JPEG encoding (lossy encoding). More specifically, image data corresponding to 8×8 pixels is orthogonally transformed, quantized using a quantization step (to be described later), and undergoes a Huffman encoding process. The quantization step determines a generated amount of encoded data, and is set by an encoding sequence control unit110as an encoding parameter which influences the compression ratio. JPEG encoding is known as a technique suitable for natural pictures.

FIG. 21shows quantization matrix tables Q0, Q1, and Q2which are used to quantize the frequency coefficient after DCT transformation (which are stored and held in the encoding sequence control unit110). Values Qi(0,0) to Qi(7,7) (i=0, 1, 2, . . . ) in the quantization matrix table mean quantization step values. Quantization step values substantially satisfy Q0<Q1≦Q2. . . . As the quantization step value increases, a possible range of the frequency coefficient value after quantization narrows, and the compression ratio increases.

A second encoding unit103is a lossless encoding unit, unlike the first encoding unit102. Because of lossless encoding, the decoding result is identical to an image before encoding, and the image quality does not degrade in principle. In the embodiment, the second encoding unit103adopts JPEG-LS. “JPEG” is prefixed to JPEG-LS, but its algorithm is completely different from lossy encoding “JPEG” which is employed in the first encoding unit. JPEG-LS encoding is suited to character/line images and computer graphics. When such an image is encoded, this technique can generate encoded data which is smaller than a quantization step “1” (substantially lossless) given to lossy encoding “JPEG”, and also a relatively small quantization step value such as “2” or “3”.

At substantially the same timing as that of the first encoding unit102, the second encoding unit103encodes the same pixel block and outputs encoded data. In outputting encoded data, the second encoding unit103adds at the start of the encoded data an identification bit representing that the data has been encoded by the second encoding unit103.

A first encode length detection unit108detects the total length (to be simply referred to as an encode data length hereinafter) of encoded data for one pixel block that is output from the first encoding unit102and contains one bit serving as an identification bit. The first encode length detection unit108then outputs the detected length to the encoding sequence control unit110. A second encode length detection unit109detects the encode data length (including one bit serving as an identification bit) of one pixel block output from the second encoding unit103, and outputs the detected length to the encoding sequence control unit110.

The encoding sequence control unit110controls the encoding unit6in the embodiment, and incorporates a first counter111. The counter is reset at the start of encoding one page, compares an encode length from the first encode length detection unit108and that from the second encode length detection unit109, selects data of a shorter encode length, and accumulates (or adds) the data. Since a shorter encode length is proved, the encoding sequence control unit110requests a first memory control unit104to store encoded data of the shorter encode length.

The first memory control unit104writes/deletes encoded data in/from a first memory105under the control of the encoding sequence control unit110. The first memory105stores encoded data which is finally defined upon the completion of 1-page encoding, and stores encoded data to be output to the secondary storage device7.

A second memory control unit106performs a process of storing encoded data generated by the second encoding unit103in a second memory107, and a process of reading out encoded data from the second memory107under the control of the encoding sequence control unit110. The second memory107is used as a work area when 1-page image data is encoded.

A re-encoding unit112re-encodes encoded data in a range designated by the encoding sequence control unit110out of encoded data (losslessly encoded data) stored in the second memory107. The re-encoding unit112has, e.g., an arrangement inFIG. 20.

Since the second memory107stores data encoded by the second encoding unit (JPEG-LS encoding unit)103, the encoded data is decoded (reconstructed) into a pixel block of an original image by a JPEG-LS decoding unit112a. A JPEG encoding unit112bJPEG-encodes (lossily encodes) the reconstructed pixel block in accordance with a quantization matrix table set by the encoding sequence control unit110. A selector112c selects and outputs a smaller one of the lossily encoded data output from the JPEG encoding unit112band the losslessly encoded data before re-encoding. This process is repetitively executed for a range designated by the encoding sequence control unit110. A second counter113is reset at the start of re-encoding by the re-encoding unit112, and accumulates and counts an encoded data amount generated by the re-encoding unit112. Upon the completion of re-encoding in the set range, a value (encoded data amount generated by re-encoding) held in the second counter is output to the encoding sequence control unit110.

The arrangement inFIG. 1has been described, and the overall process will be explained in more detail.

When encoding of 1-page image data starts, a target data amount corresponding to an input image size is set by the control unit1in the encoding sequence control unit110. The encoding sequence control unit110sets the initial quantization matrix table Q0(encoding parameter corresponding to the highest image quality and lowest compression ratio) for the first encoding unit102, and clears the first counter111to0. The encoding sequence control unit110causes the first and second encoding units102and103to start an encoding process. The following description pertains to input and an encoding process of 1-page image data.

The first and second encoding units102and103output encoded data of the same pixel block. The first and second encode length detection units108and109detect and output the encode lengths of the encoded data. The encoding sequence control unit110selects a shorter encode length, and causes the first counter111to add it. At this time, the encoding sequence control unit110outputs to the first memory control unit104a control signal representing which of the encode lengths has been selected. When the two encode lengths are equal to each other, the encoding sequence control unit110outputs a control signal representing that losslessly encoded data has been selected.

The first memory control unit104receives the control signal from the encoding sequence control unit110, selects encoded data whose encode length is determined to be shorter, and stores the encoded data in the first memory105.

As a result, the first memory105stores encoded data of a shorter encode length for each pixel block of image data. That is, the first memory105stores both losslessly encoded data and lossily encoded data. To the contrary, the second memory107stores only losslessly encoded data.

It should be noted that the first counter111stores information on the total code amount of encoded data stored in the first memory105.

While the encoding process for a 1-page image progresses, the encoding sequence control unit110monitors the value of the first counter111, i.e., the total amount of encoded data stored in the first memory105, and determines whether the total amount has exceeded (or has reached) the target data amount. If the encoding sequence control unit110determines that the value (total code amount) held by the first counter111has exceeded the target data amount, the encoding sequence control unit110executes the following process.

Step 1). The encoding sequence control unit110outputs a control signal to the first memory control unit104so as to discard data stored in the first memory105. Based on the control signal, the first memory control unit104discards the stored encoded data by clearing the memory address counter or clearing the encoded-data management table.
Step 2). The encoding sequence control unit110clears the first counter111to 0 (input of an image from the input unit101continues).
Step 3). The encoding sequence control unit110updates the quantization matrix table in order to cause the first encoding unit102to perform encoding at a compression ratio higher than the current one. When the currently set quantization matrix table is Qi, the encoding sequence control unit110sets a quantization matrix table Qi+1. Since the quantization matrix table Q0is set in the initial state, the quantization matrix table Q1is set when it is determined for the first time that the total amount has exceeded the target amount.
Step 4). The encoding sequence control unit110clears the second counter113to 0, sets the quantization matrix table Qi+1 for the re-encoding unit112, and starts re-encoding of encoded data stored in the second memory107. Encoded data (including both losslessly and lossily encoded data) obtained by re-encoding are stored again in the second memory107. The second memory107also stores encoded data from the second encoding unit103, and the encoded data from the first and second encoding units102and103are distinctively stored.
Step 5). Upon the completion of re-encoding, the encoding sequence control unit110transfers the encoded data stored “again” in the second memory107to the first memory105, and deletes the data from the second memory (encoded data from the encoding unit103is not deleted). The encoding sequence control unit110reads out the value of the second counter113, and adds it to the first counter111. As a result, the first counter111indicates again the total amount of encoded data stored in the first memory.

Whether the re-encoding process has ended is detected by the second memory control unit106. If no data to be read out for the re-encoding process is detected, the second memory control unit106notifies the encoding sequence control unit110of the end of the re-encoding process. In practice, the encoding process is completed after not only the read process by the second control unit106but also the process of the re-encoding unit112end.

If the encoding sequence control unit110determines that the total encoded data amount has exceeded the target data amount again before input and encoding of a 1-page image are completed, the encoding sequence control unit110executes steps 1 to 5 above. Finally, the first memory105stores encoded data of the target data amount or less.

The process sequence of the encoding sequence control unit110in the arrangement ofFIG. 1is shown in the flowchart ofFIG. 9. For descriptive convenience, this process will be described first with reference to the simplified flowchart ofFIG. 3.

The flowchart ofFIG. 3is roughly divided into the following three process phases:

(3) a transfer phase.

FIGS. 4 to 8visually and simply show how image data, encoded data, and the like flow and are processed and how they are stored in the memories in the respective process phases.

FIG. 4shows the initial state of the encoding phase corresponding to steps S303and S305in the flowchart ofFIG. 3. Note that a switch40inFIG. 4selects encoded data of a shorter encode length among encoded data from the first and second encoding units102and103. The switch40is implemented by the functions of the encoding sequence control unit110and first memory control unit104. The first memory105stores encoded data of a shorter encode length among encoded data from the two encoding units. This maintains a relation in which a data amount I in the first memory105is smaller than a data amount I′ in the second memory107.

FIG. 5shows a state when the quantization matrix table is changed in step S309. As shown inFIG. 5, no encoded data is stored in the first memory105.

FIG. 6shows the process state of the encoding/re-encoding phase corresponding to steps S311to S315.FIG. 7shows the process state of the transfer phase corresponding to step S317.FIG. 8shows the process state of the encoding phase after the transfer phase. Each phase will be described below.

In step S303, an encoding process starts by the first and second encoding units102and103. Consequently, the first memory105stores, for each pixel block, encoded data of a shorter encode length among encoded data from the first and second encoding units102and103. The encoded data amount in the first memory105is counted by the first counter, as described above. The second memory107stores encoded data from the second encoding unit103.FIG. 4shows this state. The area I representing a data amount in the first memory105is at least equal to or narrower than the area I′ representing a data amount in the second memory107.

In step S305, it is checked whether the count value of the data amount has exceeded the target value. If NO in step S305, the first and second encoding processes in step S303continue. This is the encoding phase in the initial state.

As the encoding process proceeds and the total code data amount in the first memory exceeds the target amount, encoded data in the first memory105is discarded in step S307. In step S309, the quantization matrix table Q0set for the first encoding unit102is updated to the next quantization matrix table Q1. That the total encoded data amount exceeds a target data amount means that the data amount after compression does not fall within the target amount. Since it is useless to continue the encoding process by using the same quantization step, the quantization step is changed to the quantization step Q1which is larger in quantization step width than the quantization step Q0.

After the quantization step is changed, the encoding process by the first and second encoding units102and103resumes in step S311. The quantization matrix table Q1(identical to the updated quantization matrix table set for the first encoding unit) is set for the re-encoding unit112. Re-encoding of the encoded data amount in the second memory starts, and the re-encoding result is stored again in the second memory. This state is shown inFIG. 5.

In step S315, the flow waits until the re-encoding process is completed.

FIG. 6shows the storage state of encoded data in the first and second memories105and107when it is determined in step S315that re-encoding is completed. InFIG. 6, areas II and II′ represent encoded data corresponding to newly input image data during the re-encoding process. The area I represents the result (including both lossily and losslessly encoded data) of re-encoding encoded data stored in the area I′.

In step S317, as shown inFIG. 7, re-encoded data (area I inFIG. 7) stored in the second memory107is transferred to the first memory105. Upon the completion of transfer, the data in the area I of the second memory107is discarded (or overwrite is permitted).

After the end of the transfer phase, the flow returns to the encoding phase in steps S303and S305. As a result, as shown inFIG. 8, encoded data III and III′ of newly input image data are stored in the respective memories. In this encoding phase, unlike the encoding phase in the initial state (FIG. 4), the quantization step used for encoding by the first encoding unit102is changed from Q0to Q1, and the order of encoded data stored in the first memory105does not coincide with the image input order. Except these differences, the encoding phase immediately after the transfer phase and that in the initial state can be regarded to be identical. Since the order of encoded data is not always time series, as shown inFIG. 8, the storage address in each phase is separately stored. When an encoding process for one page is completed and the encoded data is to be output to the secondary storage device7via a correction unit120(to be described in detail later), the encoded data are read out and output in time series from the first memory105.

By repeating the three, encoding, encoding/re-encoding, and transfer phases, codes obtained by compressing 1-page image data into a set data amount or less can be finally stored in the first memory105. The input unit101only continues input operation until the end of a series of processes. That is, no image need be input again from the beginning.

The flowchart shown inFIG. 3describes only processes corresponding to the respective phases shown inFIGS. 4 to 8for easy understanding. In practice, however, input of 1-page image data comes to an end in some phase. Depending on the phase where the input operation comes to an end, the subsequent process slightly differs. The flowchart ofFIG. 9shows the flow of a process in consideration of this. The flowchart ofFIG. 9is based on the relationship between the completion of input of 1-page image data and each kind of process described with reference toFIG. 3. In this case, steps S801, S803, S805, and S807are added to the flowchart ofFIG. 3.

In steps S801, S803, and S805, it is checked whether input of 1-page image data from the input unit101is completed in the encoding phase, encoding/re-encoding phase, and transfer phase.

If it is detected that input of 1-page image data is completed in the encoding phase and transfer phase (steps S801and S805), the flow advances to step S807to terminate a compression encoding process for the page. If there is image data of one page or more to be compressed next, the compression encoding process for the next 1-page image data starts. If there is no data to be compressed, a halt condition is set.

If the end of input of 1-page image data is detected in the encoding/re-encoding phase (step S803), the operation of the first and second encoding units102and103need be stopped until there is no image data to be re-encoded. For this reason, the encoding process in step S311is passed, and only the re-encoding process is continued in step S313to suppress, within a predetermined encoded data amount, image data which have already been encoded by the first and second encoding units102and103. If the subsequent transfer process is not terminated after the re-encoding process is terminated for all data, the overall encoded data of 1-page image data is not collected in the first memory. The re-encoding process and subsequent transfer process must be continuously performed even after the end of input of 1-page image data. In this case, if it is detected in step S315that the re-encoding process is terminated for all data, the encoded data stored in only the second memory107is transferred to the first memory during the encoding/re-encoding phase (step S317). Thereafter, the end of input of 1-page image data is detected in step S805, and the flow advances to step S807(advances to a correction process).

The above description has been made for the contents of the encoding process by the encoding unit6according to the embodiment, and is also a description of the operation inFIG. 9.

As has been described above, encoded data of a target encoded data amount or less can be generated without interrupting input of a 1-page image and inputting again it while different encoding techniques provided by the first encoding unit102which generates lossily encoded data and the second encoding unit103which generates losslessly encoded data are adopted.

It should be noted that the embodiment uses the two, JPEG and JPEG-LS techniques. JPEG encoding is known to have a high compression ratio for natural pictures. To the contrary, JPEG-LS encoding can obtain a high compression ratio for character/line images, and faithfully reconstruct an original image because of lossless encoding.

For this reason, the image encoding unit6according to the embodiment can be expected to provide the following operation effects. In the following description, a target code data amount is set on the assumption that one entire page is a natural picture.

1. For a general document which is formed from only characters, JPEG-LS-encoded data (losslessly encoded data) from the second encoding unit103is highly likely to be selected as encoded data of each pixel block that is to be stored in the first memory105. Also, it can be expected that the compression ratio at this time is very high and encoding is completed while the total encoded data amount is suppressed within a target code amount. Because of losslessly encoded data, the print result is faithful to an original image, and the image quality of the print result becomes substantially equal to that obtained without the mediacy of encoding.
2. When a document is formed from only a natural picture, JPEG-encoded data (lossily encoded data) from the first encoding unit102is highly likely to be selected as encoded data which is to be stored in the first memory105. Also, the total data amount is highly likely to exceed a target data amount several times. However, the original is a natural picture, tone reproduction is a factor which determines the image quality, and encoded data can be printed at a sufficient image quality.
3. When a document contains both a natural picture and characters, JPEG-LS-encoded data is highly likely to be selected in the character/line image area, and JPEG-encoded data is highly likely to be selected for the natural picture. In the character/line image area, JPEG-LS encoding having a high compression ratio is selected at high possibility. This means that an encoded data amount assigned to the natural picture area can be increased at a ratio equal to or more than the ratio of the natural picture area and character/line image area which occupy one page. In other words, it can be expected that the encoding process is completed while the quantization step value of a photographic image is kept relatively small. Degradation of the image quality in the character/line image area and also the photographic image area can be suppressed.
4. It is also advantageous to implement these operation effects 1 to 3 without any special circuit configuration such as an area determination circuit.

FIG. 13shows an example of transition of the first counter111(encoded data amount) along the time axis.

InFIG. 13, input of a document image starts at timing T0, and is completed at timing T5. Timing T5is fixed as far as the size of an input document is fixed. A process at each timing will be explained.

Timing T0is an image input start (encoding start) timing. At this time, the quantization matrix table Q0is set as an initial value for the first encoding unit102, and the first counter111is initialized to “0”. After that, as input and encoding of an image continue, the image data is encoded, and the count value of the first counter111gradually increases.

At timing T1, the encoded data amount of image data reaches a target code amount. At this time, encoded data of image data in the first memory105is discarded, the first counter111is cleared to 0, and the quantization matrix table set for the first encoding unit102is updated to Q1. The quantization matrix table Q1is also set for the re-encoding unit112, and the re-encoding process starts.

At timing T2, the re-encoding and transfer processes are completed. Upon the completion of re-encoding, re-encoded data is transferred from the second memory107to the first memory105, and the value of the second counter113representing the re-encoded data amount is added to the first counter111. Consequently, the first and second memories105and107store encoded data equivalent to data obtained such that image data input from the start of one page till timing T2are encoded on the basis of the quantization matrix table Q1.

At timing T3, the encoded data amount of image data reaches a target code amount again. At this time, encoded data of image data in the first memory105is discarded, the first counter111is cleared to 0, and the quantization matrix table of the first encoding unit102is changed to Q2. The quantization matrix table Q2is also set for the re-encoding unit112, and the re-encoding process starts.

At timing T4, the re-encoding and transfer processes are completed. Upon the completion of re-encoding, re-encoded data is transferred from the second memory107to the first memory105, and the value of the second counter113representing the re-encoded data amount is added to the first counter111. As a result, the first and second memories105and107store encoded data equivalent to data obtained such that image data input from the start of one page till timing T2are encoded on the basis of the quantization matrix table Q2.

At timing T5, input of the 1-page document is completed. In this case, the first memory105stores encoded data of the 1-page image, and outputs the result to the secondary storage device7via the correction unit120. At this time, the correction unit120is notified of a quantization matrix table finally used by the first encoding unit102(the reason will be described later).

To read the second document image, the process is repeated from timing T1.

Depending on an image, the value of the first counter111may exceed a target amount immediately before timing T5at which input of a document image is completed. In this case, the re-encoding and transfer processes are done after timing T5. A condition that encoded data stored in the first memory105is output to the secondary storage device7is that input of a document image is completed and encoding (re-encoding and transfer) is also completed.

An encoded data amount to be re-encoded by the re-encoding unit112tends to increase as the number by which the value of the first counter111exceeds a target data value increases. In other words, as the number by which the value exceeds the target value is smaller, the time taken for the encoding process is shorter.

The process of step S2inFIG. 23has been described. Next, the correction process of step S4inFIG. 23will be explained.

As described above, when an encoding process for one page is completed, encoded data of each pixel block that is stored in the first memory105is either lossily encoded data or losslessly encoded data, and encoded data of these two types coexist.

The embodiment exemplifies JPEG as lossy encoding and JPEG-LS as lossless encoding. Without any special area determination circuit or means, it is highly likely to employ JPEG-encoded data for a natural picture area in an input 1-page image and JPEG-LS-encoded data for a character/line image area.

However, this is a matter of probability, and it is not guaranteed that losslessly encoded data based on JPEG-LS encoding are adopted for all pixel blocks in a character/line image area and lossily encoded data based on JPEG encoding are adopted for all pixel blocks in a natural picture area. That is, encoded data of a pixel block of interest may be losslessly encoded data and those of pixel blocks around the pixel block of interest may be lossily encoded data, and vice versa. If encoded data (to be referred to as isolated encoded data hereinafter) whose encoding type is two-dimensionally isolated is generated, the pixel density and color become discontinuous at the boundary between the pixel blocks on the decoded image, resulting in an unnatural image.

This problem becomes serious particularly when a pixel block of interest has losslessly encoded data and its neighboring pixel blocks have lossily encoded data.

To solve this problem, according to the embodiment, isolated losslessly encoded data is searched for, and isolated losslessly encoded data of interest is re-encoded on the basis of a quantization matrix table notified from the encoding sequence control unit110to make the isolated losslessly encoded data coincide with its neighboring lossily encoded data. This process is executed by the correction unit120, and is the process of step S4inFIG. 23.

FIG. 24is a flowchart showing the process contents of the correction unit120. The process sequence of the correction unit120will be explained with reference toFIG. 24.

In step S11, encoded data of interest (encoded data of one pixel block) and eight neighboring encoded data, i.e., a total of nine encoded data are read out. When encoded data of interest is positioned at the uppermost portion, left end, right end, or lowermost portion of a page, no nine encoded data can be read out. In this case, the type of encoded data of a pixel block at a virtual position is treated as the same type as that of encoded data of a pixel block of interest.

In step S12, it is determined whether encoded data of interest is isolated encoded data. As is apparent from the embodiment, whether encoded data is losslessly encoded data or lossily encoded data is determined by checking the start bit of the encoded data. If all the eight encoded data around the encoded data of interest are of the same type and the encoded data of interest is of a type different from that of the neighboring encoded data, it can be determined that the encoded data of interest is isolated encoded data.

If it is determined that the encoded data of interest is not isolated encoded data, the flow advances to step S15to directly output the encoded data of interest to the secondary storage device7.

If it is determined that the encoded data of interest is isolated encoded data, the flow advances to step S13to determine on the basis of the start bit whether the encoded data of interest is losslessly encoded data.

If it is determined that the encoded data of interest is not losslessly encoded data (is lossily encoded data), the flow advances to step S15to directly output the encoded data.

If it is determined that the encoded data of interest is losslessly encoded data, the losslessly encoded data is converted into lossily encoded data in step S14. Since the encoded data of interest is losslessly encoded data, it can be reconstructed into data of the pixel block of the original image. The decoding result is encoded (JPEG-encoded) using a quantization matrix table notified from the encoding sequence control unit110. Then, the flow advances to step S15to output the encoded data as a conversion result.

The above process is repeated until it is determined in step S16that all encoded data of one page have been processed.

The first memory105stores encoded data of a shorter encode length among encoded data output from the two encoding units. Hence, the encoded data amount of one page that is output via the correction unit120does not become smaller than a data amount stored in the first memory105before the correction process by the correction unit120starts. In other words, the encoded data amount of one page that is output from the correction unit120may exceed a target encoded data amount set by the encoding process.

However, in the correction unit120, encoded data whose encoding type is to be changed is only isolated losslessly encoded data. It has been confirmed that the number of isolated losslessly encoded data is only a small percentage of the total number of pixel blocks, and falls within a permissible range. In an application of the present invention to a copying machine, like the embodiment, even if the encoded data amount exceeds a target data amount, this does not influence image formation, and no problem occurs.

As described above, according to the embodiment, encoded data of a target data amount can be generated by one input operation of page image data while both lossy and lossless encoding techniques are used and generation of block noise is suppressed.

Since JPEG as lossy encoding and JPEG-LS as lossless encoding are used, encoding suited to a character/line image or natural picture can be selected without arranging any special area determination circuit. Encoded data high in both image quality and compression ratio upon decoding can be generated.

The embodiment has been described above, and the arrangement of the embodiment can be variously modified and changed. The following description is directed to another encoding unit6and another correction unit120to which the embodiment can be applied.

First Modification of Encoding Unit6

FIG. 2shows a modification of the arrangement inFIG. 1. The arrangement inFIG. 2is different from that inFIG. 1in that the storage destination of data re-encoded by the re-encoding unit112is changed to the first memory105. The remaining arrangement is the same as that inFIG. 1.

FIG. 10shows a state in which the total encoded data amount in the first memory105exceeds a target data amount, data in the first memory105is discarded, and re-encoding of encoded data (area I′ inFIG. 10) stored in the second memory107starts.

As shown inFIG. 10, the first memory105is set as the storage destination of re-encoding by the re-encoding unit112, and re-encoding starts.

FIG. 11shows the storage state of encoded data in two memories upon the completion of re-encoding. Upon the completion of re-encoding, as shown inFIG. 11, the first memory105stores encoded data represented in the area I. Encoded data in the area I corresponds to encoded data obtained when image data input before it is determined that the total data amount has exceeded a target data amount is encoded on the basis of the quantization matrix table Q1.

Since input and encoding of image data are performed even during re-encoding, the areas II and II′ exist, as shown inFIG. 11.

Since a free area105ais ensured in the first memory105, encoded data in the area II shown inFIG. 11is moved to the end position in the area I. Thereafter, the encoding phase resumes, and the storage state in the memory at this time is illustrated inFIG. 12.

The advantage of the arrangement inFIG. 2over that inFIG. 1is that data transfer after re-encoding is substantially omitted.

This modification omits only the transfer phase, and is substantially the same as the preceding description in terms of repeating the three phases. Therefore, the contents of the process are almost the same as those inFIGS. 3 and 9, and a description thereof will be omitted. InFIG. 11, data is moved in the first memory105in order to eliminate the free area105a, but internal transfer is not always necessary when a file management table for managing the connection relationship between areas, a packet management table, or the like is employed.

Second Modification of Encoding Unit6

In the embodiment and first modification, when the encoded data amount in the first memory105exceeds a target data amount, encoded data in the second memory107is re-encoded by the re-encoding unit112. In other words, the re-encoding unit112does not execute re-encoding while the encoded data amount in the first memory105falls within the target data amount.

An example of effectively using this period will be explained as the second modification.

The following description is directed to a process while losslessly encoded data from the second encoding unit103is stored in the second memory107when the encoded data amount in the first memory105falls within the target data amount, under the condition that the quantization matrix table set for the first encoding unit102is Qi.

Similar to the above embodiment, losslessly encoded data from the second encoding unit103is stored in the second memory107. However, the re-encoding unit112moves up a process of sequentially reading out stored losslessly encoded data, re-encoding it on the basis of the quantization matrix Qi+1 to generate lossily encoded data, and storing the result in the second memory107.

Thus, it is promised that lossily encoded data exists to a certain degree in the second memory107in addition to losslessly encoded data when encoded data in the first memory105exceeds the target data amount. For the same pixel block position, encoded data in a smaller amount is transferred to the first memory. The process inFIG. 20is performed for only a pixel block whose lossily encoded data to be compared does not exist.

Upon the completion of transfer from the second memory107to the first memory105, lossily encoded data stored in the second memory is discarded, the quantization matrix Qi+2is set this time, and re-encoding starts. Consequently, the process associated with re-encoding can be further shortened.

Third Modification of Encoding Unit6

In the first embodiment described above, the first counter is temporarily cleared to 0 when the encoded data amount (value of the first counter111) exceeds a target value during input of a 1-page image. The first counter111holds an accurate total code amount again after re-encoding by the re-encoding unit112is completed. That is, the encoded data amount becomes temporarily unknown at an interval between timings T1and T2and an interval between timings T3and T4inFIG. 13. When input of a document image ends at timing T5, but the total code amount accidentally exceeds the target value immediately before timing T5, no next document image can be input until re-encoding by the re-encoding unit112is completed.

The third modification solves the above problem. The arrangement of the encoding unit6according to the third modification is shown inFIG. 14.

The arrangement inFIG. 14is different from that inFIG. 1in that the encoding unit6adopts a third encoding unit114serving as a JPEG (lossy) encoding unit, a third encode length detection unit115which detects the encode length of a pixel block that is generated by the third encoding unit114, a third counter116, a third memory control unit117, and a third memory118. Similar to the first embodiment, the third encoding unit114adds a bit representing JPEG encoding (lossy encoding) at the start of generated encoded data.

InFIG. 1, only one JPEG encoding unit performs lossy (JPEG) encoding. To the contrary, inFIG. 14according to the third modification, two, first and third image encoding units102and202are arranged, and these two lossy encoding units parallel-execute an encoding process. The first and third encoding units102and114are different in a set parameter. More specifically, when a quantization matrix table Qi is set for the first encoding unit102, a quantization matrix table Qi+1 larger by one step is always set for the third encoding unit114. At the initial stage at the start of encoding one page, a quantization matrix table set for the first encoding unit102is Q0, and that set for the third encoding unit114is Q1.

The first, second, and third encoding units102,103, and114execute an encoding process for the same pixel block at almost the same timing, and generate and output encoded data at almost the same timing.

Furthermore, losslessly encoded data output from the second encoding unit103is unconditionally stored in the third memory118via the third memory control unit117. Upon the completion of encoding one page, encoded data stored in the first memory105is finally obtained encoded data, similar to the first embodiment.

An outline of a process by the encoding sequence control unit110in the arrangement ofFIG. 14will be explained.

A basic process for each pixel block in the encoding sequence control unit110according to the third modification is as follows.

1. Letting Qi be a quantization matrix table set for the first encoding unit102(Q0at the initial stage), the encoding sequence control unit110always sets for the third encoding unit114a quantization matrix table Qi+1(Q1at the initial stage) larger by one step.
2. The encoding sequence control unit110outputs a control signal to the first memory control unit so as to store in the first memory105a smaller one of lossily encoded data output from the first encoding unit102and losslessly encoded data output from the second encoding unit103. The encoding sequence control unit110adds a shorter one of the encode lengths of the two encoded data to the first counter111. That is, the first counter111stores information representing an encoded data amount in the first memory105, similar to the first embodiment.
3. The encoding sequence control unit110outputs a control signal so as to store in the second memory107a smaller one of lossily encoded data output from the third encoding unit114and losslessly encoded data output from the second encoding unit103. The encoding sequence control unit110accumulates and adds a shorter one of the encode lengths of the two encoded data to the third counter116.

An outline of a process by the encoding sequence control unit110during an encoding process for one page will be explained.

The encoding sequence control unit110determines whether the value (encoded data amount in the first memory105) of the first counter111has exceeded a target data amount. If the encoding sequence control unit110determines that the value does not exceed the target data amount and an encoding process for one page is completed, the encoding sequence control unit110outputs, to the secondary storage device7via the correction unit120, encoded data stored in the first memory105as the encoding result of the encoding unit6.

If the encoding sequence control unit110determines that the value of the first counter111has exceeded the target data amount, the encoding sequence control unit110executes the following steps.

Step 1: The encoding sequence control unit110requests the first memory control unit104to discard encoded data of image data in the first memory105.

Step 2: The encoding sequence control unit110transfers encoded data (data containing both lossily and losslessly encoded data on the basis of the quantization matrix table Qi+1) stored in the second memory107to the first memory105. Along with this, the value of the first counter111is updated to the value of the third counter116(the value of the third counter116is overwritten in the first counter111).
Step 3: Upon the completion of transfer from the second memory107to the first memory105, the encoding sequence control unit110outputs a control signal to the second memory107so as to discard data in the second memory107.
Step 4: The encoding sequence control unit110updates the quantization matrix table for the first encoding unit102to Qi+1, that for the third encoding unit114to Qi+2, and continues encoding.
Step 5: The encoding sequence control unit110sets the quantization matrix table Qi+2(identical to the updated quantization matrix table for the third encoding unit114) for the re-encoding unit112, and causes the re-encoding unit112to re-encode the losslessly encoded data stored in the third memory118. The re-encoding unit112has the same arrangement as that in the first embodiment, and a description thereof will be omitted. Re-encoded data obtained by the re-encoding process is stored again in the third memory. At this time, the encoded data amount generated by the re-encoding process is represented by the second counter113.
Step 6: Upon the completion of re-encoding in step 5, the encoding sequence control unit110transfers the re-encoded data obtained by the re-encoding process to the second memory, and adds the value of the second counter113to the third counter116.

Of steps 1 to 6, steps 1 to 5 can be performed at a speed high enough to input image data from the input unit101. For this reason, a period during which the encoded data amount is unknown, like an interval between timings Ti and T2or an interval between timings T3and T4inFIG. 13, can be shortened. In particular, the update process for the first counter111in step 2 may be performed before the completion of the transfer process. In this case, the period during which the encoded data amount is unknown can be substantially ignored.

If the encoded data amount given by the first counter111exceeds the target value immediately before timing T5inFIG. 13, the process starts from step 1, and upon the completion of step 2, encoded data is written in the secondary storage device7because the target encoded data has been stored in the first memory105. Then, loading and encoding processes for the next page can start without performing the process from step 3.

An outline of operation in the arrangement ofFIG. 14has been described. When two lossy encoding units and one lossless encoding unit are juxtaposed, like the third modification, 1-page image data is encoded on the basis of the flowchart shown inFIG. 15.

Note that most of the process inFIG. 15is similar to that inFIG. 9, the process will be described in three phases, and points different from those inFIG. 9will be mainly described below.

The largest difference between the flow ofFIG. 9and that of the third modification is that the transfer process from the second memory107to the first memory105in step S317is moved between step S307and step S309. In addition to this, a process (step S320) of discarding data in the second memory107is added after the end of the transfer process, and a transfer process (step S321) from the third memory to the second memory is added upon the completion of a re-encoding process.

In initial setting of encoding parameters in step S301, an initial quantization matrix table Q0to be set for the first image encoding unit102is determined, and a quantization matrix table Q1larger by one step is set for the third image encoding unit114.

In the encoding phase, steps S801, S303, and S305are repetitively executed.FIG. 16shows the storage state of encoded data in the first to third memories in the encoding phase. InFIG. 16, the switch40is identical to that in the first embodiment. A switch41is implemented by the second memory control unit106and encoding sequence control unit110. That is, the switch40selects, for each pixel block, encoded data of a shorter encode length among encoded data output from the first and second encoding units102and103, and the selected encoded data is stored in the first memory105. The switch41selects, for each pixel block, encoded data of a shorter encode length among encoded data output from the third and second encoding units114and103, and the selected encoded data is stored in the second memory107. The third memory118unconditionally stores encoded data from the second encoding unit103.

A case wherein the encoded data amount (area I shown inFIG. 16) in the first memory105exceeds a target value will be examined. This is a case wherein it is determined in step S305that the encoded data amount has exceeded the target data amount.

At this time, encoded data held in the first memory105is discarded (step S307). Encoded data (area I′) having a high compression ratio that is held in the second memory107is transferred to the first memory105, and the value of the third counter116is written in the first counter111(step S317). After transfer, the encoded data stored in the second memory107is discarded, and the value of the third counter is cleared to 0 (step S320). A new quantization matrix table Q1is set for the first encoding unit102, and a new quantization matrix table Q2is set for the second encoding unit103(step S309).

FIG. 17shows the storage state of each memory immediately after step S309. In step S311, the processes of the first, third, and second encoding units102,114, and103continue. In other words, the first encoding unit102continues encoding on the basis of the newly set quantization matrix table Q1. Encoded data of image data input after it is determined that the encoded data amount has exceeded the target data amount is stored in the second memory107, but no preceding encoded data exists.

The re-encoding unit112starts re-encoding encoded data (losslessly encoded data) in the area I″ inFIG. 16that is stored in the third memory118. The arrangement of the re-encoding unit112is the same as that described in the first embodiment except that the set quantization matrix table is Q2which is also set for the third encoding unit114. Re-encoded data obtained by the re-encoding process is stored again in the third memory118.

FIG. 18shows the storage state of each memory immediately after it is determined that the re-encoding process has been completed. As shown inFIG. 18, the third memory118stores re-encoded data (area I′ inFIG. 18) corresponding to the area I″ inFIG. 18. The re-encoding process requires a slightly long time, and encoded data are newly stored as represented by the areas II, II′, and II″ inFIG. 18.

Upon the completion of re-encoding, encoded data in the area I′ that is stored in the third memory118is transferred to the second memory107, and the value of the second counter113representing the code data amount of re-encoding is added to the third counter116(step S321). After that, the process returns to the encoding sequence from step S801.FIG. 19shows a state in which the process returns to the encoding sequence and encoding progresses to a certain degree (areas III, III′, and III″ shown inFIG. 19are added). InFIG. 19, a free area exists between the areas I′ and II′ in the second memory107, but may be eliminated by transfer within the memory107. However, no problem occurs because the second memory107is auxiliary, and if the encoded data amount exceeds the target data amount again, encoded data in the areas I′, II′, and III′ inFIG. 19are transferred to the first memory105in the order named.

The third modification has been described. According to the third modification, when the encoded data amount in the first memory105exceeds a target data amount, encoded data which has a compression ratio higher by one step and is stored in the second memory107is kept used as data before the encoded data amount exceeds the target data amount. The period during which the value of the first counter111becomes unknown can be substantially ignored or shortened. The re-encoding process suffices to be performed before the encoded data amount exceeds the target data amount again, and thus the process of the re-encoding unit112need not be as fast as in the first embodiment. Even if the value of the first counter111exceeds the target data amount immediately before timing T5inFIG. 9and the process reaches timing T5, a subsequent process, i.e., re-encoding process can be omitted as far as transfer from the second memory107to the first memory105is completed. The process can quickly proceed to encoding of the next page (this corresponds to “YES” in step S1201ofFIG. 15).

The re-encoding result of the re-encoding unit112is stored in the third memory118in the third modification, but may be stored in the second memory107, similar to the first modification.

The three modifications of the encoding unit have been described. Each modification can obviously attain the same operation effects as those of the first embodiment when the correction unit120performs the same process as that in the first embodiment.

Second Embodiment

The correction unit120in the above-described first embodiment unconditionally converts isolated losslessly encoded data into lossily encoded data.

It should be noted that JPEG-LS is employed as lossless encoding in the embodiment. For this reason, when the code amount of isolated losslessly encoded data is equal to or smaller than a predetermined threshold, the pixel block is a character/line image or the like at high possibility. This situation will be easily understood from a case wherein characters (the name of a photographer and the date and time) and the like are synthesized in a natural picture.

In this situation, if isolated losslessly encoded data is converted into lossily encoded data by JPEG encoding, the sharpness of a character/line image may be lost, degrading the image quality. To prevent this, according to the second embodiment, isolated losslessly encoded data is conditionally converted into lossily encoded data.

An encoding unit6can take any one of the block arrangements inFIGS. 1,2, and14. Hence, only a process by a correction unit120will be explained below.

FIG. 25is a flowchart showing the process sequence of the correction unit120according to the second embodiment.

The process inFIG. 25is the same as that inFIG. 24except that step S17is added. By adding step S17shown inFIG. 25, isolated losslessly encoded data is not converted when its encoded data amount is equal to or smaller than a preset threshold, and is converted into lossily encoded data only when the encoded data amount exceeds the threshold.

Accordingly, in addition to the operation effects of the first embodiment, the second embodiment can attain the operation effect of, when a character/line image or the like exists in a natural picture, maintaining the sharpness and visibility of the character/line image.

Third Embodiment

In the second embodiment, isolated losslessly encoded data is conditionally converted into lossily encoded data. In the third embodiment, isolated lossily encoded data is also taken into consideration.

FIG. 26shows the arrangement of an encoding unit6according to the third embodiment. The encoding unit6inFIG. 26is different from that inFIG. 1in that a correction unit120also refers to a second memory107. The third embodiment is based onFIG. 1, but may also be based onFIG. 2or14. In short, the correction unit120suffices to be able to access a memory (the second memory107inFIG. 2or the third memory118inFIG. 14) which stores losslessly encoded data.

As described in the second embodiment, a character/line image often exists in a natural picture. To the contrary, a natural picture at the size of a pixel block (8×8 pixel size in the embodiment) serving as an encoding unit hardly exists isolatedly in a character/line image.

Such isolated lossily encoded data can, therefore, be unconditionally converted into losslessly encoded data.

FIG. 27is a flowchart showing the process contents of the correction unit120according to the third embodiment. The process inFIG. 27is different from that inFIG. 25(second embodiment) in that step S18is added.

If it is determined in step S13that encoded data is not losslessly encoded data, i.e., is isolated lossily encoded data, the process advances to step S18. In step S18, losslessly encoded data at the same position as a pixel block of interest is read out from the second memory107. The readout encoded data is output as a conversion result in step S15.

In addition to the operation effects of the second embodiment, according to the third embodiment, lossily encoded data which is isolated for any reason is replaced with losslessly encoded data, and the losslessly encoded data is output. Hence, an image in which block noise is suppressed can be formed.

The first to third embodiments according to the present invention have been described, and the first, second, and third memories105,107, and118are described as physically different memories. It is one of features of the present invention to independently arrange these memories. However, the present invention incorporates even a case wherein these memories are not physically different memories. Assume that two (or three) areas corresponding to the first and second (and third) memories are ensured in physically one memory when the transfer speed of a memory is high enough. In this case, it is obvious from the above description with the first and second memories being replaced with the first and second memory areas that the present invention can be realized by one memory.

If each embodiment described above is implemented by one memory, some steps in the data transfer process described with reference to the transfer phase become unnecessary. Details of each of such cases can be easily expected, and hence a description thereof will be omitted. When the two areas are strictly separated from each other and used, the data transfer process is required as in the case wherein physically two memories are used. If, however, identical data are shared between the two areas, the data transfer process can be omitted, and the storage capacity can also be reduced.

For example, in transferring encoded data held in the second memory area to the first memory area, two kinds of information on the start address at which the encoded data is stored and the data size of the encoded data are transferred from the second memory control unit to the first memory control unit, thereby obtaining the same effects as transferring the encoded data.

If the encoded data is stored in a file or packet form, the amount of information to be transferred between the memory control units slightly increases, and management table information associated with the encoded data must be transferred.

In the above embodiments, encoding is targeted to an 8×8 pixel block size, but this size does not limit the present invention. In short, two encoded data amounts generated for the same image area suffice to be compared using two (or more) different encoding techniques. For example, JPEG encoding can be done for each N×M pixel block, and JPEG-LS can be done for each 2N×2M pixel block. In this case, four JPEG-encoded data and one JPEG-LS encoded data may be compared.

In the third embodiment, isolated losslessly encoded data is conditionally converted into lossily encoded data, which is a desirable form. However, the condition is not essential to the present invention because it has been confirmed that an image with a sufficient image quality is formed even if no condition is made. That is, the process at step S17inFIG. 27may be omitted, like asFIG. 28.

In the embodiments, isolated encoded data has been described on the assumption that the type (lossless or lossy type) of encoded data of one pixel block of interest is different from the type of eight neighboring encoded data. However, this assumption may be expanded to a case wherein encoded data of the same type are consecutive by a count of 1 to N. In this case, N is also determined depending on the read resolution, but remains representing a small area, and is desirably a single-digit number at most.

In the above embodiments, lossy encoding “JPEG” and lossless encoding “JPEG-LS” are adopted as two encoding techniques. These two encoding techniques are different in whether the technique is lossless or lossy. At the same time, JPEG is suitable for natural pictures, JPEG-LS is suitable for character/line images and computer graphics, and these techniques are different in encoding efficiency. The use of two encoding techniques which have different properties in terms of whether the technique is lossless encoding or lossy encoding and is suited to character/line images or natural pictures acts advantageously to the present invention.

In the above embodiments, the present invention is applied to the copying machine shown inFIG. 22. It is apparent that the present invention can also be applied to a case wherein an image input apparatus such as an image scanner is connected to a general-purpose information processing apparatus such as a personal computer to encode data. In this case, a program associated with the process shown inFIG. 23(including the process shown inFIG. 3(orFIG. 9) orFIG. 15) suffices to be executed, and the computer program apparently falls within the scope of the present invention. In general, the computer program can be executed by setting a computer-readable storage medium such as a CD-ROM in a computer, and copying or installing the computer program into the system. As a matter of course, the computer-readable storage medium also falls within the scope of the present invention.

As has been described above, according to the present invention, while lossless and lossy encoding techniques are employed, encoded data of a target data amount can be generated by one image data input operation. In an application of lossy encoding to part or all of an image, a common encoding parameter can be used for the image. Further, generation of block noise can be suppressed.

Since JPEG as lossy encoding and JPEG-LS as lossless encoding are used, encoding suitable for a character/line image or natural picture can be selected without arranging any special area determination circuit. Encoded data high in both image quality and compression ratio upon decoding can be generated.

CLAIM OF PRIORITY

This application claims priority from Japanese Patent Application No. 2004-261570 filed on Sep. 8, 2004, which is hereby incorporated by reference herein.