mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-14 06:31:41 +00:00
A JPEG rounds each 8 x 8 block's tone on its own, which leaves a small step at every block edge. Where a dark ground changes slowly, those steps decided which of two palette colors a whole block got, and the trace followed the block edges as a staircase. The new deblock pass finds the block grid in the image: the mean step between neighboring opaque pixels must peak at the same one of eight positions at both block edges of a 16 px span, across and down. Cropped JPEGs and JPEGs saved in another format are found the same way; pictures of flat 8 x 8 cells are not. At each block edge, a stretch of eight lines whose step is under the limit and whose pixels hold no edge has the step spread over the eight pixels around the edge, as the deblocking filters of ITU-T H.263 Annex J and MPEG-4 Part 2 Annex F.3.1 do. Larger steps are kept. The limit, the edge guard and how much of each line's own step is smoothed depend on the mode: Black and White smooths only the smallest steps, and traces of more than 16 colors move every line of a stretch by the same amount. The pass runs before the photo pre-filter and works in strips of rows, so only its output is as large as the image.