1. A method for block-wise encoding still or video images comprising the steps of: a) encoding input image data composed of pixels having original pixel values using a block-wise encoder to obtain encoded image data; b) decoding at least a subset of the encoded image data to obtain a decoded image composed of pixels having decoded image values; c) identifying in the decoded image a plurality of coding block boundaries; d) forming training data comprising a plurality of cross-boundary filter support blocks (CBFSBs), each CBFSB comprising a group of N>1 adjacent pixels of the decoded image including adjacent pixels on both sides of a block boundary; e) generating a set of classification rules based on the training data for classifying each of the CBFSBs into at least one of a plurality of classes, so that each class is adaptively defined by a respective set of the classification rules; f) for each class defined in step (e), generating a set of filter coefficients associated with the class and defining a class-optimized filter that provides a prediction value of a selected CBFSB pixel in dependence upon decoded values of CBFSB pixels based on an original value of the selected CBFSB pixel for each CBFSB in said class; and, g) providing the sets of filter coefficients for each class and the classification rules as an output for subsequent adaptive class-based filtering of the decoded image data for suppressing blocking artefacts.