29d985ce65976ff140072d8346e47fa5ad3f57ca
[Faustine.git] / dsp_files / opening.dsp
1 import("mrfaustlib/fft.lib");
2 import("fft2d.dsp");
3
4 DILATION_MIN = 0;
5 EROSION_MAX = 255;
6
7 strel_shift_dilation = DILATION_MIN : vectorize(1);
8 strel_shift_erosion = EROSION_MAX : vectorize(1);
9
10 spray_by_three(n) = _ <: par(i, n, ([i], [i+1], [i+2]));
11
12 tri_max = max, _ : max;
13 tri_maxs(n) = par(i, n, tri_max);
14 tri_min = min, _ : min;
15 tri_mins(n) = par(i, n, tri_min);
16
17 dilating(n) = strel_shift_dilation, _, strel_shift_dilation : #, _ : # : spray_by_three(n) : tri_maxs(n) : nconcat(n);
18
19 eroding(n) = strel_shift_erosion, _, strel_shift_erosion : #, _ : # : spray_by_three(n) : tri_mins(n) : nconcat(n);
20
21 //dilation(size, iter) = seq(i, iter, dilating(size));
22 //erosion(size, iter) = seq(i, iter, eroding(size));
23
24 dilation_square(x, y) = _ : vectorize(y) : serialize : dilating(x) : vectorize(y) : matrix_transpose(y, x) : serialize : dilating(y) : vectorize(x) : matrix_transpose(x, y) : serialize;
25
26 dilations(x, y, iter) = seq(i, iter, dilation_square(x,y));
27
28 erosion_square(x, y) = _ : vectorize(y) : serialize : eroding(x) : vectorize(y) : matrix_transpose(y, x) : serialize : eroding(y) : vectorize(x) : matrix_transpose(x, y) : serialize;
29
30 erosions(x, y, iter) = seq(i, iter, erosion_square(x,y));
31
32 open(x, y, iter) = erosions(x, y, iter) : dilations(x, y, iter);
33 close(x, y, iter) = dilations(x, y, iter) : erosions(x, y, iter);
34
35 process = dilation(112, 3);
36 //process = erosion(119, 10);
37 //process = opening(119, 10);
38 //process = close(119, 123, 1);
39
40