An image coding apparatus compressing and encoding image data, includes a
frequency converging unit to perform frequency conversion on the image
data; a bit-plane encoding unit to perform bit-plane encoding on
coefficients obtained from the frequency converting unit; and a code
discarding unit to discard codes obtained from the bit-plane encoding
unit until a present code amount becomes a predetermined code amount. The
code discarding unit includes a first discarding unit to perform the
discarding operation on a basis of a first code unit; and a second
discarding unit to further perform the discarding operation on a basis of
a second code unit that is smaller than the first code unit, if
necessary, after the discarding operation on the basis of the first code
unit is performed by the first discarding unit.