1. A method for encoding a digital image, in which method the digital image is divided into blocks (C, L, U, UL, UR), characterized in that in the method a spatial prediction for a block (C) is performed to reduce the amount of information to be transmitted, wherein at least one prediction method (P1-P13) is defined, a classification is determined for at least one neighbouring block (L, U) of said block (C) to be predicted according to the contents of said neighbouring block (L, U), and a prediction method (P1-P13) is selected for the current block (C) on the basis of at least one said classification.