3 ms·
Can you expand on the one pass algorithm, or provide a link? There was a two pass variant at the end of the paper, but I didn't see any explicit one pass varian
by jwmerrill 13y ago
Can you expand on the one pass algorithm, or provide a link? There was a two pass variant at the end of the paper, but I didn't see any explicit one pass variant.
- deletes 13y agoThe single pass is the first algorithm mentioned in the article that produces "holes". You have to split the operations to avoid them and thus make more passes.
- pwg 13y agoThe first algorithm mentioned in the article is not a one-pass Paeth algorithm. The first algorithm in the article is a pure trigonometry algorithm. A one pass Paeth algorithm produces identical results to the typical three pass implementation, because there is only one round of trigonometry up front, so there is only one round of round-off. Once the shear amounts are calculated, the rest is just integer pixel shears.
- pwg 13y agoThe solution to making a one pass algorithm from the paper is to realize that each pixel moves a fixed amount. First it moves horizontally, then vertically, then horizontally, to arrive at its final location. The way the algorithm works, for each pixel, the amount of shear horizontally and vertically can be calculated up front, before "moving" the pixel. So to make a one pass algorithm, allocate a second image of sufficient size to hold the rotated original (the size of this second image can also be calculated before any pixel "movement"). Then, for each pixel, calculate its horizontal shift, followed by its vertical shift, followed by its final horizontal shift. You now have its destination coordinates, so store it into the second image buffer at the destination coordinates. The algorithm becomes essentially: foreach pixel source_coord do dest_coord = transform(source_coord) dest_image(dest_coord) = source_image(source_coord) done where transform() performs the Horiz/Vert/Horz transformation of the input coordinate.