A method for encoding an image, the method comprising: generating coefficients by performing transform on a current block; splitting the coefficients into a plurality of coefficient groups based on the current block being a non-square block, wherein the plurality of coefficient groups include a non-square coefficient group; and performing quantization and entropy encoding on the coefficients based on a first scan order and a second scan order, wherein the first scan order represents a scan order among coefficients of the non-square coefficient group, and wherein the second scan order represents a scan order among the plurality of coefficient groups, wherein the first scan order is determined based on a distance value of the coefficients within the non-square coefficient group, the distance value being based on a left upper coefficient of the non-square coefficient group, wherein a scan index is allocated to the coefficients in a coefficient group in order of which the distance value of coefficient increases according to a diagonal scan order, wherein coefficients within the non-square coefficient group are scanned from a lower left side to an upper right side on a scan line having the same distance value, wherein the second scan order is determined based on a distance of the non-square coefficient group within the plurality of coefficient groups, wherein the distance value of coefficient is calculated by summation of a horizontal coordinate increment and a vertical coordinate increment, wherein when the width of the coefficient group is larger than the height, the horizontal coordinate increment is determined as the ratio of width and height, and the vertical coordinate increment is determined as 1, and wherein when the height of the coefficient group is larger than the width, the horizontal coordinate increment is determined as 1, and the vertical coordinate increment is determined as the ratio of height and width. generating coefficients by performing transform on a current block; splitting the coefficients into a plurality of coefficient groups based on the current block being a non-square block, wherein the plurality of coefficient groups include a non-square coefficient group; and performing quantization and entropy encoding on the coefficients based on a first scan order and a second scan order, wherein the first scan order represents a scan order among coefficients of the non-square coefficient group, and wherein the second scan order represents a scan order among the plurality of coefficient groups, wherein the first scan order is determined based on a distance value of the coefficients within the non-square coefficient group, the distance value being based on a left upper coefficient of the non-square coefficient group, wherein a scan index is allocated to the coefficients in a coefficient group in order of which the distance value of coefficient increases according to a diagonal scan order, wherein coefficients within the non-square coefficient group are scanned from a lower left side to an upper right side on a scan line having the same distance value, wherein the second scan order is determined based on a distance of the non-square coefficient group within the plurality of coefficient groups, wherein the distance value of coefficient is calculated by summation of a horizontal coordinate increment and a vertical coordinate increment, wherein when the width of the coefficient group is larger than the height, the horizontal coordinate increment is determined as the ratio of width and height, and the vertical coordinate increment is determined as 1, and wherein when the height of the coefficient group is larger than the width, the horizontal coordinate increment is determined as 1, and the vertical coordinate increment is determined as the ratio of height and width.