Patent ID: 7653254

Claim:
An image coding apparatus comprising: at least one processor operatively coupled to a memory, serving as: an input unit that receives attribute information set for each pixel that forms an image and represents an attribute of the pixel; a coding unit that codes the attribute information input by said input unit; a code amount monitoring unit that obtains a total code amount by adding a code amount of coded data of the attribute information coded by the coding unit and a previously obtained code amount; a counting unit that counts the number of pieces of attribute information, in which a bit value of a predetermined bit in a bit string that forms the attribute information is a predetermined value, wherein the counting unit includes: a first counting unit that counts the number of pieces of attribute information, in which the bit value of a first bit in a bit string that forms the attribute information is a value representing a first attribute, and a second counting unit that counts the number of pieces of the attribute information, in which the bit value of the first bit in a bit stream that forms the attribute information is a value representing a second attribute; a change unit that changes, on the basis of a count value, a value of the predetermined bit in the attribute information input by the input unit when the total code amount obtained by the code amount monitoring unit reaches a predetermined amount, the change unit including: a determination unit that, when the total code amount obtained by the code amount monitoring unit reaches the predetermined amount, determines, on the basis of a magnitude relationship between a count value by said first counting unit and a count value by the second counting unit, which of the number of pieces of the attribute information representing the first attribute and the number of pieces of the attribute information representing the second attribute is larger among pieces of the attribute information which have been input by said input unit, and when the number of pieces of the attribute information representing the first attribute is determined to be larger from a determination result by the determination unit, the change unit changes, to the value representing the first attribute, values of first bits in pieces of the attribute information input by the input unit after the total code amount obtained by the code amount monitoring unit reaches the predetermined amount, and when the number of pieces of the attribute information representing the second attribute is determined to be larger, the change unit changes, to the value representing the second attribute, values of first bits in pieces of the attribute information input by the input unit after the total code amount obtained by the code amount monitoring unit reaches the predetermined amount; a coding control unit that causes the coding unit to code the attribute information changed by the change unit; and an output unit that outputs a coding result by the coding unit.