In a method for compressing an image, a number of non-zero AC coefficients
for a component transform and the locations of the non-zero AC
coefficients in a transform block are determined. One of a plurality of
coding modes is selected in response to the number of non-zero AC
coefficients and the locations of the non-zero AC coefficients satisfying
predetermined criteria, where the plurality of coding modes comprise
different bit allocations from each other. In addition, the locations and
values of the non-zero AC coefficients and a DC coefficient for the
component transform are coded according to the selected coding mode, to
thereby compress the image.