1. A method for encoding an intra prediction mode of an image, the method comprising: detecting a similarity of a prediction direction of a neighbor block with respect to a current block based on a position of the neighbor block and an intra prediction direction of the neighbor block with respect to the current block; and determining a candidate prediction mode of the current block based on the similarity and the number of candidate intra prediction modes (N), wherein the detecting of the similarity comprises detecting the similarity of the prediction direction of the neighbor block with respect to the current block based on a width of an overlapping area with the current block when extending the neighbor block along the intra prediction direction of the neighbor block from the position of the neighbor block.