An apparatus for encoding an image, the apparatus comprising: an intra prediction unit configured to determine an intra prediction mode, to generate reference pixels corresponding to unavailable reference pixels, to adaptively filter the reference pixels according to the intra prediction mode, and to generate a prediction block using the reference pixels determined by the intra prediction mode; a transform unit configured to transform a residual block, which is a residual signal between an original block and the prediction block generated by the intra prediction unit, to generate a transform block; a quantization unit configured to quantize the transform block to generate a quantized block; a scanning unit configured to scan coefficients of the quantized block using a scan pattern determined according to the intra prediction mode; and an entropy coding unit configured to entropy-code the coefficients of the quantized block, wherein the intra prediction unit adaptively filters the reference pixels according to a size of the prediction block for intra prediction modes existing between a horizontal mode and an intra prediction mode having a direction of 45° with respect to the horizontal mode, wherein, when the reference pixels are filtered for a second directional intra prediction mode, the reference pixels are also filtered for a first directional intra prediction mode that is closer to the intra prediction mode having the direction of 45° with respect to the horizontal mode than the second directional intra prediction mode is, wherein the second and the first directional intra prediction modes exist between the horizontal mode and the intra prediction mode having the direction of 45° with respect to the horizontal mode, wherein the number of intra prediction modes in which the filter is applied increases as the size of the prediction block increases, wherein the filter is applied to the intra prediction mode having a direction of 45°with respect to the horizontal mode and is not applied to the horizontal mode and the vertical mode, wherein the scanning unit divides the coefficients of the quantized block into a plurality of sub-blocks if it is determined that a size of a transform block is larger than a predetermined size, wherein the predetermined size is 4x4 or 8x8, wherein the plurality of sub-blocks and the coefficients of each sub-block are scanned according to a scan pattern, wherein the scan pattern for scanning the plurality of sub-blocks and for scanning the coefficients of each sub-block is determined by the intra prediction mode of the prediction block. an intra prediction unit configured to determine an intra prediction mode, to generate reference pixels corresponding to unavailable reference pixels, to adaptively filter the reference pixels according to the intra prediction mode, and to generate a prediction block using the reference pixels determined by the intra prediction mode; a transform unit configured to transform a residual block, which is a residual signal between an original block and the prediction block generated by the intra prediction unit, to generate a transform block; a quantization unit configured to quantize the transform block to generate a quantized block; a scanning unit configured to scan coefficients of the quantized block using a scan pattern determined according to the intra prediction mode; and an entropy coding unit configured to entropy-code the coefficients of the quantized block, wherein the intra prediction unit adaptively filters the reference pixels according to a size of the prediction block for intra prediction modes existing between a horizontal mode and an intra prediction mode having a direction of 45° with respect to the horizontal mode, wherein, when the reference pixels are filtered for a second directional intra prediction mode, the reference pixels are also filtered for a first directional intra prediction mode that is closer to the intra prediction mode having the direction of 45° with respect to the horizontal mode than the second directional intra prediction mode is, wherein the second and the first directional intra prediction modes exist between the horizontal mode and the intra prediction mode having the direction of 45° with respect to the horizontal mode, wherein the number of intra prediction modes in which the filter is applied increases as the size of the prediction block increases, wherein the filter is applied to the intra prediction mode having a direction of 45°with respect to the horizontal mode and is not applied to the horizontal mode and the vertical mode, wherein the scanning unit divides the coefficients of the quantized block into a plurality of sub-blocks if it is determined that a size of a transform block is larger than a predetermined size, wherein the predetermined size is 4x4 or 8x8, wherein the plurality of sub-blocks and the coefficients of each sub-block are scanned according to a scan pattern, wherein the scan pattern for scanning the plurality of sub-blocks and for scanning the coefficients of each sub-block is determined by the intra prediction mode of the prediction block.