ZX News #03
28 февраля 1997 |
|
Smoothing Images - An algorithm of smoothing of static images.
(C) 1997 Serge Segal Dithering algorithm for image. In this article we'll discuss smoothing algorithms for static optical images. First We will understand why this is necessary, but you can then have to disassemble itself process. So, why is it necessary? Everyone who has seen the program "EXTACY MD" Groups "RUSH", remember the part where rotates the inscription "XTC". Since it is rotates rapidly, imperceptibly, that the lines components of its look, to put it mildly, not a pretty sight, somehow zubtsevato. The thing that used a 3D-image editor that does not smooth out lines. Now all the editors for 3D-graphics on powerful machines do it. For this purpose a specially modified algorithm Drawing lines and circles. This is what we describe in the next issues of our magazine, and now, about how this problem can be solved without changing the code editor. You can write your own algorithm which automatically flatten the line. The second application of smoothing - correction of enlarged bitmaps. The problem of angularity Pictures come across anyone who has worked in the editor "Art Studio" with the increase, especially with the disproportionate. Such an enlarged picture should also be smooth. As all seems to work, this algorithm In the old tradition we do not consider the complex and maloprimenimye for "ZX-Spectrum" algorithms. So intelligent smoothing processes one Zoom in about an hour. The effect, of course ... But here's the performance like something is pulling ... So I came up with a different algorithm smooth, easy-to idiocy, but At the same time, working quickly and giving reasonable effect. Algorithm consists of two parts: smoothing lines (For vector images) and smoothing the corners (to enlarge An image). Run both algorithms on the same principle: scanning the screen in search of template and replace the template on the more beautiful. As can be seen, for the first algorithm, we find => Tooth and replace it with square or corner. What will change, according to | | Shows variable DOU BLE, if 0 - then the tooth otherwise the square. Recommendation through each for increased every mappings square, and for vector - a nook. Second pass - smoothing angles works with the matrix 3 for 3. Similar to the first, This algorithm is replaced preserves angles in a triangle => Lnye teeth. No complexity in this No, the main thing - the right correctly remove the matrix and the right to return it in place. Also had to introduce forced inversion for some pictures for a while smoothing (variable INVERT). After the end of the smoothing, the image returns to the non-inverted state. In addition to these there are two variables of process control: FIRST and SECOND, enabling / disabling the first and second algorithms. And of course the coordinates of the window, which smooths out: X1, Y1, X2, Y2. Attached you will find: - SGLAV1.Z, SGLAV2.Z two source File algorithms with comments - SGLAV2 code file ready to Uses - SGL.EXMP example of using - $ BASHK1 picture - an example. All right, maybe enough for today. In further rooms, we might (!) continued the theme of perversion of the pictures. ____________________________________
Other articles:
Similar articles:
В этот день... 23 November