1. A method of transforming an image, the method comprising: generating a substituted N×N transformation matrix by substituting elements of an N×N transformation matrix used for a 1-dimensional (1D) discrete cosine transform (DCT) of a N×N block of the image with values based on N variables, where N is an integer; obtaining a multiplication matrix of the substituted N×N transformation matrix and a transposed matrix of the substituted N×N transformation matrix; obtaining the N variables that enable a sum of squares of elements excluding diagonal components of the obtained multiplication matrix to be a minimum; and transforming the N×N block by using the substituted N×N transformation matrix, which is substituted with the values based on the obtained N variables.