Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6581 | leency | 1 | -- Apply a kind of AA filter on picture |
2 | |||
3 | -- Get the picture size |
||
4 | w, h = getpicturesize(); |
||
5 | |||
6 | -- Here is the filtering matrix |
||
7 | matrix = { |
||
8 | { 0, -1, 0 }, |
||
9 | { -1, 5, -1 }, |
||
10 | { 0, -1, 0 }}; |
||
11 | |||
12 | -- Loop trough all the pixels |
||
13 | -- To make this script simpler we don't handle the picture borders |
||
14 | -- (the matrix would get pixels outside the picture space) |
||
15 | -- for var = start_value, end_value, step do ... |
||
16 | for y = 1, h - 2, 1 do |
||
17 | for x = 1, w - 2, 1 do |
||
18 | filtered = |
||
19 | matrix[1][1] * getbackuppixel(x - 1, y - 1) + |
||
20 | matrix[1][2] * getbackuppixel(x , y - 1) + |
||
21 | matrix[1][3] * getbackuppixel(x + 1, y - 1) + |
||
22 | matrix[2][1] * getbackuppixel(x - 1, y ) + |
||
23 | matrix[2][2] * getbackuppixel(x , y ) + |
||
24 | matrix[2][3] * getbackuppixel(x + 1, y ) + |
||
25 | matrix[3][1] * getbackuppixel(x - 1, y + 1) + |
||
26 | matrix[3][2] * getbackuppixel(x , y + 1) + |
||
27 | matrix[3][3] * getbackuppixel(x + 1, y + 1); |
||
28 | putpicturepixel(x,y,filtered); |
||
29 | end |
||
30 | end |