This invention is designed to encode the image area information of a multilevel image within a target size without re-inputting the information. For this purpose, from the multilevel image data input from the input unit (101), an image area information generating unit (1701) generates, for each pixel, image area information constituted by an image area component indicating whether the pixel exists in a character line drawing area or halftone area and an image area component indicating whether the pixel is chromatic or achromatic. A lossless encoding unit (1705) encodes this information on a block basis, and stores the resultant information in a third memory (1709). An encoding control unit (1713) monitors an amount of code. Upon determining that the amount of code exceeds a target amount, the encoding control unit causes the lossless encoding unit (1705) to perform encoding upon changing image area components, of subsequently input image area components, which coincide with a condition. The codes that have already been stored in the third memory (1709) are temporarily decoded by a lossless code re-encoding unit (1715), and the above image area components are changed. The resultant data is then re-encoded and stored in the third memory (1709). <IMAGE>
Image processing method and apparatus, computer program, and storage medium