There is a unit (12, 13) for extracting a first selected pixel for a number of peripheral pixels relative to the pixel to be coded and a second selected pixel for a number of peripheral pixels relative to the first selected pixel. There is a unit (16) for counting similar pizels, a unit (17) for producing a context from the output of the counting unit and the first selected pixel, and an arithmetical counting scheme (18) for producing coding information from the context and finally coded data.