Debian Codegraph @

src/filter/select0r/select0r.c

raw symbols SCIP
1 /*
2 select0r.c
3
4 This frei0r plugin makes a color based alpha selection
5 Version 0.4 apr 2012
6
7 Copyright (C) 2010 Marko Cebokli http://lea.hamradio.si/~s57uuu
8
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 */
25
26 // apr 2012 added slope parameter
27
28 //compile: gcc -c -fPIC -Wall select0r.c -o select0r.o
29 //link: gcc -shared -o select0r.so select0r.o
30
31 //#include <stdio.h> /* for debug printf only +/
32 #include <frei0r.h>cxx . . $ `<file>/include/frei0r.h`/
33 #include <stdlib.h>
34 #include <math.h>
35 #include <assert.h>
36
37 typedef structcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#
38 {
39 float rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.;
40 float gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.;
41 float bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.;
42 float acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.;
43 } float_rgbacxx . . $ float_rgba#;
44
45 typedef structcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#
46 {
47 float xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.;
48 float ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.;
49 float zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.;
50 } tripletcxx . . $ triplet#;
51
52 double PIcxx . . $ PI.=3.14159265358979;
53
54 //-----------------------------------------------------------
55 //inline functions for subspace metrics
56 //distance from center point for different shapes
57 //for cartesian and cylindric (wraparound hue) spaces
58 //cx,cy,cz: center of subspace
59 //dx,dy,dz: size of subspace
60 //dx, dy and dz must be inverse (1/x) values! (avoid division)
61 //x,y,z: point from which distance is determined
62 // returns square of distance
63 // r==1 is edge of subspace
64 //box shape
65 static inline float dist_boxcxx . . $ dist_box(8dae299d3b082299).(float cx, float cy, float cz, float dx, float dy, float dz, float x, float y, float z)
66 {
67 float ax,ay,az,r;
68
69 ax=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(x-cx)*dx;
70 ay=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(y-cy)*dy;
71 az=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(z-cz)*dz;
72 r=ax;
73 if (ay>r) r=ay;
74 if (az>r) r=az;
75 r=r*r;
76 return r;
77 }
78 //ellipsoid shape
79 static inline float dist_elicxx . . $ dist_eli(8dae299d3b082299).(float cx, float cy, float cz, float dx, float dy, float dz, float x, float y, float z)
80 {
81 float ax,ay,az,r;
82
83 ax=(x-cx)*dx;
84 ay=(y-cy)*dy;
85 az=(z-cz)*dz;
86 r=ax*ax+ay*ay+az*az;
87 return r;
88 }
89 //octahedron shape
90 static inline float dist_octcxx . . $ dist_oct(8dae299d3b082299).(float cx, float cy, float cz, float dx, float dy, float dz, float x, float y, float z)
91 {
92 float ax,ay,az,r;
93
94 ax=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(x-cx)*dx;
95 ay=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(y-cy)*dy;
96 az=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(z-cz)*dz;
97 r=ax+ay+az;
98 r=r*r;
99 return r;
100 }
101 //box shape, cylindrical space
102 static inline float dist_box_ccxx . . $ dist_box_c(8dae299d3b082299).(float chue, float cy, float cz, float dhue, float dy, float dz, float hue, float y, float z)
103 {
104 float ax,ay,az,r;
105
106 // wrap hue term -0.5 .. 0.5
107 ax = 0.5f - fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(hue - chue) - 0.5f);
108 ax=ax*dhue;
109 ay=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(y-cy)*dy;
110 az=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(z-cz)*dz;
111 r=ax;
112 if (ay>r) r=ay;
113 if (az>r) r=az;
114 r=r*r;
115 return r;
116 }
117 //ellipsoid shape, cylindrical space
118 static inline float dist_eli_ccxx . . $ dist_eli_c(8dae299d3b082299).(float chue, float cy, float cz, float dhue, float dy, float dz, float hue, float y, float z)
119 {
120 float ax,ay,az,r;
121
122 ax = 0.5f - fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(hue - chue) - 0.5f);
123 ax=ax*dhue;
124 ay=(y-cy)*dy;
125 az=(z-cz)*dz;
126 r=ax*ax+ay*ay+az*az;
127 return r;
128 }
129 //octahedron shape, cylindrical space
130 static inline float dist_oct_ccxx . . $ dist_oct_c(8dae299d3b082299).(float chue, float cy, float cz, float dhue, float dy, float dz, float hue, float y, float z)
131 {
132 float ax,ay,az,r;
133
134 ax = 0.5f - fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(hue - chue) - 0.5f);
135 ax=ax*dhue;
136 ay=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(y-cy)*dy;
137 az=fabsfcxx . . $ fabsf(fbcf3211dfe1bfd1).(z-cz)*dz;
138 r=ax+ay+az;
139 r=r*r;
140 return r;
141 }
142
143 //----------------------------------------------------------
144 //inline RGB to ABI conversion function
145 static inline void rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(float k32, float r, float g, float b, float *a, float *bb, float *i)
146 {
147 *a=r-0.5*g-0.5*b;
148 *bb=k32*(g-b);
149 *i=0.3333*(r+g+b);
150 }
151
152 //----------------------------------------------------------
153 //inline RGB to HCI conversion function
154 static inline void rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(float ipi2, float k32, float r, float g, float b, float *h, float *c, float *i)
155 {
156 float a,bb;
157 a=r-0.5*g-0.5*b;
158 bb=k32*(g-b);
159 *h=atan2(bb,a)*ipi2;
160 *c=hypotfcxx . . $ hypotf(d59a45cd3bfd2eda).(a,bb);
161 *i=0.3333*(r+g+b);
162 }
163
164 //------------------------------------------------------
165 //thresholding inline functions (hard and soft)
166 static inline float threscxx . . $ thres(fbcf3211dfe1bfd1).(float a)
167 {
168 return (a<1.0) ? 1.0 : 0.0;
169 }
170
171 static inline float fatcxx . . $ fat(fbcf3211dfe1bfd1).(float a)
172 {
173 a=a*a*a*a;
174 return (a<1.0) ? 1.0-a : 0.0;
175 }
176
177 static inline float normcxx . . $ norm(fbcf3211dfe1bfd1).(float a)
178 {
179 a=a*a;
180 return (a<1.0) ? 1.0-a : 0.0;
181 }
182
183 static inline float skinycxx . . $ skiny(fbcf3211dfe1bfd1).(float a)
184 {
185 return (a<1.0) ? 1.0-a : 0.0;
186 }
187
188 static inline float slopecxx . . $ slope(d59a45cd3bfd2eda).(float a, float is)
189 {
190 a = (a<1.0) ? 1.0 : 1.0-is*(a-1);
191 return (a>=0) ? a : 0.0;
192 }
193
194 //----------------------------------------------------------
195 //RGB selection
196 //d = deltas (size of subspace)
197 //n = nudges
198 //ss = subspace shape [0..2] box, ellipsoid, octahedron
199 //thr: 0=thresholded 1=linear fat 2=lin norm 3=lin skiny
200 //avoids switch () inside inner loop for speed - this means
201 //a big, repetitive switch statement outside....
202 void sel_rgbcxx . . $ sel_rgb(83869001087b96a7).(float_rgbacxx . . $ float_rgba# *slika, int w, int h, float_rgbacxx . . $ float_rgba# key, tripletcxx . . $ triplet# d, tripletcxx . . $ triplet# n, float slp, int ss, int thr)
203 {
204 float kr,kg,kb,dd;
205 int i,s;
206 float ddx,ddy,ddz;
207 float islp;
208
209 //add nudge
210 kr=key.rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.+n.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.;
211 kg=key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.+n.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.;
212 kb=key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.+n.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.;
213 ddx = (d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.!=0) ? 1.0/d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x. : 1.0E6;
214 ddy = (d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.!=0) ? 1.0/d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y. : 1.0E6;
215 ddz = (d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.!=0) ? 1.0/d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z. : 1.0E6;
216
217 islp = (slp>0.000001) ? 0.2/slp : 200000.0;
218
219 s=10*ss+thr; //to avoid nested switch statements
220
221 switch (s)
222 {
223 case 0: //box, thresholded
224 for (i=0;i<w*h;i++)
225 {
226 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
227 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
228 }
229 break;
230 case 1: //box, linear fat
231 for (i=0;i<w*h;i++)
232 {
233 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
234 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
235 }
236 break;
237 case 2: //box, linear normal
238 for (i=0;i<w*h;i++)
239 {
240 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
241 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
242 }
243 break;
244 case 3: //box, linear skiny
245 for (i=0;i<w*h;i++)
246 {
247 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
248 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
249 }
250 break;
251 case 4: //box, linear slope
252 for (i=0;i<w*h;i++)
253 {
254 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
255 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
256 }
257 break;
258
259 case 10: //ellipsoid, thresholded
260 for (i=0;i<w*h;i++)
261 {
262 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
263 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
264 }
265 break;
266 case 11: //ellipsoid, linear fat
267 for (i=0;i<w*h;i++)
268 {
269 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
270 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
271 }
272 break;
273 case 12: //ellipsoid, linear normal
274 for (i=0;i<w*h;i++)
275 {
276 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
277 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
278 }
279 break;
280 case 13: //ellipsoid, linear skiny
281 for (i=0;i<w*h;i++)
282 {
283 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
284 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
285 }
286 break;
287 case 14: //ellipsoid, linear slope
288 for (i=0;i<w*h;i++)
289 {
290 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
291 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
292 }
293 break;
294
295 case 20: //octahedron, thresholded
296 for (i=0;i<w*h;i++)
297 {
298 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
299 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
300 }
301 break;
302 case 21: //octahedron, linear fat
303 for (i=0;i<w*h;i++)
304 {
305 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
306 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
307 }
308 break;
309 case 22: //octahedron, linear normal
310 for (i=0;i<w*h;i++)
311 {
312 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
313 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
314 }
315 break;
316 case 23: //octahedron, linear skiny
317 for (i=0;i<w*h;i++)
318 {
319 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
320 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
321 }
322 break;
323 case 24: //octahedron, linear slope
324 for (i=0;i<w*h;i++)
325 {
326 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(kr, kg, kb, ddx, ddy, ddz, slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r., slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g., slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
327 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
328 }
329 break;
330 default:
331 break;
332 }
333 }
334
335 //----------------------------------------------------------
336 //ABI selection
337 //d = deltas (size of subspace)
338 //n = nudges
339 //ss = subspace shape [0..2] box, ellipsoid, octahedron
340 //thr: 0=thresholded 1=linear fat 2=lin norm 3=lin skiny
341 //avoids switch () inside inner loop for speed - this means
342 //a big, repetitive switch statement outside....
343 void sel_abicxx . . $ sel_abi(83869001087b96a7).(float_rgbacxx . . $ float_rgba# *slika, int w, int h, float_rgbacxx . . $ float_rgba# key, tripletcxx . . $ triplet# d, tripletcxx . . $ triplet# n, float slp, int ss, int thr)
344 {
345 float ka,kb,ki,k32,dd;
346 int i,s;
347 float dda,ddb,ddi,sa,sb,si;
348 float islp;
349
350 dda = (d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.!=0) ? 1.0/d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x. : 1.0E6;
351 ddb = (d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.!=0) ? 1.0/d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y. : 1.0E6;
352 ddi = (d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.!=0) ? 1.0/d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z. : 1.0E6;
353
354 //convert key to ABI and add nudge
355 k32=sqrtfcxx . . $ sqrtf(fbcf3211dfe1bfd1).(3.0)/2.0;
356 ka=key.rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.-0.5*key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.-0.5*key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.+n.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.;
357 kb=k32*(key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.-key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.)+n.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.;
358 ki=0.3333*(key.rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.+key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.+key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.)+n.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.;
359
360 islp = (slp>0.000001) ? 0.2/slp : 200000.0;
361
362 s=10*ss+thr; //to avoid nested switch statements
363
364 switch (s)
365 {
366 case 0: //box, thresholded
367 for (i=0;i<w*h;i++)
368 {
369 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
370 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
371 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
372 }
373 break;
374 case 1: //box, linear fat
375 for (i=0;i<w*h;i++)
376 {
377 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
378 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
379 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
380 }
381 break;
382 case 2: //box, linear normal
383 for (i=0;i<w*h;i++)
384 {
385 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
386 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
387 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
388 }
389 break;
390 case 3: //box, linear skiny
391 for (i=0;i<w*h;i++)
392 {
393 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
394 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
395 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
396 }
397 break;
398 case 4: //box, linear slope
399 for (i=0;i<w*h;i++)
400 {
401 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
402 dd = dist_boxcxx . . $ dist_box(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
403 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
404 }
405 break;
406
407 case 10: //ellipsoid, thresholded
408 for (i=0;i<w*h;i++)
409 {
410 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
411 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
412 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
413 }
414 break;
415 case 11: //ellipsoid, linear fat
416 for (i=0;i<w*h;i++)
417 {
418 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
419 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
420 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
421 }
422 break;
423 case 12: //ellipsoid, linear normal
424 for (i=0;i<w*h;i++)
425 {
426 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
427 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
428 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
429 }
430 break;
431 case 13: //ellipsoid, linear skiny
432 for (i=0;i<w*h;i++)
433 {
434 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
435 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
436 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
437 }
438 break;
439 case 14: //ellipsoid, linear slope
440 for (i=0;i<w*h;i++)
441 {
442 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
443 dd = dist_elicxx . . $ dist_eli(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
444 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
445 }
446 break;
447
448 case 20: //octahedron, thresholded
449 for (i=0;i<w*h;i++)
450 {
451 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
452 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
453 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
454 }
455 break;
456 case 21: //octahedron, linear fat
457 for (i=0;i<w*h;i++)
458 {
459 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
460 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
461 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
462 }
463 break;
464 case 22: //octahedron, linear normal
465 for (i=0;i<w*h;i++)
466 {
467 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
468 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
469 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
470 }
471 break;
472 case 23: //octahedron, linear skiny
473 for (i=0;i<w*h;i++)
474 {
475 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
476 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
477 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
478 }
479 break;
480 case 24: //octahedron, linear slope
481 for (i=0;i<w*h;i++)
482 {
483 rgb2abicxx . . $ rgb2abi(1d2e826c87b679e2).(k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sa,&sb,&si);
484 dd = dist_octcxx . . $ dist_oct(8dae299d3b082299).(ka, kb, ki, dda, ddb, ddi, sa, sb, si);
485 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
486 }
487 break;
488 default:
489 break;
490 }
491 }
492
493 //----------------------------------------------------------
494 //HCI selection
495 //d = deltas (size of subspace)
496 //n = nudges
497 //ss = subspace shape [0..2] box, ellipsoid, octahedron
498 //thr: 0=thresholded 1=linear fat 2=lin norm 3=lin skiny
499 //avoids switch () inside inner loop for speed - this means
500 //a big, repetitive switch statement outside....
501 void sel_hcicxx . . $ sel_hci(83869001087b96a7).(float_rgbacxx . . $ float_rgba# *slika, int w, int h, float_rgbacxx . . $ float_rgba# key, tripletcxx . . $ triplet# d, tripletcxx . . $ triplet# n, float slp, int ss, int thr)
502 {
503 float ka,kb,ki,kh,kc,k32,dd;
504 int i,s;
505 float ddh,ddc,ddi,sh,sc,si,ipi2;
506 float islp;
507
508 ipi2=0.5/PIcxx . . $ PI.;
509 ddh = (d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.!=0) ? 1.0/d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x. : 1.0E6;
510 ddc = (d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.!=0) ? 1.0/d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y. : 1.0E6;
511 ddi = (d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.!=0) ? 1.0/d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z. : 1.0E6;
512
513 //convert key to HCI and add nudge
514 k32=sqrtfcxx . . $ sqrtf(fbcf3211dfe1bfd1).(3.0)/2.0;
515 ka=key.rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.-0.5*key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.-0.5*key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.;
516 kb=k32*(key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.-key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.);
517 ki=0.3333*(key.rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.+key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.+key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.)+n.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.;
518 kh=atan2fcxx . . $ atan2f(d59a45cd3bfd2eda).(kb,ka)*ipi2+n.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.;
519 kc=hypotfcxx . . $ hypotf(d59a45cd3bfd2eda).(ka,kb)+n.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.;
520
521 islp = (slp>0.000001) ? 0.2/slp : 200000.0;
522
523 s=10*ss+thr; //to avoid nested switch statements
524
525 switch (s)
526 {
527 case 0: //box, thresholded
528 for (i=0;i<w*h;i++)
529 {
530 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
531 dd = dist_box_ccxx . . $ dist_box_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
532 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
533 }
534 break;
535 case 1: //box, linear fat
536 for (i=0;i<w*h;i++)
537 {
538 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
539 dd = dist_box_ccxx . . $ dist_box_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
540 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
541 }
542 break;
543 case 2: //box, linear normal
544 for (i=0;i<w*h;i++)
545 {
546 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
547 dd = dist_box_ccxx . . $ dist_box_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
548 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
549 }
550 break;
551 case 3: //box, linear skiny
552 for (i=0;i<w*h;i++)
553 {
554 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
555 dd = dist_box_ccxx . . $ dist_box_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
556 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
557 }
558 break;
559 case 4: //box, linear slope
560 for (i=0;i<w*h;i++)
561 {
562 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
563 dd = dist_box_ccxx . . $ dist_box_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
564 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
565 }
566 break;
567
568 case 10: //ellipsoid, thresholded
569 for (i=0;i<w*h;i++)
570 {
571 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
572 dd = dist_eli_ccxx . . $ dist_eli_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
573 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
574 }
575 break;
576 case 11: //ellipsoid, linear fat
577 for (i=0;i<w*h;i++)
578 {
579 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
580 dd = dist_eli_ccxx . . $ dist_eli_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
581 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
582 }
583 break;
584 case 12: //ellipsoid, linear normal
585 for (i=0;i<w*h;i++)
586 {
587 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
588 dd = dist_eli_ccxx . . $ dist_eli_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
589 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
590 }
591 break;
592 case 13: //ellipsoid, linear skiny
593 for (i=0;i<w*h;i++)
594 {
595 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
596 dd = dist_eli_ccxx . . $ dist_eli_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
597 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
598 }
599 break;
600 case 14: //ellipsoid, linear slope
601 for (i=0;i<w*h;i++)
602 {
603 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
604 dd = dist_eli_ccxx . . $ dist_eli_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
605 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
606 }
607 break;
608
609 case 20: //octahedron, thresholded
610 for (i=0;i<w*h;i++)
611 {
612 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
613 dd = dist_oct_ccxx . . $ dist_oct_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
614 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = threscxx . . $ thres(fbcf3211dfe1bfd1).(dd);
615 }
616 break;
617 case 21: //octahedron, linear fat
618 for (i=0;i<w*h;i++)
619 {
620 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
621 dd = dist_oct_ccxx . . $ dist_oct_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
622 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = fatcxx . . $ fat(fbcf3211dfe1bfd1).(dd);
623 }
624 break;
625 case 22: //octahedron, linear normal
626 for (i=0;i<w*h;i++)
627 {
628 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
629 dd = dist_oct_ccxx . . $ dist_oct_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
630 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = normcxx . . $ norm(fbcf3211dfe1bfd1).(dd);
631 }
632 break;
633 case 23: //octahedron, linear skiny
634 for (i=0;i<w*h;i++)
635 {
636 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
637 dd = dist_oct_ccxx . . $ dist_oct_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
638 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = skinycxx . . $ skiny(fbcf3211dfe1bfd1).(dd);
639 }
640 break;
641 case 24: //octahedron, linear slope
642 for (i=0;i<w*h;i++)
643 {
644 rgb2hcicxx . . $ rgb2hci(499ef8fcb4f68671).(ipi2,k32,slika[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.,slika[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.,slika[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.,&sh,&sc,&si);
645 dd = dist_oct_ccxx . . $ dist_oct_c(8dae299d3b082299).(kh, kc, ki, ddh, ddc, ddi, sh, sc, si);
646 slika[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = slopecxx . . $ slope(d59a45cd3bfd2eda).(dd, islp);
647 }
648 break;
649 default:
650 break;
651 }
652 }
653
654 //----------------------------------------
655 //struktura za instanco efekta
656 typedef structcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#
657 {
658 int hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.;
659 int wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;
660 f0r_param_color_tcxx . . $ f0r_param_color_t# colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col.;
661 int subspcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#subsp.;
662 int sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape.;
663 float del1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del1.,del2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del2.,del3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del3.;
664 float slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp.;
665 float nud1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud1.,nud2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud2.,nud3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud3.;
666 int softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft.;
667 int invcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#inv.;
668 int opcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#op.;
669 } instcxx . . $ inst#;
670
671 //-----------------------------------------------------
672 //stretch [0...1] to parameter range [min...max] linear
673 float map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(double v, float min, float max)
674 {
675 return min+(max-min)*v;
676 }
677
678 //-----------------------------------------------------
679 //collapse from parameter range [min...max] to [0...1] linear
680 double map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(float v, float min, float max)
681 {
682 return (v-min)/(max-min);
683 }
684
685 //***********************************************
686 // OBVEZNE FREI0R FUNKCIJE
687
688 //-----------------------------------------------
689 int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).()
690 {
691 return 1;
692 }
693
694 //------------------------------------------------
695 void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).()
696 {
697 }
698
699 //-----------------------------------------------
700 void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* info)
701 {
702
703 info->namecxx . . $ f0r_plugin_info#name.="select0r";
704 info->authorcxx . . $ f0r_plugin_info#author.="Marko Cebokli";
705 info->plugin_typecxx . . $ f0r_plugin_info#plugin_type.=F0R_PLUGIN_TYPE_FILTERcxx . . $ `include/frei0r.h:247:9`!;
706 info->color_modelcxx . . $ f0r_plugin_info#color_model.=F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!;
707 info->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version.=FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!;
708 info->major_versioncxx . . $ f0r_plugin_info#major_version.=0;
709 info->minor_versioncxx . . $ f0r_plugin_info#minor_version.=6;
710 info->num_paramscxx . . $ f0r_plugin_info#num_params.=10;
711 info->explanationcxx . . $ f0r_plugin_info#explanation.="Color based alpha selection";
712 }
713
714 //--------------------------------------------------
715 void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index)
716 {
717 switch(param_index)
718 {
719 case 0:
720 info->namecxx . . $ f0r_param_info#name. = "Color to select";
721 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_COLORcxx . . $ `include/frei0r.h:389:9`!;
722 info->explanationcxx . . $ f0r_param_info#explanation. = "";
723 break;
724 case 1:
725 info->namecxx . . $ f0r_param_info#name. = "Invert selection";
726 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_BOOLcxx . . $ `include/frei0r.h:377:9`!;
727 info->explanationcxx . . $ f0r_param_info#explanation. = "";
728 break;
729 case 2:
730 info->namecxx . . $ f0r_param_info#name. = "Delta R / A / Hue";
731 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
732 info->explanationcxx . . $ f0r_param_info#explanation. = "";
733 break;
734 case 3:
735 info->namecxx . . $ f0r_param_info#name. = "Delta G / B / Chroma";
736 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
737 info->explanationcxx . . $ f0r_param_info#explanation. = "";
738 break;
739 case 4:
740 info->namecxx . . $ f0r_param_info#name. = "Delta B / I / I";
741 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
742 info->explanationcxx . . $ f0r_param_info#explanation. = "";
743 break;
744 case 5:
745 info->namecxx . . $ f0r_param_info#name. = "Slope";
746 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
747 info->explanationcxx . . $ f0r_param_info#explanation. = "";
748 break;
749 case 6:
750 info->namecxx . . $ f0r_param_info#name. = "Selection subspace";
751 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
752 info->explanationcxx . . $ f0r_param_info#explanation. = "";
753 break;
754 case 7:
755 info->namecxx . . $ f0r_param_info#name. = "Subspace shape";
756 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
757 info->explanationcxx . . $ f0r_param_info#explanation. = "";
758 break;
759 case 8:
760 info->namecxx . . $ f0r_param_info#name. = "Edge mode";
761 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
762 info->explanationcxx . . $ f0r_param_info#explanation. = "";
763 break;
764 case 9:
765 info->namecxx . . $ f0r_param_info#name. = "Operation";
766 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
767 info->explanationcxx . . $ f0r_param_info#explanation. = "";
768 break;
769 }
770 }
771
772 //----------------------------------------------
773 f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height)
774 {
775 instcxx . . $ inst# *in;
776
777 in=calloccxx . . $ calloc(63a7bf2941bfcd7a).(1,sizeof(instcxx . . $ inst#));
778
779 in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.=width;
780 in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.=height;
781
782 in->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..rcxx . . $ f0r_param_color#r.=0.0;
783 in->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..gcxx . . $ f0r_param_color#g.=0.8;
784 in->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..bcxx . . $ f0r_param_color#b.=0.0;
785 in->subspcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#subsp.=0;
786 in->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape.=0;
787 in->del1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del1.=0.2; in->del2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del2.=0.2; in->del3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del3.=0.2;
788 in->nud1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud1.=0.0; in->nud2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud2.=0.0; in->nud3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud3.=0.0;
789 in->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp.=0.0;
790 in->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft.=0;
791 in->invcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#inv.=0;
792 in->opcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#op.=0;
793
794 return (f0r_instance_tcxx . . $ f0r_instance_t#)in;
795 }
796
797 //---------------------------------------------------
798 void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance)
799 {
800 freecxx . . $ free(5d22bdacc48458e8).(instance);
801 }
802
803 //-----------------------------------------------------
804 void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# parm, int param_index)
805 {
806 instcxx . . $ inst# *p;
807 double tmpf;
808 int tmpi,chg;
809 f0r_param_color_tcxx . . $ f0r_param_color_t# tmpc;
810
811 p=(instcxx . . $ inst#*)instance;
812
813 chg=0;
814 switch(param_index)
815 {
816 case 0: //color
817 tmpc=*(f0r_param_color_tcxx . . $ f0r_param_color_t#*)parm;
818 if ((tmpc.rcxx . . $ f0r_param_color#r.!=p->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..rcxx . . $ f0r_param_color#r.) || (tmpc.gcxx . . $ f0r_param_color#g.!=p->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..gcxx . . $ f0r_param_color#g.) || (tmpc.bcxx . . $ f0r_param_color#b.!=p->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..bcxx . . $ f0r_param_color#b.))
819 chg=1;
820 p->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col.=tmpc;
821 break;
822 case 1: //invert
823 tmpi=map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*((double*)parm), 0.0, 1.0); //BOOL!!
824 if (p->invcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#inv. != tmpi) chg=1;
825 p->invcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#inv.=tmpi;
826 break;
827 case 2: //delta 1
828 tmpf=*(double*)parm;
829 if (tmpf!=p->del1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del1.) chg=1;
830 p->del1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del1.=tmpf;
831 break;
832 case 3: //delta 2
833 tmpf=*(double*)parm;
834 if (tmpf!=p->del2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del2.) chg=1;
835 p->del2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del2.=tmpf;
836 break;
837 case 4: //delta 3
838 tmpf=*(double*)parm;
839 if (tmpf!=p->del3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del3.) chg=1;
840 p->del3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del3.=tmpf;
841 break;
842 case 5: //slope 1
843 tmpf=*(double*)parm;
844 if (tmpf!=p->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp.) chg=1;
845 p->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp.=tmpf;
846 break;
847 case 6: //subspace
848 tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*(double*)parm, 0.0, 2.9999); //N-0.0001 if ((tmpi<0)||(tmpi>2.0)) break;
849 if (p->subspcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#subsp. != tmpi) chg=1;
850 p->subspcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#subsp. = tmpi;
851 break;
852 case 7: //shape
853 tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*(double*)parm, 0.0, 2.9999); //N-0.0001 if ((tmpi<0)||(tmpi>2.0)) break;
854 if (p->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape. != tmpi) chg=1;
855 p->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape. = tmpi;
856 break;
857 case 8: //edge mode
858 tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*(double*)parm, 0.0, 4.9999); //N-0.0001 if ((tmpi<0)||(tmpi>2.0)) break;
859 if (p->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft. != tmpi) chg=1;
860 p->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft. = tmpi;
861 break;
862 case 9: //operation
863 tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*(double*)parm, 0.0, 4.9999); //N-0.0001 if ((tmpi<0)||(tmpi>2.0)) break;
864 if (p->opcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#op. != tmpi) chg=1;
865 p->opcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#op. = tmpi;
866 break;
867 }
868
869 if (chg==0) return;
870
871 }
872
873 //--------------------------------------------------
874 void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
875 {
876 instcxx . . $ inst# *p;
877
878 p=(instcxx . . $ inst#*)instance;
879
880 switch(param_index)
881 {
882 case 0:
883 *((f0r_param_color_tcxx . . $ f0r_param_color_t#*)param)=p->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col.;
884 break;
885 case 1:
886 *((double*)param)=map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(p->invcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#inv., 0.0, 1.0);//BOOL!!
887 break;
888 case 2:
889 *((double*)param)=p->del1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del1.;
890 break;
891 case 3:
892 *((double*)param)=p->del2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del2.;
893 break;
894 case 4:
895 *((double*)param)=p->del3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del3.;
896 break;
897 case 5:
898 *((double*)param)=p->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp.;
899 break;
900 case 6:
901 *((double*)param)=map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(p->subspcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#subsp., 0.0, 2.9999);
902 break;
903 case 7:
904 *((double*)param)=map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(p->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape., 0.0, 2.9999);
905 break;
906 case 8:
907 *((double*)param)=map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(p->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft., 0.0, 3.9999);
908 break;
909 case 9:
910 *((double*)param)=map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(p->opcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#op., 0.0, 4.9999);
911 break;
912 }
913 }
914
915 //-------------------------------------------------
916 //RGBA8888 little endian
917 void f0r_updatecxx . . $ f0r_update(96cd7b27f2fca8a7).(f0r_instance_tcxx . . $ f0r_instance_t# instance, double time, const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe)
918 {
919 instcxx . . $ inst# *in;
920 float_rgbacxx . . $ float_rgba# key;
921 tripletcxx . . $ triplet# d,n;
922 int i;
923 uint32_tcxx . . $ uint32_t# t;
924 uint8_tcxx . . $ uint8_t# *cin, *cout;
925 float f1=1.0/256.0;
926 uint8_tcxx . . $ uint8_t# a1,a2;
927 float_rgbacxx . . $ float_rgba# *sl;
928
929 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance);
930 in=(instcxx . . $ inst#*)instance;
931
932 key.rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.=in->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..rcxx . . $ f0r_param_color#r.;
933 key.gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.=in->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..gcxx . . $ f0r_param_color#g.;
934 key.bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.=in->colcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#col..bcxx . . $ f0r_param_color#b.;
935 key.acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.=1.0;
936 d.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.=in->del1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del1.;
937 d.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.=in->del2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del2.;
938 d.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.=in->del3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#del3.;
939 n.xcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#x.=in->nud1cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud1.;
940 n.ycxx . . $ $anonymous_type_cf1033e6a3ed8766_1#y.=in->nud2cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud2.;
941 n.zcxx . . $ $anonymous_type_cf1033e6a3ed8766_1#z.=in->nud3cxx . . $ $anonymous_type_cf1033e6a3ed8766_2#nud3.;
942
943 //convert to float
944 sl = calloccxx . . $ calloc(63a7bf2941bfcd7a).(in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w. * in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h., sizeof(float_rgbacxx . . $ float_rgba#));
945 cin=(uint8_tcxx . . $ uint8_t# *)inframe;
946 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
947 {
948 sl[i].rcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#r.=f1*(float)*cin++;
949 sl[i].gcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#g.=f1*(float)*cin++;
950 sl[i].bcxx . . $ $anonymous_type_cf1033e6a3ed8766_0#b.=f1*(float)*cin++;
951 cin++;
952 }
953
954 //make the selection
955 switch (in->subspcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#subsp.)
956 {
957 case 0:
958 sel_rgbcxx . . $ sel_rgb(83869001087b96a7).(sl, in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w., in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h., key, d, n, in->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp., in->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape., in->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft.);
959 break;
960 case 1:
961 sel_abicxx . . $ sel_abi(83869001087b96a7).(sl, in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w., in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h., key, d, n, in->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp., in->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape., in->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft.);
962 break;
963 case 2:
964 sel_hcicxx . . $ sel_hci(83869001087b96a7).(sl, in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w., in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h., key, d, n, in->slpcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#slp., in->sshapecxx . . $ $anonymous_type_cf1033e6a3ed8766_2#sshape., in->softcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#soft.);
965 break;
966 default:
967 break;
968 }
969
970 //invert selection if required
971 if (in->invcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#inv.==1)
972 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
973 sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a. = 1.0 - sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.;
974
975 //apply alpha
976 cin=(uint8_tcxx . . $ uint8_t# *)inframe;
977 cout=(uint8_tcxx . . $ uint8_t# *)outframe;
978 switch (in->opcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#op.)
979 {
980 case 0: //write on clear
981 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
982 {
983 *cout++ = *cin++; //copy R
984 *cout++ = *cin++; //copy G
985 *cout++ = *cin++; //copy B
986 *cout++ = (uint8_tcxx . . $ uint8_t#)(sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.*255.0);
987 cin++;
988 }
989 break;
990 case 1: //max
991 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
992 {
993 *cout++ = *cin++; //copy R
994 *cout++ = *cin++; //copy G
995 *cout++ = *cin++; //copy B
996 a1 = *cin++;
997 a2 = (uint8_tcxx . . $ uint8_t#)(sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.*255.0);
998 *cout++ = (a1>a2) ? a1 : a2;
999 }
1000 break;
1001 case 2: //min
1002 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
1003 {
1004 *cout++ = *cin++; //copy R
1005 *cout++ = *cin++; //copy G
1006 *cout++ = *cin++; //copy B
1007 a1 = *cin++;
1008 a2 = (uint8_tcxx . . $ uint8_t#)(sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.*255.0);
1009 *cout++ = (a1<a2) ? a1 : a2;
1010 }
1011 break;
1012 case 3: //add
1013 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
1014 {
1015 *cout++ = *cin++; //copy R
1016 *cout++ = *cin++; //copy G
1017 *cout++ = *cin++; //copy B
1018 a1 = *cin++;
1019 a2 = (uint8_tcxx . . $ uint8_t#)(sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.*255.0);
1020 t=(uint32_tcxx . . $ uint32_t#)a1+(uint32_tcxx . . $ uint32_t#)a2;
1021 *cout++ = (t<=255) ? (uint8_tcxx . . $ uint8_t#)t : 255;
1022 }
1023 break;
1024 case 4: //subtract
1025 for (i=0;i<in->hcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#h.*in->wcxx . . $ $anonymous_type_cf1033e6a3ed8766_2#w.;i++)
1026 {
1027 *cout++ = *cin++; //copy R
1028 *cout++ = *cin++; //copy G
1029 *cout++ = *cin++; //copy B
1030 a1 = *cin++;
1031 a2 = (uint8_tcxx . . $ uint8_t#)(sl[i].acxx . . $ $anonymous_type_cf1033e6a3ed8766_0#a.*255.0);
1032 *cout++ = (a1>a2) ? a1-a2 : 0;
1033 }
1034 break;
1035 default:
1036 break;
1037 }
1038 freecxx . . $ free(5d22bdacc48458e8).(sl);
1039 }
1040
1041 //**********************************************************