1. A method of decoding an image, the method comprising: determining a context model to be used to entropy decode a residual value of a current pixel with reference to at least one pixel value that is decoded before the current pixel; determining an index indicating a residual value group to which the residual value belongs based on the determined context model; determining a context model parameter of the residual value group indicated by the index comprising a parameter indicating the number of pixels included in the residual value group and a parameter for the sum total of the absolute values of the residual value of the pixels included in the residual value group indicated by the index; selecting a code table based on the determined context model parameter of the residual value group indicated by the index; and entropy decoding the residual value according to the selected code table.