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; and an entropy coding unit configured to entropy-code the quantized block, wherein 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 filter is applied to the intra prediction mode having the direction of 45° with respect to the horizontal mode and is not applied to the horizontal mode and a vertical 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 intra prediction unit does not filter the reference pixels of the prediction block which is smaller than a predetermined size. 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; and an entropy coding unit configured to entropy-code the quantized block, wherein 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 filter is applied to the intra prediction mode having the direction of 45° with respect to the horizontal mode and is not applied to the horizontal mode and a vertical 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 intra prediction unit does not filter the reference pixels of the prediction block which is smaller than a predetermined size.