]>
Commit | Line | Data |
---|---|---|
1 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
2 | } | |
3 | typedef long int ptrdiff_t; | |
4 | typedef long unsigned int size_t; | |
5 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
6 | using ::ptrdiff_t; | |
7 | using ::size_t; | |
8 | } | |
9 | extern "C" { | |
10 | typedef unsigned char __u_char; | |
11 | typedef unsigned short int __u_short; | |
12 | typedef unsigned int __u_int; | |
13 | typedef unsigned long int __u_long; | |
14 | typedef signed char __int8_t; | |
15 | typedef unsigned char __uint8_t; | |
16 | typedef signed short int __int16_t; | |
17 | typedef unsigned short int __uint16_t; | |
18 | typedef signed int __int32_t; | |
19 | typedef unsigned int __uint32_t; | |
20 | typedef signed long int __int64_t; | |
21 | typedef unsigned long int __uint64_t; | |
22 | typedef long int __quad_t; | |
23 | typedef unsigned long int __u_quad_t; | |
24 | typedef unsigned long int __dev_t; | |
25 | typedef unsigned int __uid_t; | |
26 | typedef unsigned int __gid_t; | |
27 | typedef unsigned long int __ino_t; | |
28 | typedef unsigned long int __ino64_t; | |
29 | typedef unsigned int __mode_t; | |
30 | typedef unsigned long int __nlink_t; | |
31 | typedef long int __off_t; | |
32 | typedef long int __off64_t; | |
33 | typedef int __pid_t; | |
34 | typedef struct { int __val[2]; } __fsid_t; | |
35 | typedef long int __clock_t; | |
36 | typedef unsigned long int __rlim_t; | |
37 | typedef unsigned long int __rlim64_t; | |
38 | typedef unsigned int __id_t; | |
39 | typedef long int __time_t; | |
40 | typedef unsigned int __useconds_t; | |
41 | typedef long int __suseconds_t; | |
42 | typedef int __daddr_t; | |
43 | typedef long int __swblk_t; | |
44 | typedef int __key_t; | |
45 | typedef int __clockid_t; | |
46 | typedef void * __timer_t; | |
47 | typedef long int __blksize_t; | |
48 | typedef long int __blkcnt_t; | |
49 | typedef long int __blkcnt64_t; | |
50 | typedef unsigned long int __fsblkcnt_t; | |
51 | typedef unsigned long int __fsblkcnt64_t; | |
52 | typedef unsigned long int __fsfilcnt_t; | |
53 | typedef unsigned long int __fsfilcnt64_t; | |
54 | typedef long int __ssize_t; | |
55 | typedef __off64_t __loff_t; | |
56 | typedef __quad_t *__qaddr_t; | |
57 | typedef char *__caddr_t; | |
58 | typedef long int __intptr_t; | |
59 | typedef unsigned int __socklen_t; | |
60 | struct _IO_FILE; | |
61 | typedef struct _IO_FILE FILE; | |
62 | typedef struct _IO_FILE __FILE; | |
63 | typedef struct | |
64 | { | |
65 | int __count; | |
66 | union | |
67 | { | |
68 | unsigned int __wch; | |
69 | char __wchb[4]; | |
70 | } __value; | |
71 | } __mbstate_t; | |
72 | typedef struct | |
73 | { | |
74 | __off_t __pos; | |
75 | __mbstate_t __state; | |
76 | } _G_fpos_t; | |
77 | typedef struct | |
78 | { | |
79 | __off64_t __pos; | |
80 | __mbstate_t __state; | |
81 | } _G_fpos64_t; | |
82 | typedef int _G_int16_t __attribute__ ((__mode__ (__HI__))); | |
83 | typedef int _G_int32_t __attribute__ ((__mode__ (__SI__))); | |
84 | typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__))); | |
85 | typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__))); | |
86 | typedef __builtin_va_list __gnuc_va_list; | |
87 | struct _IO_jump_t; struct _IO_FILE; | |
88 | typedef void _IO_lock_t; | |
89 | struct _IO_marker { | |
90 | struct _IO_marker *_next; | |
91 | struct _IO_FILE *_sbuf; | |
92 | int _pos; | |
93 | }; | |
94 | enum __codecvt_result | |
95 | { | |
96 | __codecvt_ok, | |
97 | __codecvt_partial, | |
98 | __codecvt_error, | |
99 | __codecvt_noconv | |
100 | }; | |
101 | struct _IO_FILE { | |
102 | int _flags; | |
103 | char* _IO_read_ptr; | |
104 | char* _IO_read_end; | |
105 | char* _IO_read_base; | |
106 | char* _IO_write_base; | |
107 | char* _IO_write_ptr; | |
108 | char* _IO_write_end; | |
109 | char* _IO_buf_base; | |
110 | char* _IO_buf_end; | |
111 | char *_IO_save_base; | |
112 | char *_IO_backup_base; | |
113 | char *_IO_save_end; | |
114 | struct _IO_marker *_markers; | |
115 | struct _IO_FILE *_chain; | |
116 | int _fileno; | |
117 | int _flags2; | |
118 | __off_t _old_offset; | |
119 | unsigned short _cur_column; | |
120 | signed char _vtable_offset; | |
121 | char _shortbuf[1]; | |
122 | _IO_lock_t *_lock; | |
123 | __off64_t _offset; | |
124 | void *__pad1; | |
125 | void *__pad2; | |
126 | void *__pad3; | |
127 | void *__pad4; | |
128 | size_t __pad5; | |
129 | int _mode; | |
130 | char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; | |
131 | }; | |
132 | struct _IO_FILE_plus; | |
133 | extern struct _IO_FILE_plus _IO_2_1_stdin_; | |
134 | extern struct _IO_FILE_plus _IO_2_1_stdout_; | |
135 | extern struct _IO_FILE_plus _IO_2_1_stderr_; | |
136 | typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); | |
137 | typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf, | |
138 | size_t __n); | |
139 | typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w); | |
140 | typedef int __io_close_fn (void *__cookie); | |
141 | typedef __io_read_fn cookie_read_function_t; | |
142 | typedef __io_write_fn cookie_write_function_t; | |
143 | typedef __io_seek_fn cookie_seek_function_t; | |
144 | typedef __io_close_fn cookie_close_function_t; | |
145 | typedef struct | |
146 | { | |
147 | __io_read_fn *read; | |
148 | __io_write_fn *write; | |
149 | __io_seek_fn *seek; | |
150 | __io_close_fn *close; | |
151 | } _IO_cookie_io_functions_t; | |
152 | typedef _IO_cookie_io_functions_t cookie_io_functions_t; | |
153 | struct _IO_cookie_file; | |
154 | extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, | |
155 | void *__cookie, _IO_cookie_io_functions_t __fns); | |
156 | extern "C" { | |
157 | extern int __underflow (_IO_FILE *); | |
158 | extern int __uflow (_IO_FILE *); | |
159 | extern int __overflow (_IO_FILE *, int); | |
160 | extern int _IO_getc (_IO_FILE *__fp); | |
161 | extern int _IO_putc (int __c, _IO_FILE *__fp); | |
162 | extern int _IO_feof (_IO_FILE *__fp) throw (); | |
163 | extern int _IO_ferror (_IO_FILE *__fp) throw (); | |
164 | extern int _IO_peekc_locked (_IO_FILE *__fp); | |
165 | extern void _IO_flockfile (_IO_FILE *) throw (); | |
166 | extern void _IO_funlockfile (_IO_FILE *) throw (); | |
167 | extern int _IO_ftrylockfile (_IO_FILE *) throw (); | |
168 | extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, | |
169 | __gnuc_va_list, int *__restrict); | |
170 | extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, | |
171 | __gnuc_va_list); | |
172 | extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t); | |
173 | extern size_t _IO_sgetn (_IO_FILE *, void *, size_t); | |
174 | extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int); | |
175 | extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int); | |
176 | extern void _IO_free_backup_area (_IO_FILE *) throw (); | |
177 | } | |
178 | typedef __gnuc_va_list va_list; | |
179 | typedef _G_fpos_t fpos_t; | |
180 | typedef _G_fpos64_t fpos64_t; | |
181 | extern struct _IO_FILE *stdin; | |
182 | extern struct _IO_FILE *stdout; | |
183 | extern struct _IO_FILE *stderr; | |
184 | extern int remove (__const char *__filename) throw (); | |
185 | extern int rename (__const char *__old, __const char *__new) throw (); | |
186 | extern int renameat (int __oldfd, __const char *__old, int __newfd, | |
187 | __const char *__new) throw (); | |
188 | extern FILE *tmpfile (void) ; | |
189 | extern FILE *tmpfile64 (void) ; | |
190 | extern char *tmpnam (char *__s) throw () ; | |
191 | extern char *tmpnam_r (char *__s) throw () ; | |
192 | extern char *tempnam (__const char *__dir, __const char *__pfx) | |
193 | throw () __attribute__ ((__malloc__)) ; | |
194 | extern int fclose (FILE *__stream); | |
195 | extern int fflush (FILE *__stream); | |
196 | extern int fflush_unlocked (FILE *__stream); | |
197 | extern int fcloseall (void); | |
198 | extern FILE *fopen (__const char *__restrict __filename, | |
199 | __const char *__restrict __modes) ; | |
200 | extern FILE *freopen (__const char *__restrict __filename, | |
201 | __const char *__restrict __modes, | |
202 | FILE *__restrict __stream) ; | |
203 | extern FILE *fopen64 (__const char *__restrict __filename, | |
204 | __const char *__restrict __modes) ; | |
205 | extern FILE *freopen64 (__const char *__restrict __filename, | |
206 | __const char *__restrict __modes, | |
207 | FILE *__restrict __stream) ; | |
208 | extern FILE *fdopen (int __fd, __const char *__modes) throw () ; | |
209 | extern FILE *fopencookie (void *__restrict __magic_cookie, | |
210 | __const char *__restrict __modes, | |
211 | _IO_cookie_io_functions_t __io_funcs) throw () ; | |
212 | extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) | |
213 | throw () ; | |
214 | extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) throw () ; | |
215 | extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) throw (); | |
216 | extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, | |
217 | int __modes, size_t __n) throw (); | |
218 | extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, | |
219 | size_t __size) throw (); | |
220 | extern void setlinebuf (FILE *__stream) throw (); | |
221 | extern int fprintf (FILE *__restrict __stream, | |
222 | __const char *__restrict __format, ...); | |
223 | extern int printf (__const char *__restrict __format, ...); | |
224 | extern int sprintf (char *__restrict __s, | |
225 | __const char *__restrict __format, ...) throw (); | |
226 | extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format, | |
227 | __gnuc_va_list __arg); | |
228 | extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg); | |
229 | extern int vsprintf (char *__restrict __s, __const char *__restrict __format, | |
230 | __gnuc_va_list __arg) throw (); | |
231 | extern int snprintf (char *__restrict __s, size_t __maxlen, | |
232 | __const char *__restrict __format, ...) | |
233 | throw () __attribute__ ((__format__ (__printf__, 3, 4))); | |
234 | extern int vsnprintf (char *__restrict __s, size_t __maxlen, | |
235 | __const char *__restrict __format, __gnuc_va_list __arg) | |
236 | throw () __attribute__ ((__format__ (__printf__, 3, 0))); | |
237 | extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f, | |
238 | __gnuc_va_list __arg) | |
239 | throw () __attribute__ ((__format__ (__printf__, 2, 0))) ; | |
240 | extern int __asprintf (char **__restrict __ptr, | |
241 | __const char *__restrict __fmt, ...) | |
242 | throw () __attribute__ ((__format__ (__printf__, 2, 3))) ; | |
243 | extern int asprintf (char **__restrict __ptr, | |
244 | __const char *__restrict __fmt, ...) | |
245 | throw () __attribute__ ((__format__ (__printf__, 2, 3))) ; | |
246 | extern int vdprintf (int __fd, __const char *__restrict __fmt, | |
247 | __gnuc_va_list __arg) | |
248 | __attribute__ ((__format__ (__printf__, 2, 0))); | |
249 | extern int dprintf (int __fd, __const char *__restrict __fmt, ...) | |
250 | __attribute__ ((__format__ (__printf__, 2, 3))); | |
251 | extern int fscanf (FILE *__restrict __stream, | |
252 | __const char *__restrict __format, ...) ; | |
253 | extern int scanf (__const char *__restrict __format, ...) ; | |
254 | extern int sscanf (__const char *__restrict __s, | |
255 | __const char *__restrict __format, ...) throw (); | |
256 | extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format, | |
257 | __gnuc_va_list __arg) | |
258 | __attribute__ ((__format__ (__scanf__, 2, 0))) ; | |
259 | extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg) | |
260 | __attribute__ ((__format__ (__scanf__, 1, 0))) ; | |
261 | extern int vsscanf (__const char *__restrict __s, | |
262 | __const char *__restrict __format, __gnuc_va_list __arg) | |
263 | throw () __attribute__ ((__format__ (__scanf__, 2, 0))); | |
264 | extern int fgetc (FILE *__stream); | |
265 | extern int getc (FILE *__stream); | |
266 | extern int getchar (void); | |
267 | extern int getc_unlocked (FILE *__stream); | |
268 | extern int getchar_unlocked (void); | |
269 | extern int fgetc_unlocked (FILE *__stream); | |
270 | extern int fputc (int __c, FILE *__stream); | |
271 | extern int putc (int __c, FILE *__stream); | |
272 | extern int putchar (int __c); | |
273 | extern int fputc_unlocked (int __c, FILE *__stream); | |
274 | extern int putc_unlocked (int __c, FILE *__stream); | |
275 | extern int putchar_unlocked (int __c); | |
276 | extern int getw (FILE *__stream); | |
277 | extern int putw (int __w, FILE *__stream); | |
278 | extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) | |
279 | ; | |
280 | extern char *gets (char *__s) ; | |
281 | extern char *fgets_unlocked (char *__restrict __s, int __n, | |
282 | FILE *__restrict __stream) ; | |
283 | extern __ssize_t __getdelim (char **__restrict __lineptr, | |
284 | size_t *__restrict __n, int __delimiter, | |
285 | FILE *__restrict __stream) ; | |
286 | extern __ssize_t getdelim (char **__restrict __lineptr, | |
287 | size_t *__restrict __n, int __delimiter, | |
288 | FILE *__restrict __stream) ; | |
289 | extern __ssize_t getline (char **__restrict __lineptr, | |
290 | size_t *__restrict __n, | |
291 | FILE *__restrict __stream) ; | |
292 | extern int fputs (__const char *__restrict __s, FILE *__restrict __stream); | |
293 | extern int puts (__const char *__s); | |
294 | extern int ungetc (int __c, FILE *__stream); | |
295 | extern size_t fread (void *__restrict __ptr, size_t __size, | |
296 | size_t __n, FILE *__restrict __stream) ; | |
297 | extern size_t fwrite (__const void *__restrict __ptr, size_t __size, | |
298 | size_t __n, FILE *__restrict __s) ; | |
299 | extern int fputs_unlocked (__const char *__restrict __s, | |
300 | FILE *__restrict __stream); | |
301 | extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, | |
302 | size_t __n, FILE *__restrict __stream) ; | |
303 | extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size, | |
304 | size_t __n, FILE *__restrict __stream) ; | |
305 | extern int fseek (FILE *__stream, long int __off, int __whence); | |
306 | extern long int ftell (FILE *__stream) ; | |
307 | extern void rewind (FILE *__stream); | |
308 | extern int fseeko (FILE *__stream, __off_t __off, int __whence); | |
309 | extern __off_t ftello (FILE *__stream) ; | |
310 | extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); | |
311 | extern int fsetpos (FILE *__stream, __const fpos_t *__pos); | |
312 | extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); | |
313 | extern __off64_t ftello64 (FILE *__stream) ; | |
314 | extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); | |
315 | extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos); | |
316 | extern void clearerr (FILE *__stream) throw (); | |
317 | extern int feof (FILE *__stream) throw () ; | |
318 | extern int ferror (FILE *__stream) throw () ; | |
319 | extern void clearerr_unlocked (FILE *__stream) throw (); | |
320 | extern int feof_unlocked (FILE *__stream) throw () ; | |
321 | extern int ferror_unlocked (FILE *__stream) throw () ; | |
322 | extern void perror (__const char *__s); | |
323 | extern int sys_nerr; | |
324 | extern __const char *__const sys_errlist[]; | |
325 | extern int _sys_nerr; | |
326 | extern __const char *__const _sys_errlist[]; | |
327 | extern int fileno (FILE *__stream) throw () ; | |
328 | extern int fileno_unlocked (FILE *__stream) throw () ; | |
329 | extern FILE *popen (__const char *__command, __const char *__modes) ; | |
330 | extern int pclose (FILE *__stream); | |
331 | extern char *ctermid (char *__s) throw (); | |
332 | extern char *cuserid (char *__s); | |
333 | struct obstack; | |
334 | extern int obstack_printf (struct obstack *__restrict __obstack, | |
335 | __const char *__restrict __format, ...) | |
336 | throw () __attribute__ ((__format__ (__printf__, 2, 3))); | |
337 | extern int obstack_vprintf (struct obstack *__restrict __obstack, | |
338 | __const char *__restrict __format, | |
339 | __gnuc_va_list __args) | |
340 | throw () __attribute__ ((__format__ (__printf__, 2, 0))); | |
341 | extern void flockfile (FILE *__stream) throw (); | |
342 | extern int ftrylockfile (FILE *__stream) throw () ; | |
343 | extern void funlockfile (FILE *__stream) throw (); | |
344 | extern __inline __attribute__ ((__gnu_inline__)) int | |
345 | vprintf (__const char *__restrict __fmt, __gnuc_va_list __arg) | |
346 | { | |
347 | return vfprintf (stdout, __fmt, __arg); | |
348 | } | |
349 | extern __inline __attribute__ ((__gnu_inline__)) int | |
350 | getchar (void) | |
351 | { | |
352 | return _IO_getc (stdin); | |
353 | } | |
354 | extern __inline __attribute__ ((__gnu_inline__)) int | |
355 | fgetc_unlocked (FILE *__fp) | |
356 | { | |
357 | return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++); | |
358 | } | |
359 | extern __inline __attribute__ ((__gnu_inline__)) int | |
360 | getc_unlocked (FILE *__fp) | |
361 | { | |
362 | return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++); | |
363 | } | |
364 | extern __inline __attribute__ ((__gnu_inline__)) int | |
365 | getchar_unlocked (void) | |
366 | { | |
367 | return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++); | |
368 | } | |
369 | extern __inline __attribute__ ((__gnu_inline__)) int | |
370 | putchar (int __c) | |
371 | { | |
372 | return _IO_putc (__c, stdout); | |
373 | } | |
374 | extern __inline __attribute__ ((__gnu_inline__)) int | |
375 | fputc_unlocked (int __c, FILE *__stream) | |
376 | { | |
377 | return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); | |
378 | } | |
379 | extern __inline __attribute__ ((__gnu_inline__)) int | |
380 | putc_unlocked (int __c, FILE *__stream) | |
381 | { | |
382 | return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); | |
383 | } | |
384 | extern __inline __attribute__ ((__gnu_inline__)) int | |
385 | putchar_unlocked (int __c) | |
386 | { | |
387 | return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c))); | |
388 | } | |
389 | extern __inline __attribute__ ((__gnu_inline__)) __ssize_t | |
390 | getline (char **__lineptr, size_t *__n, FILE *__stream) | |
391 | { | |
392 | return __getdelim (__lineptr, __n, '\n', __stream); | |
393 | } | |
394 | extern __inline __attribute__ ((__gnu_inline__)) int | |
395 | feof_unlocked (FILE *__stream) throw () | |
396 | { | |
397 | return (((__stream)->_flags & 0x10) != 0); | |
398 | } | |
399 | extern __inline __attribute__ ((__gnu_inline__)) int | |
400 | ferror_unlocked (FILE *__stream) throw () | |
401 | { | |
402 | return (((__stream)->_flags & 0x20) != 0); | |
403 | } | |
404 | } | |
405 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
406 | using ::FILE; | |
407 | using ::fpos_t; | |
408 | using ::clearerr; | |
409 | using ::fclose; | |
410 | using ::feof; | |
411 | using ::ferror; | |
412 | using ::fflush; | |
413 | using ::fgetc; | |
414 | using ::fgetpos; | |
415 | using ::fgets; | |
416 | using ::fopen; | |
417 | using ::fprintf; | |
418 | using ::fputc; | |
419 | using ::fputs; | |
420 | using ::fread; | |
421 | using ::freopen; | |
422 | using ::fscanf; | |
423 | using ::fseek; | |
424 | using ::fsetpos; | |
425 | using ::ftell; | |
426 | using ::fwrite; | |
427 | using ::getc; | |
428 | using ::getchar; | |
429 | using ::gets; | |
430 | using ::perror; | |
431 | using ::printf; | |
432 | using ::putc; | |
433 | using ::putchar; | |
434 | using ::puts; | |
435 | using ::remove; | |
436 | using ::rename; | |
437 | using ::rewind; | |
438 | using ::scanf; | |
439 | using ::setbuf; | |
440 | using ::setvbuf; | |
441 | using ::sprintf; | |
442 | using ::sscanf; | |
443 | using ::tmpfile; | |
444 | using ::tmpnam; | |
445 | using ::ungetc; | |
446 | using ::vfprintf; | |
447 | using ::vprintf; | |
448 | using ::vsprintf; | |
449 | } | |
450 | namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { | |
451 | using ::snprintf; | |
452 | using ::vfscanf; | |
453 | using ::vscanf; | |
454 | using ::vsnprintf; | |
455 | using ::vsscanf; | |
456 | } | |
457 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
458 | using ::__gnu_cxx::snprintf; | |
459 | using ::__gnu_cxx::vfscanf; | |
460 | using ::__gnu_cxx::vscanf; | |
461 | using ::__gnu_cxx::vsnprintf; | |
462 | using ::__gnu_cxx::vsscanf; | |
463 | } | |
464 | extern "C" { | |
465 | union wait | |
466 | { | |
467 | int w_status; | |
468 | struct | |
469 | { | |
470 | unsigned int __w_termsig:7; | |
471 | unsigned int __w_coredump:1; | |
472 | unsigned int __w_retcode:8; | |
473 | unsigned int:16; | |
474 | } __wait_terminated; | |
475 | struct | |
476 | { | |
477 | unsigned int __w_stopval:8; | |
478 | unsigned int __w_stopsig:8; | |
479 | unsigned int:16; | |
480 | } __wait_stopped; | |
481 | }; | |
482 | typedef struct | |
483 | { | |
484 | int quot; | |
485 | int rem; | |
486 | } div_t; | |
487 | typedef struct | |
488 | { | |
489 | long int quot; | |
490 | long int rem; | |
491 | } ldiv_t; | |
492 | __extension__ typedef struct | |
493 | { | |
494 | long long int quot; | |
495 | long long int rem; | |
496 | } lldiv_t; | |
497 | extern size_t __ctype_get_mb_cur_max (void) throw () ; | |
498 | extern double atof (__const char *__nptr) | |
499 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; | |
500 | extern int atoi (__const char *__nptr) | |
501 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; | |
502 | extern long int atol (__const char *__nptr) | |
503 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; | |
504 | __extension__ extern long long int atoll (__const char *__nptr) | |
505 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; | |
506 | extern double strtod (__const char *__restrict __nptr, | |
507 | char **__restrict __endptr) | |
508 | throw () __attribute__ ((__nonnull__ (1))) ; | |
509 | extern float strtof (__const char *__restrict __nptr, | |
510 | char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))) ; | |
511 | extern long double strtold (__const char *__restrict __nptr, | |
512 | char **__restrict __endptr) | |
513 | throw () __attribute__ ((__nonnull__ (1))) ; | |
514 | extern long int strtol (__const char *__restrict __nptr, | |
515 | char **__restrict __endptr, int __base) | |
516 | throw () __attribute__ ((__nonnull__ (1))) ; | |
517 | extern unsigned long int strtoul (__const char *__restrict __nptr, | |
518 | char **__restrict __endptr, int __base) | |
519 | throw () __attribute__ ((__nonnull__ (1))) ; | |
520 | __extension__ | |
521 | extern long long int strtoq (__const char *__restrict __nptr, | |
522 | char **__restrict __endptr, int __base) | |
523 | throw () __attribute__ ((__nonnull__ (1))) ; | |
524 | __extension__ | |
525 | extern unsigned long long int strtouq (__const char *__restrict __nptr, | |
526 | char **__restrict __endptr, int __base) | |
527 | throw () __attribute__ ((__nonnull__ (1))) ; | |
528 | __extension__ | |
529 | extern long long int strtoll (__const char *__restrict __nptr, | |
530 | char **__restrict __endptr, int __base) | |
531 | throw () __attribute__ ((__nonnull__ (1))) ; | |
532 | __extension__ | |
533 | extern unsigned long long int strtoull (__const char *__restrict __nptr, | |
534 | char **__restrict __endptr, int __base) | |
535 | throw () __attribute__ ((__nonnull__ (1))) ; | |
536 | typedef struct __locale_struct | |
537 | { | |
538 | struct locale_data *__locales[13]; | |
539 | const unsigned short int *__ctype_b; | |
540 | const int *__ctype_tolower; | |
541 | const int *__ctype_toupper; | |
542 | const char *__names[13]; | |
543 | } *__locale_t; | |
544 | extern long int strtol_l (__const char *__restrict __nptr, | |
545 | char **__restrict __endptr, int __base, | |
546 | __locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))) ; | |
547 | extern unsigned long int strtoul_l (__const char *__restrict __nptr, | |
548 | char **__restrict __endptr, | |
549 | int __base, __locale_t __loc) | |
550 | throw () __attribute__ ((__nonnull__ (1, 4))) ; | |
551 | __extension__ | |
552 | extern long long int strtoll_l (__const char *__restrict __nptr, | |
553 | char **__restrict __endptr, int __base, | |
554 | __locale_t __loc) | |
555 | throw () __attribute__ ((__nonnull__ (1, 4))) ; | |
556 | __extension__ | |
557 | extern unsigned long long int strtoull_l (__const char *__restrict __nptr, | |
558 | char **__restrict __endptr, | |
559 | int __base, __locale_t __loc) | |
560 | throw () __attribute__ ((__nonnull__ (1, 4))) ; | |
561 | extern double strtod_l (__const char *__restrict __nptr, | |
562 | char **__restrict __endptr, __locale_t __loc) | |
563 | throw () __attribute__ ((__nonnull__ (1, 3))) ; | |
564 | extern float strtof_l (__const char *__restrict __nptr, | |
565 | char **__restrict __endptr, __locale_t __loc) | |
566 | throw () __attribute__ ((__nonnull__ (1, 3))) ; | |
567 | extern long double strtold_l (__const char *__restrict __nptr, | |
568 | char **__restrict __endptr, | |
569 | __locale_t __loc) | |
570 | throw () __attribute__ ((__nonnull__ (1, 3))) ; | |
571 | extern __inline __attribute__ ((__gnu_inline__)) double | |
572 | atof (__const char *__nptr) throw () | |
573 | { | |
574 | return strtod (__nptr, (char **) __null); | |
575 | } | |
576 | extern __inline __attribute__ ((__gnu_inline__)) int | |
577 | atoi (__const char *__nptr) throw () | |
578 | { | |
579 | return (int) strtol (__nptr, (char **) __null, 10); | |
580 | } | |
581 | extern __inline __attribute__ ((__gnu_inline__)) long int | |
582 | atol (__const char *__nptr) throw () | |
583 | { | |
584 | return strtol (__nptr, (char **) __null, 10); | |
585 | } | |
586 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) long long int | |
587 | atoll (__const char *__nptr) throw () | |
588 | { | |
589 | return strtoll (__nptr, (char **) __null, 10); | |
590 | } | |
591 | extern char *l64a (long int __n) throw () ; | |
592 | extern long int a64l (__const char *__s) | |
593 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; | |
594 | extern "C" { | |
595 | typedef __u_char u_char; | |
596 | typedef __u_short u_short; | |
597 | typedef __u_int u_int; | |
598 | typedef __u_long u_long; | |
599 | typedef __quad_t quad_t; | |
600 | typedef __u_quad_t u_quad_t; | |
601 | typedef __fsid_t fsid_t; | |
602 | typedef __loff_t loff_t; | |
603 | typedef __ino_t ino_t; | |
604 | typedef __ino64_t ino64_t; | |
605 | typedef __dev_t dev_t; | |
606 | typedef __gid_t gid_t; | |
607 | typedef __mode_t mode_t; | |
608 | typedef __nlink_t nlink_t; | |
609 | typedef __uid_t uid_t; | |
610 | typedef __off_t off_t; | |
611 | typedef __off64_t off64_t; | |
612 | typedef __pid_t pid_t; | |
613 | typedef __id_t id_t; | |
614 | typedef __ssize_t ssize_t; | |
615 | typedef __daddr_t daddr_t; | |
616 | typedef __caddr_t caddr_t; | |
617 | typedef __key_t key_t; | |
618 | typedef __clock_t clock_t; | |
619 | typedef __time_t time_t; | |
620 | typedef __clockid_t clockid_t; | |
621 | typedef __timer_t timer_t; | |
622 | typedef __useconds_t useconds_t; | |
623 | typedef __suseconds_t suseconds_t; | |
624 | typedef unsigned long int ulong; | |
625 | typedef unsigned short int ushort; | |
626 | typedef unsigned int uint; | |
627 | typedef int int8_t __attribute__ ((__mode__ (__QI__))); | |
628 | typedef int int16_t __attribute__ ((__mode__ (__HI__))); | |
629 | typedef int int32_t __attribute__ ((__mode__ (__SI__))); | |
630 | typedef int int64_t __attribute__ ((__mode__ (__DI__))); | |
631 | typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__))); | |
632 | typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__))); | |
633 | typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__))); | |
634 | typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__))); | |
635 | typedef int register_t __attribute__ ((__mode__ (__word__))); | |
636 | typedef int __sig_atomic_t; | |
637 | typedef struct | |
638 | { | |
639 | unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; | |
640 | } __sigset_t; | |
641 | typedef __sigset_t sigset_t; | |
642 | struct timespec | |
643 | { | |
644 | __time_t tv_sec; | |
645 | long int tv_nsec; | |
646 | }; | |
647 | struct timeval | |
648 | { | |
649 | __time_t tv_sec; | |
650 | __suseconds_t tv_usec; | |
651 | }; | |
652 | typedef long int __fd_mask; | |
653 | typedef struct | |
654 | { | |
655 | __fd_mask fds_bits[1024 / (8 * sizeof (__fd_mask))]; | |
656 | } fd_set; | |
657 | typedef __fd_mask fd_mask; | |
658 | extern "C" { | |
659 | extern int select (int __nfds, fd_set *__restrict __readfds, | |
660 | fd_set *__restrict __writefds, | |
661 | fd_set *__restrict __exceptfds, | |
662 | struct timeval *__restrict __timeout); | |
663 | extern int pselect (int __nfds, fd_set *__restrict __readfds, | |
664 | fd_set *__restrict __writefds, | |
665 | fd_set *__restrict __exceptfds, | |
666 | const struct timespec *__restrict __timeout, | |
667 | const __sigset_t *__restrict __sigmask); | |
668 | } | |
669 | __extension__ | |
670 | extern unsigned int gnu_dev_major (unsigned long long int __dev) | |
671 | throw (); | |
672 | __extension__ | |
673 | extern unsigned int gnu_dev_minor (unsigned long long int __dev) | |
674 | throw (); | |
675 | __extension__ | |
676 | extern unsigned long long int gnu_dev_makedev (unsigned int __major, | |
677 | unsigned int __minor) | |
678 | throw (); | |
679 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned int | |
680 | gnu_dev_major (unsigned long long int __dev) throw () | |
681 | { | |
682 | return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); | |
683 | } | |
684 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned int | |
685 | gnu_dev_minor (unsigned long long int __dev) throw () | |
686 | { | |
687 | return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); | |
688 | } | |
689 | __extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned long long int | |
690 | gnu_dev_makedev (unsigned int __major, unsigned int __minor) throw () | |
691 | { | |
692 | return ((__minor & 0xff) | ((__major & 0xfff) << 8) | |
693 | | (((unsigned long long int) (__minor & ~0xff)) << 12) | |
694 | | (((unsigned long long int) (__major & ~0xfff)) << 32)); | |
695 | } | |
696 | typedef __blksize_t blksize_t; | |
697 | typedef __blkcnt_t blkcnt_t; | |
698 | typedef __fsblkcnt_t fsblkcnt_t; | |
699 | typedef __fsfilcnt_t fsfilcnt_t; | |
700 | typedef __blkcnt64_t blkcnt64_t; | |
701 | typedef __fsblkcnt64_t fsblkcnt64_t; | |
702 | typedef __fsfilcnt64_t fsfilcnt64_t; | |
703 | typedef unsigned long int pthread_t; | |
704 | typedef union | |
705 | { | |
706 | char __size[56]; | |
707 | long int __align; | |
708 | } pthread_attr_t; | |
709 | typedef struct __pthread_internal_list | |
710 | { | |
711 | struct __pthread_internal_list *__prev; | |
712 | struct __pthread_internal_list *__next; | |
713 | } __pthread_list_t; | |
714 | typedef union | |
715 | { | |
716 | struct __pthread_mutex_s | |
717 | { | |
718 | int __lock; | |
719 | unsigned int __count; | |
720 | int __owner; | |
721 | unsigned int __nusers; | |
722 | int __kind; | |
723 | int __spins; | |
724 | __pthread_list_t __list; | |
725 | } __data; | |
726 | char __size[40]; | |
727 | long int __align; | |
728 | } pthread_mutex_t; | |
729 | typedef union | |
730 | { | |
731 | char __size[4]; | |
732 | int __align; | |
733 | } pthread_mutexattr_t; | |
734 | typedef union | |
735 | { | |
736 | struct | |
737 | { | |
738 | int __lock; | |
739 | unsigned int __futex; | |
740 | __extension__ unsigned long long int __total_seq; | |
741 | __extension__ unsigned long long int __wakeup_seq; | |
742 | __extension__ unsigned long long int __woken_seq; | |
743 | void *__mutex; | |
744 | unsigned int __nwaiters; | |
745 | unsigned int __broadcast_seq; | |
746 | } __data; | |
747 | char __size[48]; | |
748 | __extension__ long long int __align; | |
749 | } pthread_cond_t; | |
750 | typedef union | |
751 | { | |
752 | char __size[4]; | |
753 | int __align; | |
754 | } pthread_condattr_t; | |
755 | typedef unsigned int pthread_key_t; | |
756 | typedef int pthread_once_t; | |
757 | typedef union | |
758 | { | |
759 | struct | |
760 | { | |
761 | int __lock; | |
762 | unsigned int __nr_readers; | |
763 | unsigned int __readers_wakeup; | |
764 | unsigned int __writer_wakeup; | |
765 | unsigned int __nr_readers_queued; | |
766 | unsigned int __nr_writers_queued; | |
767 | int __writer; | |
768 | int __shared; | |
769 | unsigned long int __pad1; | |
770 | unsigned long int __pad2; | |
771 | unsigned int __flags; | |
772 | } __data; | |
773 | char __size[56]; | |
774 | long int __align; | |
775 | } pthread_rwlock_t; | |
776 | typedef union | |
777 | { | |
778 | char __size[8]; | |
779 | long int __align; | |
780 | } pthread_rwlockattr_t; | |
781 | typedef volatile int pthread_spinlock_t; | |
782 | typedef union | |
783 | { | |
784 | char __size[32]; | |
785 | long int __align; | |
786 | } pthread_barrier_t; | |
787 | typedef union | |
788 | { | |
789 | char __size[4]; | |
790 | int __align; | |
791 | } pthread_barrierattr_t; | |
792 | } | |
793 | extern long int random (void) throw (); | |
794 | extern void srandom (unsigned int __seed) throw (); | |
795 | extern char *initstate (unsigned int __seed, char *__statebuf, | |
796 | size_t __statelen) throw () __attribute__ ((__nonnull__ (2))); | |
797 | extern char *setstate (char *__statebuf) throw () __attribute__ ((__nonnull__ (1))); | |
798 | struct random_data | |
799 | { | |
800 | int32_t *fptr; | |
801 | int32_t *rptr; | |
802 | int32_t *state; | |
803 | int rand_type; | |
804 | int rand_deg; | |
805 | int rand_sep; | |
806 | int32_t *end_ptr; | |
807 | }; | |
808 | extern int random_r (struct random_data *__restrict __buf, | |
809 | int32_t *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); | |
810 | extern int srandom_r (unsigned int __seed, struct random_data *__buf) | |
811 | throw () __attribute__ ((__nonnull__ (2))); | |
812 | extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, | |
813 | size_t __statelen, | |
814 | struct random_data *__restrict __buf) | |
815 | throw () __attribute__ ((__nonnull__ (2, 4))); | |
816 | extern int setstate_r (char *__restrict __statebuf, | |
817 | struct random_data *__restrict __buf) | |
818 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
819 | extern int rand (void) throw (); | |
820 | extern void srand (unsigned int __seed) throw (); | |
821 | extern int rand_r (unsigned int *__seed) throw (); | |
822 | extern double drand48 (void) throw (); | |
823 | extern double erand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1))); | |
824 | extern long int lrand48 (void) throw (); | |
825 | extern long int nrand48 (unsigned short int __xsubi[3]) | |
826 | throw () __attribute__ ((__nonnull__ (1))); | |
827 | extern long int mrand48 (void) throw (); | |
828 | extern long int jrand48 (unsigned short int __xsubi[3]) | |
829 | throw () __attribute__ ((__nonnull__ (1))); | |
830 | extern void srand48 (long int __seedval) throw (); | |
831 | extern unsigned short int *seed48 (unsigned short int __seed16v[3]) | |
832 | throw () __attribute__ ((__nonnull__ (1))); | |
833 | extern void lcong48 (unsigned short int __param[7]) throw () __attribute__ ((__nonnull__ (1))); | |
834 | struct drand48_data | |
835 | { | |
836 | unsigned short int __x[3]; | |
837 | unsigned short int __old_x[3]; | |
838 | unsigned short int __c; | |
839 | unsigned short int __init; | |
840 | unsigned long long int __a; | |
841 | }; | |
842 | extern int drand48_r (struct drand48_data *__restrict __buffer, | |
843 | double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); | |
844 | extern int erand48_r (unsigned short int __xsubi[3], | |
845 | struct drand48_data *__restrict __buffer, | |
846 | double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); | |
847 | extern int lrand48_r (struct drand48_data *__restrict __buffer, | |
848 | long int *__restrict __result) | |
849 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
850 | extern int nrand48_r (unsigned short int __xsubi[3], | |
851 | struct drand48_data *__restrict __buffer, | |
852 | long int *__restrict __result) | |
853 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
854 | extern int mrand48_r (struct drand48_data *__restrict __buffer, | |
855 | long int *__restrict __result) | |
856 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
857 | extern int jrand48_r (unsigned short int __xsubi[3], | |
858 | struct drand48_data *__restrict __buffer, | |
859 | long int *__restrict __result) | |
860 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
861 | extern int srand48_r (long int __seedval, struct drand48_data *__buffer) | |
862 | throw () __attribute__ ((__nonnull__ (2))); | |
863 | extern int seed48_r (unsigned short int __seed16v[3], | |
864 | struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2))); | |
865 | extern int lcong48_r (unsigned short int __param[7], | |
866 | struct drand48_data *__buffer) | |
867 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
868 | extern void *malloc (size_t __size) throw () __attribute__ ((__malloc__)) ; | |
869 | extern void *calloc (size_t __nmemb, size_t __size) | |
870 | throw () __attribute__ ((__malloc__)) ; | |
871 | extern void *realloc (void *__ptr, size_t __size) | |
872 | throw () __attribute__ ((__warn_unused_result__)); | |
873 | extern void free (void *__ptr) throw (); | |
874 | extern void cfree (void *__ptr) throw (); | |
875 | extern "C" { | |
876 | extern void *alloca (size_t __size) throw (); | |
877 | } | |
878 | extern void *valloc (size_t __size) throw () __attribute__ ((__malloc__)) ; | |
879 | extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) | |
880 | throw () __attribute__ ((__nonnull__ (1))) ; | |
881 | extern void abort (void) throw () __attribute__ ((__noreturn__)); | |
882 | extern int atexit (void (*__func) (void)) throw () __attribute__ ((__nonnull__ (1))); | |
883 | extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) | |
884 | throw () __attribute__ ((__nonnull__ (1))); | |
885 | extern void exit (int __status) throw () __attribute__ ((__noreturn__)); | |
886 | extern void _Exit (int __status) throw () __attribute__ ((__noreturn__)); | |
887 | extern char *getenv (__const char *__name) throw () __attribute__ ((__nonnull__ (1))) ; | |
888 | extern char *__secure_getenv (__const char *__name) | |
889 | throw () __attribute__ ((__nonnull__ (1))) ; | |
890 | extern int putenv (char *__string) throw () __attribute__ ((__nonnull__ (1))); | |
891 | extern int setenv (__const char *__name, __const char *__value, int __replace) | |
892 | throw () __attribute__ ((__nonnull__ (2))); | |
893 | extern int unsetenv (__const char *__name) throw (); | |
894 | extern int clearenv (void) throw (); | |
895 | extern char *mktemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ; | |
896 | extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ; | |
897 | extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) ; | |
898 | extern char *mkdtemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ; | |
899 | extern int mkostemp (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ; | |
900 | extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ; | |
901 | extern int system (__const char *__command) ; | |
902 | extern char *canonicalize_file_name (__const char *__name) | |
903 | throw () __attribute__ ((__nonnull__ (1))) ; | |
904 | extern char *realpath (__const char *__restrict __name, | |
905 | char *__restrict __resolved) throw () ; | |
906 | typedef int (*__compar_fn_t) (__const void *, __const void *); | |
907 | typedef __compar_fn_t comparison_fn_t; | |
908 | extern void *bsearch (__const void *__key, __const void *__base, | |
909 | size_t __nmemb, size_t __size, __compar_fn_t __compar) | |
910 | __attribute__ ((__nonnull__ (1, 2, 5))) ; | |
911 | extern void qsort (void *__base, size_t __nmemb, size_t __size, | |
912 | __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4))); | |
913 | extern int abs (int __x) throw () __attribute__ ((__const__)) ; | |
914 | extern long int labs (long int __x) throw () __attribute__ ((__const__)) ; | |
915 | __extension__ extern long long int llabs (long long int __x) | |
916 | throw () __attribute__ ((__const__)) ; | |
917 | extern div_t div (int __numer, int __denom) | |
918 | throw () __attribute__ ((__const__)) ; | |
919 | extern ldiv_t ldiv (long int __numer, long int __denom) | |
920 | throw () __attribute__ ((__const__)) ; | |
921 | __extension__ extern lldiv_t lldiv (long long int __numer, | |
922 | long long int __denom) | |
923 | throw () __attribute__ ((__const__)) ; | |
924 | extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, | |
925 | int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ; | |
926 | extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, | |
927 | int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ; | |
928 | extern char *gcvt (double __value, int __ndigit, char *__buf) | |
929 | throw () __attribute__ ((__nonnull__ (3))) ; | |
930 | extern char *qecvt (long double __value, int __ndigit, | |
931 | int *__restrict __decpt, int *__restrict __sign) | |
932 | throw () __attribute__ ((__nonnull__ (3, 4))) ; | |
933 | extern char *qfcvt (long double __value, int __ndigit, | |
934 | int *__restrict __decpt, int *__restrict __sign) | |
935 | throw () __attribute__ ((__nonnull__ (3, 4))) ; | |
936 | extern char *qgcvt (long double __value, int __ndigit, char *__buf) | |
937 | throw () __attribute__ ((__nonnull__ (3))) ; | |
938 | extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, | |
939 | int *__restrict __sign, char *__restrict __buf, | |
940 | size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
941 | extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, | |
942 | int *__restrict __sign, char *__restrict __buf, | |
943 | size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
944 | extern int qecvt_r (long double __value, int __ndigit, | |
945 | int *__restrict __decpt, int *__restrict __sign, | |
946 | char *__restrict __buf, size_t __len) | |
947 | throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
948 | extern int qfcvt_r (long double __value, int __ndigit, | |
949 | int *__restrict __decpt, int *__restrict __sign, | |
950 | char *__restrict __buf, size_t __len) | |
951 | throw () __attribute__ ((__nonnull__ (3, 4, 5))); | |
952 | extern int mblen (__const char *__s, size_t __n) throw () ; | |
953 | extern int mbtowc (wchar_t *__restrict __pwc, | |
954 | __const char *__restrict __s, size_t __n) throw () ; | |
955 | extern int wctomb (char *__s, wchar_t __wchar) throw () ; | |
956 | extern size_t mbstowcs (wchar_t *__restrict __pwcs, | |
957 | __const char *__restrict __s, size_t __n) throw (); | |
958 | extern size_t wcstombs (char *__restrict __s, | |
959 | __const wchar_t *__restrict __pwcs, size_t __n) | |
960 | throw (); | |
961 | extern int rpmatch (__const char *__response) throw () __attribute__ ((__nonnull__ (1))) ; | |
962 | extern int getsubopt (char **__restrict __optionp, | |
963 | char *__const *__restrict __tokens, | |
964 | char **__restrict __valuep) | |
965 | throw () __attribute__ ((__nonnull__ (1, 2, 3))) ; | |
966 | extern void setkey (__const char *__key) throw () __attribute__ ((__nonnull__ (1))); | |
967 | extern int posix_openpt (int __oflag) ; | |
968 | extern int grantpt (int __fd) throw (); | |
969 | extern int unlockpt (int __fd) throw (); | |
970 | extern char *ptsname (int __fd) throw () ; | |
971 | extern int ptsname_r (int __fd, char *__buf, size_t __buflen) | |
972 | throw () __attribute__ ((__nonnull__ (2))); | |
973 | extern int getpt (void); | |
974 | extern int getloadavg (double __loadavg[], int __nelem) | |
975 | throw () __attribute__ ((__nonnull__ (1))); | |
976 | } | |
977 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
978 | using ::div_t; | |
979 | using ::ldiv_t; | |
980 | using ::abort; | |
981 | using ::abs; | |
982 | using ::atexit; | |
983 | using ::atof; | |
984 | using ::atoi; | |
985 | using ::atol; | |
986 | using ::bsearch; | |
987 | using ::calloc; | |
988 | using ::div; | |
989 | using ::exit; | |
990 | using ::free; | |
991 | using ::getenv; | |
992 | using ::labs; | |
993 | using ::ldiv; | |
994 | using ::malloc; | |
995 | using ::mblen; | |
996 | using ::mbstowcs; | |
997 | using ::mbtowc; | |
998 | using ::qsort; | |
999 | using ::rand; | |
1000 | using ::realloc; | |
1001 | using ::srand; | |
1002 | using ::strtod; | |
1003 | using ::strtol; | |
1004 | using ::strtoul; | |
1005 | using ::system; | |
1006 | using ::wcstombs; | |
1007 | using ::wctomb; | |
1008 | inline long | |
1009 | abs(long __i) { return labs(__i); } | |
1010 | inline ldiv_t | |
1011 | div(long __i, long __j) { return ldiv(__i, __j); } | |
1012 | } | |
1013 | namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { | |
1014 | using ::lldiv_t; | |
1015 | using ::_Exit; | |
1016 | inline long long | |
1017 | abs(long long __x) { return __x >= 0 ? __x : -__x; } | |
1018 | using ::llabs; | |
1019 | inline lldiv_t | |
1020 | div(long long __n, long long __d) | |
1021 | { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } | |
1022 | using ::lldiv; | |
1023 | using ::atoll; | |
1024 | using ::strtoll; | |
1025 | using ::strtoull; | |
1026 | using ::strtof; | |
1027 | using ::strtold; | |
1028 | } | |
1029 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
1030 | using ::__gnu_cxx::lldiv_t; | |
1031 | using ::__gnu_cxx::_Exit; | |
1032 | using ::__gnu_cxx::abs; | |
1033 | using ::__gnu_cxx::llabs; | |
1034 | using ::__gnu_cxx::div; | |
1035 | using ::__gnu_cxx::lldiv; | |
1036 | using ::__gnu_cxx::atoll; | |
1037 | using ::__gnu_cxx::strtof; | |
1038 | using ::__gnu_cxx::strtoll; | |
1039 | using ::__gnu_cxx::strtoull; | |
1040 | using ::__gnu_cxx::strtold; | |
1041 | } | |
1042 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
1043 | using ::va_list; | |
1044 | } | |
1045 | extern "C" { | |
1046 | extern void *memcpy (void *__restrict __dest, | |
1047 | __const void *__restrict __src, size_t __n) | |
1048 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1049 | extern void *memmove (void *__dest, __const void *__src, size_t __n) | |
1050 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1051 | extern void *memccpy (void *__restrict __dest, __const void *__restrict __src, | |
1052 | int __c, size_t __n) | |
1053 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1054 | extern void *memset (void *__s, int __c, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
1055 | extern int memcmp (__const void *__s1, __const void *__s2, size_t __n) | |
1056 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1057 | extern void *memchr (__const void *__s, int __c, size_t __n) | |
1058 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1059 | extern void *rawmemchr (__const void *__s, int __c) | |
1060 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1061 | extern void *memrchr (__const void *__s, int __c, size_t __n) | |
1062 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1063 | extern char *strcpy (char *__restrict __dest, __const char *__restrict __src) | |
1064 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1065 | extern char *strncpy (char *__restrict __dest, | |
1066 | __const char *__restrict __src, size_t __n) | |
1067 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1068 | extern char *strcat (char *__restrict __dest, __const char *__restrict __src) | |
1069 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1070 | extern char *strncat (char *__restrict __dest, __const char *__restrict __src, | |
1071 | size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); | |
1072 | extern int strcmp (__const char *__s1, __const char *__s2) | |
1073 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1074 | extern int strncmp (__const char *__s1, __const char *__s2, size_t __n) | |
1075 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1076 | extern int strcoll (__const char *__s1, __const char *__s2) | |
1077 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1078 | extern size_t strxfrm (char *__restrict __dest, | |
1079 | __const char *__restrict __src, size_t __n) | |
1080 | throw () __attribute__ ((__nonnull__ (2))); | |
1081 | extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l) | |
1082 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); | |
1083 | extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n, | |
1084 | __locale_t __l) throw () __attribute__ ((__nonnull__ (2, 4))); | |
1085 | extern char *strdup (__const char *__s) | |
1086 | throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); | |
1087 | extern char *strndup (__const char *__string, size_t __n) | |
1088 | throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); | |
1089 | extern char *strchr (__const char *__s, int __c) | |
1090 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1091 | extern char *strrchr (__const char *__s, int __c) | |
1092 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1093 | extern char *strchrnul (__const char *__s, int __c) | |
1094 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1095 | extern size_t strcspn (__const char *__s, __const char *__reject) | |
1096 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1097 | extern size_t strspn (__const char *__s, __const char *__accept) | |
1098 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1099 | extern char *strpbrk (__const char *__s, __const char *__accept) | |
1100 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1101 | extern char *strstr (__const char *__haystack, __const char *__needle) | |
1102 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1103 | extern char *strtok (char *__restrict __s, __const char *__restrict __delim) | |
1104 | throw () __attribute__ ((__nonnull__ (2))); | |
1105 | extern char *__strtok_r (char *__restrict __s, | |
1106 | __const char *__restrict __delim, | |
1107 | char **__restrict __save_ptr) | |
1108 | throw () __attribute__ ((__nonnull__ (2, 3))); | |
1109 | extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim, | |
1110 | char **__restrict __save_ptr) | |
1111 | throw () __attribute__ ((__nonnull__ (2, 3))); | |
1112 | extern char *strcasestr (__const char *__haystack, __const char *__needle) | |
1113 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1114 | extern void *memmem (__const void *__haystack, size_t __haystacklen, | |
1115 | __const void *__needle, size_t __needlelen) | |
1116 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 3))); | |
1117 | extern void *__mempcpy (void *__restrict __dest, | |
1118 | __const void *__restrict __src, size_t __n) | |
1119 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1120 | extern void *mempcpy (void *__restrict __dest, | |
1121 | __const void *__restrict __src, size_t __n) | |
1122 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1123 | extern size_t strlen (__const char *__s) | |
1124 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1125 | extern size_t strnlen (__const char *__string, size_t __maxlen) | |
1126 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1127 | extern char *strerror (int __errnum) throw (); | |
1128 | extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) | |
1129 | throw () __attribute__ ((__nonnull__ (2))); | |
1130 | extern char *strerror_l (int __errnum, __locale_t __l) throw (); | |
1131 | extern void __bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
1132 | extern void bcopy (__const void *__src, void *__dest, size_t __n) | |
1133 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1134 | extern void bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
1135 | extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) | |
1136 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1137 | extern char *index (__const char *__s, int __c) | |
1138 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1139 | extern char *rindex (__const char *__s, int __c) | |
1140 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); | |
1141 | extern int ffs (int __i) throw () __attribute__ ((__const__)); | |
1142 | extern int ffsl (long int __l) throw () __attribute__ ((__const__)); | |
1143 | __extension__ extern int ffsll (long long int __ll) | |
1144 | throw () __attribute__ ((__const__)); | |
1145 | extern int strcasecmp (__const char *__s1, __const char *__s2) | |
1146 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1147 | extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) | |
1148 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1149 | extern int strcasecmp_l (__const char *__s1, __const char *__s2, | |
1150 | __locale_t __loc) | |
1151 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); | |
1152 | extern int strncasecmp_l (__const char *__s1, __const char *__s2, | |
1153 | size_t __n, __locale_t __loc) | |
1154 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4))); | |
1155 | extern char *strsep (char **__restrict __stringp, | |
1156 | __const char *__restrict __delim) | |
1157 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1158 | extern int strverscmp (__const char *__s1, __const char *__s2) | |
1159 | throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); | |
1160 | extern char *strsignal (int __sig) throw (); | |
1161 | extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src) | |
1162 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1163 | extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src) | |
1164 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1165 | extern char *__stpncpy (char *__restrict __dest, | |
1166 | __const char *__restrict __src, size_t __n) | |
1167 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1168 | extern char *stpncpy (char *__restrict __dest, | |
1169 | __const char *__restrict __src, size_t __n) | |
1170 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
1171 | extern char *strfry (char *__string) throw () __attribute__ ((__nonnull__ (1))); | |
1172 | extern void *memfrob (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); | |
1173 | extern char *basename (__const char *__filename) throw () __attribute__ ((__nonnull__ (1))); | |
1174 | } | |
1175 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
1176 | using ::memchr; | |
1177 | using ::memcmp; | |
1178 | using ::memcpy; | |
1179 | using ::memmove; | |
1180 | using ::memset; | |
1181 | using ::strcat; | |
1182 | using ::strcmp; | |
1183 | using ::strcoll; | |
1184 | using ::strcpy; | |
1185 | using ::strcspn; | |
1186 | using ::strerror; | |
1187 | using ::strlen; | |
1188 | using ::strncat; | |
1189 | using ::strncmp; | |
1190 | using ::strncpy; | |
1191 | using ::strspn; | |
1192 | using ::strtok; | |
1193 | using ::strxfrm; | |
1194 | inline void* | |
1195 | memchr(void* __p, int __c, size_t __n) | |
1196 | { return memchr(const_cast<const void*>(__p), __c, __n); } | |
1197 | using ::strchr; | |
1198 | inline char* | |
1199 | strchr(char* __s1, int __n) | |
1200 | { return __builtin_strchr(const_cast<const char*>(__s1), __n); } | |
1201 | using ::strpbrk; | |
1202 | inline char* | |
1203 | strpbrk(char* __s1, const char* __s2) | |
1204 | { return __builtin_strpbrk(const_cast<const char*>(__s1), __s2); } | |
1205 | using ::strrchr; | |
1206 | inline char* | |
1207 | strrchr(char* __s1, int __n) | |
1208 | { return __builtin_strrchr(const_cast<const char*>(__s1), __n); } | |
1209 | using ::strstr; | |
1210 | inline char* | |
1211 | strstr(char* __s1, const char* __s2) | |
1212 | { return __builtin_strstr(const_cast<const char*>(__s1), __s2); } | |
1213 | } | |
1214 | namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { | |
1215 | template<typename _Iterator, typename _Container> | |
1216 | class __normal_iterator; | |
1217 | } | |
1218 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
1219 | struct __true_type { }; | |
1220 | struct __false_type { }; | |
1221 | template<bool> | |
1222 | struct __truth_type | |
1223 | { typedef __false_type __type; }; | |
1224 | template<> | |
1225 | struct __truth_type<true> | |
1226 | { typedef __true_type __type; }; | |
1227 | template<class _Sp, class _Tp> | |
1228 | struct __traitor | |
1229 | { | |
1230 | enum { __value = bool(_Sp::__value) || bool(_Tp::__value) }; | |
1231 | typedef typename __truth_type<__value>::__type __type; | |
1232 | }; | |
1233 | template<typename, typename> | |
1234 | struct __are_same | |
1235 | { | |
1236 | enum { __value = 0 }; | |
1237 | typedef __false_type __type; | |
1238 | }; | |
1239 | template<typename _Tp> | |
1240 | struct __are_same<_Tp, _Tp> | |
1241 | { | |
1242 | enum { __value = 1 }; | |
1243 | typedef __true_type __type; | |
1244 | }; | |
1245 | template<typename _Tp> | |
1246 | struct __is_void | |
1247 | { | |
1248 | enum { __value = 0 }; | |
1249 | typedef __false_type __type; | |
1250 | }; | |
1251 | template<> | |
1252 | struct __is_void<void> | |
1253 | { | |
1254 | enum { __value = 1 }; | |
1255 | typedef __true_type __type; | |
1256 | }; | |
1257 | template<typename _Tp> | |
1258 | struct __is_integer | |
1259 | { | |
1260 | enum { __value = 0 }; | |
1261 | typedef __false_type __type; | |
1262 | }; | |
1263 | template<> | |
1264 | struct __is_integer<bool> | |
1265 | { | |
1266 | enum { __value = 1 }; | |
1267 | typedef __true_type __type; | |
1268 | }; | |
1269 | template<> | |
1270 | struct __is_integer<char> | |
1271 | { | |
1272 | enum { __value = 1 }; | |
1273 | typedef __true_type __type; | |
1274 | }; | |
1275 | template<> | |
1276 | struct __is_integer<signed char> | |
1277 | { | |
1278 | enum { __value = 1 }; | |
1279 | typedef __true_type __type; | |
1280 | }; | |
1281 | template<> | |
1282 | struct __is_integer<unsigned char> | |
1283 | { | |
1284 | enum { __value = 1 }; | |
1285 | typedef __true_type __type; | |
1286 | }; | |
1287 | template<> | |
1288 | struct __is_integer<wchar_t> | |
1289 | { | |
1290 | enum { __value = 1 }; | |
1291 | typedef __true_type __type; | |
1292 | }; | |
1293 | template<> | |
1294 | struct __is_integer<short> | |
1295 | { | |
1296 | enum { __value = 1 }; | |
1297 | typedef __true_type __type; | |
1298 | }; | |
1299 | template<> | |
1300 | struct __is_integer<unsigned short> | |
1301 | { | |
1302 | enum { __value = 1 }; | |
1303 | typedef __true_type __type; | |
1304 | }; | |
1305 | template<> | |
1306 | struct __is_integer<int> | |
1307 | { | |
1308 | enum { __value = 1 }; | |
1309 | typedef __true_type __type; | |
1310 | }; | |
1311 | template<> | |
1312 | struct __is_integer<unsigned int> | |
1313 | { | |
1314 | enum { __value = 1 }; | |
1315 | typedef __true_type __type; | |
1316 | }; | |
1317 | template<> | |
1318 | struct __is_integer<long> | |
1319 | { | |
1320 | enum { __value = 1 }; | |
1321 | typedef __true_type __type; | |
1322 | }; | |
1323 | template<> | |
1324 | struct __is_integer<unsigned long> | |
1325 | { | |
1326 | enum { __value = 1 }; | |
1327 | typedef __true_type __type; | |
1328 | }; | |
1329 | template<> | |
1330 | struct __is_integer<long long> | |
1331 | { | |
1332 | enum { __value = 1 }; | |
1333 | typedef __true_type __type; | |
1334 | }; | |
1335 | template<> | |
1336 | struct __is_integer<unsigned long long> | |
1337 | { | |
1338 | enum { __value = 1 }; | |
1339 | typedef __true_type __type; | |
1340 | }; | |
1341 | template<typename _Tp> | |
1342 | struct __is_floating | |
1343 | { | |
1344 | enum { __value = 0 }; | |
1345 | typedef __false_type __type; | |
1346 | }; | |
1347 | template<> | |
1348 | struct __is_floating<float> | |
1349 | { | |
1350 | enum { __value = 1 }; | |
1351 | typedef __true_type __type; | |
1352 | }; | |
1353 | template<> | |
1354 | struct __is_floating<double> | |
1355 | { | |
1356 | enum { __value = 1 }; | |
1357 | typedef __true_type __type; | |
1358 | }; | |
1359 | template<> | |
1360 | struct __is_floating<long double> | |
1361 | { | |
1362 | enum { __value = 1 }; | |
1363 | typedef __true_type __type; | |
1364 | }; | |
1365 | template<typename _Tp> | |
1366 | struct __is_pointer | |
1367 | { | |
1368 | enum { __value = 0 }; | |
1369 | typedef __false_type __type; | |
1370 | }; | |
1371 | template<typename _Tp> | |
1372 | struct __is_pointer<_Tp*> | |
1373 | { | |
1374 | enum { __value = 1 }; | |
1375 | typedef __true_type __type; | |
1376 | }; | |
1377 | template<typename _Tp> | |
1378 | struct __is_normal_iterator | |
1379 | { | |
1380 | enum { __value = 0 }; | |
1381 | typedef __false_type __type; | |
1382 | }; | |
1383 | template<typename _Iterator, typename _Container> | |
1384 | struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, | |
1385 | _Container> > | |
1386 | { | |
1387 | enum { __value = 1 }; | |
1388 | typedef __true_type __type; | |
1389 | }; | |
1390 | template<typename _Tp> | |
1391 | struct __is_arithmetic | |
1392 | : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > | |
1393 | { }; | |
1394 | template<typename _Tp> | |
1395 | struct __is_fundamental | |
1396 | : public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> > | |
1397 | { }; | |
1398 | template<typename _Tp> | |
1399 | struct __is_scalar | |
1400 | : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > | |
1401 | { }; | |
1402 | template<typename _Tp> | |
1403 | struct __is_char | |
1404 | { | |
1405 | enum { __value = 0 }; | |
1406 | typedef __false_type __type; | |
1407 | }; | |
1408 | template<> | |
1409 | struct __is_char<char> | |
1410 | { | |
1411 | enum { __value = 1 }; | |
1412 | typedef __true_type __type; | |
1413 | }; | |
1414 | template<> | |
1415 | struct __is_char<wchar_t> | |
1416 | { | |
1417 | enum { __value = 1 }; | |
1418 | typedef __true_type __type; | |
1419 | }; | |
1420 | template<typename _Tp> | |
1421 | struct __is_byte | |
1422 | { | |
1423 | enum { __value = 0 }; | |
1424 | typedef __false_type __type; | |
1425 | }; | |
1426 | template<> | |
1427 | struct __is_byte<char> | |
1428 | { | |
1429 | enum { __value = 1 }; | |
1430 | typedef __true_type __type; | |
1431 | }; | |
1432 | template<> | |
1433 | struct __is_byte<signed char> | |
1434 | { | |
1435 | enum { __value = 1 }; | |
1436 | typedef __true_type __type; | |
1437 | }; | |
1438 | template<> | |
1439 | struct __is_byte<unsigned char> | |
1440 | { | |
1441 | enum { __value = 1 }; | |
1442 | typedef __true_type __type; | |
1443 | }; | |
1444 | template<typename _Tp> | |
1445 | struct __is_move_iterator | |
1446 | { | |
1447 | enum { __value = 0 }; | |
1448 | typedef __false_type __type; | |
1449 | }; | |
1450 | } | |
1451 | namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { | |
1452 | template<bool, typename> | |
1453 | struct __enable_if | |
1454 | { }; | |
1455 | template<typename _Tp> | |
1456 | struct __enable_if<true, _Tp> | |
1457 | { typedef _Tp __type; }; | |
1458 | template<bool _Cond, typename _Iftrue, typename _Iffalse> | |
1459 | struct __conditional_type | |
1460 | { typedef _Iftrue __type; }; | |
1461 | template<typename _Iftrue, typename _Iffalse> | |
1462 | struct __conditional_type<false, _Iftrue, _Iffalse> | |
1463 | { typedef _Iffalse __type; }; | |
1464 | template<typename _Tp> | |
1465 | struct __add_unsigned | |
1466 | { | |
1467 | private: | |
1468 | typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type; | |
1469 | public: | |
1470 | typedef typename __if_type::__type __type; | |
1471 | }; | |
1472 | template<> | |
1473 | struct __add_unsigned<char> | |
1474 | { typedef unsigned char __type; }; | |
1475 | template<> | |
1476 | struct __add_unsigned<signed char> | |
1477 | { typedef unsigned char __type; }; | |
1478 | template<> | |
1479 | struct __add_unsigned<short> | |
1480 | { typedef unsigned short __type; }; | |
1481 | template<> | |
1482 | struct __add_unsigned<int> | |
1483 | { typedef unsigned int __type; }; | |
1484 | template<> | |
1485 | struct __add_unsigned<long> | |
1486 | { typedef unsigned long __type; }; | |
1487 | template<> | |
1488 | struct __add_unsigned<long long> | |
1489 | { typedef unsigned long long __type; }; | |
1490 | template<> | |
1491 | struct __add_unsigned<bool>; | |
1492 | template<> | |
1493 | struct __add_unsigned<wchar_t>; | |
1494 | template<typename _Tp> | |
1495 | struct __remove_unsigned | |
1496 | { | |
1497 | private: | |
1498 | typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type; | |
1499 | public: | |
1500 | typedef typename __if_type::__type __type; | |
1501 | }; | |
1502 | template<> | |
1503 | struct __remove_unsigned<char> | |
1504 | { typedef signed char __type; }; | |
1505 | template<> | |
1506 | struct __remove_unsigned<unsigned char> | |
1507 | { typedef signed char __type; }; | |
1508 | template<> | |
1509 | struct __remove_unsigned<unsigned short> | |
1510 | { typedef short __type; }; | |
1511 | template<> | |
1512 | struct __remove_unsigned<unsigned int> | |
1513 | { typedef int __type; }; | |
1514 | template<> | |
1515 | struct __remove_unsigned<unsigned long> | |
1516 | { typedef long __type; }; | |
1517 | template<> | |
1518 | struct __remove_unsigned<unsigned long long> | |
1519 | { typedef long long __type; }; | |
1520 | template<> | |
1521 | struct __remove_unsigned<bool>; | |
1522 | template<> | |
1523 | struct __remove_unsigned<wchar_t>; | |
1524 | template<typename _Type> | |
1525 | inline bool | |
1526 | __is_null_pointer(_Type* __ptr) | |
1527 | { return __ptr == 0; } | |
1528 | template<typename _Type> | |
1529 | inline bool | |
1530 | __is_null_pointer(_Type) | |
1531 | { return false; } | |
1532 | template<typename _Tp, bool = std::__is_integer<_Tp>::__value> | |
1533 | struct __promote | |
1534 | { typedef double __type; }; | |
1535 | template<typename _Tp> | |
1536 | struct __promote<_Tp, false> | |
1537 | { typedef _Tp __type; }; | |
1538 | template<typename _Tp, typename _Up> | |
1539 | struct __promote_2 | |
1540 | { | |
1541 | private: | |
1542 | typedef typename __promote<_Tp>::__type __type1; | |
1543 | typedef typename __promote<_Up>::__type __type2; | |
1544 | public: | |
1545 | typedef __typeof__(__type1() + __type2()) __type; | |
1546 | }; | |
1547 | template<typename _Tp, typename _Up, typename _Vp> | |
1548 | struct __promote_3 | |
1549 | { | |
1550 | private: | |
1551 | typedef typename __promote<_Tp>::__type __type1; | |
1552 | typedef typename __promote<_Up>::__type __type2; | |
1553 | typedef typename __promote<_Vp>::__type __type3; | |
1554 | public: | |
1555 | typedef __typeof__(__type1() + __type2() + __type3()) __type; | |
1556 | }; | |
1557 | template<typename _Tp, typename _Up, typename _Vp, typename _Wp> | |
1558 | struct __promote_4 | |
1559 | { | |
1560 | private: | |
1561 | typedef typename __promote<_Tp>::__type __type1; | |
1562 | typedef typename __promote<_Up>::__type __type2; | |
1563 | typedef typename __promote<_Vp>::__type __type3; | |
1564 | typedef typename __promote<_Wp>::__type __type4; | |
1565 | public: | |
1566 | typedef __typeof__(__type1() + __type2() + __type3() + __type4()) __type; | |
1567 | }; | |
1568 | } | |
1569 | extern "C" { | |
1570 | typedef float float_t; | |
1571 | typedef double double_t; | |
1572 | extern double acos (double __x) throw (); extern double __acos (double __x) throw (); | |
1573 | extern double asin (double __x) throw (); extern double __asin (double __x) throw (); | |
1574 | extern double atan (double __x) throw (); extern double __atan (double __x) throw (); | |
1575 | extern double atan2 (double __y, double __x) throw (); extern double __atan2 (double __y, double __x) throw (); | |
1576 | extern double cos (double __x) throw (); extern double __cos (double __x) throw (); | |
1577 | extern double sin (double __x) throw (); extern double __sin (double __x) throw (); | |
1578 | extern double tan (double __x) throw (); extern double __tan (double __x) throw (); | |
1579 | extern double cosh (double __x) throw (); extern double __cosh (double __x) throw (); | |
1580 | extern double sinh (double __x) throw (); extern double __sinh (double __x) throw (); | |
1581 | extern double tanh (double __x) throw (); extern double __tanh (double __x) throw (); | |
1582 | extern void sincos (double __x, double *__sinx, double *__cosx) throw (); extern void __sincos (double __x, double *__sinx, double *__cosx) throw (); | |
1583 | extern double acosh (double __x) throw (); extern double __acosh (double __x) throw (); | |
1584 | extern double asinh (double __x) throw (); extern double __asinh (double __x) throw (); | |
1585 | extern double atanh (double __x) throw (); extern double __atanh (double __x) throw (); | |
1586 | extern double exp (double __x) throw (); extern double __exp (double __x) throw (); | |
1587 | extern double frexp (double __x, int *__exponent) throw (); extern double __frexp (double __x, int *__exponent) throw (); | |
1588 | extern double ldexp (double __x, int __exponent) throw (); extern double __ldexp (double __x, int __exponent) throw (); | |
1589 | extern double log (double __x) throw (); extern double __log (double __x) throw (); | |
1590 | extern double log10 (double __x) throw (); extern double __log10 (double __x) throw (); | |
1591 | extern double modf (double __x, double *__iptr) throw (); extern double __modf (double __x, double *__iptr) throw (); | |
1592 | extern double exp10 (double __x) throw (); extern double __exp10 (double __x) throw (); | |
1593 | extern double pow10 (double __x) throw (); extern double __pow10 (double __x) throw (); | |
1594 | extern double expm1 (double __x) throw (); extern double __expm1 (double __x) throw (); | |
1595 | extern double log1p (double __x) throw (); extern double __log1p (double __x) throw (); | |
1596 | extern double logb (double __x) throw (); extern double __logb (double __x) throw (); | |
1597 | extern double exp2 (double __x) throw (); extern double __exp2 (double __x) throw (); | |
1598 | extern double log2 (double __x) throw (); extern double __log2 (double __x) throw (); | |
1599 | extern double pow (double __x, double __y) throw (); extern double __pow (double __x, double __y) throw (); | |
1600 | extern double sqrt (double __x) throw (); extern double __sqrt (double __x) throw (); | |
1601 | extern double hypot (double __x, double __y) throw (); extern double __hypot (double __x, double __y) throw (); | |
1602 | extern double cbrt (double __x) throw (); extern double __cbrt (double __x) throw (); | |
1603 | extern double ceil (double __x) throw () __attribute__ ((__const__)); extern double __ceil (double __x) throw () __attribute__ ((__const__)); | |
1604 | extern double fabs (double __x) throw () __attribute__ ((__const__)); extern double __fabs (double __x) throw () __attribute__ ((__const__)); | |
1605 | extern double floor (double __x) throw () __attribute__ ((__const__)); extern double __floor (double __x) throw () __attribute__ ((__const__)); | |
1606 | extern double fmod (double __x, double __y) throw (); extern double __fmod (double __x, double __y) throw (); | |
1607 | extern int __isinf (double __value) throw () __attribute__ ((__const__)); | |
1608 | extern int __finite (double __value) throw () __attribute__ ((__const__)); | |
1609 | extern int isinf (double __value) throw () __attribute__ ((__const__)); | |
1610 | extern int finite (double __value) throw () __attribute__ ((__const__)); | |
1611 | extern double drem (double __x, double __y) throw (); extern double __drem (double __x, double __y) throw (); | |
1612 | extern double significand (double __x) throw (); extern double __significand (double __x) throw (); | |
1613 | extern double copysign (double __x, double __y) throw () __attribute__ ((__const__)); extern double __copysign (double __x, double __y) throw () __attribute__ ((__const__)); | |
1614 | extern double nan (__const char *__tagb) throw () __attribute__ ((__const__)); extern double __nan (__const char *__tagb) throw () __attribute__ ((__const__)); | |
1615 | extern int __isnan (double __value) throw () __attribute__ ((__const__)); | |
1616 | extern int isnan (double __value) throw () __attribute__ ((__const__)); | |
1617 | extern double j0 (double) throw (); extern double __j0 (double) throw (); | |
1618 | extern double j1 (double) throw (); extern double __j1 (double) throw (); | |
1619 | extern double jn (int, double) throw (); extern double __jn (int, double) throw (); | |
1620 | extern double y0 (double) throw (); extern double __y0 (double) throw (); | |
1621 | extern double y1 (double) throw (); extern double __y1 (double) throw (); | |
1622 | extern double yn (int, double) throw (); extern double __yn (int, double) throw (); | |
1623 | extern double erf (double) throw (); extern double __erf (double) throw (); | |
1624 | extern double erfc (double) throw (); extern double __erfc (double) throw (); | |
1625 | extern double lgamma (double) throw (); extern double __lgamma (double) throw (); | |
1626 | extern double tgamma (double) throw (); extern double __tgamma (double) throw (); | |
1627 | extern double gamma (double) throw (); extern double __gamma (double) throw (); | |
1628 | extern double lgamma_r (double, int *__signgamp) throw (); extern double __lgamma_r (double, int *__signgamp) throw (); | |
1629 | extern double rint (double __x) throw (); extern double __rint (double __x) throw (); | |
1630 | extern double nextafter (double __x, double __y) throw () __attribute__ ((__const__)); extern double __nextafter (double __x, double __y) throw () __attribute__ ((__const__)); | |
1631 | extern double nexttoward (double __x, long double __y) throw () __attribute__ ((__const__)); extern double __nexttoward (double __x, long double __y) throw () __attribute__ ((__const__)); | |
1632 | extern double remainder (double __x, double __y) throw (); extern double __remainder (double __x, double __y) throw (); | |
1633 | extern double scalbn (double __x, int __n) throw (); extern double __scalbn (double __x, int __n) throw (); | |
1634 | extern int ilogb (double __x) throw (); extern int __ilogb (double __x) throw (); | |
1635 | extern double scalbln (double __x, long int __n) throw (); extern double __scalbln (double __x, long int __n) throw (); | |
1636 | extern double nearbyint (double __x) throw (); extern double __nearbyint (double __x) throw (); | |
1637 | extern double round (double __x) throw () __attribute__ ((__const__)); extern double __round (double __x) throw () __attribute__ ((__const__)); | |
1638 | extern double trunc (double __x) throw () __attribute__ ((__const__)); extern double __trunc (double __x) throw () __attribute__ ((__const__)); | |
1639 | extern double remquo (double __x, double __y, int *__quo) throw (); extern double __remquo (double __x, double __y, int *__quo) throw (); | |
1640 | extern long int lrint (double __x) throw (); extern long int __lrint (double __x) throw (); | |
1641 | extern long long int llrint (double __x) throw (); extern long long int __llrint (double __x) throw (); | |
1642 | extern long int lround (double __x) throw (); extern long int __lround (double __x) throw (); | |
1643 | extern long long int llround (double __x) throw (); extern long long int __llround (double __x) throw (); | |
1644 | extern double fdim (double __x, double __y) throw (); extern double __fdim (double __x, double __y) throw (); | |
1645 | extern double fmax (double __x, double __y) throw (); extern double __fmax (double __x, double __y) throw (); | |
1646 | extern double fmin (double __x, double __y) throw (); extern double __fmin (double __x, double __y) throw (); | |
1647 | extern int __fpclassify (double __value) throw () | |
1648 | __attribute__ ((__const__)); | |
1649 | extern int __signbit (double __value) throw () | |
1650 | __attribute__ ((__const__)); | |
1651 | extern double fma (double __x, double __y, double __z) throw (); extern double __fma (double __x, double __y, double __z) throw (); | |
1652 | extern double scalb (double __x, double __n) throw (); extern double __scalb (double __x, double __n) throw (); | |
1653 | extern float acosf (float __x) throw (); extern float __acosf (float __x) throw (); | |
1654 | extern float asinf (float __x) throw (); extern float __asinf (float __x) throw (); | |
1655 | extern float atanf (float __x) throw (); extern float __atanf (float __x) throw (); | |
1656 | extern float atan2f (float __y, float __x) throw (); extern float __atan2f (float __y, float __x) throw (); | |
1657 | extern float cosf (float __x) throw (); extern float __cosf (float __x) throw (); | |
1658 | extern float sinf (float __x) throw (); extern float __sinf (float __x) throw (); | |
1659 | extern float tanf (float __x) throw (); extern float __tanf (float __x) throw (); | |
1660 | extern float coshf (float __x) throw (); extern float __coshf (float __x) throw (); | |
1661 | extern float sinhf (float __x) throw (); extern float __sinhf (float __x) throw (); | |
1662 | extern float tanhf (float __x) throw (); extern float __tanhf (float __x) throw (); | |
1663 | extern void sincosf (float __x, float *__sinx, float *__cosx) throw (); extern void __sincosf (float __x, float *__sinx, float *__cosx) throw (); | |
1664 | extern float acoshf (float __x) throw (); extern float __acoshf (float __x) throw (); | |
1665 | extern float asinhf (float __x) throw (); extern float __asinhf (float __x) throw (); | |
1666 | extern float atanhf (float __x) throw (); extern float __atanhf (float __x) throw (); | |
1667 | extern float expf (float __x) throw (); extern float __expf (float __x) throw (); | |
1668 | extern float frexpf (float __x, int *__exponent) throw (); extern float __frexpf (float __x, int *__exponent) throw (); | |
1669 | extern float ldexpf (float __x, int __exponent) throw (); extern float __ldexpf (float __x, int __exponent) throw (); | |
1670 | extern float logf (float __x) throw (); extern float __logf (float __x) throw (); | |
1671 | extern float log10f (float __x) throw (); extern float __log10f (float __x) throw (); | |
1672 | extern float modff (float __x, float *__iptr) throw (); extern float __modff (float __x, float *__iptr) throw (); | |
1673 | extern float exp10f (float __x) throw (); extern float __exp10f (float __x) throw (); | |
1674 | extern float pow10f (float __x) throw (); extern float __pow10f (float __x) throw (); | |
1675 | extern float expm1f (float __x) throw (); extern float __expm1f (float __x) throw (); | |
1676 | extern float log1pf (float __x) throw (); extern float __log1pf (float __x) throw (); | |
1677 | extern float logbf (float __x) throw (); extern float __logbf (float __x) throw (); | |
1678 | extern float exp2f (float __x) throw (); extern float __exp2f (float __x) throw (); | |
1679 | extern float log2f (float __x) throw (); extern float __log2f (float __x) throw (); | |
1680 | extern float powf (float __x, float __y) throw (); extern float __powf (float __x, float __y) throw (); | |
1681 | extern float sqrtf (float __x) throw (); extern float __sqrtf (float __x) throw (); | |
1682 | extern float hypotf (float __x, float __y) throw (); extern float __hypotf (float __x, float __y) throw (); | |
1683 | extern float cbrtf (float __x) throw (); extern float __cbrtf (float __x) throw (); | |
1684 | extern float ceilf (float __x) throw () __attribute__ ((__const__)); extern float __ceilf (float __x) throw () __attribute__ ((__const__)); | |
1685 | extern float fabsf (float __x) throw () __attribute__ ((__const__)); extern float __fabsf (float __x) throw () __attribute__ ((__const__)); | |
1686 | extern float floorf (float __x) throw () __attribute__ ((__const__)); extern float __floorf (float __x) throw () __attribute__ ((__const__)); | |
1687 | extern float fmodf (float __x, float __y) throw (); extern float __fmodf (float __x, float __y) throw (); | |
1688 | extern int __isinff (float __value) throw () __attribute__ ((__const__)); | |
1689 | extern int __finitef (float __value) throw () __attribute__ ((__const__)); | |
1690 | extern int isinff (float __value) throw () __attribute__ ((__const__)); | |
1691 | extern int finitef (float __value) throw () __attribute__ ((__const__)); | |
1692 | extern float dremf (float __x, float __y) throw (); extern float __dremf (float __x, float __y) throw (); | |
1693 | extern float significandf (float __x) throw (); extern float __significandf (float __x) throw (); | |
1694 | extern float copysignf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) throw () __attribute__ ((__const__)); | |
1695 | extern float nanf (__const char *__tagb) throw () __attribute__ ((__const__)); extern float __nanf (__const char *__tagb) throw () __attribute__ ((__const__)); | |
1696 | extern int __isnanf (float __value) throw () __attribute__ ((__const__)); | |
1697 | extern int isnanf (float __value) throw () __attribute__ ((__const__)); | |
1698 | extern float j0f (float) throw (); extern float __j0f (float) throw (); | |
1699 | extern float j1f (float) throw (); extern float __j1f (float) throw (); | |
1700 | extern float jnf (int, float) throw (); extern float __jnf (int, float) throw (); | |
1701 | extern float y0f (float) throw (); extern float __y0f (float) throw (); | |
1702 | extern float y1f (float) throw (); extern float __y1f (float) throw (); | |
1703 | extern float ynf (int, float) throw (); extern float __ynf (int, float) throw (); | |
1704 | extern float erff (float) throw (); extern float __erff (float) throw (); | |
1705 | extern float erfcf (float) throw (); extern float __erfcf (float) throw (); | |
1706 | extern float lgammaf (float) throw (); extern float __lgammaf (float) throw (); | |
1707 | extern float tgammaf (float) throw (); extern float __tgammaf (float) throw (); | |
1708 | extern float gammaf (float) throw (); extern float __gammaf (float) throw (); | |
1709 | extern float lgammaf_r (float, int *__signgamp) throw (); extern float __lgammaf_r (float, int *__signgamp) throw (); | |
1710 | extern float rintf (float __x) throw (); extern float __rintf (float __x) throw (); | |
1711 | extern float nextafterf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __nextafterf (float __x, float __y) throw () __attribute__ ((__const__)); | |
1712 | extern float nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__)); extern float __nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__)); | |
1713 | extern float remainderf (float __x, float __y) throw (); extern float __remainderf (float __x, float __y) throw (); | |
1714 | extern float scalbnf (float __x, int __n) throw (); extern float __scalbnf (float __x, int __n) throw (); | |
1715 | extern int ilogbf (float __x) throw (); extern int __ilogbf (float __x) throw (); | |
1716 | extern float scalblnf (float __x, long int __n) throw (); extern float __scalblnf (float __x, long int __n) throw (); | |
1717 | extern float nearbyintf (float __x) throw (); extern float __nearbyintf (float __x) throw (); | |
1718 | extern float roundf (float __x) throw () __attribute__ ((__const__)); extern float __roundf (float __x) throw () __attribute__ ((__const__)); | |
1719 | extern float truncf (float __x) throw () __attribute__ ((__const__)); extern float __truncf (float __x) throw () __attribute__ ((__const__)); | |
1720 | extern float remquof (float __x, float __y, int *__quo) throw (); extern float __remquof (float __x, float __y, int *__quo) throw (); | |
1721 | extern long int lrintf (float __x) throw (); extern long int __lrintf (float __x) throw (); | |
1722 | extern long long int llrintf (float __x) throw (); extern long long int __llrintf (float __x) throw (); | |
1723 | extern long int lroundf (float __x) throw (); extern long int __lroundf (float __x) throw (); | |
1724 | extern long long int llroundf (float __x) throw (); extern long long int __llroundf (float __x) throw (); | |
1725 | extern float fdimf (float __x, float __y) throw (); extern float __fdimf (float __x, float __y) throw (); | |
1726 | extern float fmaxf (float __x, float __y) throw (); extern float __fmaxf (float __x, float __y) throw (); | |
1727 | extern float fminf (float __x, float __y) throw (); extern float __fminf (float __x, float __y) throw (); | |
1728 | extern int __fpclassifyf (float __value) throw () | |
1729 | __attribute__ ((__const__)); | |
1730 | extern int __signbitf (float __value) throw () | |
1731 | __attribute__ ((__const__)); | |
1732 | extern float fmaf (float __x, float __y, float __z) throw (); extern float __fmaf (float __x, float __y, float __z) throw (); | |
1733 | extern float scalbf (float __x, float __n) throw (); extern float __scalbf (float __x, float __n) throw (); | |
1734 | extern long double acosl (long double __x) throw (); extern long double __acosl (long double __x) throw (); | |
1735 | extern long double asinl (long double __x) throw (); extern long double __asinl (long double __x) throw (); | |
1736 | extern long double atanl (long double __x) throw (); extern long double __atanl (long double __x) throw (); | |
1737 | extern long double atan2l (long double __y, long double __x) throw (); extern long double __atan2l (long double __y, long double __x) throw (); | |
1738 | extern long double cosl (long double __x) throw (); extern long double __cosl (long double __x) throw (); | |
1739 | extern long double sinl (long double __x) throw (); extern long double __sinl (long double __x) throw (); | |
1740 | extern long double tanl (long double __x) throw (); extern long double __tanl (long double __x) throw (); | |
1741 | extern long double coshl (long double __x) throw (); extern long double __coshl (long double __x) throw (); | |
1742 | extern long double sinhl (long double __x) throw (); extern long double __sinhl (long double __x) throw (); | |
1743 | extern long double tanhl (long double __x) throw (); extern long double __tanhl (long double __x) throw (); | |
1744 | extern void sincosl (long double __x, long double *__sinx, long double *__cosx) throw (); extern void __sincosl (long double __x, long double *__sinx, long double *__cosx) throw (); | |
1745 | extern long double acoshl (long double __x) throw (); extern long double __acoshl (long double __x) throw (); | |
1746 | extern long double asinhl (long double __x) throw (); extern long double __asinhl (long double __x) throw (); | |
1747 | extern long double atanhl (long double __x) throw (); extern long double __atanhl (long double __x) throw (); | |
1748 | extern long double expl (long double __x) throw (); extern long double __expl (long double __x) throw (); | |
1749 | extern long double frexpl (long double __x, int *__exponent) throw (); extern long double __frexpl (long double __x, int *__exponent) throw (); | |
1750 | extern long double ldexpl (long double __x, int __exponent) throw (); extern long double __ldexpl (long double __x, int __exponent) throw (); | |
1751 | extern long double logl (long double __x) throw (); extern long double __logl (long double __x) throw (); | |
1752 | extern long double log10l (long double __x) throw (); extern long double __log10l (long double __x) throw (); | |
1753 | extern long double modfl (long double __x, long double *__iptr) throw (); extern long double __modfl (long double __x, long double *__iptr) throw (); | |
1754 | extern long double exp10l (long double __x) throw (); extern long double __exp10l (long double __x) throw (); | |
1755 | extern long double pow10l (long double __x) throw (); extern long double __pow10l (long double __x) throw (); | |
1756 | extern long double expm1l (long double __x) throw (); extern long double __expm1l (long double __x) throw (); | |
1757 | extern long double log1pl (long double __x) throw (); extern long double __log1pl (long double __x) throw (); | |
1758 | extern long double logbl (long double __x) throw (); extern long double __logbl (long double __x) throw (); | |
1759 | extern long double exp2l (long double __x) throw (); extern long double __exp2l (long double __x) throw (); | |
1760 | extern long double log2l (long double __x) throw (); extern long double __log2l (long double __x) throw (); | |
1761 | extern long double powl (long double __x, long double __y) throw (); extern long double __powl (long double __x, long double __y) throw (); | |
1762 | extern long double sqrtl (long double __x) throw (); extern long double __sqrtl (long double __x) throw (); | |
1763 | extern long double hypotl (long double __x, long double __y) throw (); extern long double __hypotl (long double __x, long double __y) throw (); | |
1764 | extern long double cbrtl (long double __x) throw (); extern long double __cbrtl (long double __x) throw (); | |
1765 | extern long double ceill (long double __x) throw () __attribute__ ((__const__)); extern long double __ceill (long double __x) throw () __attribute__ ((__const__)); | |
1766 | extern long double fabsl (long double __x) throw () __attribute__ ((__const__)); extern long double __fabsl (long double __x) throw () __attribute__ ((__const__)); | |
1767 | extern long double floorl (long double __x) throw () __attribute__ ((__const__)); extern long double __floorl (long double __x) throw () __attribute__ ((__const__)); | |
1768 | extern long double fmodl (long double __x, long double __y) throw (); extern long double __fmodl (long double __x, long double __y) throw (); | |
1769 | extern int __isinfl (long double __value) throw () __attribute__ ((__const__)); | |
1770 | extern int __finitel (long double __value) throw () __attribute__ ((__const__)); | |
1771 | extern int isinfl (long double __value) throw () __attribute__ ((__const__)); | |
1772 | extern int finitel (long double __value) throw () __attribute__ ((__const__)); | |
1773 | extern long double dreml (long double __x, long double __y) throw (); extern long double __dreml (long double __x, long double __y) throw (); | |
1774 | extern long double significandl (long double __x) throw (); extern long double __significandl (long double __x) throw (); | |
1775 | extern long double copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
1776 | extern long double nanl (__const char *__tagb) throw () __attribute__ ((__const__)); extern long double __nanl (__const char *__tagb) throw () __attribute__ ((__const__)); | |
1777 | extern int __isnanl (long double __value) throw () __attribute__ ((__const__)); | |
1778 | extern int isnanl (long double __value) throw () __attribute__ ((__const__)); | |
1779 | extern long double j0l (long double) throw (); extern long double __j0l (long double) throw (); | |
1780 | extern long double j1l (long double) throw (); extern long double __j1l (long double) throw (); | |
1781 | extern long double jnl (int, long double) throw (); extern long double __jnl (int, long double) throw (); | |
1782 | extern long double y0l (long double) throw (); extern long double __y0l (long double) throw (); | |
1783 | extern long double y1l (long double) throw (); extern long double __y1l (long double) throw (); | |
1784 | extern long double ynl (int, long double) throw (); extern long double __ynl (int, long double) throw (); | |
1785 | extern long double erfl (long double) throw (); extern long double __erfl (long double) throw (); | |
1786 | extern long double erfcl (long double) throw (); extern long double __erfcl (long double) throw (); | |
1787 | extern long double lgammal (long double) throw (); extern long double __lgammal (long double) throw (); | |
1788 | extern long double tgammal (long double) throw (); extern long double __tgammal (long double) throw (); | |
1789 | extern long double gammal (long double) throw (); extern long double __gammal (long double) throw (); | |
1790 | extern long double lgammal_r (long double, int *__signgamp) throw (); extern long double __lgammal_r (long double, int *__signgamp) throw (); | |
1791 | extern long double rintl (long double __x) throw (); extern long double __rintl (long double __x) throw (); | |
1792 | extern long double nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
1793 | extern long double nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__)); | |
1794 | extern long double remainderl (long double __x, long double __y) throw (); extern long double __remainderl (long double __x, long double __y) throw (); | |
1795 | extern long double scalbnl (long double __x, int __n) throw (); extern long double __scalbnl (long double __x, int __n) throw (); | |
1796 | extern int ilogbl (long double __x) throw (); extern int __ilogbl (long double __x) throw (); | |
1797 | extern long double scalblnl (long double __x, long int __n) throw (); extern long double __scalblnl (long double __x, long int __n) throw (); | |
1798 | extern long double nearbyintl (long double __x) throw (); extern long double __nearbyintl (long double __x) throw (); | |
1799 | extern long double roundl (long double __x) throw () __attribute__ ((__const__)); extern long double __roundl (long double __x) throw () __attribute__ ((__const__)); | |
1800 | extern long double truncl (long double __x) throw () __attribute__ ((__const__)); extern long double __truncl (long double __x) throw () __attribute__ ((__const__)); | |
1801 | extern long double remquol (long double __x, long double __y, int *__quo) throw (); extern long double __remquol (long double __x, long double __y, int *__quo) throw (); | |
1802 | extern long int lrintl (long double __x) throw (); extern long int __lrintl (long double __x) throw (); | |
1803 | extern long long int llrintl (long double __x) throw (); extern long long int __llrintl (long double __x) throw (); | |
1804 | extern long int lroundl (long double __x) throw (); extern long int __lroundl (long double __x) throw (); | |
1805 | extern long long int llroundl (long double __x) throw (); extern long long int __llroundl (long double __x) throw (); | |
1806 | extern long double fdiml (long double __x, long double __y) throw (); extern long double __fdiml (long double __x, long double __y) throw (); | |
1807 | extern long double fmaxl (long double __x, long double __y) throw (); extern long double __fmaxl (long double __x, long double __y) throw (); | |
1808 | extern long double fminl (long double __x, long double __y) throw (); extern long double __fminl (long double __x, long double __y) throw (); | |
1809 | extern int __fpclassifyl (long double __value) throw () | |
1810 | __attribute__ ((__const__)); | |
1811 | extern int __signbitl (long double __value) throw () | |
1812 | __attribute__ ((__const__)); | |
1813 | extern long double fmal (long double __x, long double __y, long double __z) throw (); extern long double __fmal (long double __x, long double __y, long double __z) throw (); | |
1814 | extern long double scalbl (long double __x, long double __n) throw (); extern long double __scalbl (long double __x, long double __n) throw (); | |
1815 | extern int signgam; | |
1816 | enum | |
1817 | { | |
1818 | FP_NAN, | |
1819 | FP_INFINITE, | |
1820 | FP_ZERO, | |
1821 | FP_SUBNORMAL, | |
1822 | FP_NORMAL | |
1823 | }; | |
1824 | typedef enum | |
1825 | { | |
1826 | _IEEE_ = -1, | |
1827 | _SVID_, | |
1828 | _XOPEN_, | |
1829 | _POSIX_, | |
1830 | _ISOC_ | |
1831 | } _LIB_VERSION_TYPE; | |
1832 | extern _LIB_VERSION_TYPE _LIB_VERSION; | |
1833 | struct __exception | |
1834 | { | |
1835 | int type; | |
1836 | char *name; | |
1837 | double arg1; | |
1838 | double arg2; | |
1839 | double retval; | |
1840 | }; | |
1841 | extern int matherr (struct __exception *__exc) throw (); | |
1842 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1843 | __signbitf (float __x) throw () | |
1844 | { | |
1845 | __extension__ union { float __f; int __i; } __u = { __f: __x }; | |
1846 | return __u.__i < 0; | |
1847 | } | |
1848 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1849 | __signbit (double __x) throw () | |
1850 | { | |
1851 | __extension__ union { double __d; int __i[2]; } __u = { __d: __x }; | |
1852 | return __u.__i[1] < 0; | |
1853 | } | |
1854 | extern __inline __attribute__ ((__gnu_inline__)) int | |
1855 | __signbitl (long double __x) throw () | |
1856 | { | |
1857 | __extension__ union { long double __l; int __i[3]; } __u = { __l: __x }; | |
1858 | return (__u.__i[2] & 0x8000) != 0; | |
1859 | } | |
1860 | } | |
1861 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
1862 | template<typename _Tp> | |
1863 | _Tp __cmath_power(_Tp, unsigned int); | |
1864 | template<typename _Tp> | |
1865 | inline _Tp | |
1866 | __pow_helper(_Tp __x, int __n) | |
1867 | { | |
1868 | return __n < 0 | |
1869 | ? _Tp(1)/__cmath_power(__x, -__n) | |
1870 | : __cmath_power(__x, __n); | |
1871 | } | |
1872 | inline double | |
1873 | abs(double __x) | |
1874 | { return __builtin_fabs(__x); } | |
1875 | inline float | |
1876 | abs(float __x) | |
1877 | { return __builtin_fabsf(__x); } | |
1878 | inline long double | |
1879 | abs(long double __x) | |
1880 | { return __builtin_fabsl(__x); } | |
1881 | using ::acos; | |
1882 | inline float | |
1883 | acos(float __x) | |
1884 | { return __builtin_acosf(__x); } | |
1885 | inline long double | |
1886 | acos(long double __x) | |
1887 | { return __builtin_acosl(__x); } | |
1888 | template<typename _Tp> | |
1889 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1890 | double>::__type | |
1891 | acos(_Tp __x) | |
1892 | { return __builtin_acos(__x); } | |
1893 | using ::asin; | |
1894 | inline float | |
1895 | asin(float __x) | |
1896 | { return __builtin_asinf(__x); } | |
1897 | inline long double | |
1898 | asin(long double __x) | |
1899 | { return __builtin_asinl(__x); } | |
1900 | template<typename _Tp> | |
1901 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1902 | double>::__type | |
1903 | asin(_Tp __x) | |
1904 | { return __builtin_asin(__x); } | |
1905 | using ::atan; | |
1906 | inline float | |
1907 | atan(float __x) | |
1908 | { return __builtin_atanf(__x); } | |
1909 | inline long double | |
1910 | atan(long double __x) | |
1911 | { return __builtin_atanl(__x); } | |
1912 | template<typename _Tp> | |
1913 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1914 | double>::__type | |
1915 | atan(_Tp __x) | |
1916 | { return __builtin_atan(__x); } | |
1917 | using ::atan2; | |
1918 | inline float | |
1919 | atan2(float __y, float __x) | |
1920 | { return __builtin_atan2f(__y, __x); } | |
1921 | inline long double | |
1922 | atan2(long double __y, long double __x) | |
1923 | { return __builtin_atan2l(__y, __x); } | |
1924 | template<typename _Tp, typename _Up> | |
1925 | inline | |
1926 | typename __gnu_cxx::__promote_2< | |
1927 | typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value | |
1928 | && __is_arithmetic<_Up>::__value, | |
1929 | _Tp>::__type, _Up>::__type | |
1930 | atan2(_Tp __y, _Up __x) | |
1931 | { | |
1932 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1933 | return atan2(__type(__y), __type(__x)); | |
1934 | } | |
1935 | using ::ceil; | |
1936 | inline float | |
1937 | ceil(float __x) | |
1938 | { return __builtin_ceilf(__x); } | |
1939 | inline long double | |
1940 | ceil(long double __x) | |
1941 | { return __builtin_ceill(__x); } | |
1942 | template<typename _Tp> | |
1943 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1944 | double>::__type | |
1945 | ceil(_Tp __x) | |
1946 | { return __builtin_ceil(__x); } | |
1947 | using ::cos; | |
1948 | inline float | |
1949 | cos(float __x) | |
1950 | { return __builtin_cosf(__x); } | |
1951 | inline long double | |
1952 | cos(long double __x) | |
1953 | { return __builtin_cosl(__x); } | |
1954 | template<typename _Tp> | |
1955 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1956 | double>::__type | |
1957 | cos(_Tp __x) | |
1958 | { return __builtin_cos(__x); } | |
1959 | using ::cosh; | |
1960 | inline float | |
1961 | cosh(float __x) | |
1962 | { return __builtin_coshf(__x); } | |
1963 | inline long double | |
1964 | cosh(long double __x) | |
1965 | { return __builtin_coshl(__x); } | |
1966 | template<typename _Tp> | |
1967 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1968 | double>::__type | |
1969 | cosh(_Tp __x) | |
1970 | { return __builtin_cosh(__x); } | |
1971 | using ::exp; | |
1972 | inline float | |
1973 | exp(float __x) | |
1974 | { return __builtin_expf(__x); } | |
1975 | inline long double | |
1976 | exp(long double __x) | |
1977 | { return __builtin_expl(__x); } | |
1978 | template<typename _Tp> | |
1979 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1980 | double>::__type | |
1981 | exp(_Tp __x) | |
1982 | { return __builtin_exp(__x); } | |
1983 | using ::fabs; | |
1984 | inline float | |
1985 | fabs(float __x) | |
1986 | { return __builtin_fabsf(__x); } | |
1987 | inline long double | |
1988 | fabs(long double __x) | |
1989 | { return __builtin_fabsl(__x); } | |
1990 | template<typename _Tp> | |
1991 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1992 | double>::__type | |
1993 | fabs(_Tp __x) | |
1994 | { return __builtin_fabs(__x); } | |
1995 | using ::floor; | |
1996 | inline float | |
1997 | floor(float __x) | |
1998 | { return __builtin_floorf(__x); } | |
1999 | inline long double | |
2000 | floor(long double __x) | |
2001 | { return __builtin_floorl(__x); } | |
2002 | template<typename _Tp> | |
2003 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2004 | double>::__type | |
2005 | floor(_Tp __x) | |
2006 | { return __builtin_floor(__x); } | |
2007 | using ::fmod; | |
2008 | inline float | |
2009 | fmod(float __x, float __y) | |
2010 | { return __builtin_fmodf(__x, __y); } | |
2011 | inline long double | |
2012 | fmod(long double __x, long double __y) | |
2013 | { return __builtin_fmodl(__x, __y); } | |
2014 | using ::frexp; | |
2015 | inline float | |
2016 | frexp(float __x, int* __exp) | |
2017 | { return __builtin_frexpf(__x, __exp); } | |
2018 | inline long double | |
2019 | frexp(long double __x, int* __exp) | |
2020 | { return __builtin_frexpl(__x, __exp); } | |
2021 | template<typename _Tp> | |
2022 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2023 | double>::__type | |
2024 | frexp(_Tp __x, int* __exp) | |
2025 | { return __builtin_frexp(__x, __exp); } | |
2026 | using ::ldexp; | |
2027 | inline float | |
2028 | ldexp(float __x, int __exp) | |
2029 | { return __builtin_ldexpf(__x, __exp); } | |
2030 | inline long double | |
2031 | ldexp(long double __x, int __exp) | |
2032 | { return __builtin_ldexpl(__x, __exp); } | |
2033 | template<typename _Tp> | |
2034 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2035 | double>::__type | |
2036 | ldexp(_Tp __x, int __exp) | |
2037 | { return __builtin_ldexp(__x, __exp); } | |
2038 | using ::log; | |
2039 | inline float | |
2040 | log(float __x) | |
2041 | { return __builtin_logf(__x); } | |
2042 | inline long double | |
2043 | log(long double __x) | |
2044 | { return __builtin_logl(__x); } | |
2045 | template<typename _Tp> | |
2046 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2047 | double>::__type | |
2048 | log(_Tp __x) | |
2049 | { return __builtin_log(__x); } | |
2050 | using ::log10; | |
2051 | inline float | |
2052 | log10(float __x) | |
2053 | { return __builtin_log10f(__x); } | |
2054 | inline long double | |
2055 | log10(long double __x) | |
2056 | { return __builtin_log10l(__x); } | |
2057 | template<typename _Tp> | |
2058 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2059 | double>::__type | |
2060 | log10(_Tp __x) | |
2061 | { return __builtin_log10(__x); } | |
2062 | using ::modf; | |
2063 | inline float | |
2064 | modf(float __x, float* __iptr) | |
2065 | { return __builtin_modff(__x, __iptr); } | |
2066 | inline long double | |
2067 | modf(long double __x, long double* __iptr) | |
2068 | { return __builtin_modfl(__x, __iptr); } | |
2069 | using ::pow; | |
2070 | inline float | |
2071 | pow(float __x, float __y) | |
2072 | { return __builtin_powf(__x, __y); } | |
2073 | inline long double | |
2074 | pow(long double __x, long double __y) | |
2075 | { return __builtin_powl(__x, __y); } | |
2076 | inline double | |
2077 | pow(double __x, int __i) | |
2078 | { return __builtin_powi(__x, __i); } | |
2079 | inline float | |
2080 | pow(float __x, int __n) | |
2081 | { return __builtin_powif(__x, __n); } | |
2082 | inline long double | |
2083 | pow(long double __x, int __n) | |
2084 | { return __builtin_powil(__x, __n); } | |
2085 | template<typename _Tp, typename _Up> | |
2086 | inline | |
2087 | typename __gnu_cxx::__promote_2< | |
2088 | typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value | |
2089 | && __is_arithmetic<_Up>::__value, | |
2090 | _Tp>::__type, _Up>::__type | |
2091 | pow(_Tp __x, _Up __y) | |
2092 | { | |
2093 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
2094 | return pow(__type(__x), __type(__y)); | |
2095 | } | |
2096 | using ::sin; | |
2097 | inline float | |
2098 | sin(float __x) | |
2099 | { return __builtin_sinf(__x); } | |
2100 | inline long double | |
2101 | sin(long double __x) | |
2102 | { return __builtin_sinl(__x); } | |
2103 | template<typename _Tp> | |
2104 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2105 | double>::__type | |
2106 | sin(_Tp __x) | |
2107 | { return __builtin_sin(__x); } | |
2108 | using ::sinh; | |
2109 | inline float | |
2110 | sinh(float __x) | |
2111 | { return __builtin_sinhf(__x); } | |
2112 | inline long double | |
2113 | sinh(long double __x) | |
2114 | { return __builtin_sinhl(__x); } | |
2115 | template<typename _Tp> | |
2116 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2117 | double>::__type | |
2118 | sinh(_Tp __x) | |
2119 | { return __builtin_sinh(__x); } | |
2120 | using ::sqrt; | |
2121 | inline float | |
2122 | sqrt(float __x) | |
2123 | { return __builtin_sqrtf(__x); } | |
2124 | inline long double | |
2125 | sqrt(long double __x) | |
2126 | { return __builtin_sqrtl(__x); } | |
2127 | template<typename _Tp> | |
2128 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2129 | double>::__type | |
2130 | sqrt(_Tp __x) | |
2131 | { return __builtin_sqrt(__x); } | |
2132 | using ::tan; | |
2133 | inline float | |
2134 | tan(float __x) | |
2135 | { return __builtin_tanf(__x); } | |
2136 | inline long double | |
2137 | tan(long double __x) | |
2138 | { return __builtin_tanl(__x); } | |
2139 | template<typename _Tp> | |
2140 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2141 | double>::__type | |
2142 | tan(_Tp __x) | |
2143 | { return __builtin_tan(__x); } | |
2144 | using ::tanh; | |
2145 | inline float | |
2146 | tanh(float __x) | |
2147 | { return __builtin_tanhf(__x); } | |
2148 | inline long double | |
2149 | tanh(long double __x) | |
2150 | { return __builtin_tanhl(__x); } | |
2151 | template<typename _Tp> | |
2152 | inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
2153 | double>::__type | |
2154 | tanh(_Tp __x) | |
2155 | { return __builtin_tanh(__x); } | |
2156 | } | |
2157 | namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { | |
2158 | template<typename _Tp> | |
2159 | inline int | |
2160 | __capture_fpclassify(_Tp __f) { return (sizeof (__f) == sizeof (float) ? __fpclassifyf (__f) : sizeof (__f) == sizeof (double) ? __fpclassify (__f) : __fpclassifyl (__f)); } | |
2161 | } | |
2162 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
2163 | template<typename _Tp> | |
2164 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2165 | int>::__type | |
2166 | fpclassify(_Tp __f) | |
2167 | { | |
2168 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2169 | return ::__gnu_cxx::__capture_fpclassify(__type(__f)); | |
2170 | } | |
2171 | template<typename _Tp> | |
2172 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2173 | int>::__type | |
2174 | isfinite(_Tp __f) | |
2175 | { | |
2176 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2177 | return __builtin_isfinite(__type(__f)); | |
2178 | } | |
2179 | template<typename _Tp> | |
2180 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2181 | int>::__type | |
2182 | isinf(_Tp __f) | |
2183 | { | |
2184 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2185 | return __builtin_isinf(__type(__f)); | |
2186 | } | |
2187 | template<typename _Tp> | |
2188 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2189 | int>::__type | |
2190 | isnan(_Tp __f) | |
2191 | { | |
2192 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2193 | return __builtin_isnan(__type(__f)); | |
2194 | } | |
2195 | template<typename _Tp> | |
2196 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2197 | int>::__type | |
2198 | isnormal(_Tp __f) | |
2199 | { | |
2200 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2201 | return __builtin_isnormal(__type(__f)); | |
2202 | } | |
2203 | template<typename _Tp> | |
2204 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2205 | int>::__type | |
2206 | signbit(_Tp __f) | |
2207 | { | |
2208 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2209 | return __builtin_signbit(__type(__f)); | |
2210 | } | |
2211 | template<typename _Tp> | |
2212 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2213 | int>::__type | |
2214 | isgreater(_Tp __f1, _Tp __f2) | |
2215 | { | |
2216 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2217 | return __builtin_isgreater(__type(__f1), __type(__f2)); | |
2218 | } | |
2219 | template<typename _Tp> | |
2220 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2221 | int>::__type | |
2222 | isgreaterequal(_Tp __f1, _Tp __f2) | |
2223 | { | |
2224 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2225 | return __builtin_isgreaterequal(__type(__f1), __type(__f2)); | |
2226 | } | |
2227 | template<typename _Tp> | |
2228 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2229 | int>::__type | |
2230 | isless(_Tp __f1, _Tp __f2) | |
2231 | { | |
2232 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2233 | return __builtin_isless(__type(__f1), __type(__f2)); | |
2234 | } | |
2235 | template<typename _Tp> | |
2236 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2237 | int>::__type | |
2238 | islessequal(_Tp __f1, _Tp __f2) | |
2239 | { | |
2240 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2241 | return __builtin_islessequal(__type(__f1), __type(__f2)); | |
2242 | } | |
2243 | template<typename _Tp> | |
2244 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2245 | int>::__type | |
2246 | islessgreater(_Tp __f1, _Tp __f2) | |
2247 | { | |
2248 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2249 | return __builtin_islessgreater(__type(__f1), __type(__f2)); | |
2250 | } | |
2251 | template<typename _Tp> | |
2252 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, | |
2253 | int>::__type | |
2254 | isunordered(_Tp __f1, _Tp __f2) | |
2255 | { | |
2256 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
2257 | return __builtin_isunordered(__type(__f1), __type(__f2)); | |
2258 | } | |
2259 | } | |
2260 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
2261 | template<typename _Tp> | |
2262 | inline _Tp | |
2263 | __cmath_power(_Tp __x, unsigned int __n) | |
2264 | { | |
2265 | _Tp __y = __n % 2 ? __x : _Tp(1); | |
2266 | while (__n >>= 1) | |
2267 | { | |
2268 | __x = __x * __x; | |
2269 | if (__n % 2) | |
2270 | __y = __y * __x; | |
2271 | } | |
2272 | return __y; | |
2273 | } | |
2274 | } | |
2275 | extern "C" { | |
2276 | struct tm | |
2277 | { | |
2278 | int tm_sec; | |
2279 | int tm_min; | |
2280 | int tm_hour; | |
2281 | int tm_mday; | |
2282 | int tm_mon; | |
2283 | int tm_year; | |
2284 | int tm_wday; | |
2285 | int tm_yday; | |
2286 | int tm_isdst; | |
2287 | long int tm_gmtoff; | |
2288 | __const char *tm_zone; | |
2289 | }; | |
2290 | struct itimerspec | |
2291 | { | |
2292 | struct timespec it_interval; | |
2293 | struct timespec it_value; | |
2294 | }; | |
2295 | struct sigevent; | |
2296 | extern clock_t clock (void) throw (); | |
2297 | extern time_t time (time_t *__timer) throw (); | |
2298 | extern double difftime (time_t __time1, time_t __time0) | |
2299 | throw () __attribute__ ((__const__)); | |
2300 | extern time_t mktime (struct tm *__tp) throw (); | |
2301 | extern size_t strftime (char *__restrict __s, size_t __maxsize, | |
2302 | __const char *__restrict __format, | |
2303 | __const struct tm *__restrict __tp) throw (); | |
2304 | extern char *strptime (__const char *__restrict __s, | |
2305 | __const char *__restrict __fmt, struct tm *__tp) | |
2306 | throw (); | |
2307 | extern size_t strftime_l (char *__restrict __s, size_t __maxsize, | |
2308 | __const char *__restrict __format, | |
2309 | __const struct tm *__restrict __tp, | |
2310 | __locale_t __loc) throw (); | |
2311 | extern char *strptime_l (__const char *__restrict __s, | |
2312 | __const char *__restrict __fmt, struct tm *__tp, | |
2313 | __locale_t __loc) throw (); | |
2314 | extern struct tm *gmtime (__const time_t *__timer) throw (); | |
2315 | extern struct tm *localtime (__const time_t *__timer) throw (); | |
2316 | extern struct tm *gmtime_r (__const time_t *__restrict __timer, | |
2317 | struct tm *__restrict __tp) throw (); | |
2318 | extern struct tm *localtime_r (__const time_t *__restrict __timer, | |
2319 | struct tm *__restrict __tp) throw (); | |
2320 | extern char *asctime (__const struct tm *__tp) throw (); | |
2321 | extern char *ctime (__const time_t *__timer) throw (); | |
2322 | extern char *asctime_r (__const struct tm *__restrict __tp, | |
2323 | char *__restrict __buf) throw (); | |
2324 | extern char *ctime_r (__const time_t *__restrict __timer, | |
2325 | char *__restrict __buf) throw (); | |
2326 | extern char *__tzname[2]; | |
2327 | extern int __daylight; | |
2328 | extern long int __timezone; | |
2329 | extern char *tzname[2]; | |
2330 | extern void tzset (void) throw (); | |
2331 | extern int daylight; | |
2332 | extern long int timezone; | |
2333 | extern int stime (__const time_t *__when) throw (); | |
2334 | extern time_t timegm (struct tm *__tp) throw (); | |
2335 | extern time_t timelocal (struct tm *__tp) throw (); | |
2336 | extern int dysize (int __year) throw () __attribute__ ((__const__)); | |
2337 | extern int nanosleep (__const struct timespec *__requested_time, | |
2338 | struct timespec *__remaining); | |
2339 | extern int clock_getres (clockid_t __clock_id, struct timespec *__res) throw (); | |
2340 | extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) throw (); | |
2341 | extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp) | |
2342 | throw (); | |
2343 | extern int clock_nanosleep (clockid_t __clock_id, int __flags, | |
2344 | __const struct timespec *__req, | |
2345 | struct timespec *__rem); | |
2346 | extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) throw (); | |
2347 | extern int timer_create (clockid_t __clock_id, | |
2348 | struct sigevent *__restrict __evp, | |
2349 | timer_t *__restrict __timerid) throw (); | |
2350 | extern int timer_delete (timer_t __timerid) throw (); | |
2351 | extern int timer_settime (timer_t __timerid, int __flags, | |
2352 | __const struct itimerspec *__restrict __value, | |
2353 | struct itimerspec *__restrict __ovalue) throw (); | |
2354 | extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) | |
2355 | throw (); | |
2356 | extern int timer_getoverrun (timer_t __timerid) throw (); | |
2357 | extern int getdate_err; | |
2358 | extern struct tm *getdate (__const char *__string); | |
2359 | extern int getdate_r (__const char *__restrict __string, | |
2360 | struct tm *__restrict __resbufp); | |
2361 | } | |
2362 | namespace std __attribute__ ((__visibility__ ("default"))) { | |
2363 | using ::clock_t; | |
2364 | using ::time_t; | |
2365 | using ::tm; | |
2366 | using ::clock; | |
2367 | using ::difftime; | |
2368 | using ::mktime; | |
2369 | using ::time; | |
2370 | using ::asctime; | |
2371 | using ::ctime; | |
2372 | using ::gmtime; | |
2373 | using ::localtime; | |
2374 | using ::strftime; | |
2375 | } | |
2376 | extern "C" { | |
2377 | struct timezone | |
2378 | { | |
2379 | int tz_minuteswest; | |
2380 | int tz_dsttime; | |
2381 | }; | |
2382 | typedef struct timezone *__restrict __timezone_ptr_t; | |
2383 | extern int gettimeofday (struct timeval *__restrict __tv, | |
2384 | __timezone_ptr_t __tz) throw () __attribute__ ((__nonnull__ (1))); | |
2385 | extern int settimeofday (__const struct timeval *__tv, | |
2386 | __const struct timezone *__tz) | |
2387 | throw () __attribute__ ((__nonnull__ (1))); | |
2388 | extern int adjtime (__const struct timeval *__delta, | |
2389 | struct timeval *__olddelta) throw (); | |
2390 | enum __itimer_which | |
2391 | { | |
2392 | ITIMER_REAL = 0, | |
2393 | ITIMER_VIRTUAL = 1, | |
2394 | ITIMER_PROF = 2 | |
2395 | }; | |
2396 | struct itimerval | |
2397 | { | |
2398 | struct timeval it_interval; | |
2399 | struct timeval it_value; | |
2400 | }; | |
2401 | typedef int __itimer_which_t; | |
2402 | extern int getitimer (__itimer_which_t __which, | |
2403 | struct itimerval *__value) throw (); | |
2404 | extern int setitimer (__itimer_which_t __which, | |
2405 | __const struct itimerval *__restrict __new, | |
2406 | struct itimerval *__restrict __old) throw (); | |
2407 | extern int utimes (__const char *__file, __const struct timeval __tvp[2]) | |
2408 | throw () __attribute__ ((__nonnull__ (1))); | |
2409 | extern int lutimes (__const char *__file, __const struct timeval __tvp[2]) | |
2410 | throw () __attribute__ ((__nonnull__ (1))); | |
2411 | extern int futimes (int __fd, __const struct timeval __tvp[2]) throw (); | |
2412 | extern int futimesat (int __fd, __const char *__file, | |
2413 | __const struct timeval __tvp[2]) throw (); | |
2414 | } | |
2415 | extern "C" { | |
2416 | typedef __intptr_t intptr_t; | |
2417 | typedef __socklen_t socklen_t; | |
2418 | extern int access (__const char *__name, int __type) throw () __attribute__ ((__nonnull__ (1))); | |
2419 | extern int euidaccess (__const char *__name, int __type) | |
2420 | throw () __attribute__ ((__nonnull__ (1))); | |
2421 | extern int eaccess (__const char *__name, int __type) | |
2422 | throw () __attribute__ ((__nonnull__ (1))); | |
2423 | extern int faccessat (int __fd, __const char *__file, int __type, int __flag) | |
2424 | throw () __attribute__ ((__nonnull__ (2))) ; | |
2425 | extern __off_t lseek (int __fd, __off_t __offset, int __whence) throw (); | |
2426 | extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) | |
2427 | throw (); | |
2428 | extern int close (int __fd); | |
2429 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ; | |
2430 | extern ssize_t write (int __fd, __const void *__buf, size_t __n) ; | |
2431 | extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, | |
2432 | __off_t __offset) ; | |
2433 | extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n, | |
2434 | __off_t __offset) ; | |
2435 | extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, | |
2436 | __off64_t __offset) ; | |
2437 | extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n, | |
2438 | __off64_t __offset) ; | |
2439 | extern int pipe (int __pipedes[2]) throw () ; | |
2440 | extern unsigned int alarm (unsigned int __seconds) throw (); | |
2441 | extern unsigned int sleep (unsigned int __seconds); | |
2442 | extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval) | |
2443 | throw (); | |
2444 | extern int usleep (__useconds_t __useconds); | |
2445 | extern int pause (void); | |
2446 | extern int chown (__const char *__file, __uid_t __owner, __gid_t __group) | |
2447 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2448 | extern int fchown (int __fd, __uid_t __owner, __gid_t __group) throw () ; | |
2449 | extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group) | |
2450 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2451 | extern int fchownat (int __fd, __const char *__file, __uid_t __owner, | |
2452 | __gid_t __group, int __flag) | |
2453 | throw () __attribute__ ((__nonnull__ (2))) ; | |
2454 | extern int chdir (__const char *__path) throw () __attribute__ ((__nonnull__ (1))) ; | |
2455 | extern int fchdir (int __fd) throw () ; | |
2456 | extern char *getcwd (char *__buf, size_t __size) throw () ; | |
2457 | extern char *get_current_dir_name (void) throw (); | |
2458 | extern char *getwd (char *__buf) | |
2459 | throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) ; | |
2460 | extern int dup (int __fd) throw () ; | |
2461 | extern int dup2 (int __fd, int __fd2) throw (); | |
2462 | extern char **__environ; | |
2463 | extern char **environ; | |
2464 | extern int execve (__const char *__path, char *__const __argv[], | |
2465 | char *__const __envp[]) throw () __attribute__ ((__nonnull__ (1))); | |
2466 | extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[]) | |
2467 | throw (); | |
2468 | extern int execv (__const char *__path, char *__const __argv[]) | |
2469 | throw () __attribute__ ((__nonnull__ (1))); | |
2470 | extern int execle (__const char *__path, __const char *__arg, ...) | |
2471 | throw () __attribute__ ((__nonnull__ (1))); | |
2472 | extern int execl (__const char *__path, __const char *__arg, ...) | |
2473 | throw () __attribute__ ((__nonnull__ (1))); | |
2474 | extern int execvp (__const char *__file, char *__const __argv[]) | |
2475 | throw () __attribute__ ((__nonnull__ (1))); | |
2476 | extern int execlp (__const char *__file, __const char *__arg, ...) | |
2477 | throw () __attribute__ ((__nonnull__ (1))); | |
2478 | extern int nice (int __inc) throw () ; | |
2479 | extern void _exit (int __status) __attribute__ ((__noreturn__)); | |
2480 | enum | |
2481 | { | |
2482 | _PC_LINK_MAX, | |
2483 | _PC_MAX_CANON, | |
2484 | _PC_MAX_INPUT, | |
2485 | _PC_NAME_MAX, | |
2486 | _PC_PATH_MAX, | |
2487 | _PC_PIPE_BUF, | |
2488 | _PC_CHOWN_RESTRICTED, | |
2489 | _PC_NO_TRUNC, | |
2490 | _PC_VDISABLE, | |
2491 | _PC_SYNC_IO, | |
2492 | _PC_ASYNC_IO, | |
2493 | _PC_PRIO_IO, | |
2494 | _PC_SOCK_MAXBUF, | |
2495 | _PC_FILESIZEBITS, | |
2496 | _PC_REC_INCR_XFER_SIZE, | |
2497 | _PC_REC_MAX_XFER_SIZE, | |
2498 | _PC_REC_MIN_XFER_SIZE, | |
2499 | _PC_REC_XFER_ALIGN, | |
2500 | _PC_ALLOC_SIZE_MIN, | |
2501 | _PC_SYMLINK_MAX, | |
2502 | _PC_2_SYMLINKS | |
2503 | }; | |
2504 | enum | |
2505 | { | |
2506 | _SC_ARG_MAX, | |
2507 | _SC_CHILD_MAX, | |
2508 | _SC_CLK_TCK, | |
2509 | _SC_NGROUPS_MAX, | |
2510 | _SC_OPEN_MAX, | |
2511 | _SC_STREAM_MAX, | |
2512 | _SC_TZNAME_MAX, | |
2513 | _SC_JOB_CONTROL, | |
2514 | _SC_SAVED_IDS, | |
2515 | _SC_REALTIME_SIGNALS, | |
2516 | _SC_PRIORITY_SCHEDULING, | |
2517 | _SC_TIMERS, | |
2518 | _SC_ASYNCHRONOUS_IO, | |
2519 | _SC_PRIORITIZED_IO, | |
2520 | _SC_SYNCHRONIZED_IO, | |
2521 | _SC_FSYNC, | |
2522 | _SC_MAPPED_FILES, | |
2523 | _SC_MEMLOCK, | |
2524 | _SC_MEMLOCK_RANGE, | |
2525 | _SC_MEMORY_PROTECTION, | |
2526 | _SC_MESSAGE_PASSING, | |
2527 | _SC_SEMAPHORES, | |
2528 | _SC_SHARED_MEMORY_OBJECTS, | |
2529 | _SC_AIO_LISTIO_MAX, | |
2530 | _SC_AIO_MAX, | |
2531 | _SC_AIO_PRIO_DELTA_MAX, | |
2532 | _SC_DELAYTIMER_MAX, | |
2533 | _SC_MQ_OPEN_MAX, | |
2534 | _SC_MQ_PRIO_MAX, | |
2535 | _SC_VERSION, | |
2536 | _SC_PAGESIZE, | |
2537 | _SC_RTSIG_MAX, | |
2538 | _SC_SEM_NSEMS_MAX, | |
2539 | _SC_SEM_VALUE_MAX, | |
2540 | _SC_SIGQUEUE_MAX, | |
2541 | _SC_TIMER_MAX, | |
2542 | _SC_BC_BASE_MAX, | |
2543 | _SC_BC_DIM_MAX, | |
2544 | _SC_BC_SCALE_MAX, | |
2545 | _SC_BC_STRING_MAX, | |
2546 | _SC_COLL_WEIGHTS_MAX, | |
2547 | _SC_EQUIV_CLASS_MAX, | |
2548 | _SC_EXPR_NEST_MAX, | |
2549 | _SC_LINE_MAX, | |
2550 | _SC_RE_DUP_MAX, | |
2551 | _SC_CHARCLASS_NAME_MAX, | |
2552 | _SC_2_VERSION, | |
2553 | _SC_2_C_BIND, | |
2554 | _SC_2_C_DEV, | |
2555 | _SC_2_FORT_DEV, | |
2556 | _SC_2_FORT_RUN, | |
2557 | _SC_2_SW_DEV, | |
2558 | _SC_2_LOCALEDEF, | |
2559 | _SC_PII, | |
2560 | _SC_PII_XTI, | |
2561 | _SC_PII_SOCKET, | |
2562 | _SC_PII_INTERNET, | |
2563 | _SC_PII_OSI, | |
2564 | _SC_POLL, | |
2565 | _SC_SELECT, | |
2566 | _SC_UIO_MAXIOV, | |
2567 | _SC_IOV_MAX = _SC_UIO_MAXIOV, | |
2568 | _SC_PII_INTERNET_STREAM, | |
2569 | _SC_PII_INTERNET_DGRAM, | |
2570 | _SC_PII_OSI_COTS, | |
2571 | _SC_PII_OSI_CLTS, | |
2572 | _SC_PII_OSI_M, | |
2573 | _SC_T_IOV_MAX, | |
2574 | _SC_THREADS, | |
2575 | _SC_THREAD_SAFE_FUNCTIONS, | |
2576 | _SC_GETGR_R_SIZE_MAX, | |
2577 | _SC_GETPW_R_SIZE_MAX, | |
2578 | _SC_LOGIN_NAME_MAX, | |
2579 | _SC_TTY_NAME_MAX, | |
2580 | _SC_THREAD_DESTRUCTOR_ITERATIONS, | |
2581 | _SC_THREAD_KEYS_MAX, | |
2582 | _SC_THREAD_STACK_MIN, | |
2583 | _SC_THREAD_THREADS_MAX, | |
2584 | _SC_THREAD_ATTR_STACKADDR, | |
2585 | _SC_THREAD_ATTR_STACKSIZE, | |
2586 | _SC_THREAD_PRIORITY_SCHEDULING, | |
2587 | _SC_THREAD_PRIO_INHERIT, | |
2588 | _SC_THREAD_PRIO_PROTECT, | |
2589 | _SC_THREAD_PROCESS_SHARED, | |
2590 | _SC_NPROCESSORS_CONF, | |
2591 | _SC_NPROCESSORS_ONLN, | |
2592 | _SC_PHYS_PAGES, | |
2593 | _SC_AVPHYS_PAGES, | |
2594 | _SC_ATEXIT_MAX, | |
2595 | _SC_PASS_MAX, | |
2596 | _SC_XOPEN_VERSION, | |
2597 | _SC_XOPEN_XCU_VERSION, | |
2598 | _SC_XOPEN_UNIX, | |
2599 | _SC_XOPEN_CRYPT, | |
2600 | _SC_XOPEN_ENH_I18N, | |
2601 | _SC_XOPEN_SHM, | |
2602 | _SC_2_CHAR_TERM, | |
2603 | _SC_2_C_VERSION, | |
2604 | _SC_2_UPE, | |
2605 | _SC_XOPEN_XPG2, | |
2606 | _SC_XOPEN_XPG3, | |
2607 | _SC_XOPEN_XPG4, | |
2608 | _SC_CHAR_BIT, | |
2609 | _SC_CHAR_MAX, | |
2610 | _SC_CHAR_MIN, | |
2611 | _SC_INT_MAX, | |
2612 | _SC_INT_MIN, | |
2613 | _SC_LONG_BIT, | |
2614 | _SC_WORD_BIT, | |
2615 | _SC_MB_LEN_MAX, | |
2616 | _SC_NZERO, | |
2617 | _SC_SSIZE_MAX, | |
2618 | _SC_SCHAR_MAX, | |
2619 | _SC_SCHAR_MIN, | |
2620 | _SC_SHRT_MAX, | |
2621 | _SC_SHRT_MIN, | |
2622 | _SC_UCHAR_MAX, | |
2623 | _SC_UINT_MAX, | |
2624 | _SC_ULONG_MAX, | |
2625 | _SC_USHRT_MAX, | |
2626 | _SC_NL_ARGMAX, | |
2627 | _SC_NL_LANGMAX, | |
2628 | _SC_NL_MSGMAX, | |
2629 | _SC_NL_NMAX, | |
2630 | _SC_NL_SETMAX, | |
2631 | _SC_NL_TEXTMAX, | |
2632 | _SC_XBS5_ILP32_OFF32, | |
2633 | _SC_XBS5_ILP32_OFFBIG, | |
2634 | _SC_XBS5_LP64_OFF64, | |
2635 | _SC_XBS5_LPBIG_OFFBIG, | |
2636 | _SC_XOPEN_LEGACY, | |
2637 | _SC_XOPEN_REALTIME, | |
2638 | _SC_XOPEN_REALTIME_THREADS, | |
2639 | _SC_ADVISORY_INFO, | |
2640 | _SC_BARRIERS, | |
2641 | _SC_BASE, | |
2642 | _SC_C_LANG_SUPPORT, | |
2643 | _SC_C_LANG_SUPPORT_R, | |
2644 | _SC_CLOCK_SELECTION, | |
2645 | _SC_CPUTIME, | |
2646 | _SC_THREAD_CPUTIME, | |
2647 | _SC_DEVICE_IO, | |
2648 | _SC_DEVICE_SPECIFIC, | |
2649 | _SC_DEVICE_SPECIFIC_R, | |
2650 | _SC_FD_MGMT, | |
2651 | _SC_FIFO, | |
2652 | _SC_PIPE, | |
2653 | _SC_FILE_ATTRIBUTES, | |
2654 | _SC_FILE_LOCKING, | |
2655 | _SC_FILE_SYSTEM, | |
2656 | _SC_MONOTONIC_CLOCK, | |
2657 | _SC_MULTI_PROCESS, | |
2658 | _SC_SINGLE_PROCESS, | |
2659 | _SC_NETWORKING, | |
2660 | _SC_READER_WRITER_LOCKS, | |
2661 | _SC_SPIN_LOCKS, | |
2662 | _SC_REGEXP, | |
2663 | _SC_REGEX_VERSION, | |
2664 | _SC_SHELL, | |
2665 | _SC_SIGNALS, | |
2666 | _SC_SPAWN, | |
2667 | _SC_SPORADIC_SERVER, | |
2668 | _SC_THREAD_SPORADIC_SERVER, | |
2669 | _SC_SYSTEM_DATABASE, | |
2670 | _SC_SYSTEM_DATABASE_R, | |
2671 | _SC_TIMEOUTS, | |
2672 | _SC_TYPED_MEMORY_OBJECTS, | |
2673 | _SC_USER_GROUPS, | |
2674 | _SC_USER_GROUPS_R, | |
2675 | _SC_2_PBS, | |
2676 | _SC_2_PBS_ACCOUNTING, | |
2677 | _SC_2_PBS_LOCATE, | |
2678 | _SC_2_PBS_MESSAGE, | |
2679 | _SC_2_PBS_TRACK, | |
2680 | _SC_SYMLOOP_MAX, | |
2681 | _SC_STREAMS, | |
2682 | _SC_2_PBS_CHECKPOINT, | |
2683 | _SC_V6_ILP32_OFF32, | |
2684 | _SC_V6_ILP32_OFFBIG, | |
2685 | _SC_V6_LP64_OFF64, | |
2686 | _SC_V6_LPBIG_OFFBIG, | |
2687 | _SC_HOST_NAME_MAX, | |
2688 | _SC_TRACE, | |
2689 | _SC_TRACE_EVENT_FILTER, | |
2690 | _SC_TRACE_INHERIT, | |
2691 | _SC_TRACE_LOG, | |
2692 | _SC_LEVEL1_ICACHE_SIZE, | |
2693 | _SC_LEVEL1_ICACHE_ASSOC, | |
2694 | _SC_LEVEL1_ICACHE_LINESIZE, | |
2695 | _SC_LEVEL1_DCACHE_SIZE, | |
2696 | _SC_LEVEL1_DCACHE_ASSOC, | |
2697 | _SC_LEVEL1_DCACHE_LINESIZE, | |
2698 | _SC_LEVEL2_CACHE_SIZE, | |
2699 | _SC_LEVEL2_CACHE_ASSOC, | |
2700 | _SC_LEVEL2_CACHE_LINESIZE, | |
2701 | _SC_LEVEL3_CACHE_SIZE, | |
2702 | _SC_LEVEL3_CACHE_ASSOC, | |
2703 | _SC_LEVEL3_CACHE_LINESIZE, | |
2704 | _SC_LEVEL4_CACHE_SIZE, | |
2705 | _SC_LEVEL4_CACHE_ASSOC, | |
2706 | _SC_LEVEL4_CACHE_LINESIZE, | |
2707 | _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50, | |
2708 | _SC_RAW_SOCKETS | |
2709 | }; | |
2710 | enum | |
2711 | { | |
2712 | _CS_PATH, | |
2713 | _CS_V6_WIDTH_RESTRICTED_ENVS, | |
2714 | _CS_GNU_LIBC_VERSION, | |
2715 | _CS_GNU_LIBPTHREAD_VERSION, | |
2716 | _CS_LFS_CFLAGS = 1000, | |
2717 | _CS_LFS_LDFLAGS, | |
2718 | _CS_LFS_LIBS, | |
2719 | _CS_LFS_LINTFLAGS, | |
2720 | _CS_LFS64_CFLAGS, | |
2721 | _CS_LFS64_LDFLAGS, | |
2722 | _CS_LFS64_LIBS, | |
2723 | _CS_LFS64_LINTFLAGS, | |
2724 | _CS_XBS5_ILP32_OFF32_CFLAGS = 1100, | |
2725 | _CS_XBS5_ILP32_OFF32_LDFLAGS, | |
2726 | _CS_XBS5_ILP32_OFF32_LIBS, | |
2727 | _CS_XBS5_ILP32_OFF32_LINTFLAGS, | |
2728 | _CS_XBS5_ILP32_OFFBIG_CFLAGS, | |
2729 | _CS_XBS5_ILP32_OFFBIG_LDFLAGS, | |
2730 | _CS_XBS5_ILP32_OFFBIG_LIBS, | |
2731 | _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, | |
2732 | _CS_XBS5_LP64_OFF64_CFLAGS, | |
2733 | _CS_XBS5_LP64_OFF64_LDFLAGS, | |
2734 | _CS_XBS5_LP64_OFF64_LIBS, | |
2735 | _CS_XBS5_LP64_OFF64_LINTFLAGS, | |
2736 | _CS_XBS5_LPBIG_OFFBIG_CFLAGS, | |
2737 | _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, | |
2738 | _CS_XBS5_LPBIG_OFFBIG_LIBS, | |
2739 | _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, | |
2740 | _CS_POSIX_V6_ILP32_OFF32_CFLAGS, | |
2741 | _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, | |
2742 | _CS_POSIX_V6_ILP32_OFF32_LIBS, | |
2743 | _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS, | |
2744 | _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, | |
2745 | _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, | |
2746 | _CS_POSIX_V6_ILP32_OFFBIG_LIBS, | |
2747 | _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS, | |
2748 | _CS_POSIX_V6_LP64_OFF64_CFLAGS, | |
2749 | _CS_POSIX_V6_LP64_OFF64_LDFLAGS, | |
2750 | _CS_POSIX_V6_LP64_OFF64_LIBS, | |
2751 | _CS_POSIX_V6_LP64_OFF64_LINTFLAGS, | |
2752 | _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, | |
2753 | _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, | |
2754 | _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, | |
2755 | _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS | |
2756 | }; | |
2757 | extern long int pathconf (__const char *__path, int __name) | |
2758 | throw () __attribute__ ((__nonnull__ (1))); | |
2759 | extern long int fpathconf (int __fd, int __name) throw (); | |
2760 | extern long int sysconf (int __name) throw (); | |
2761 | extern size_t confstr (int __name, char *__buf, size_t __len) throw (); | |
2762 | extern __pid_t getpid (void) throw (); | |
2763 | extern __pid_t getppid (void) throw (); | |
2764 | extern __pid_t getpgrp (void) throw (); | |
2765 | extern __pid_t __getpgid (__pid_t __pid) throw (); | |
2766 | extern __pid_t getpgid (__pid_t __pid) throw (); | |
2767 | extern int setpgid (__pid_t __pid, __pid_t __pgid) throw (); | |
2768 | extern int setpgrp (void) throw (); | |
2769 | extern __pid_t setsid (void) throw (); | |
2770 | extern __pid_t getsid (__pid_t __pid) throw (); | |
2771 | extern __uid_t getuid (void) throw (); | |
2772 | extern __uid_t geteuid (void) throw (); | |
2773 | extern __gid_t getgid (void) throw (); | |
2774 | extern __gid_t getegid (void) throw (); | |
2775 | extern int getgroups (int __size, __gid_t __list[]) throw () ; | |
2776 | extern int group_member (__gid_t __gid) throw (); | |
2777 | extern int setuid (__uid_t __uid) throw (); | |
2778 | extern int setreuid (__uid_t __ruid, __uid_t __euid) throw (); | |
2779 | extern int seteuid (__uid_t __uid) throw (); | |
2780 | extern int setgid (__gid_t __gid) throw (); | |
2781 | extern int setregid (__gid_t __rgid, __gid_t __egid) throw (); | |
2782 | extern int setegid (__gid_t __gid) throw (); | |
2783 | extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid) | |
2784 | throw (); | |
2785 | extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid) | |
2786 | throw (); | |
2787 | extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid) | |
2788 | throw (); | |
2789 | extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid) | |
2790 | throw (); | |
2791 | extern __pid_t fork (void) throw (); | |
2792 | extern __pid_t vfork (void) throw (); | |
2793 | extern char *ttyname (int __fd) throw (); | |
2794 | extern int ttyname_r (int __fd, char *__buf, size_t __buflen) | |
2795 | throw () __attribute__ ((__nonnull__ (2))) ; | |
2796 | extern int isatty (int __fd) throw (); | |
2797 | extern int ttyslot (void) throw (); | |
2798 | extern int link (__const char *__from, __const char *__to) | |
2799 | throw () __attribute__ ((__nonnull__ (1, 2))) ; | |
2800 | extern int linkat (int __fromfd, __const char *__from, int __tofd, | |
2801 | __const char *__to, int __flags) | |
2802 | throw () __attribute__ ((__nonnull__ (2, 4))) ; | |
2803 | extern int symlink (__const char *__from, __const char *__to) | |
2804 | throw () __attribute__ ((__nonnull__ (1, 2))) ; | |
2805 | extern ssize_t readlink (__const char *__restrict __path, | |
2806 | char *__restrict __buf, size_t __len) | |
2807 | throw () __attribute__ ((__nonnull__ (1, 2))) ; | |
2808 | extern int symlinkat (__const char *__from, int __tofd, | |
2809 | __const char *__to) throw () __attribute__ ((__nonnull__ (1, 3))) ; | |
2810 | extern ssize_t readlinkat (int __fd, __const char *__restrict __path, | |
2811 | char *__restrict __buf, size_t __len) | |
2812 | throw () __attribute__ ((__nonnull__ (2, 3))) ; | |
2813 | extern int unlink (__const char *__name) throw () __attribute__ ((__nonnull__ (1))); | |
2814 | extern int unlinkat (int __fd, __const char *__name, int __flag) | |
2815 | throw () __attribute__ ((__nonnull__ (2))); | |
2816 | extern int rmdir (__const char *__path) throw () __attribute__ ((__nonnull__ (1))); | |
2817 | extern __pid_t tcgetpgrp (int __fd) throw (); | |
2818 | extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) throw (); | |
2819 | extern char *getlogin (void); | |
2820 | extern int getlogin_r (char *__name, size_t __name_len) __attribute__ ((__nonnull__ (1))); | |
2821 | extern int setlogin (__const char *__name) throw () __attribute__ ((__nonnull__ (1))); | |
2822 | extern "C" { | |
2823 | extern char *optarg; | |
2824 | extern int optind; | |
2825 | extern int opterr; | |
2826 | extern int optopt; | |
2827 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) | |
2828 | throw (); | |
2829 | } | |
2830 | extern int gethostname (char *__name, size_t __len) throw () __attribute__ ((__nonnull__ (1))); | |
2831 | extern int sethostname (__const char *__name, size_t __len) | |
2832 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2833 | extern int sethostid (long int __id) throw () ; | |
2834 | extern int getdomainname (char *__name, size_t __len) | |
2835 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2836 | extern int setdomainname (__const char *__name, size_t __len) | |
2837 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2838 | extern int vhangup (void) throw (); | |
2839 | extern int revoke (__const char *__file) throw () __attribute__ ((__nonnull__ (1))) ; | |
2840 | extern int profil (unsigned short int *__sample_buffer, size_t __size, | |
2841 | size_t __offset, unsigned int __scale) | |
2842 | throw () __attribute__ ((__nonnull__ (1))); | |
2843 | extern int acct (__const char *__name) throw (); | |
2844 | extern char *getusershell (void) throw (); | |
2845 | extern void endusershell (void) throw (); | |
2846 | extern void setusershell (void) throw (); | |
2847 | extern int daemon (int __nochdir, int __noclose) throw () ; | |
2848 | extern int chroot (__const char *__path) throw () __attribute__ ((__nonnull__ (1))) ; | |
2849 | extern char *getpass (__const char *__prompt) __attribute__ ((__nonnull__ (1))); | |
2850 | extern int fsync (int __fd); | |
2851 | extern long int gethostid (void); | |
2852 | extern void sync (void) throw (); | |
2853 | extern int getpagesize (void) throw () __attribute__ ((__const__)); | |
2854 | extern int getdtablesize (void) throw (); | |
2855 | extern int truncate (__const char *__file, __off_t __length) | |
2856 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2857 | extern int truncate64 (__const char *__file, __off64_t __length) | |
2858 | throw () __attribute__ ((__nonnull__ (1))) ; | |
2859 | extern int ftruncate (int __fd, __off_t __length) throw () ; | |
2860 | extern int ftruncate64 (int __fd, __off64_t __length) throw () ; | |
2861 | extern int brk (void *__addr) throw () ; | |
2862 | extern void *sbrk (intptr_t __delta) throw (); | |
2863 | extern long int syscall (long int __sysno, ...) throw (); | |
2864 | extern int lockf (int __fd, int __cmd, __off_t __len) ; | |
2865 | extern int lockf64 (int __fd, int __cmd, __off64_t __len) ; | |
2866 | extern int fdatasync (int __fildes); | |
2867 | extern char *crypt (__const char *__key, __const char *__salt) | |
2868 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
2869 | extern void encrypt (char *__block, int __edflag) throw () __attribute__ ((__nonnull__ (1))); | |
2870 | extern void swab (__const void *__restrict __from, void *__restrict __to, | |
2871 | ssize_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); | |
2872 | extern char *ctermid (char *__s) throw (); | |
2873 | } | |
2874 | typedef unsigned long XID; | |
2875 | typedef unsigned long Mask; | |
2876 | typedef unsigned long Atom; | |
2877 | typedef unsigned long VisualID; | |
2878 | typedef unsigned long Time; | |
2879 | typedef XID Window; | |
2880 | typedef XID Drawable; | |
2881 | typedef XID Font; | |
2882 | typedef XID Pixmap; | |
2883 | typedef XID Cursor; | |
2884 | typedef XID Colormap; | |
2885 | typedef XID GContext; | |
2886 | typedef XID KeySym; | |
2887 | typedef unsigned char KeyCode; | |
2888 | extern int | |
2889 | _Xmblen( | |
2890 | char *str, | |
2891 | int len | |
2892 | ); | |
2893 | typedef char *XPointer; | |
2894 | typedef struct _XExtData { | |
2895 | int number; | |
2896 | struct _XExtData *next; | |
2897 | int (*free_private)( | |
2898 | struct _XExtData *extension | |
2899 | ); | |
2900 | XPointer private_data; | |
2901 | } XExtData; | |
2902 | typedef struct { | |
2903 | int extension; | |
2904 | int major_opcode; | |
2905 | int first_event; | |
2906 | int first_error; | |
2907 | } XExtCodes; | |
2908 | typedef struct { | |
2909 | int depth; | |
2910 | int bits_per_pixel; | |
2911 | int scanline_pad; | |
2912 | } XPixmapFormatValues; | |
2913 | typedef struct { | |
2914 | int function; | |
2915 | unsigned long plane_mask; | |
2916 | unsigned long foreground; | |
2917 | unsigned long background; | |
2918 | int line_width; | |
2919 | int line_style; | |
2920 | int cap_style; | |
2921 | int join_style; | |
2922 | int fill_style; | |
2923 | int fill_rule; | |
2924 | int arc_mode; | |
2925 | Pixmap tile; | |
2926 | Pixmap stipple; | |
2927 | int ts_x_origin; | |
2928 | int ts_y_origin; | |
2929 | Font font; | |
2930 | int subwindow_mode; | |
2931 | int graphics_exposures; | |
2932 | int clip_x_origin; | |
2933 | int clip_y_origin; | |
2934 | Pixmap clip_mask; | |
2935 | int dash_offset; | |
2936 | char dashes; | |
2937 | } XGCValues; | |
2938 | typedef struct _XGC | |
2939 | *GC; | |
2940 | typedef struct { | |
2941 | XExtData *ext_data; | |
2942 | VisualID visualid; | |
2943 | int c_class; | |
2944 | unsigned long red_mask, green_mask, blue_mask; | |
2945 | int bits_per_rgb; | |
2946 | int map_entries; | |
2947 | } Visual; | |
2948 | typedef struct { | |
2949 | int depth; | |
2950 | int nvisuals; | |
2951 | Visual *visuals; | |
2952 | } Depth; | |
2953 | struct _XDisplay; | |
2954 | typedef struct { | |
2955 | XExtData *ext_data; | |
2956 | struct _XDisplay *display; | |
2957 | Window root; | |
2958 | int width, height; | |
2959 | int mwidth, mheight; | |
2960 | int ndepths; | |
2961 | Depth *depths; | |
2962 | int root_depth; | |
2963 | Visual *root_visual; | |
2964 | GC default_gc; | |
2965 | Colormap cmap; | |
2966 | unsigned long white_pixel; | |
2967 | unsigned long black_pixel; | |
2968 | int max_maps, min_maps; | |
2969 | int backing_store; | |
2970 | int save_unders; | |
2971 | long root_input_mask; | |
2972 | } Screen; | |
2973 | typedef struct { | |
2974 | XExtData *ext_data; | |
2975 | int depth; | |
2976 | int bits_per_pixel; | |
2977 | int scanline_pad; | |
2978 | } ScreenFormat; | |
2979 | typedef struct { | |
2980 | Pixmap background_pixmap; | |
2981 | unsigned long background_pixel; | |
2982 | Pixmap border_pixmap; | |
2983 | unsigned long border_pixel; | |
2984 | int bit_gravity; | |
2985 | int win_gravity; | |
2986 | int backing_store; | |
2987 | unsigned long backing_planes; | |
2988 | unsigned long backing_pixel; | |
2989 | int save_under; | |
2990 | long event_mask; | |
2991 | long do_not_propagate_mask; | |
2992 | int override_redirect; | |
2993 | Colormap colormap; | |
2994 | Cursor cursor; | |
2995 | } XSetWindowAttributes; | |
2996 | typedef struct { | |
2997 | int x, y; | |
2998 | int width, height; | |
2999 | int border_width; | |
3000 | int depth; | |
3001 | Visual *visual; | |
3002 | Window root; | |
3003 | int c_class; | |
3004 | int bit_gravity; | |
3005 | int win_gravity; | |
3006 | int backing_store; | |
3007 | unsigned long backing_planes; | |
3008 | unsigned long backing_pixel; | |
3009 | int save_under; | |
3010 | Colormap colormap; | |
3011 | int map_installed; | |
3012 | int map_state; | |
3013 | long all_event_masks; | |
3014 | long your_event_mask; | |
3015 | long do_not_propagate_mask; | |
3016 | int override_redirect; | |
3017 | Screen *screen; | |
3018 | } XWindowAttributes; | |
3019 | typedef struct { | |
3020 | int family; | |
3021 | int length; | |
3022 | char *address; | |
3023 | } XHostAddress; | |
3024 | typedef struct { | |
3025 | int typelength; | |
3026 | int valuelength; | |
3027 | char *type; | |
3028 | char *value; | |
3029 | } XServerInterpretedAddress; | |
3030 | typedef struct _XImage { | |
3031 | int width, height; | |
3032 | int xoffset; | |
3033 | int format; | |
3034 | char *data; | |
3035 | int byte_order; | |
3036 | int bitmap_unit; | |
3037 | int bitmap_bit_order; | |
3038 | int bitmap_pad; | |
3039 | int depth; | |
3040 | int bytes_per_line; | |
3041 | int bits_per_pixel; | |
3042 | unsigned long red_mask; | |
3043 | unsigned long green_mask; | |
3044 | unsigned long blue_mask; | |
3045 | XPointer obdata; | |
3046 | struct funcs { | |
3047 | struct _XImage *(*create_image)( | |
3048 | struct _XDisplay* , | |
3049 | Visual* , | |
3050 | unsigned int , | |
3051 | int , | |
3052 | int , | |
3053 | char* , | |
3054 | unsigned int , | |
3055 | unsigned int , | |
3056 | int , | |
3057 | int ); | |
3058 | int (*destroy_image) (struct _XImage *); | |
3059 | unsigned long (*get_pixel) (struct _XImage *, int, int); | |
3060 | int (*put_pixel) (struct _XImage *, int, int, unsigned long); | |
3061 | struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); | |
3062 | int (*add_pixel) (struct _XImage *, long); | |
3063 | } f; | |
3064 | } XImage; | |
3065 | typedef struct { | |
3066 | int x, y; | |
3067 | int width, height; | |
3068 | int border_width; | |
3069 | Window sibling; | |
3070 | int stack_mode; | |
3071 | } XWindowChanges; | |
3072 | typedef struct { | |
3073 | unsigned long pixel; | |
3074 | unsigned short red, green, blue; | |
3075 | char flags; | |
3076 | char pad; | |
3077 | } XColor; | |
3078 | typedef struct { | |
3079 | short x1, y1, x2, y2; | |
3080 | } XSegment; | |
3081 | typedef struct { | |
3082 | short x, y; | |
3083 | } XPoint; | |
3084 | typedef struct { | |
3085 | short x, y; | |
3086 | unsigned short width, height; | |
3087 | } XRectangle; | |
3088 | typedef struct { | |
3089 | short x, y; | |
3090 | unsigned short width, height; | |
3091 | short angle1, angle2; | |
3092 | } XArc; | |
3093 | typedef struct { | |
3094 | int key_click_percent; | |
3095 | int bell_percent; | |
3096 | int bell_pitch; | |
3097 | int bell_duration; | |
3098 | int led; | |
3099 | int led_mode; | |
3100 | int key; | |
3101 | int auto_repeat_mode; | |
3102 | } XKeyboardControl; | |
3103 | typedef struct { | |
3104 | int key_click_percent; | |
3105 | int bell_percent; | |
3106 | unsigned int bell_pitch, bell_duration; | |
3107 | unsigned long led_mask; | |
3108 | int global_auto_repeat; | |
3109 | char auto_repeats[32]; | |
3110 | } XKeyboardState; | |
3111 | typedef struct { | |
3112 | Time time; | |
3113 | short x, y; | |
3114 | } XTimeCoord; | |
3115 | typedef struct { | |
3116 | int max_keypermod; | |
3117 | KeyCode *modifiermap; | |
3118 | } XModifierKeymap; | |
3119 | typedef struct _XDisplay Display; | |
3120 | struct _XPrivate; | |
3121 | struct _XrmHashBucketRec; | |
3122 | typedef struct | |
3123 | { | |
3124 | XExtData *ext_data; | |
3125 | struct _XPrivate *private1; | |
3126 | int fd; | |
3127 | int private2; | |
3128 | int proto_major_version; | |
3129 | int proto_minor_version; | |
3130 | char *vendor; | |
3131 | XID private3; | |
3132 | XID private4; | |
3133 | XID private5; | |
3134 | int private6; | |
3135 | XID (*resource_alloc)( | |
3136 | struct _XDisplay* | |
3137 | ); | |
3138 | int byte_order; | |
3139 | int bitmap_unit; | |
3140 | int bitmap_pad; | |
3141 | int bitmap_bit_order; | |
3142 | int nformats; | |
3143 | ScreenFormat *pixmap_format; | |
3144 | int private8; | |
3145 | int release; | |
3146 | struct _XPrivate *private9, *private10; | |
3147 | int qlen; | |
3148 | unsigned long last_request_read; | |
3149 | unsigned long request; | |
3150 | XPointer private11; | |
3151 | XPointer private12; | |
3152 | XPointer private13; | |
3153 | XPointer private14; | |
3154 | unsigned max_request_size; | |
3155 | struct _XrmHashBucketRec *db; | |
3156 | int (*private15)( | |
3157 | struct _XDisplay* | |
3158 | ); | |
3159 | char *display_name; | |
3160 | int default_screen; | |
3161 | int nscreens; | |
3162 | Screen *screens; | |
3163 | unsigned long motion_buffer; | |
3164 | unsigned long private16; | |
3165 | int min_keycode; | |
3166 | int max_keycode; | |
3167 | XPointer private17; | |
3168 | XPointer private18; | |
3169 | int private19; | |
3170 | char *xdefaults; | |
3171 | } | |
3172 | *_XPrivDisplay; | |
3173 | typedef struct { | |
3174 | int type; | |
3175 | unsigned long serial; | |
3176 | int send_event; | |
3177 | Display *display; | |
3178 | Window window; | |
3179 | Window root; | |
3180 | Window subwindow; | |
3181 | Time time; | |
3182 | int x, y; | |
3183 | int x_root, y_root; | |
3184 | unsigned int state; | |
3185 | unsigned int keycode; | |
3186 | int same_screen; | |
3187 | } XKeyEvent; | |
3188 | typedef XKeyEvent XKeyPressedEvent; | |
3189 | typedef XKeyEvent XKeyReleasedEvent; | |
3190 | typedef struct { | |
3191 | int type; | |
3192 | unsigned long serial; | |
3193 | int send_event; | |
3194 | Display *display; | |
3195 | Window window; | |
3196 | Window root; | |
3197 | Window subwindow; | |
3198 | Time time; | |
3199 | int x, y; | |
3200 | int x_root, y_root; | |
3201 | unsigned int state; | |
3202 | unsigned int button; | |
3203 | int same_screen; | |
3204 | } XButtonEvent; | |
3205 | typedef XButtonEvent XButtonPressedEvent; | |
3206 | typedef XButtonEvent XButtonReleasedEvent; | |
3207 | typedef struct { | |
3208 | int type; | |
3209 | unsigned long serial; | |
3210 | int send_event; | |
3211 | Display *display; | |
3212 | Window window; | |
3213 | Window root; | |
3214 | Window subwindow; | |
3215 | Time time; | |
3216 | int x, y; | |
3217 | int x_root, y_root; | |
3218 | unsigned int state; | |
3219 | char is_hint; | |
3220 | int same_screen; | |
3221 | } XMotionEvent; | |
3222 | typedef XMotionEvent XPointerMovedEvent; | |
3223 | typedef struct { | |
3224 | int type; | |
3225 | unsigned long serial; | |
3226 | int send_event; | |
3227 | Display *display; | |
3228 | Window window; | |
3229 | Window root; | |
3230 | Window subwindow; | |
3231 | Time time; | |
3232 | int x, y; | |
3233 | int x_root, y_root; | |
3234 | int mode; | |
3235 | int detail; | |
3236 | int same_screen; | |
3237 | int focus; | |
3238 | unsigned int state; | |
3239 | } XCrossingEvent; | |
3240 | typedef XCrossingEvent XEnterWindowEvent; | |
3241 | typedef XCrossingEvent XLeaveWindowEvent; | |
3242 | typedef struct { | |
3243 | int type; | |
3244 | unsigned long serial; | |
3245 | int send_event; | |
3246 | Display *display; | |
3247 | Window window; | |
3248 | int mode; | |
3249 | int detail; | |
3250 | } XFocusChangeEvent; | |
3251 | typedef XFocusChangeEvent XFocusInEvent; | |
3252 | typedef XFocusChangeEvent XFocusOutEvent; | |
3253 | typedef struct { | |
3254 | int type; | |
3255 | unsigned long serial; | |
3256 | int send_event; | |
3257 | Display *display; | |
3258 | Window window; | |
3259 | char key_vector[32]; | |
3260 | } XKeymapEvent; | |
3261 | typedef struct { | |
3262 | int type; | |
3263 | unsigned long serial; | |
3264 | int send_event; | |
3265 | Display *display; | |
3266 | Window window; | |
3267 | int x, y; | |
3268 | int width, height; | |
3269 | int count; | |
3270 | } XExposeEvent; | |
3271 | typedef struct { | |
3272 | int type; | |
3273 | unsigned long serial; | |
3274 | int send_event; | |
3275 | Display *display; | |
3276 | Drawable drawable; | |
3277 | int x, y; | |
3278 | int width, height; | |
3279 | int count; | |
3280 | int major_code; | |
3281 | int minor_code; | |
3282 | } XGraphicsExposeEvent; | |
3283 | typedef struct { | |
3284 | int type; | |
3285 | unsigned long serial; | |
3286 | int send_event; | |
3287 | Display *display; | |
3288 | Drawable drawable; | |
3289 | int major_code; | |
3290 | int minor_code; | |
3291 | } XNoExposeEvent; | |
3292 | typedef struct { | |
3293 | int type; | |
3294 | unsigned long serial; | |
3295 | int send_event; | |
3296 | Display *display; | |
3297 | Window window; | |
3298 | int state; | |
3299 | } XVisibilityEvent; | |
3300 | typedef struct { | |
3301 | int type; | |
3302 | unsigned long serial; | |
3303 | int send_event; | |
3304 | Display *display; | |
3305 | Window parent; | |
3306 | Window window; | |
3307 | int x, y; | |
3308 | int width, height; | |
3309 | int border_width; | |
3310 | int override_redirect; | |
3311 | } XCreateWindowEvent; | |
3312 | typedef struct { | |
3313 | int type; | |
3314 | unsigned long serial; | |
3315 | int send_event; | |
3316 | Display *display; | |
3317 | Window event; | |
3318 | Window window; | |
3319 | } XDestroyWindowEvent; | |
3320 | typedef struct { | |
3321 | int type; | |
3322 | unsigned long serial; | |
3323 | int send_event; | |
3324 | Display *display; | |
3325 | Window event; | |
3326 | Window window; | |
3327 | int from_configure; | |
3328 | } XUnmapEvent; | |
3329 | typedef struct { | |
3330 | int type; | |
3331 | unsigned long serial; | |
3332 | int send_event; | |
3333 | Display *display; | |
3334 | Window event; | |
3335 | Window window; | |
3336 | int override_redirect; | |
3337 | } XMapEvent; | |
3338 | typedef struct { | |
3339 | int type; | |
3340 | unsigned long serial; | |
3341 | int send_event; | |
3342 | Display *display; | |
3343 | Window parent; | |
3344 | Window window; | |
3345 | } XMapRequestEvent; | |
3346 | typedef struct { | |
3347 | int type; | |
3348 | unsigned long serial; | |
3349 | int send_event; | |
3350 | Display *display; | |
3351 | Window event; | |
3352 | Window window; | |
3353 | Window parent; | |
3354 | int x, y; | |
3355 | int override_redirect; | |
3356 | } XReparentEvent; | |
3357 | typedef struct { | |
3358 | int type; | |
3359 | unsigned long serial; | |
3360 | int send_event; | |
3361 | Display *display; | |
3362 | Window event; | |
3363 | Window window; | |
3364 | int x, y; | |
3365 | int width, height; | |
3366 | int border_width; | |
3367 | Window above; | |
3368 | int override_redirect; | |
3369 | } XConfigureEvent; | |
3370 | typedef struct { | |
3371 | int type; | |
3372 | unsigned long serial; | |
3373 | int send_event; | |
3374 | Display *display; | |
3375 | Window event; | |
3376 | Window window; | |
3377 | int x, y; | |
3378 | } XGravityEvent; | |
3379 | typedef struct { | |
3380 | int type; | |
3381 | unsigned long serial; | |
3382 | int send_event; | |
3383 | Display *display; | |
3384 | Window window; | |
3385 | int width, height; | |
3386 | } XResizeRequestEvent; | |
3387 | typedef struct { | |
3388 | int type; | |
3389 | unsigned long serial; | |
3390 | int send_event; | |
3391 | Display *display; | |
3392 | Window parent; | |
3393 | Window window; | |
3394 | int x, y; | |
3395 | int width, height; | |
3396 | int border_width; | |
3397 | Window above; | |
3398 | int detail; | |
3399 | unsigned long value_mask; | |
3400 | } XConfigureRequestEvent; | |
3401 | typedef struct { | |
3402 | int type; | |
3403 | unsigned long serial; | |
3404 | int send_event; | |
3405 | Display *display; | |
3406 | Window event; | |
3407 | Window window; | |
3408 | int place; | |
3409 | } XCirculateEvent; | |
3410 | typedef struct { | |
3411 | int type; | |
3412 | unsigned long serial; | |
3413 | int send_event; | |
3414 | Display *display; | |
3415 | Window parent; | |
3416 | Window window; | |
3417 | int place; | |
3418 | } XCirculateRequestEvent; | |
3419 | typedef struct { | |
3420 | int type; | |
3421 | unsigned long serial; | |
3422 | int send_event; | |
3423 | Display *display; | |
3424 | Window window; | |
3425 | Atom atom; | |
3426 | Time time; | |
3427 | int state; | |
3428 | } XPropertyEvent; | |
3429 | typedef struct { | |
3430 | int type; | |
3431 | unsigned long serial; | |
3432 | int send_event; | |
3433 | Display *display; | |
3434 | Window window; | |
3435 | Atom selection; | |
3436 | Time time; | |
3437 | } XSelectionClearEvent; | |
3438 | typedef struct { | |
3439 | int type; | |
3440 | unsigned long serial; | |
3441 | int send_event; | |
3442 | Display *display; | |
3443 | Window owner; | |
3444 | Window requestor; | |
3445 | Atom selection; | |
3446 | Atom target; | |
3447 | Atom property; | |
3448 | Time time; | |
3449 | } XSelectionRequestEvent; | |
3450 | typedef struct { | |
3451 | int type; | |
3452 | unsigned long serial; | |
3453 | int send_event; | |
3454 | Display *display; | |
3455 | Window requestor; | |
3456 | Atom selection; | |
3457 | Atom target; | |
3458 | Atom property; | |
3459 | Time time; | |
3460 | } XSelectionEvent; | |
3461 | typedef struct { | |
3462 | int type; | |
3463 | unsigned long serial; | |
3464 | int send_event; | |
3465 | Display *display; | |
3466 | Window window; | |
3467 | Colormap colormap; | |
3468 | int c_new; | |
3469 | int state; | |
3470 | } XColormapEvent; | |
3471 | typedef struct { | |
3472 | int type; | |
3473 | unsigned long serial; | |
3474 | int send_event; | |
3475 | Display *display; | |
3476 | Window window; | |
3477 | Atom message_type; | |
3478 | int format; | |
3479 | union { | |
3480 | char b[20]; | |
3481 | short s[10]; | |
3482 | long l[5]; | |
3483 | } data; | |
3484 | } XClientMessageEvent; | |
3485 | typedef struct { | |
3486 | int type; | |
3487 | unsigned long serial; | |
3488 | int send_event; | |
3489 | Display *display; | |
3490 | Window window; | |
3491 | int request; | |
3492 | int first_keycode; | |
3493 | int count; | |
3494 | } XMappingEvent; | |
3495 | typedef struct { | |
3496 | int type; | |
3497 | Display *display; | |
3498 | XID resourceid; | |
3499 | unsigned long serial; | |
3500 | unsigned char error_code; | |
3501 | unsigned char request_code; | |
3502 | unsigned char minor_code; | |
3503 | } XErrorEvent; | |
3504 | typedef struct { | |
3505 | int type; | |
3506 | unsigned long serial; | |
3507 | int send_event; | |
3508 | Display *display; | |
3509 | Window window; | |
3510 | } XAnyEvent; | |
3511 | typedef union _XEvent { | |
3512 | int type; | |
3513 | XAnyEvent xany; | |
3514 | XKeyEvent xkey; | |
3515 | XButtonEvent xbutton; | |
3516 | XMotionEvent xmotion; | |
3517 | XCrossingEvent xcrossing; | |
3518 | XFocusChangeEvent xfocus; | |
3519 | XExposeEvent xexpose; | |
3520 | XGraphicsExposeEvent xgraphicsexpose; | |
3521 | XNoExposeEvent xnoexpose; | |
3522 | XVisibilityEvent xvisibility; | |
3523 | XCreateWindowEvent xcreatewindow; | |
3524 | XDestroyWindowEvent xdestroywindow; | |
3525 | XUnmapEvent xunmap; | |
3526 | XMapEvent xmap; | |
3527 | XMapRequestEvent xmaprequest; | |
3528 | XReparentEvent xreparent; | |
3529 | XConfigureEvent xconfigure; | |
3530 | XGravityEvent xgravity; | |
3531 | XResizeRequestEvent xresizerequest; | |
3532 | XConfigureRequestEvent xconfigurerequest; | |
3533 | XCirculateEvent xcirculate; | |
3534 | XCirculateRequestEvent xcirculaterequest; | |
3535 | XPropertyEvent xproperty; | |
3536 | XSelectionClearEvent xselectionclear; | |
3537 | XSelectionRequestEvent xselectionrequest; | |
3538 | XSelectionEvent xselection; | |
3539 | XColormapEvent xcolormap; | |
3540 | XClientMessageEvent xclient; | |
3541 | XMappingEvent xmapping; | |
3542 | XErrorEvent xerror; | |
3543 | XKeymapEvent xkeymap; | |
3544 | long pad[24]; | |
3545 | } XEvent; | |
3546 | typedef struct { | |
3547 | short lbearing; | |
3548 | short rbearing; | |
3549 | short width; | |
3550 | short ascent; | |
3551 | short descent; | |
3552 | unsigned short attributes; | |
3553 | } XCharStruct; | |
3554 | typedef struct { | |
3555 | Atom name; | |
3556 | unsigned long card32; | |
3557 | } XFontProp; | |
3558 | typedef struct { | |
3559 | XExtData *ext_data; | |
3560 | Font fid; | |
3561 | unsigned direction; | |
3562 | unsigned min_char_or_byte2; | |
3563 | unsigned max_char_or_byte2; | |
3564 | unsigned min_byte1; | |
3565 | unsigned max_byte1; | |
3566 | int all_chars_exist; | |
3567 | unsigned default_char; | |
3568 | int n_properties; | |
3569 | XFontProp *properties; | |
3570 | XCharStruct min_bounds; | |
3571 | XCharStruct max_bounds; | |
3572 | XCharStruct *per_char; | |
3573 | int ascent; | |
3574 | int descent; | |
3575 | } XFontStruct; | |
3576 | typedef struct { | |
3577 | char *chars; | |
3578 | int nchars; | |
3579 | int delta; | |
3580 | Font font; | |
3581 | } XTextItem; | |
3582 | typedef struct { | |
3583 | unsigned char byte1; | |
3584 | unsigned char byte2; | |
3585 | } XChar2b; | |
3586 | typedef struct { | |
3587 | XChar2b *chars; | |
3588 | int nchars; | |
3589 | int delta; | |
3590 | Font font; | |
3591 | } XTextItem16; | |
3592 | typedef union { Display *display; | |
3593 | GC gc; | |
3594 | Visual *visual; | |
3595 | Screen *screen; | |
3596 | ScreenFormat *pixmap_format; | |
3597 | XFontStruct *font; } XEDataObject; | |
3598 | typedef struct { | |
3599 | XRectangle max_ink_extent; | |
3600 | XRectangle max_logical_extent; | |
3601 | } XFontSetExtents; | |
3602 | typedef struct _XOM *XOM; | |
3603 | typedef struct _XOC *XOC, *XFontSet; | |
3604 | typedef struct { | |
3605 | char *chars; | |
3606 | int nchars; | |
3607 | int delta; | |
3608 | XFontSet font_set; | |
3609 | } XmbTextItem; | |
3610 | typedef struct { | |
3611 | wchar_t *chars; | |
3612 | int nchars; | |
3613 | int delta; | |
3614 | XFontSet font_set; | |
3615 | } XwcTextItem; | |
3616 | typedef struct { | |
3617 | int charset_count; | |
3618 | char **charset_list; | |
3619 | } XOMCharSetList; | |
3620 | typedef enum { | |
3621 | XOMOrientation_LTR_TTB, | |
3622 | XOMOrientation_RTL_TTB, | |
3623 | XOMOrientation_TTB_LTR, | |
3624 | XOMOrientation_TTB_RTL, | |
3625 | XOMOrientation_Context | |
3626 | } XOrientation; | |
3627 | typedef struct { | |
3628 | int num_orientation; | |
3629 | XOrientation *orientation; | |
3630 | } XOMOrientation; | |
3631 | typedef struct { | |
3632 | int num_font; | |
3633 | XFontStruct **font_struct_list; | |
3634 | char **font_name_list; | |
3635 | } XOMFontInfo; | |
3636 | typedef struct _XIM *XIM; | |
3637 | typedef struct _XIC *XIC; | |
3638 | typedef void (*XIMProc)( | |
3639 | XIM, | |
3640 | XPointer, | |
3641 | XPointer | |
3642 | ); | |
3643 | typedef int (*XICProc)( | |
3644 | XIC, | |
3645 | XPointer, | |
3646 | XPointer | |
3647 | ); | |
3648 | typedef void (*XIDProc)( | |
3649 | Display*, | |
3650 | XPointer, | |
3651 | XPointer | |
3652 | ); | |
3653 | typedef unsigned long XIMStyle; | |
3654 | typedef struct { | |
3655 | unsigned short count_styles; | |
3656 | XIMStyle *supported_styles; | |
3657 | } XIMStyles; | |
3658 | typedef void *XVaNestedList; | |
3659 | typedef struct { | |
3660 | XPointer client_data; | |
3661 | XIMProc callback; | |
3662 | } XIMCallback; | |
3663 | typedef struct { | |
3664 | XPointer client_data; | |
3665 | XICProc callback; | |
3666 | } XICCallback; | |
3667 | typedef unsigned long XIMFeedback; | |
3668 | typedef struct _XIMText { | |
3669 | unsigned short length; | |
3670 | XIMFeedback *feedback; | |
3671 | int encoding_is_wchar; | |
3672 | union { | |
3673 | char *multi_byte; | |
3674 | wchar_t *wide_char; | |
3675 | } string; | |
3676 | } XIMText; | |
3677 | typedef unsigned long XIMPreeditState; | |
3678 | typedef struct _XIMPreeditStateNotifyCallbackStruct { | |
3679 | XIMPreeditState state; | |
3680 | } XIMPreeditStateNotifyCallbackStruct; | |
3681 | typedef unsigned long XIMResetState; | |
3682 | typedef unsigned long XIMStringConversionFeedback; | |
3683 | typedef struct _XIMStringConversionText { | |
3684 | unsigned short length; | |
3685 | XIMStringConversionFeedback *feedback; | |
3686 | int encoding_is_wchar; | |
3687 | union { | |
3688 | char *mbs; | |
3689 | wchar_t *wcs; | |
3690 | } string; | |
3691 | } XIMStringConversionText; | |
3692 | typedef unsigned short XIMStringConversionPosition; | |
3693 | typedef unsigned short XIMStringConversionType; | |
3694 | typedef unsigned short XIMStringConversionOperation; | |
3695 | typedef enum { | |
3696 | XIMForwardChar, XIMBackwardChar, | |
3697 | XIMForwardWord, XIMBackwardWord, | |
3698 | XIMCaretUp, XIMCaretDown, | |
3699 | XIMNextLine, XIMPreviousLine, | |
3700 | XIMLineStart, XIMLineEnd, | |
3701 | XIMAbsolutePosition, | |
3702 | XIMDontChange | |
3703 | } XIMCaretDirection; | |
3704 | typedef struct _XIMStringConversionCallbackStruct { | |
3705 | XIMStringConversionPosition position; | |
3706 | XIMCaretDirection direction; | |
3707 | XIMStringConversionOperation operation; | |
3708 | unsigned short factor; | |
3709 | XIMStringConversionText *text; | |
3710 | } XIMStringConversionCallbackStruct; | |
3711 | typedef struct _XIMPreeditDrawCallbackStruct { | |
3712 | int caret; | |
3713 | int chg_first; | |
3714 | int chg_length; | |
3715 | XIMText *text; | |
3716 | } XIMPreeditDrawCallbackStruct; | |
3717 | typedef enum { | |
3718 | XIMIsInvisible, | |
3719 | XIMIsPrimary, | |
3720 | XIMIsSecondary | |
3721 | } XIMCaretStyle; | |
3722 | typedef struct _XIMPreeditCaretCallbackStruct { | |
3723 | int position; | |
3724 | XIMCaretDirection direction; | |
3725 | XIMCaretStyle style; | |
3726 | } XIMPreeditCaretCallbackStruct; | |
3727 | typedef enum { | |
3728 | XIMTextType, | |
3729 | XIMBitmapType | |
3730 | } XIMStatusDataType; | |
3731 | typedef struct _XIMStatusDrawCallbackStruct { | |
3732 | XIMStatusDataType type; | |
3733 | union { | |
3734 | XIMText *text; | |
3735 | Pixmap bitmap; | |
3736 | } data; | |
3737 | } XIMStatusDrawCallbackStruct; | |
3738 | typedef struct _XIMHotKeyTrigger { | |
3739 | KeySym keysym; | |
3740 | int modifier; | |
3741 | int modifier_mask; | |
3742 | } XIMHotKeyTrigger; | |
3743 | typedef struct _XIMHotKeyTriggers { | |
3744 | int num_hot_key; | |
3745 | XIMHotKeyTrigger *key; | |
3746 | } XIMHotKeyTriggers; | |
3747 | typedef unsigned long XIMHotKeyState; | |
3748 | typedef struct { | |
3749 | unsigned short count_values; | |
3750 | char **supported_values; | |
3751 | } XIMValuesList; | |
3752 | extern "C" { | |
3753 | extern int _Xdebug; | |
3754 | extern XFontStruct *XLoadQueryFont( | |
3755 | Display* , | |
3756 | const char* | |
3757 | ); | |
3758 | extern XFontStruct *XQueryFont( | |
3759 | Display* , | |
3760 | XID | |
3761 | ); | |
3762 | extern XTimeCoord *XGetMotionEvents( | |
3763 | Display* , | |
3764 | Window , | |
3765 | Time , | |
3766 | Time , | |
3767 | int* | |
3768 | ); | |
3769 | extern XModifierKeymap *XDeleteModifiermapEntry( | |
3770 | XModifierKeymap* , | |
3771 | KeyCode , | |
3772 | int | |
3773 | ); | |
3774 | extern XModifierKeymap *XGetModifierMapping( | |
3775 | Display* | |
3776 | ); | |
3777 | extern XModifierKeymap *XInsertModifiermapEntry( | |
3778 | XModifierKeymap* , | |
3779 | KeyCode , | |
3780 | int | |
3781 | ); | |
3782 | extern XModifierKeymap *XNewModifiermap( | |
3783 | int | |
3784 | ); | |
3785 | extern XImage *XCreateImage( | |
3786 | Display* , | |
3787 | Visual* , | |
3788 | unsigned int , | |
3789 | int , | |
3790 | int , | |
3791 | char* , | |
3792 | unsigned int , | |
3793 | unsigned int , | |
3794 | int , | |
3795 | int | |
3796 | ); | |
3797 | extern int XInitImage( | |
3798 | XImage* | |
3799 | ); | |
3800 | extern XImage *XGetImage( | |
3801 | Display* , | |
3802 | Drawable , | |
3803 | int , | |
3804 | int , | |
3805 | unsigned int , | |
3806 | unsigned int , | |
3807 | unsigned long , | |
3808 | int | |
3809 | ); | |
3810 | extern XImage *XGetSubImage( | |
3811 | Display* , | |
3812 | Drawable , | |
3813 | int , | |
3814 | int , | |
3815 | unsigned int , | |
3816 | unsigned int , | |
3817 | unsigned long , | |
3818 | int , | |
3819 | XImage* , | |
3820 | int , | |
3821 | int | |
3822 | ); | |
3823 | extern Display *XOpenDisplay( | |
3824 | const char* | |
3825 | ); | |
3826 | extern void XrmInitialize( | |
3827 | void | |
3828 | ); | |
3829 | extern char *XFetchBytes( | |
3830 | Display* , | |
3831 | int* | |
3832 | ); | |
3833 | extern char *XFetchBuffer( | |
3834 | Display* , | |
3835 | int* , | |
3836 | int | |
3837 | ); | |
3838 | extern char *XGetAtomName( | |
3839 | Display* , | |
3840 | Atom | |
3841 | ); | |
3842 | extern int XGetAtomNames( | |
3843 | Display* , | |
3844 | Atom* , | |
3845 | int , | |
3846 | char** | |
3847 | ); | |
3848 | extern char *XGetDefault( | |
3849 | Display* , | |
3850 | const char* , | |
3851 | const char* | |
3852 | ); | |
3853 | extern char *XDisplayName( | |
3854 | const char* | |
3855 | ); | |
3856 | extern char *XKeysymToString( | |
3857 | KeySym | |
3858 | ); | |
3859 | extern int (*XSynchronize( | |
3860 | Display* , | |
3861 | int | |
3862 | ))( | |
3863 | Display* | |
3864 | ); | |
3865 | extern int (*XSetAfterFunction( | |
3866 | Display* , | |
3867 | int (*) ( | |
3868 | Display* | |
3869 | ) | |
3870 | ))( | |
3871 | Display* | |
3872 | ); | |
3873 | extern Atom XInternAtom( | |
3874 | Display* , | |
3875 | const char* , | |
3876 | int | |
3877 | ); | |
3878 | extern int XInternAtoms( | |
3879 | Display* , | |
3880 | char** , | |
3881 | int , | |
3882 | int , | |
3883 | Atom* | |
3884 | ); | |
3885 | extern Colormap XCopyColormapAndFree( | |
3886 | Display* , | |
3887 | Colormap | |
3888 | ); | |
3889 | extern Colormap XCreateColormap( | |
3890 | Display* , | |
3891 | Window , | |
3892 | Visual* , | |
3893 | int | |
3894 | ); | |
3895 | extern Cursor XCreatePixmapCursor( | |
3896 | Display* , | |
3897 | Pixmap , | |
3898 | Pixmap , | |
3899 | XColor* , | |
3900 | XColor* , | |
3901 | unsigned int , | |
3902 | unsigned int | |
3903 | ); | |
3904 | extern Cursor XCreateGlyphCursor( | |
3905 | Display* , | |
3906 | Font , | |
3907 | Font , | |
3908 | unsigned int , | |
3909 | unsigned int , | |
3910 | XColor const * , | |
3911 | XColor const * | |
3912 | ); | |
3913 | extern Cursor XCreateFontCursor( | |
3914 | Display* , | |
3915 | unsigned int | |
3916 | ); | |
3917 | extern Font XLoadFont( | |
3918 | Display* , | |
3919 | const char* | |
3920 | ); | |
3921 | extern GC XCreateGC( | |
3922 | Display* , | |
3923 | Drawable , | |
3924 | unsigned long , | |
3925 | XGCValues* | |
3926 | ); | |
3927 | extern GContext XGContextFromGC( | |
3928 | GC | |
3929 | ); | |
3930 | extern void XFlushGC( | |
3931 | Display* , | |
3932 | GC | |
3933 | ); | |
3934 | extern Pixmap XCreatePixmap( | |
3935 | Display* , | |
3936 | Drawable , | |
3937 | unsigned int , | |
3938 | unsigned int , | |
3939 | unsigned int | |
3940 | ); | |
3941 | extern Pixmap XCreateBitmapFromData( | |
3942 | Display* , | |
3943 | Drawable , | |
3944 | const char* , | |
3945 | unsigned int , | |
3946 | unsigned int | |
3947 | ); | |
3948 | extern Pixmap XCreatePixmapFromBitmapData( | |
3949 | Display* , | |
3950 | Drawable , | |
3951 | char* , | |
3952 | unsigned int , | |
3953 | unsigned int , | |
3954 | unsigned long , | |
3955 | unsigned long , | |
3956 | unsigned int | |
3957 | ); | |
3958 | extern Window XCreateSimpleWindow( | |
3959 | Display* , | |
3960 | Window , | |
3961 | int , | |
3962 | int , | |
3963 | unsigned int , | |
3964 | unsigned int , | |
3965 | unsigned int , | |
3966 | unsigned long , | |
3967 | unsigned long | |
3968 | ); | |
3969 | extern Window XGetSelectionOwner( | |
3970 | Display* , | |
3971 | Atom | |
3972 | ); | |
3973 | extern Window XCreateWindow( | |
3974 | Display* , | |
3975 | Window , | |
3976 | int , | |
3977 | int , | |
3978 | unsigned int , | |
3979 | unsigned int , | |
3980 | unsigned int , | |
3981 | int , | |
3982 | unsigned int , | |
3983 | Visual* , | |
3984 | unsigned long , | |
3985 | XSetWindowAttributes* | |
3986 | ); | |
3987 | extern Colormap *XListInstalledColormaps( | |
3988 | Display* , | |
3989 | Window , | |
3990 | int* | |
3991 | ); | |
3992 | extern char **XListFonts( | |
3993 | Display* , | |
3994 | const char* , | |
3995 | int , | |
3996 | int* | |
3997 | ); | |
3998 | extern char **XListFontsWithInfo( | |
3999 | Display* , | |
4000 | const char* , | |
4001 | int , | |
4002 | int* , | |
4003 | XFontStruct** | |
4004 | ); | |
4005 | extern char **XGetFontPath( | |
4006 | Display* , | |
4007 | int* | |
4008 | ); | |
4009 | extern char **XListExtensions( | |
4010 | Display* , | |
4011 | int* | |
4012 | ); | |
4013 | extern Atom *XListProperties( | |
4014 | Display* , | |
4015 | Window , | |
4016 | int* | |
4017 | ); | |
4018 | extern XHostAddress *XListHosts( | |
4019 | Display* , | |
4020 | int* , | |
4021 | int* | |
4022 | ); | |
4023 | extern KeySym XKeycodeToKeysym( | |
4024 | Display* , | |
4025 | KeyCode , | |
4026 | int | |
4027 | ); | |
4028 | extern KeySym XLookupKeysym( | |
4029 | XKeyEvent* , | |
4030 | int | |
4031 | ); | |
4032 | extern KeySym *XGetKeyboardMapping( | |
4033 | Display* , | |
4034 | KeyCode , | |
4035 | int , | |
4036 | int* | |
4037 | ); | |
4038 | extern KeySym XStringToKeysym( | |
4039 | const char* | |
4040 | ); | |
4041 | extern long XMaxRequestSize( | |
4042 | Display* | |
4043 | ); | |
4044 | extern long XExtendedMaxRequestSize( | |
4045 | Display* | |
4046 | ); | |
4047 | extern char *XResourceManagerString( | |
4048 | Display* | |
4049 | ); | |
4050 | extern char *XScreenResourceString( | |
4051 | Screen* | |
4052 | ); | |
4053 | extern unsigned long XDisplayMotionBufferSize( | |
4054 | Display* | |
4055 | ); | |
4056 | extern VisualID XVisualIDFromVisual( | |
4057 | Visual* | |
4058 | ); | |
4059 | extern int XInitThreads( | |
4060 | void | |
4061 | ); | |
4062 | extern void XLockDisplay( | |
4063 | Display* | |
4064 | ); | |
4065 | extern void XUnlockDisplay( | |
4066 | Display* | |
4067 | ); | |
4068 | extern XExtCodes *XInitExtension( | |
4069 | Display* , | |
4070 | const char* | |
4071 | ); | |
4072 | extern XExtCodes *XAddExtension( | |
4073 | Display* | |
4074 | ); | |
4075 | extern XExtData *XFindOnExtensionList( | |
4076 | XExtData** , | |
4077 | int | |
4078 | ); | |
4079 | extern XExtData **XEHeadOfExtensionList( | |
4080 | XEDataObject | |
4081 | ); | |
4082 | extern Window XRootWindow( | |
4083 | Display* , | |
4084 | int | |
4085 | ); | |
4086 | extern Window XDefaultRootWindow( | |
4087 | Display* | |
4088 | ); | |
4089 | extern Window XRootWindowOfScreen( | |
4090 | Screen* | |
4091 | ); | |
4092 | extern Visual *XDefaultVisual( | |
4093 | Display* , | |
4094 | int | |
4095 | ); | |
4096 | extern Visual *XDefaultVisualOfScreen( | |
4097 | Screen* | |
4098 | ); | |
4099 | extern GC XDefaultGC( | |
4100 | Display* , | |
4101 | int | |
4102 | ); | |
4103 | extern GC XDefaultGCOfScreen( | |
4104 | Screen* | |
4105 | ); | |
4106 | extern unsigned long XBlackPixel( | |
4107 | Display* , | |
4108 | int | |
4109 | ); | |
4110 | extern unsigned long XWhitePixel( | |
4111 | Display* , | |
4112 | int | |
4113 | ); | |
4114 | extern unsigned long XAllPlanes( | |
4115 | void | |
4116 | ); | |
4117 | extern unsigned long XBlackPixelOfScreen( | |
4118 | Screen* | |
4119 | ); | |
4120 | extern unsigned long XWhitePixelOfScreen( | |
4121 | Screen* | |
4122 | ); | |
4123 | extern unsigned long XNextRequest( | |
4124 | Display* | |
4125 | ); | |
4126 | extern unsigned long XLastKnownRequestProcessed( | |
4127 | Display* | |
4128 | ); | |
4129 | extern char *XServerVendor( | |
4130 | Display* | |
4131 | ); | |
4132 | extern char *XDisplayString( | |
4133 | Display* | |
4134 | ); | |
4135 | extern Colormap XDefaultColormap( | |
4136 | Display* , | |
4137 | int | |
4138 | ); | |
4139 | extern Colormap XDefaultColormapOfScreen( | |
4140 | Screen* | |
4141 | ); | |
4142 | extern Display *XDisplayOfScreen( | |
4143 | Screen* | |
4144 | ); | |
4145 | extern Screen *XScreenOfDisplay( | |
4146 | Display* , | |
4147 | int | |
4148 | ); | |
4149 | extern Screen *XDefaultScreenOfDisplay( | |
4150 | Display* | |
4151 | ); | |
4152 | extern long XEventMaskOfScreen( | |
4153 | Screen* | |
4154 | ); | |
4155 | extern int XScreenNumberOfScreen( | |
4156 | Screen* | |
4157 | ); | |
4158 | typedef int (*XErrorHandler) ( | |
4159 | Display* , | |
4160 | XErrorEvent* | |
4161 | ); | |
4162 | extern XErrorHandler XSetErrorHandler ( | |
4163 | XErrorHandler | |
4164 | ); | |
4165 | typedef int (*XIOErrorHandler) ( | |
4166 | Display* | |
4167 | ); | |
4168 | extern XIOErrorHandler XSetIOErrorHandler ( | |
4169 | XIOErrorHandler | |
4170 | ); | |
4171 | extern XPixmapFormatValues *XListPixmapFormats( | |
4172 | Display* , | |
4173 | int* | |
4174 | ); | |
4175 | extern int *XListDepths( | |
4176 | Display* , | |
4177 | int , | |
4178 | int* | |
4179 | ); | |
4180 | extern int XReconfigureWMWindow( | |
4181 | Display* , | |
4182 | Window , | |
4183 | int , | |
4184 | unsigned int , | |
4185 | XWindowChanges* | |
4186 | ); | |
4187 | extern int XGetWMProtocols( | |
4188 | Display* , | |
4189 | Window , | |
4190 | Atom** , | |
4191 | int* | |
4192 | ); | |
4193 | extern int XSetWMProtocols( | |
4194 | Display* , | |
4195 | Window , | |
4196 | Atom* , | |
4197 | int | |
4198 | ); | |
4199 | extern int XIconifyWindow( | |
4200 | Display* , | |
4201 | Window , | |
4202 | int | |
4203 | ); | |
4204 | extern int XWithdrawWindow( | |
4205 | Display* , | |
4206 | Window , | |
4207 | int | |
4208 | ); | |
4209 | extern int XGetCommand( | |
4210 | Display* , | |
4211 | Window , | |
4212 | char*** , | |
4213 | int* | |
4214 | ); | |
4215 | extern int XGetWMColormapWindows( | |
4216 | Display* , | |
4217 | Window , | |
4218 | Window** , | |
4219 | int* | |
4220 | ); | |
4221 | extern int XSetWMColormapWindows( | |
4222 | Display* , | |
4223 | Window , | |
4224 | Window* , | |
4225 | int | |
4226 | ); | |
4227 | extern void XFreeStringList( | |
4228 | char** | |
4229 | ); | |
4230 | extern int XSetTransientForHint( | |
4231 | Display* , | |
4232 | Window , | |
4233 | Window | |
4234 | ); | |
4235 | extern int XActivateScreenSaver( | |
4236 | Display* | |
4237 | ); | |
4238 | extern int XAddHost( | |
4239 | Display* , | |
4240 | XHostAddress* | |
4241 | ); | |
4242 | extern int XAddHosts( | |
4243 | Display* , | |
4244 | XHostAddress* , | |
4245 | int | |
4246 | ); | |
4247 | extern int XAddToExtensionList( | |
4248 | struct _XExtData** , | |
4249 | XExtData* | |
4250 | ); | |
4251 | extern int XAddToSaveSet( | |
4252 | Display* , | |
4253 | Window | |
4254 | ); | |
4255 | extern int XAllocColor( | |
4256 | Display* , | |
4257 | Colormap , | |
4258 | XColor* | |
4259 | ); | |
4260 | extern int XAllocColorCells( | |
4261 | Display* , | |
4262 | Colormap , | |
4263 | int , | |
4264 | unsigned long* , | |
4265 | unsigned int , | |
4266 | unsigned long* , | |
4267 | unsigned int | |
4268 | ); | |
4269 | extern int XAllocColorPlanes( | |
4270 | Display* , | |
4271 | Colormap , | |
4272 | int , | |
4273 | unsigned long* , | |
4274 | int , | |
4275 | int , | |
4276 | int , | |
4277 | int , | |
4278 | unsigned long* , | |
4279 | unsigned long* , | |
4280 | unsigned long* | |
4281 | ); | |
4282 | extern int XAllocNamedColor( | |
4283 | Display* , | |
4284 | Colormap , | |
4285 | const char* , | |
4286 | XColor* , | |
4287 | XColor* | |
4288 | ); | |
4289 | extern int XAllowEvents( | |
4290 | Display* , | |
4291 | int , | |
4292 | Time | |
4293 | ); | |
4294 | extern int XAutoRepeatOff( | |
4295 | Display* | |
4296 | ); | |
4297 | extern int XAutoRepeatOn( | |
4298 | Display* | |
4299 | ); | |
4300 | extern int XBell( | |
4301 | Display* , | |
4302 | int | |
4303 | ); | |
4304 | extern int XBitmapBitOrder( | |
4305 | Display* | |
4306 | ); | |
4307 | extern int XBitmapPad( | |
4308 | Display* | |
4309 | ); | |
4310 | extern int XBitmapUnit( | |
4311 | Display* | |
4312 | ); | |
4313 | extern int XCellsOfScreen( | |
4314 | Screen* | |
4315 | ); | |
4316 | extern int XChangeActivePointerGrab( | |
4317 | Display* , | |
4318 | unsigned int , | |
4319 | Cursor , | |
4320 | Time | |
4321 | ); | |
4322 | extern int XChangeGC( | |
4323 | Display* , | |
4324 | GC , | |
4325 | unsigned long , | |
4326 | XGCValues* | |
4327 | ); | |
4328 | extern int XChangeKeyboardControl( | |
4329 | Display* , | |
4330 | unsigned long , | |
4331 | XKeyboardControl* | |
4332 | ); | |
4333 | extern int XChangeKeyboardMapping( | |
4334 | Display* , | |
4335 | int , | |
4336 | int , | |
4337 | KeySym* , | |
4338 | int | |
4339 | ); | |
4340 | extern int XChangePointerControl( | |
4341 | Display* , | |
4342 | int , | |
4343 | int , | |
4344 | int , | |
4345 | int , | |
4346 | int | |
4347 | ); | |
4348 | extern int XChangeProperty( | |
4349 | Display* , | |
4350 | Window , | |
4351 | Atom , | |
4352 | Atom , | |
4353 | int , | |
4354 | int , | |
4355 | const unsigned char* , | |
4356 | int | |
4357 | ); | |
4358 | extern int XChangeSaveSet( | |
4359 | Display* , | |
4360 | Window , | |
4361 | int | |
4362 | ); | |
4363 | extern int XChangeWindowAttributes( | |
4364 | Display* , | |
4365 | Window , | |
4366 | unsigned long , | |
4367 | XSetWindowAttributes* | |
4368 | ); | |
4369 | extern int XCheckIfEvent( | |
4370 | Display* , | |
4371 | XEvent* , | |
4372 | int (*) ( | |
4373 | Display* , | |
4374 | XEvent* , | |
4375 | XPointer | |
4376 | ) , | |
4377 | XPointer | |
4378 | ); | |
4379 | extern int XCheckMaskEvent( | |
4380 | Display* , | |
4381 | long , | |
4382 | XEvent* | |
4383 | ); | |
4384 | extern int XCheckTypedEvent( | |
4385 | Display* , | |
4386 | int , | |
4387 | XEvent* | |
4388 | ); | |
4389 | extern int XCheckTypedWindowEvent( | |
4390 | Display* , | |
4391 | Window , | |
4392 | int , | |
4393 | XEvent* | |
4394 | ); | |
4395 | extern int XCheckWindowEvent( | |
4396 | Display* , | |
4397 | Window , | |
4398 | long , | |
4399 | XEvent* | |
4400 | ); | |
4401 | extern int XCirculateSubwindows( | |
4402 | Display* , | |
4403 | Window , | |
4404 | int | |
4405 | ); | |
4406 | extern int XCirculateSubwindowsDown( | |
4407 | Display* , | |
4408 | Window | |
4409 | ); | |
4410 | extern int XCirculateSubwindowsUp( | |
4411 | Display* , | |
4412 | Window | |
4413 | ); | |
4414 | extern int XClearArea( | |
4415 | Display* , | |
4416 | Window , | |
4417 | int , | |
4418 | int , | |
4419 | unsigned int , | |
4420 | unsigned int , | |
4421 | int | |
4422 | ); | |
4423 | extern int XClearWindow( | |
4424 | Display* , | |
4425 | Window | |
4426 | ); | |
4427 | extern int XCloseDisplay( | |
4428 | Display* | |
4429 | ); | |
4430 | extern int XConfigureWindow( | |
4431 | Display* , | |
4432 | Window , | |
4433 | unsigned int , | |
4434 | XWindowChanges* | |
4435 | ); | |
4436 | extern int XConnectionNumber( | |
4437 | Display* | |
4438 | ); | |
4439 | extern int XConvertSelection( | |
4440 | Display* , | |
4441 | Atom , | |
4442 | Atom , | |
4443 | Atom , | |
4444 | Window , | |
4445 | Time | |
4446 | ); | |
4447 | extern int XCopyArea( | |
4448 | Display* , | |
4449 | Drawable , | |
4450 | Drawable , | |
4451 | GC , | |
4452 | int , | |
4453 | int , | |
4454 | unsigned int , | |
4455 | unsigned int , | |
4456 | int , | |
4457 | int | |
4458 | ); | |
4459 | extern int XCopyGC( | |
4460 | Display* , | |
4461 | GC , | |
4462 | unsigned long , | |
4463 | GC | |
4464 | ); | |
4465 | extern int XCopyPlane( | |
4466 | Display* , | |
4467 | Drawable , | |
4468 | Drawable , | |
4469 | GC , | |
4470 | int , | |
4471 | int , | |
4472 | unsigned int , | |
4473 | unsigned int , | |
4474 | int , | |
4475 | int , | |
4476 | unsigned long | |
4477 | ); | |
4478 | extern int XDefaultDepth( | |
4479 | Display* , | |
4480 | int | |
4481 | ); | |
4482 | extern int XDefaultDepthOfScreen( | |
4483 | Screen* | |
4484 | ); | |
4485 | extern int XDefaultScreen( | |
4486 | Display* | |
4487 | ); | |
4488 | extern int XDefineCursor( | |
4489 | Display* , | |
4490 | Window , | |
4491 | Cursor | |
4492 | ); | |
4493 | extern int XDeleteProperty( | |
4494 | Display* , | |
4495 | Window , | |
4496 | Atom | |
4497 | ); | |
4498 | extern int XDestroyWindow( | |
4499 | Display* , | |
4500 | Window | |
4501 | ); | |
4502 | extern int XDestroySubwindows( | |
4503 | Display* , | |
4504 | Window | |
4505 | ); | |
4506 | extern int XDoesBackingStore( | |
4507 | Screen* | |
4508 | ); | |
4509 | extern int XDoesSaveUnders( | |
4510 | Screen* | |
4511 | ); | |
4512 | extern int XDisableAccessControl( | |
4513 | Display* | |
4514 | ); | |
4515 | extern int XDisplayCells( | |
4516 | Display* , | |
4517 | int | |
4518 | ); | |
4519 | extern int XDisplayHeight( | |
4520 | Display* , | |
4521 | int | |
4522 | ); | |
4523 | extern int XDisplayHeightMM( | |
4524 | Display* , | |
4525 | int | |
4526 | ); | |
4527 | extern int XDisplayKeycodes( | |
4528 | Display* , | |
4529 | int* , | |
4530 | int* | |
4531 | ); | |
4532 | extern int XDisplayPlanes( | |
4533 | Display* , | |
4534 | int | |
4535 | ); | |
4536 | extern int XDisplayWidth( | |
4537 | Display* , | |
4538 | int | |
4539 | ); | |
4540 | extern int XDisplayWidthMM( | |
4541 | Display* , | |
4542 | int | |
4543 | ); | |
4544 | extern int XDrawArc( | |
4545 | Display* , | |
4546 | Drawable , | |
4547 | GC , | |
4548 | int , | |
4549 | int , | |
4550 | unsigned int , | |
4551 | unsigned int , | |
4552 | int , | |
4553 | int | |
4554 | ); | |
4555 | extern int XDrawArcs( | |
4556 | Display* , | |
4557 | Drawable , | |
4558 | GC , | |
4559 | XArc* , | |
4560 | int | |
4561 | ); | |
4562 | extern int XDrawImageString( | |
4563 | Display* , | |
4564 | Drawable , | |
4565 | GC , | |
4566 | int , | |
4567 | int , | |
4568 | const char* , | |
4569 | int | |
4570 | ); | |
4571 | extern int XDrawImageString16( | |
4572 | Display* , | |
4573 | Drawable , | |
4574 | GC , | |
4575 | int , | |
4576 | int , | |
4577 | const XChar2b* , | |
4578 | int | |
4579 | ); | |
4580 | extern int XDrawLine( | |
4581 | Display* , | |
4582 | Drawable , | |
4583 | GC , | |
4584 | int , | |
4585 | int , | |
4586 | int , | |
4587 | int | |
4588 | ); | |
4589 | extern int XDrawLines( | |
4590 | Display* , | |
4591 | Drawable , | |
4592 | GC , | |
4593 | XPoint* , | |
4594 | int , | |
4595 | int | |
4596 | ); | |
4597 | extern int XDrawPoint( | |
4598 | Display* , | |
4599 | Drawable , | |
4600 | GC , | |
4601 | int , | |
4602 | int | |
4603 | ); | |
4604 | extern int XDrawPoints( | |
4605 | Display* , | |
4606 | Drawable , | |
4607 | GC , | |
4608 | XPoint* , | |
4609 | int , | |
4610 | int | |
4611 | ); | |
4612 | extern int XDrawRectangle( | |
4613 | Display* , | |
4614 | Drawable , | |
4615 | GC , | |
4616 | int , | |
4617 | int , | |
4618 | unsigned int , | |
4619 | unsigned int | |
4620 | ); | |
4621 | extern int XDrawRectangles( | |
4622 | Display* , | |
4623 | Drawable , | |
4624 | GC , | |
4625 | XRectangle* , | |
4626 | int | |
4627 | ); | |
4628 | extern int XDrawSegments( | |
4629 | Display* , | |
4630 | Drawable , | |
4631 | GC , | |
4632 | XSegment* , | |
4633 | int | |
4634 | ); | |
4635 | extern int XDrawString( | |
4636 | Display* , | |
4637 | Drawable , | |
4638 | GC , | |
4639 | int , | |
4640 | int , | |
4641 | const char* , | |
4642 | int | |
4643 | ); | |
4644 | extern int XDrawString16( | |
4645 | Display* , | |
4646 | Drawable , | |
4647 | GC , | |
4648 | int , | |
4649 | int , | |
4650 | const XChar2b* , | |
4651 | int | |
4652 | ); | |
4653 | extern int XDrawText( | |
4654 | Display* , | |
4655 | Drawable , | |
4656 | GC , | |
4657 | int , | |
4658 | int , | |
4659 | XTextItem* , | |
4660 | int | |
4661 | ); | |
4662 | extern int XDrawText16( | |
4663 | Display* , | |
4664 | Drawable , | |
4665 | GC , | |
4666 | int , | |
4667 | int , | |
4668 | XTextItem16* , | |
4669 | int | |
4670 | ); | |
4671 | extern int XEnableAccessControl( | |
4672 | Display* | |
4673 | ); | |
4674 | extern int XEventsQueued( | |
4675 | Display* , | |
4676 | int | |
4677 | ); | |
4678 | extern int XFetchName( | |
4679 | Display* , | |
4680 | Window , | |
4681 | char** | |
4682 | ); | |
4683 | extern int XFillArc( | |
4684 | Display* , | |
4685 | Drawable , | |
4686 | GC , | |
4687 | int , | |
4688 | int , | |
4689 | unsigned int , | |
4690 | unsigned int , | |
4691 | int , | |
4692 | int | |
4693 | ); | |
4694 | extern int XFillArcs( | |
4695 | Display* , | |
4696 | Drawable , | |
4697 | GC , | |
4698 | XArc* , | |
4699 | int | |
4700 | ); | |
4701 | extern int XFillPolygon( | |
4702 | Display* , | |
4703 | Drawable , | |
4704 | GC , | |
4705 | XPoint* , | |
4706 | int , | |
4707 | int , | |
4708 | int | |
4709 | ); | |
4710 | extern int XFillRectangle( | |
4711 | Display* , | |
4712 | Drawable , | |
4713 | GC , | |
4714 | int , | |
4715 | int , | |
4716 | unsigned int , | |
4717 | unsigned int | |
4718 | ); | |
4719 | extern int XFillRectangles( | |
4720 | Display* , | |
4721 | Drawable , | |
4722 | GC , | |
4723 | XRectangle* , | |
4724 | int | |
4725 | ); | |
4726 | extern int XFlush( | |
4727 | Display* | |
4728 | ); | |
4729 | extern int XForceScreenSaver( | |
4730 | Display* , | |
4731 | int | |
4732 | ); | |
4733 | extern int XFree( | |
4734 | void* | |
4735 | ); | |
4736 | extern int XFreeColormap( | |
4737 | Display* , | |
4738 | Colormap | |
4739 | ); | |
4740 | extern int XFreeColors( | |
4741 | Display* , | |
4742 | Colormap , | |
4743 | unsigned long* , | |
4744 | int , | |
4745 | unsigned long | |
4746 | ); | |
4747 | extern int XFreeCursor( | |
4748 | Display* , | |
4749 | Cursor | |
4750 | ); | |
4751 | extern int XFreeExtensionList( | |
4752 | char** | |
4753 | ); | |
4754 | extern int XFreeFont( | |
4755 | Display* , | |
4756 | XFontStruct* | |
4757 | ); | |
4758 | extern int XFreeFontInfo( | |
4759 | char** , | |
4760 | XFontStruct* , | |
4761 | int | |
4762 | ); | |
4763 | extern int XFreeFontNames( | |
4764 | char** | |
4765 | ); | |
4766 | extern int XFreeFontPath( | |
4767 | char** | |
4768 | ); | |
4769 | extern int XFreeGC( | |
4770 | Display* , | |
4771 | GC | |
4772 | ); | |
4773 | extern int XFreeModifiermap( | |
4774 | XModifierKeymap* | |
4775 | ); | |
4776 | extern int XFreePixmap( | |
4777 | Display* , | |
4778 | Pixmap | |
4779 | ); | |
4780 | extern int XGeometry( | |
4781 | Display* , | |
4782 | int , | |
4783 | const char* , | |
4784 | const char* , | |
4785 | unsigned int , | |
4786 | unsigned int , | |
4787 | unsigned int , | |
4788 | int , | |
4789 | int , | |
4790 | int* , | |
4791 | int* , | |
4792 | int* , | |
4793 | int* | |
4794 | ); | |
4795 | extern int XGetErrorDatabaseText( | |
4796 | Display* , | |
4797 | const char* , | |
4798 | const char* , | |
4799 | const char* , | |
4800 | char* , | |
4801 | int | |
4802 | ); | |
4803 | extern int XGetErrorText( | |
4804 | Display* , | |
4805 | int , | |
4806 | char* , | |
4807 | int | |
4808 | ); | |
4809 | extern int XGetFontProperty( | |
4810 | XFontStruct* , | |
4811 | Atom , | |
4812 | unsigned long* | |
4813 | ); | |
4814 | extern int XGetGCValues( | |
4815 | Display* , | |
4816 | GC , | |
4817 | unsigned long , | |
4818 | XGCValues* | |
4819 | ); | |
4820 | extern int XGetGeometry( | |
4821 | Display* , | |
4822 | Drawable , | |
4823 | Window* , | |
4824 | int* , | |
4825 | int* , | |
4826 | unsigned int* , | |
4827 | unsigned int* , | |
4828 | unsigned int* , | |
4829 | unsigned int* | |
4830 | ); | |
4831 | extern int XGetIconName( | |
4832 | Display* , | |
4833 | Window , | |
4834 | char** | |
4835 | ); | |
4836 | extern int XGetInputFocus( | |
4837 | Display* , | |
4838 | Window* , | |
4839 | int* | |
4840 | ); | |
4841 | extern int XGetKeyboardControl( | |
4842 | Display* , | |
4843 | XKeyboardState* | |
4844 | ); | |
4845 | extern int XGetPointerControl( | |
4846 | Display* , | |
4847 | int* , | |
4848 | int* , | |
4849 | int* | |
4850 | ); | |
4851 | extern int XGetPointerMapping( | |
4852 | Display* , | |
4853 | unsigned char* , | |
4854 | int | |
4855 | ); | |
4856 | extern int XGetScreenSaver( | |
4857 | Display* , | |
4858 | int* , | |
4859 | int* , | |
4860 | int* , | |
4861 | int* | |
4862 | ); | |
4863 | extern int XGetTransientForHint( | |
4864 | Display* , | |
4865 | Window , | |
4866 | Window* | |
4867 | ); | |
4868 | extern int XGetWindowProperty( | |
4869 | Display* , | |
4870 | Window , | |
4871 | Atom , | |
4872 | long , | |
4873 | long , | |
4874 | int , | |
4875 | Atom , | |
4876 | Atom* , | |
4877 | int* , | |
4878 | unsigned long* , | |
4879 | unsigned long* , | |
4880 | unsigned char** | |
4881 | ); | |
4882 | extern int XGetWindowAttributes( | |
4883 | Display* , | |
4884 | Window , | |
4885 | XWindowAttributes* | |
4886 | ); | |
4887 | extern int XGrabButton( | |
4888 | Display* , | |
4889 | unsigned int , | |
4890 | unsigned int , | |
4891 | Window , | |
4892 | int , | |
4893 | unsigned int , | |
4894 | int , | |
4895 | int , | |
4896 | Window , | |
4897 | Cursor | |
4898 | ); | |
4899 | extern int XGrabKey( | |
4900 | Display* , | |
4901 | int , | |
4902 | unsigned int , | |
4903 | Window , | |
4904 | int , | |
4905 | int , | |
4906 | int | |
4907 | ); | |
4908 | extern int XGrabKeyboard( | |
4909 | Display* , | |
4910 | Window , | |
4911 | int , | |
4912 | int , | |
4913 | int , | |
4914 | Time | |
4915 | ); | |
4916 | extern int XGrabPointer( | |
4917 | Display* , | |
4918 | Window , | |
4919 | int , | |
4920 | unsigned int , | |
4921 | int , | |
4922 | int , | |
4923 | Window , | |
4924 | Cursor , | |
4925 | Time | |
4926 | ); | |
4927 | extern int XGrabServer( | |
4928 | Display* | |
4929 | ); | |
4930 | extern int XHeightMMOfScreen( | |
4931 | Screen* | |
4932 | ); | |
4933 | extern int XHeightOfScreen( | |
4934 | Screen* | |
4935 | ); | |
4936 | extern int XIfEvent( | |
4937 | Display* , | |
4938 | XEvent* , | |
4939 | int (*) ( | |
4940 | Display* , | |
4941 | XEvent* , | |
4942 | XPointer | |
4943 | ) , | |
4944 | XPointer | |
4945 | ); | |
4946 | extern int XImageByteOrder( | |
4947 | Display* | |
4948 | ); | |
4949 | extern int XInstallColormap( | |
4950 | Display* , | |
4951 | Colormap | |
4952 | ); | |
4953 | extern KeyCode XKeysymToKeycode( | |
4954 | Display* , | |
4955 | KeySym | |
4956 | ); | |
4957 | extern int XKillClient( | |
4958 | Display* , | |
4959 | XID | |
4960 | ); | |
4961 | extern int XLookupColor( | |
4962 | Display* , | |
4963 | Colormap , | |
4964 | const char* , | |
4965 | XColor* , | |
4966 | XColor* | |
4967 | ); | |
4968 | extern int XLowerWindow( | |
4969 | Display* , | |
4970 | Window | |
4971 | ); | |
4972 | extern int XMapRaised( | |
4973 | Display* , | |
4974 | Window | |
4975 | ); | |
4976 | extern int XMapSubwindows( | |
4977 | Display* , | |
4978 | Window | |
4979 | ); | |
4980 | extern int XMapWindow( | |
4981 | Display* , | |
4982 | Window | |
4983 | ); | |
4984 | extern int XMaskEvent( | |
4985 | Display* , | |
4986 | long , | |
4987 | XEvent* | |
4988 | ); | |
4989 | extern int XMaxCmapsOfScreen( | |
4990 | Screen* | |
4991 | ); | |
4992 | extern int XMinCmapsOfScreen( | |
4993 | Screen* | |
4994 | ); | |
4995 | extern int XMoveResizeWindow( | |
4996 | Display* , | |
4997 | Window , | |
4998 | int , | |
4999 | int , | |
5000 | unsigned int , | |
5001 | unsigned int | |
5002 | ); | |
5003 | extern int XMoveWindow( | |
5004 | Display* , | |
5005 | Window , | |
5006 | int , | |
5007 | int | |
5008 | ); | |
5009 | extern int XNextEvent( | |
5010 | Display* , | |
5011 | XEvent* | |
5012 | ); | |
5013 | extern int XNoOp( | |
5014 | Display* | |
5015 | ); | |
5016 | extern int XParseColor( | |
5017 | Display* , | |
5018 | Colormap , | |
5019 | const char* , | |
5020 | XColor* | |
5021 | ); | |
5022 | extern int XParseGeometry( | |
5023 | const char* , | |
5024 | int* , | |
5025 | int* , | |
5026 | unsigned int* , | |
5027 | unsigned int* | |
5028 | ); | |
5029 | extern int XPeekEvent( | |
5030 | Display* , | |
5031 | XEvent* | |
5032 | ); | |
5033 | extern int XPeekIfEvent( | |
5034 | Display* , | |
5035 | XEvent* , | |
5036 | int (*) ( | |
5037 | Display* , | |
5038 | XEvent* , | |
5039 | XPointer | |
5040 | ) , | |
5041 | XPointer | |
5042 | ); | |
5043 | extern int XPending( | |
5044 | Display* | |
5045 | ); | |
5046 | extern int XPlanesOfScreen( | |
5047 | Screen* | |
5048 | ); | |
5049 | extern int XProtocolRevision( | |
5050 | Display* | |
5051 | ); | |
5052 | extern int XProtocolVersion( | |
5053 | Display* | |
5054 | ); | |
5055 | extern int XPutBackEvent( | |
5056 | Display* , | |
5057 | XEvent* | |
5058 | ); | |
5059 | extern int XPutImage( | |
5060 | Display* , | |
5061 | Drawable , | |
5062 | GC , | |
5063 | XImage* , | |
5064 | int , | |
5065 | int , | |
5066 | int , | |
5067 | int , | |
5068 | unsigned int , | |
5069 | unsigned int | |
5070 | ); | |
5071 | extern int XQLength( | |
5072 | Display* | |
5073 | ); | |
5074 | extern int XQueryBestCursor( | |
5075 | Display* , | |
5076 | Drawable , | |
5077 | unsigned int , | |
5078 | unsigned int , | |
5079 | unsigned int* , | |
5080 | unsigned int* | |
5081 | ); | |
5082 | extern int XQueryBestSize( | |
5083 | Display* , | |
5084 | int , | |
5085 | Drawable , | |
5086 | unsigned int , | |
5087 | unsigned int , | |
5088 | unsigned int* , | |
5089 | unsigned int* | |
5090 | ); | |
5091 | extern int XQueryBestStipple( | |
5092 | Display* , | |
5093 | Drawable , | |
5094 | unsigned int , | |
5095 | unsigned int , | |
5096 | unsigned int* , | |
5097 | unsigned int* | |
5098 | ); | |
5099 | extern int XQueryBestTile( | |
5100 | Display* , | |
5101 | Drawable , | |
5102 | unsigned int , | |
5103 | unsigned int , | |
5104 | unsigned int* , | |
5105 | unsigned int* | |
5106 | ); | |
5107 | extern int XQueryColor( | |
5108 | Display* , | |
5109 | Colormap , | |
5110 | XColor* | |
5111 | ); | |
5112 | extern int XQueryColors( | |
5113 | Display* , | |
5114 | Colormap , | |
5115 | XColor* , | |
5116 | int | |
5117 | ); | |
5118 | extern int XQueryExtension( | |
5119 | Display* , | |
5120 | const char* , | |
5121 | int* , | |
5122 | int* , | |
5123 | int* | |
5124 | ); | |
5125 | extern int XQueryKeymap( | |
5126 | Display* , | |
5127 | char [32] | |
5128 | ); | |
5129 | extern int XQueryPointer( | |
5130 | Display* , | |
5131 | Window , | |
5132 | Window* , | |
5133 | Window* , | |
5134 | int* , | |
5135 | int* , | |
5136 | int* , | |
5137 | int* , | |
5138 | unsigned int* | |
5139 | ); | |
5140 | extern int XQueryTextExtents( | |
5141 | Display* , | |
5142 | XID , | |
5143 | const char* , | |
5144 | int , | |
5145 | int* , | |
5146 | int* , | |
5147 | int* , | |
5148 | XCharStruct* | |
5149 | ); | |
5150 | extern int XQueryTextExtents16( | |
5151 | Display* , | |
5152 | XID , | |
5153 | const XChar2b* , | |
5154 | int , | |
5155 | int* , | |
5156 | int* , | |
5157 | int* , | |
5158 | XCharStruct* | |
5159 | ); | |
5160 | extern int XQueryTree( | |
5161 | Display* , | |
5162 | Window , | |
5163 | Window* , | |
5164 | Window* , | |
5165 | Window** , | |
5166 | unsigned int* | |
5167 | ); | |
5168 | extern int XRaiseWindow( | |
5169 | Display* , | |
5170 | Window | |
5171 | ); | |
5172 | extern int XReadBitmapFile( | |
5173 | Display* , | |
5174 | Drawable , | |
5175 | const char* , | |
5176 | unsigned int* , | |
5177 | unsigned int* , | |
5178 | Pixmap* , | |
5179 | int* , | |
5180 | int* | |
5181 | ); | |
5182 | extern int XReadBitmapFileData( | |
5183 | const char* , | |
5184 | unsigned int* , | |
5185 | unsigned int* , | |
5186 | unsigned char** , | |
5187 | int* , | |
5188 | int* | |
5189 | ); | |
5190 | extern int XRebindKeysym( | |
5191 | Display* , | |
5192 | KeySym , | |
5193 | KeySym* , | |
5194 | int , | |
5195 | const unsigned char* , | |
5196 | int | |
5197 | ); | |
5198 | extern int XRecolorCursor( | |
5199 | Display* , | |
5200 | Cursor , | |
5201 | XColor* , | |
5202 | XColor* | |
5203 | ); | |
5204 | extern int XRefreshKeyboardMapping( | |
5205 | XMappingEvent* | |
5206 | ); | |
5207 | extern int XRemoveFromSaveSet( | |
5208 | Display* , | |
5209 | Window | |
5210 | ); | |
5211 | extern int XRemoveHost( | |
5212 | Display* , | |
5213 | XHostAddress* | |
5214 | ); | |
5215 | extern int XRemoveHosts( | |
5216 | Display* , | |
5217 | XHostAddress* , | |
5218 | int | |
5219 | ); | |
5220 | extern int XReparentWindow( | |
5221 | Display* , | |
5222 | Window , | |
5223 | Window , | |
5224 | int , | |
5225 | int | |
5226 | ); | |
5227 | extern int XResetScreenSaver( | |
5228 | Display* | |
5229 | ); | |
5230 | extern int XResizeWindow( | |
5231 | Display* , | |
5232 | Window , | |
5233 | unsigned int , | |
5234 | unsigned int | |
5235 | ); | |
5236 | extern int XRestackWindows( | |
5237 | Display* , | |
5238 | Window* , | |
5239 | int | |
5240 | ); | |
5241 | extern int XRotateBuffers( | |
5242 | Display* , | |
5243 | int | |
5244 | ); | |
5245 | extern int XRotateWindowProperties( | |
5246 | Display* , | |
5247 | Window , | |
5248 | Atom* , | |
5249 | int , | |
5250 | int | |
5251 | ); | |
5252 | extern int XScreenCount( | |
5253 | Display* | |
5254 | ); | |
5255 | extern int XSelectInput( | |
5256 | Display* , | |
5257 | Window , | |
5258 | long | |
5259 | ); | |
5260 | extern int XSendEvent( | |
5261 | Display* , | |
5262 | Window , | |
5263 | int , | |
5264 | long , | |
5265 | XEvent* | |
5266 | ); | |
5267 | extern int XSetAccessControl( | |
5268 | Display* , | |
5269 | int | |
5270 | ); | |
5271 | extern int XSetArcMode( | |
5272 | Display* , | |
5273 | GC , | |
5274 | int | |
5275 | ); | |
5276 | extern int XSetBackground( | |
5277 | Display* , | |
5278 | GC , | |
5279 | unsigned long | |
5280 | ); | |
5281 | extern int XSetClipMask( | |
5282 | Display* , | |
5283 | GC , | |
5284 | Pixmap | |
5285 | ); | |
5286 | extern int XSetClipOrigin( | |
5287 | Display* , | |
5288 | GC , | |
5289 | int , | |
5290 | int | |
5291 | ); | |
5292 | extern int XSetClipRectangles( | |
5293 | Display* , | |
5294 | GC , | |
5295 | int , | |
5296 | int , | |
5297 | XRectangle* , | |
5298 | int , | |
5299 | int | |
5300 | ); | |
5301 | extern int XSetCloseDownMode( | |
5302 | Display* , | |
5303 | int | |
5304 | ); | |
5305 | extern int XSetCommand( | |
5306 | Display* , | |
5307 | Window , | |
5308 | char** , | |
5309 | int | |
5310 | ); | |
5311 | extern int XSetDashes( | |
5312 | Display* , | |
5313 | GC , | |
5314 | int , | |
5315 | const char* , | |
5316 | int | |
5317 | ); | |
5318 | extern int XSetFillRule( | |
5319 | Display* , | |
5320 | GC , | |
5321 | int | |
5322 | ); | |
5323 | extern int XSetFillStyle( | |
5324 | Display* , | |
5325 | GC , | |
5326 | int | |
5327 | ); | |
5328 | extern int XSetFont( | |
5329 | Display* , | |
5330 | GC , | |
5331 | Font | |
5332 | ); | |
5333 | extern int XSetFontPath( | |
5334 | Display* , | |
5335 | char** , | |
5336 | int | |
5337 | ); | |
5338 | extern int XSetForeground( | |
5339 | Display* , | |
5340 | GC , | |
5341 | unsigned long | |
5342 | ); | |
5343 | extern int XSetFunction( | |
5344 | Display* , | |
5345 | GC , | |
5346 | int | |
5347 | ); | |
5348 | extern int XSetGraphicsExposures( | |
5349 | Display* , | |
5350 | GC , | |
5351 | int | |
5352 | ); | |
5353 | extern int XSetIconName( | |
5354 | Display* , | |
5355 | Window , | |
5356 | const char* | |
5357 | ); | |
5358 | extern int XSetInputFocus( | |
5359 | Display* , | |
5360 | Window , | |
5361 | int , | |
5362 | Time | |
5363 | ); | |
5364 | extern int XSetLineAttributes( | |
5365 | Display* , | |
5366 | GC , | |
5367 | unsigned int , | |
5368 | int , | |
5369 | int , | |
5370 | int | |
5371 | ); | |
5372 | extern int XSetModifierMapping( | |
5373 | Display* , | |
5374 | XModifierKeymap* | |
5375 | ); | |
5376 | extern int XSetPlaneMask( | |
5377 | Display* , | |
5378 | GC , | |
5379 | unsigned long | |
5380 | ); | |
5381 | extern int XSetPointerMapping( | |
5382 | Display* , | |
5383 | const unsigned char* , | |
5384 | int | |
5385 | ); | |
5386 | extern int XSetScreenSaver( | |
5387 | Display* , | |
5388 | int , | |
5389 | int , | |
5390 | int , | |
5391 | int | |
5392 | ); | |
5393 | extern int XSetSelectionOwner( | |
5394 | Display* , | |
5395 | Atom , | |
5396 | Window , | |
5397 | Time | |
5398 | ); | |
5399 | extern int XSetState( | |
5400 | Display* , | |
5401 | GC , | |
5402 | unsigned long , | |
5403 | unsigned long , | |
5404 | int , | |
5405 | unsigned long | |
5406 | ); | |
5407 | extern int XSetStipple( | |
5408 | Display* , | |
5409 | GC , | |
5410 | Pixmap | |
5411 | ); | |
5412 | extern int XSetSubwindowMode( | |
5413 | Display* , | |
5414 | GC , | |
5415 | int | |
5416 | ); | |
5417 | extern int XSetTSOrigin( | |
5418 | Display* , | |
5419 | GC , | |
5420 | int , | |
5421 | int | |
5422 | ); | |
5423 | extern int XSetTile( | |
5424 | Display* , | |
5425 | GC , | |
5426 | Pixmap | |
5427 | ); | |
5428 | extern int XSetWindowBackground( | |
5429 | Display* , | |
5430 | Window , | |
5431 | unsigned long | |
5432 | ); | |
5433 | extern int XSetWindowBackgroundPixmap( | |
5434 | Display* , | |
5435 | Window , | |
5436 | Pixmap | |
5437 | ); | |
5438 | extern int XSetWindowBorder( | |
5439 | Display* , | |
5440 | Window , | |
5441 | unsigned long | |
5442 | ); | |
5443 | extern int XSetWindowBorderPixmap( | |
5444 | Display* , | |
5445 | Window , | |
5446 | Pixmap | |
5447 | ); | |
5448 | extern int XSetWindowBorderWidth( | |
5449 | Display* , | |
5450 | Window , | |
5451 | unsigned int | |
5452 | ); | |
5453 | extern int XSetWindowColormap( | |
5454 | Display* , | |
5455 | Window , | |
5456 | Colormap | |
5457 | ); | |
5458 | extern int XStoreBuffer( | |
5459 | Display* , | |
5460 | const char* , | |
5461 | int , | |
5462 | int | |
5463 | ); | |
5464 | extern int XStoreBytes( | |
5465 | Display* , | |
5466 | const char* , | |
5467 | int | |
5468 | ); | |
5469 | extern int XStoreColor( | |
5470 | Display* , | |
5471 | Colormap , | |
5472 | XColor* | |
5473 | ); | |
5474 | extern int XStoreColors( | |
5475 | Display* , | |
5476 | Colormap , | |
5477 | XColor* , | |
5478 | int | |
5479 | ); | |
5480 | extern int XStoreName( | |
5481 | Display* , | |
5482 | Window , | |
5483 | const char* | |
5484 | ); | |
5485 | extern int XStoreNamedColor( | |
5486 | Display* , | |
5487 | Colormap , | |
5488 | const char* , | |
5489 | unsigned long , | |
5490 | int | |
5491 | ); | |
5492 | extern int XSync( | |
5493 | Display* , | |
5494 | int | |
5495 | ); | |
5496 | extern int XTextExtents( | |
5497 | XFontStruct* , | |
5498 | const char* , | |
5499 | int , | |
5500 | int* , | |
5501 | int* , | |
5502 | int* , | |
5503 | XCharStruct* | |
5504 | ); | |
5505 | extern int XTextExtents16( | |
5506 | XFontStruct* , | |
5507 | const XChar2b* , | |
5508 | int , | |
5509 | int* , | |
5510 | int* , | |
5511 | int* , | |
5512 | XCharStruct* | |
5513 | ); | |
5514 | extern int XTextWidth( | |
5515 | XFontStruct* , | |
5516 | const char* , | |
5517 | int | |
5518 | ); | |
5519 | extern int XTextWidth16( | |
5520 | XFontStruct* , | |
5521 | const XChar2b* , | |
5522 | int | |
5523 | ); | |
5524 | extern int XTranslateCoordinates( | |
5525 | Display* , | |
5526 | Window , | |
5527 | Window , | |
5528 | int , | |
5529 | int , | |
5530 | int* , | |
5531 | int* , | |
5532 | Window* | |
5533 | ); | |
5534 | extern int XUndefineCursor( | |
5535 | Display* , | |
5536 | Window | |
5537 | ); | |
5538 | extern int XUngrabButton( | |
5539 | Display* , | |
5540 | unsigned int , | |
5541 | unsigned int , | |
5542 | Window | |
5543 | ); | |
5544 | extern int XUngrabKey( | |
5545 | Display* , | |
5546 | int , | |
5547 | unsigned int , | |
5548 | Window | |
5549 | ); | |
5550 | extern int XUngrabKeyboard( | |
5551 | Display* , | |
5552 | Time | |
5553 | ); | |
5554 | extern int XUngrabPointer( | |
5555 | Display* , | |
5556 | Time | |
5557 | ); | |
5558 | extern int XUngrabServer( | |
5559 | Display* | |
5560 | ); | |
5561 | extern int XUninstallColormap( | |
5562 | Display* , | |
5563 | Colormap | |
5564 | ); | |
5565 | extern int XUnloadFont( | |
5566 | Display* , | |
5567 | Font | |
5568 | ); | |
5569 | extern int XUnmapSubwindows( | |
5570 | Display* , | |
5571 | Window | |
5572 | ); | |
5573 | extern int XUnmapWindow( | |
5574 | Display* , | |
5575 | Window | |
5576 | ); | |
5577 | extern int XVendorRelease( | |
5578 | Display* | |
5579 | ); | |
5580 | extern int XWarpPointer( | |
5581 | Display* , | |
5582 | Window , | |
5583 | Window , | |
5584 | int , | |
5585 | int , | |
5586 | unsigned int , | |
5587 | unsigned int , | |
5588 | int , | |
5589 | int | |
5590 | ); | |
5591 | extern int XWidthMMOfScreen( | |
5592 | Screen* | |
5593 | ); | |
5594 | extern int XWidthOfScreen( | |
5595 | Screen* | |
5596 | ); | |
5597 | extern int XWindowEvent( | |
5598 | Display* , | |
5599 | Window , | |
5600 | long , | |
5601 | XEvent* | |
5602 | ); | |
5603 | extern int XWriteBitmapFile( | |
5604 | Display* , | |
5605 | const char* , | |
5606 | Pixmap , | |
5607 | unsigned int , | |
5608 | unsigned int , | |
5609 | int , | |
5610 | int | |
5611 | ); | |
5612 | extern int XSupportsLocale (void); | |
5613 | extern char *XSetLocaleModifiers( | |
5614 | const char* | |
5615 | ); | |
5616 | extern XOM XOpenOM( | |
5617 | Display* , | |
5618 | struct _XrmHashBucketRec* , | |
5619 | const char* , | |
5620 | const char* | |
5621 | ); | |
5622 | extern int XCloseOM( | |
5623 | XOM | |
5624 | ); | |
5625 | extern char *XSetOMValues( | |
5626 | XOM , | |
5627 | ... | |
5628 | ) __attribute__ ((__sentinel__(0))); | |
5629 | extern char *XGetOMValues( | |
5630 | XOM , | |
5631 | ... | |
5632 | ) __attribute__ ((__sentinel__(0))); | |
5633 | extern Display *XDisplayOfOM( | |
5634 | XOM | |
5635 | ); | |
5636 | extern char *XLocaleOfOM( | |
5637 | XOM | |
5638 | ); | |
5639 | extern XOC XCreateOC( | |
5640 | XOM , | |
5641 | ... | |
5642 | ) __attribute__ ((__sentinel__(0))); | |
5643 | extern void XDestroyOC( | |
5644 | XOC | |
5645 | ); | |
5646 | extern XOM XOMOfOC( | |
5647 | XOC | |
5648 | ); | |
5649 | extern char *XSetOCValues( | |
5650 | XOC , | |
5651 | ... | |
5652 | ) __attribute__ ((__sentinel__(0))); | |
5653 | extern char *XGetOCValues( | |
5654 | XOC , | |
5655 | ... | |
5656 | ) __attribute__ ((__sentinel__(0))); | |
5657 | extern XFontSet XCreateFontSet( | |
5658 | Display* , | |
5659 | const char* , | |
5660 | char*** , | |
5661 | int* , | |
5662 | char** | |
5663 | ); | |
5664 | extern void XFreeFontSet( | |
5665 | Display* , | |
5666 | XFontSet | |
5667 | ); | |
5668 | extern int XFontsOfFontSet( | |
5669 | XFontSet , | |
5670 | XFontStruct*** , | |
5671 | char*** | |
5672 | ); | |
5673 | extern char *XBaseFontNameListOfFontSet( | |
5674 | XFontSet | |
5675 | ); | |
5676 | extern char *XLocaleOfFontSet( | |
5677 | XFontSet | |
5678 | ); | |
5679 | extern int XContextDependentDrawing( | |
5680 | XFontSet | |
5681 | ); | |
5682 | extern int XDirectionalDependentDrawing( | |
5683 | XFontSet | |
5684 | ); | |
5685 | extern int XContextualDrawing( | |
5686 | XFontSet | |
5687 | ); | |
5688 | extern XFontSetExtents *XExtentsOfFontSet( | |
5689 | XFontSet | |
5690 | ); | |
5691 | extern int XmbTextEscapement( | |
5692 | XFontSet , | |
5693 | const char* , | |
5694 | int | |
5695 | ); | |
5696 | extern int XwcTextEscapement( | |
5697 | XFontSet , | |
5698 | const wchar_t* , | |
5699 | int | |
5700 | ); | |
5701 | extern int Xutf8TextEscapement( | |
5702 | XFontSet , | |
5703 | const char* , | |
5704 | int | |
5705 | ); | |
5706 | extern int XmbTextExtents( | |
5707 | XFontSet , | |
5708 | const char* , | |
5709 | int , | |
5710 | XRectangle* , | |
5711 | XRectangle* | |
5712 | ); | |
5713 | extern int XwcTextExtents( | |
5714 | XFontSet , | |
5715 | const wchar_t* , | |
5716 | int , | |
5717 | XRectangle* , | |
5718 | XRectangle* | |
5719 | ); | |
5720 | extern int Xutf8TextExtents( | |
5721 | XFontSet , | |
5722 | const char* , | |
5723 | int , | |
5724 | XRectangle* , | |
5725 | XRectangle* | |
5726 | ); | |
5727 | extern int XmbTextPerCharExtents( | |
5728 | XFontSet , | |
5729 | const char* , | |
5730 | int , | |
5731 | XRectangle* , | |
5732 | XRectangle* , | |
5733 | int , | |
5734 | int* , | |
5735 | XRectangle* , | |
5736 | XRectangle* | |
5737 | ); | |
5738 | extern int XwcTextPerCharExtents( | |
5739 | XFontSet , | |
5740 | const wchar_t* , | |
5741 | int , | |
5742 | XRectangle* , | |
5743 | XRectangle* , | |
5744 | int , | |
5745 | int* , | |
5746 | XRectangle* , | |
5747 | XRectangle* | |
5748 | ); | |
5749 | extern int Xutf8TextPerCharExtents( | |
5750 | XFontSet , | |
5751 | const char* , | |
5752 | int , | |
5753 | XRectangle* , | |
5754 | XRectangle* , | |
5755 | int , | |
5756 | int* , | |
5757 | XRectangle* , | |
5758 | XRectangle* | |
5759 | ); | |
5760 | extern void XmbDrawText( | |
5761 | Display* , | |
5762 | Drawable , | |
5763 | GC , | |
5764 | int , | |
5765 | int , | |
5766 | XmbTextItem* , | |
5767 | int | |
5768 | ); | |
5769 | extern void XwcDrawText( | |
5770 | Display* , | |
5771 | Drawable , | |
5772 | GC , | |
5773 | int , | |
5774 | int , | |
5775 | XwcTextItem* , | |
5776 | int | |
5777 | ); | |
5778 | extern void Xutf8DrawText( | |
5779 | Display* , | |
5780 | Drawable , | |
5781 | GC , | |
5782 | int , | |
5783 | int , | |
5784 | XmbTextItem* , | |
5785 | int | |
5786 | ); | |
5787 | extern void XmbDrawString( | |
5788 | Display* , | |
5789 | Drawable , | |
5790 | XFontSet , | |
5791 | GC , | |
5792 | int , | |
5793 | int , | |
5794 | const char* , | |
5795 | int | |
5796 | ); | |
5797 | extern void XwcDrawString( | |
5798 | Display* , | |
5799 | Drawable , | |
5800 | XFontSet , | |
5801 | GC , | |
5802 | int , | |
5803 | int , | |
5804 | const wchar_t* , | |
5805 | int | |
5806 | ); | |
5807 | extern void Xutf8DrawString( | |
5808 | Display* , | |
5809 | Drawable , | |
5810 | XFontSet , | |
5811 | GC , | |
5812 | int , | |
5813 | int , | |
5814 | const char* , | |
5815 | int | |
5816 | ); | |
5817 | extern void XmbDrawImageString( | |
5818 | Display* , | |
5819 | Drawable , | |
5820 | XFontSet , | |
5821 | GC , | |
5822 | int , | |
5823 | int , | |
5824 | const char* , | |
5825 | int | |
5826 | ); | |
5827 | extern void XwcDrawImageString( | |
5828 | Display* , | |
5829 | Drawable , | |
5830 | XFontSet , | |
5831 | GC , | |
5832 | int , | |
5833 | int , | |
5834 | const wchar_t* , | |
5835 | int | |
5836 | ); | |
5837 | extern void Xutf8DrawImageString( | |
5838 | Display* , | |
5839 | Drawable , | |
5840 | XFontSet , | |
5841 | GC , | |
5842 | int , | |
5843 | int , | |
5844 | const char* , | |
5845 | int | |
5846 | ); | |
5847 | extern XIM XOpenIM( | |
5848 | Display* , | |
5849 | struct _XrmHashBucketRec* , | |
5850 | char* , | |
5851 | char* | |
5852 | ); | |
5853 | extern int XCloseIM( | |
5854 | XIM | |
5855 | ); | |
5856 | extern char *XGetIMValues( | |
5857 | XIM , ... | |
5858 | ) __attribute__ ((__sentinel__(0))); | |
5859 | extern char *XSetIMValues( | |
5860 | XIM , ... | |
5861 | ) __attribute__ ((__sentinel__(0))); | |
5862 | extern Display *XDisplayOfIM( | |
5863 | XIM | |
5864 | ); | |
5865 | extern char *XLocaleOfIM( | |
5866 | XIM | |
5867 | ); | |
5868 | extern XIC XCreateIC( | |
5869 | XIM , ... | |
5870 | ) __attribute__ ((__sentinel__(0))); | |
5871 | extern void XDestroyIC( | |
5872 | XIC | |
5873 | ); | |
5874 | extern void XSetICFocus( | |
5875 | XIC | |
5876 | ); | |
5877 | extern void XUnsetICFocus( | |
5878 | XIC | |
5879 | ); | |
5880 | extern wchar_t *XwcResetIC( | |
5881 | XIC | |
5882 | ); | |
5883 | extern char *XmbResetIC( | |
5884 | XIC | |
5885 | ); | |
5886 | extern char *Xutf8ResetIC( | |
5887 | XIC | |
5888 | ); | |
5889 | extern char *XSetICValues( | |
5890 | XIC , ... | |
5891 | ) __attribute__ ((__sentinel__(0))); | |
5892 | extern char *XGetICValues( | |
5893 | XIC , ... | |
5894 | ) __attribute__ ((__sentinel__(0))); | |
5895 | extern XIM XIMOfIC( | |
5896 | XIC | |
5897 | ); | |
5898 | extern int XFilterEvent( | |
5899 | XEvent* , | |
5900 | Window | |
5901 | ); | |
5902 | extern int XmbLookupString( | |
5903 | XIC , | |
5904 | XKeyPressedEvent* , | |
5905 | char* , | |
5906 | int , | |
5907 | KeySym* , | |
5908 | int* | |
5909 | ); | |
5910 | extern int XwcLookupString( | |
5911 | XIC , | |
5912 | XKeyPressedEvent* , | |
5913 | wchar_t* , | |
5914 | int , | |
5915 | KeySym* , | |
5916 | int* | |
5917 | ); | |
5918 | extern int Xutf8LookupString( | |
5919 | XIC , | |
5920 | XKeyPressedEvent* , | |
5921 | char* , | |
5922 | int , | |
5923 | KeySym* , | |
5924 | int* | |
5925 | ); | |
5926 | extern XVaNestedList XVaCreateNestedList( | |
5927 | int , ... | |
5928 | ) __attribute__ ((__sentinel__(0))); | |
5929 | extern int XRegisterIMInstantiateCallback( | |
5930 | Display* , | |
5931 | struct _XrmHashBucketRec* , | |
5932 | char* , | |
5933 | char* , | |
5934 | XIDProc , | |
5935 | XPointer | |
5936 | ); | |
5937 | extern int XUnregisterIMInstantiateCallback( | |
5938 | Display* , | |
5939 | struct _XrmHashBucketRec* , | |
5940 | char* , | |
5941 | char* , | |
5942 | XIDProc , | |
5943 | XPointer | |
5944 | ); | |
5945 | typedef void (*XConnectionWatchProc)( | |
5946 | Display* , | |
5947 | XPointer , | |
5948 | int , | |
5949 | int , | |
5950 | XPointer* | |
5951 | ); | |
5952 | extern int XInternalConnectionNumbers( | |
5953 | Display* , | |
5954 | int** , | |
5955 | int* | |
5956 | ); | |
5957 | extern void XProcessInternalConnection( | |
5958 | Display* , | |
5959 | int | |
5960 | ); | |
5961 | extern int XAddConnectionWatch( | |
5962 | Display* , | |
5963 | XConnectionWatchProc , | |
5964 | XPointer | |
5965 | ); | |
5966 | extern void XRemoveConnectionWatch( | |
5967 | Display* , | |
5968 | XConnectionWatchProc , | |
5969 | XPointer | |
5970 | ); | |
5971 | extern void XSetAuthorization( | |
5972 | char * , | |
5973 | int , | |
5974 | char * , | |
5975 | int | |
5976 | ); | |
5977 | extern int _Xmbtowc( | |
5978 | wchar_t * , | |
5979 | char * , | |
5980 | int | |
5981 | ); | |
5982 | extern int _Xwctomb( | |
5983 | char * , | |
5984 | wchar_t | |
5985 | ); | |
5986 | } | |
5987 | typedef struct { | |
5988 | long flags; | |
5989 | int x, y; | |
5990 | int width, height; | |
5991 | int min_width, min_height; | |
5992 | int max_width, max_height; | |
5993 | int width_inc, height_inc; | |
5994 | struct { | |
5995 | int x; | |
5996 | int y; | |
5997 | } min_aspect, max_aspect; | |
5998 | int base_width, base_height; | |
5999 | int win_gravity; | |
6000 | } XSizeHints; | |
6001 | typedef struct { | |
6002 | long flags; | |
6003 | int input; | |
6004 | int initial_state; | |
6005 | Pixmap icon_pixmap; | |
6006 | Window icon_window; | |
6007 | int icon_x, icon_y; | |
6008 | Pixmap icon_mask; | |
6009 | XID window_group; | |
6010 | } XWMHints; | |
6011 | typedef struct { | |
6012 | unsigned char *value; | |
6013 | Atom encoding; | |
6014 | int format; | |
6015 | unsigned long nitems; | |
6016 | } XTextProperty; | |
6017 | typedef enum { | |
6018 | XStringStyle, | |
6019 | XCompoundTextStyle, | |
6020 | XTextStyle, | |
6021 | XStdICCTextStyle, | |
6022 | XUTF8StringStyle | |
6023 | } XICCEncodingStyle; | |
6024 | typedef struct { | |
6025 | int min_width, min_height; | |
6026 | int max_width, max_height; | |
6027 | int width_inc, height_inc; | |
6028 | } XIconSize; | |
6029 | typedef struct { | |
6030 | char *res_name; | |
6031 | char *res_class; | |
6032 | } XClassHint; | |
6033 | typedef struct _XComposeStatus { | |
6034 | XPointer compose_ptr; | |
6035 | int chars_matched; | |
6036 | } XComposeStatus; | |
6037 | typedef struct _XRegion *Region; | |
6038 | typedef struct { | |
6039 | Visual *visual; | |
6040 | VisualID visualid; | |
6041 | int screen; | |
6042 | int depth; | |
6043 | int c_class; | |
6044 | unsigned long red_mask; | |
6045 | unsigned long green_mask; | |
6046 | unsigned long blue_mask; | |
6047 | int colormap_size; | |
6048 | int bits_per_rgb; | |
6049 | } XVisualInfo; | |
6050 | typedef struct { | |
6051 | Colormap colormap; | |
6052 | unsigned long red_max; | |
6053 | unsigned long red_mult; | |
6054 | unsigned long green_max; | |
6055 | unsigned long green_mult; | |
6056 | unsigned long blue_max; | |
6057 | unsigned long blue_mult; | |
6058 | unsigned long base_pixel; | |
6059 | VisualID visualid; | |
6060 | XID killid; | |
6061 | } XStandardColormap; | |
6062 | typedef int XContext; | |
6063 | extern "C" { | |
6064 | extern XClassHint *XAllocClassHint ( | |
6065 | void | |
6066 | ); | |
6067 | extern XIconSize *XAllocIconSize ( | |
6068 | void | |
6069 | ); | |
6070 | extern XSizeHints *XAllocSizeHints ( | |
6071 | void | |
6072 | ); | |
6073 | extern XStandardColormap *XAllocStandardColormap ( | |
6074 | void | |
6075 | ); | |
6076 | extern XWMHints *XAllocWMHints ( | |
6077 | void | |
6078 | ); | |
6079 | extern int XClipBox( | |
6080 | Region , | |
6081 | XRectangle* | |
6082 | ); | |
6083 | extern Region XCreateRegion( | |
6084 | void | |
6085 | ); | |
6086 | extern const char *XDefaultString (void); | |
6087 | extern int XDeleteContext( | |
6088 | Display* , | |
6089 | XID , | |
6090 | XContext | |
6091 | ); | |
6092 | extern int XDestroyRegion( | |
6093 | Region | |
6094 | ); | |
6095 | extern int XEmptyRegion( | |
6096 | Region | |
6097 | ); | |
6098 | extern int XEqualRegion( | |
6099 | Region , | |
6100 | Region | |
6101 | ); | |
6102 | extern int XFindContext( | |
6103 | Display* , | |
6104 | XID , | |
6105 | XContext , | |
6106 | XPointer* | |
6107 | ); | |
6108 | extern int XGetClassHint( | |
6109 | Display* , | |
6110 | Window , | |
6111 | XClassHint* | |
6112 | ); | |
6113 | extern int XGetIconSizes( | |
6114 | Display* , | |
6115 | Window , | |
6116 | XIconSize** , | |
6117 | int* | |
6118 | ); | |
6119 | extern int XGetNormalHints( | |
6120 | Display* , | |
6121 | Window , | |
6122 | XSizeHints* | |
6123 | ); | |
6124 | extern int XGetRGBColormaps( | |
6125 | Display* , | |
6126 | Window , | |
6127 | XStandardColormap** , | |
6128 | int* , | |
6129 | Atom | |
6130 | ); | |
6131 | extern int XGetSizeHints( | |
6132 | Display* , | |
6133 | Window , | |
6134 | XSizeHints* , | |
6135 | Atom | |
6136 | ); | |
6137 | extern int XGetStandardColormap( | |
6138 | Display* , | |
6139 | Window , | |
6140 | XStandardColormap* , | |
6141 | Atom | |
6142 | ); | |
6143 | extern int XGetTextProperty( | |
6144 | Display* , | |
6145 | Window , | |
6146 | XTextProperty* , | |
6147 | Atom | |
6148 | ); | |
6149 | extern XVisualInfo *XGetVisualInfo( | |
6150 | Display* , | |
6151 | long , | |
6152 | XVisualInfo* , | |
6153 | int* | |
6154 | ); | |
6155 | extern int XGetWMClientMachine( | |
6156 | Display* , | |
6157 | Window , | |
6158 | XTextProperty* | |
6159 | ); | |
6160 | extern XWMHints *XGetWMHints( | |
6161 | Display* , | |
6162 | Window | |
6163 | ); | |
6164 | extern int XGetWMIconName( | |
6165 | Display* , | |
6166 | Window , | |
6167 | XTextProperty* | |
6168 | ); | |
6169 | extern int XGetWMName( | |
6170 | Display* , | |
6171 | Window , | |
6172 | XTextProperty* | |
6173 | ); | |
6174 | extern int XGetWMNormalHints( | |
6175 | Display* , | |
6176 | Window , | |
6177 | XSizeHints* , | |
6178 | long* | |
6179 | ); | |
6180 | extern int XGetWMSizeHints( | |
6181 | Display* , | |
6182 | Window , | |
6183 | XSizeHints* , | |
6184 | long* , | |
6185 | Atom | |
6186 | ); | |
6187 | extern int XGetZoomHints( | |
6188 | Display* , | |
6189 | Window , | |
6190 | XSizeHints* | |
6191 | ); | |
6192 | extern int XIntersectRegion( | |
6193 | Region , | |
6194 | Region , | |
6195 | Region | |
6196 | ); | |
6197 | extern void XConvertCase( | |
6198 | KeySym , | |
6199 | KeySym* , | |
6200 | KeySym* | |
6201 | ); | |
6202 | extern int XLookupString( | |
6203 | XKeyEvent* , | |
6204 | char* , | |
6205 | int , | |
6206 | KeySym* , | |
6207 | XComposeStatus* | |
6208 | ); | |
6209 | extern int XMatchVisualInfo( | |
6210 | Display* , | |
6211 | int , | |
6212 | int , | |
6213 | int , | |
6214 | XVisualInfo* | |
6215 | ); | |
6216 | extern int XOffsetRegion( | |
6217 | Region , | |
6218 | int , | |
6219 | int | |
6220 | ); | |
6221 | extern int XPointInRegion( | |
6222 | Region , | |
6223 | int , | |
6224 | int | |
6225 | ); | |
6226 | extern Region XPolygonRegion( | |
6227 | XPoint* , | |
6228 | int , | |
6229 | int | |
6230 | ); | |
6231 | extern int XRectInRegion( | |
6232 | Region , | |
6233 | int , | |
6234 | int , | |
6235 | unsigned int , | |
6236 | unsigned int | |
6237 | ); | |
6238 | extern int XSaveContext( | |
6239 | Display* , | |
6240 | XID , | |
6241 | XContext , | |
6242 | const char* | |
6243 | ); | |
6244 | extern int XSetClassHint( | |
6245 | Display* , | |
6246 | Window , | |
6247 | XClassHint* | |
6248 | ); | |
6249 | extern int XSetIconSizes( | |
6250 | Display* , | |
6251 | Window , | |
6252 | XIconSize* , | |
6253 | int | |
6254 | ); | |
6255 | extern int XSetNormalHints( | |
6256 | Display* , | |
6257 | Window , | |
6258 | XSizeHints* | |
6259 | ); | |
6260 | extern void XSetRGBColormaps( | |
6261 | Display* , | |
6262 | Window , | |
6263 | XStandardColormap* , | |
6264 | int , | |
6265 | Atom | |
6266 | ); | |
6267 | extern int XSetSizeHints( | |
6268 | Display* , | |
6269 | Window , | |
6270 | XSizeHints* , | |
6271 | Atom | |
6272 | ); | |
6273 | extern int XSetStandardProperties( | |
6274 | Display* , | |
6275 | Window , | |
6276 | const char* , | |
6277 | const char* , | |
6278 | Pixmap , | |
6279 | char** , | |
6280 | int , | |
6281 | XSizeHints* | |
6282 | ); | |
6283 | extern void XSetTextProperty( | |
6284 | Display* , | |
6285 | Window , | |
6286 | XTextProperty* , | |
6287 | Atom | |
6288 | ); | |
6289 | extern void XSetWMClientMachine( | |
6290 | Display* , | |
6291 | Window , | |
6292 | XTextProperty* | |
6293 | ); | |
6294 | extern int XSetWMHints( | |
6295 | Display* , | |
6296 | Window , | |
6297 | XWMHints* | |
6298 | ); | |
6299 | extern void XSetWMIconName( | |
6300 | Display* , | |
6301 | Window , | |
6302 | XTextProperty* | |
6303 | ); | |
6304 | extern void XSetWMName( | |
6305 | Display* , | |
6306 | Window , | |
6307 | XTextProperty* | |
6308 | ); | |
6309 | extern void XSetWMNormalHints( | |
6310 | Display* , | |
6311 | Window , | |
6312 | XSizeHints* | |
6313 | ); | |
6314 | extern void XSetWMProperties( | |
6315 | Display* , | |
6316 | Window , | |
6317 | XTextProperty* , | |
6318 | XTextProperty* , | |
6319 | char** , | |
6320 | int , | |
6321 | XSizeHints* , | |
6322 | XWMHints* , | |
6323 | XClassHint* | |
6324 | ); | |
6325 | extern void XmbSetWMProperties( | |
6326 | Display* , | |
6327 | Window , | |
6328 | const char* , | |
6329 | const char* , | |
6330 | char** , | |
6331 | int , | |
6332 | XSizeHints* , | |
6333 | XWMHints* , | |
6334 | XClassHint* | |
6335 | ); | |
6336 | extern void Xutf8SetWMProperties( | |
6337 | Display* , | |
6338 | Window , | |
6339 | const char* , | |
6340 | const char* , | |
6341 | char** , | |
6342 | int , | |
6343 | XSizeHints* , | |
6344 | XWMHints* , | |
6345 | XClassHint* | |
6346 | ); | |
6347 | extern void XSetWMSizeHints( | |
6348 | Display* , | |
6349 | Window , | |
6350 | XSizeHints* , | |
6351 | Atom | |
6352 | ); | |
6353 | extern int XSetRegion( | |
6354 | Display* , | |
6355 | GC , | |
6356 | Region | |
6357 | ); | |
6358 | extern void XSetStandardColormap( | |
6359 | Display* , | |
6360 | Window , | |
6361 | XStandardColormap* , | |
6362 | Atom | |
6363 | ); | |
6364 | extern int XSetZoomHints( | |
6365 | Display* , | |
6366 | Window , | |
6367 | XSizeHints* | |
6368 | ); | |
6369 | extern int XShrinkRegion( | |
6370 | Region , | |
6371 | int , | |
6372 | int | |
6373 | ); | |
6374 | extern int XStringListToTextProperty( | |
6375 | char** , | |
6376 | int , | |
6377 | XTextProperty* | |
6378 | ); | |
6379 | extern int XSubtractRegion( | |
6380 | Region , | |
6381 | Region , | |
6382 | Region | |
6383 | ); | |
6384 | extern int XmbTextListToTextProperty( | |
6385 | Display* display, | |
6386 | char** list, | |
6387 | int count, | |
6388 | XICCEncodingStyle style, | |
6389 | XTextProperty* text_prop_return | |
6390 | ); | |
6391 | extern int XwcTextListToTextProperty( | |
6392 | Display* display, | |
6393 | wchar_t** list, | |
6394 | int count, | |
6395 | XICCEncodingStyle style, | |
6396 | XTextProperty* text_prop_return | |
6397 | ); | |
6398 | extern int Xutf8TextListToTextProperty( | |
6399 | Display* display, | |
6400 | char** list, | |
6401 | int count, | |
6402 | XICCEncodingStyle style, | |
6403 | XTextProperty* text_prop_return | |
6404 | ); | |
6405 | extern void XwcFreeStringList( | |
6406 | wchar_t** list | |
6407 | ); | |
6408 | extern int XTextPropertyToStringList( | |
6409 | XTextProperty* , | |
6410 | char*** , | |
6411 | int* | |
6412 | ); | |
6413 | extern int XmbTextPropertyToTextList( | |
6414 | Display* display, | |
6415 | const XTextProperty* text_prop, | |
6416 | char*** list_return, | |
6417 | int* count_return | |
6418 | ); | |
6419 | extern int XwcTextPropertyToTextList( | |
6420 | Display* display, | |
6421 | const XTextProperty* text_prop, | |
6422 | wchar_t*** list_return, | |
6423 | int* count_return | |
6424 | ); | |
6425 | extern int Xutf8TextPropertyToTextList( | |
6426 | Display* display, | |
6427 | const XTextProperty* text_prop, | |
6428 | char*** list_return, | |
6429 | int* count_return | |
6430 | ); | |
6431 | extern int XUnionRectWithRegion( | |
6432 | XRectangle* , | |
6433 | Region , | |
6434 | Region | |
6435 | ); | |
6436 | extern int XUnionRegion( | |
6437 | Region , | |
6438 | Region , | |
6439 | Region | |
6440 | ); | |
6441 | extern int XWMGeometry( | |
6442 | Display* , | |
6443 | int , | |
6444 | const char* , | |
6445 | const char* , | |
6446 | unsigned int , | |
6447 | XSizeHints* , | |
6448 | int* , | |
6449 | int* , | |
6450 | int* , | |
6451 | int* , | |
6452 | int* | |
6453 | ); | |
6454 | extern int XXorRegion( | |
6455 | Region , | |
6456 | Region , | |
6457 | Region | |
6458 | ); | |
6459 | } | |
6460 | struct sched_param | |
6461 | { | |
6462 | int __sched_priority; | |
6463 | }; | |
6464 | extern "C" { | |
6465 | extern int clone (int (*__fn) (void *__arg), void *__child_stack, | |
6466 | int __flags, void *__arg, ...) throw (); | |
6467 | extern int unshare (int __flags) throw (); | |
6468 | extern int sched_getcpu (void) throw (); | |
6469 | } | |
6470 | struct __sched_param | |
6471 | { | |
6472 | int __sched_priority; | |
6473 | }; | |
6474 | typedef unsigned long int __cpu_mask; | |
6475 | typedef struct | |
6476 | { | |
6477 | __cpu_mask __bits[1024 / (8 * sizeof (__cpu_mask))]; | |
6478 | } cpu_set_t; | |
6479 | extern "C" { | |
6480 | extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp) | |
6481 | throw (); | |
6482 | extern cpu_set_t *__sched_cpualloc (size_t __count) throw () ; | |
6483 | extern void __sched_cpufree (cpu_set_t *__set) throw (); | |
6484 | } | |
6485 | extern "C" { | |
6486 | extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param) | |
6487 | throw (); | |
6488 | extern int sched_getparam (__pid_t __pid, struct sched_param *__param) throw (); | |
6489 | extern int sched_setscheduler (__pid_t __pid, int __policy, | |
6490 | __const struct sched_param *__param) throw (); | |
6491 | extern int sched_getscheduler (__pid_t __pid) throw (); | |
6492 | extern int sched_yield (void) throw (); | |
6493 | extern int sched_get_priority_max (int __algorithm) throw (); | |
6494 | extern int sched_get_priority_min (int __algorithm) throw (); | |
6495 | extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) throw (); | |
6496 | extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize, | |
6497 | __const cpu_set_t *__cpuset) throw (); | |
6498 | extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize, | |
6499 | cpu_set_t *__cpuset) throw (); | |
6500 | } | |
6501 | extern "C" { | |
6502 | } | |
6503 | typedef long int __jmp_buf[8]; | |
6504 | enum | |
6505 | { | |
6506 | PTHREAD_CREATE_JOINABLE, | |
6507 | PTHREAD_CREATE_DETACHED | |
6508 | }; | |
6509 | enum | |
6510 | { | |
6511 | PTHREAD_MUTEX_TIMED_NP, | |
6512 | PTHREAD_MUTEX_RECURSIVE_NP, | |
6513 | PTHREAD_MUTEX_ERRORCHECK_NP, | |
6514 | PTHREAD_MUTEX_ADAPTIVE_NP | |
6515 | , | |
6516 | PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, | |
6517 | PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, | |
6518 | PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, | |
6519 | PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL | |
6520 | , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP | |
6521 | }; | |
6522 | enum | |
6523 | { | |
6524 | PTHREAD_MUTEX_STALLED_NP, | |
6525 | PTHREAD_MUTEX_ROBUST_NP | |
6526 | }; | |
6527 | enum | |
6528 | { | |
6529 | PTHREAD_PRIO_NONE, | |
6530 | PTHREAD_PRIO_INHERIT, | |
6531 | PTHREAD_PRIO_PROTECT | |
6532 | }; | |
6533 | enum | |
6534 | { | |
6535 | PTHREAD_RWLOCK_PREFER_READER_NP, | |
6536 | PTHREAD_RWLOCK_PREFER_WRITER_NP, | |
6537 | PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, | |
6538 | PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP | |
6539 | }; | |
6540 | enum | |
6541 | { | |
6542 | PTHREAD_INHERIT_SCHED, | |
6543 | PTHREAD_EXPLICIT_SCHED | |
6544 | }; | |
6545 | enum | |
6546 | { | |
6547 | PTHREAD_SCOPE_SYSTEM, | |
6548 | PTHREAD_SCOPE_PROCESS | |
6549 | }; | |
6550 | enum | |
6551 | { | |
6552 | PTHREAD_PROCESS_PRIVATE, | |
6553 | PTHREAD_PROCESS_SHARED | |
6554 | }; | |
6555 | struct _pthread_cleanup_buffer | |
6556 | { | |
6557 | void (*__routine) (void *); | |
6558 | void *__arg; | |
6559 | int __canceltype; | |
6560 | struct _pthread_cleanup_buffer *__prev; | |
6561 | }; | |
6562 | enum | |
6563 | { | |
6564 | PTHREAD_CANCEL_ENABLE, | |
6565 | PTHREAD_CANCEL_DISABLE | |
6566 | }; | |
6567 | enum | |
6568 | { | |
6569 | PTHREAD_CANCEL_DEFERRED, | |
6570 | PTHREAD_CANCEL_ASYNCHRONOUS | |
6571 | }; | |
6572 | extern "C" { | |
6573 | extern int pthread_create (pthread_t *__restrict __newthread, | |
6574 | __const pthread_attr_t *__restrict __attr, | |
6575 | void *(*__start_routine) (void *), | |
6576 | void *__restrict __arg) throw () __attribute__ ((__nonnull__ (1, 3))); | |
6577 | extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); | |
6578 | extern int pthread_join (pthread_t __th, void **__thread_return); | |
6579 | extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) throw (); | |
6580 | extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return, | |
6581 | __const struct timespec *__abstime); | |
6582 | extern int pthread_detach (pthread_t __th) throw (); | |
6583 | extern pthread_t pthread_self (void) throw () __attribute__ ((__const__)); | |
6584 | extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) throw (); | |
6585 | extern int pthread_attr_init (pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); | |
6586 | extern int pthread_attr_destroy (pthread_attr_t *__attr) | |
6587 | throw () __attribute__ ((__nonnull__ (1))); | |
6588 | extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr, | |
6589 | int *__detachstate) | |
6590 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6591 | extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, | |
6592 | int __detachstate) | |
6593 | throw () __attribute__ ((__nonnull__ (1))); | |
6594 | extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr, | |
6595 | size_t *__guardsize) | |
6596 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6597 | extern int pthread_attr_setguardsize (pthread_attr_t *__attr, | |
6598 | size_t __guardsize) | |
6599 | throw () __attribute__ ((__nonnull__ (1))); | |
6600 | extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict | |
6601 | __attr, | |
6602 | struct sched_param *__restrict __param) | |
6603 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6604 | extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, | |
6605 | __const struct sched_param *__restrict | |
6606 | __param) throw () __attribute__ ((__nonnull__ (1, 2))); | |
6607 | extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict | |
6608 | __attr, int *__restrict __policy) | |
6609 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6610 | extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) | |
6611 | throw () __attribute__ ((__nonnull__ (1))); | |
6612 | extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict | |
6613 | __attr, int *__restrict __inherit) | |
6614 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6615 | extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, | |
6616 | int __inherit) | |
6617 | throw () __attribute__ ((__nonnull__ (1))); | |
6618 | extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr, | |
6619 | int *__restrict __scope) | |
6620 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6621 | extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) | |
6622 | throw () __attribute__ ((__nonnull__ (1))); | |
6623 | extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict | |
6624 | __attr, void **__restrict __stackaddr) | |
6625 | throw () __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__deprecated__)); | |
6626 | extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, | |
6627 | void *__stackaddr) | |
6628 | throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)); | |
6629 | extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict | |
6630 | __attr, size_t *__restrict __stacksize) | |
6631 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6632 | extern int pthread_attr_setstacksize (pthread_attr_t *__attr, | |
6633 | size_t __stacksize) | |
6634 | throw () __attribute__ ((__nonnull__ (1))); | |
6635 | extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr, | |
6636 | void **__restrict __stackaddr, | |
6637 | size_t *__restrict __stacksize) | |
6638 | throw () __attribute__ ((__nonnull__ (1, 2, 3))); | |
6639 | extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, | |
6640 | size_t __stacksize) throw () __attribute__ ((__nonnull__ (1))); | |
6641 | extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, | |
6642 | size_t __cpusetsize, | |
6643 | __const cpu_set_t *__cpuset) | |
6644 | throw () __attribute__ ((__nonnull__ (1, 3))); | |
6645 | extern int pthread_attr_getaffinity_np (__const pthread_attr_t *__attr, | |
6646 | size_t __cpusetsize, | |
6647 | cpu_set_t *__cpuset) | |
6648 | throw () __attribute__ ((__nonnull__ (1, 3))); | |
6649 | extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) | |
6650 | throw () __attribute__ ((__nonnull__ (2))); | |
6651 | extern int pthread_setschedparam (pthread_t __target_thread, int __policy, | |
6652 | __const struct sched_param *__param) | |
6653 | throw () __attribute__ ((__nonnull__ (3))); | |
6654 | extern int pthread_getschedparam (pthread_t __target_thread, | |
6655 | int *__restrict __policy, | |
6656 | struct sched_param *__restrict __param) | |
6657 | throw () __attribute__ ((__nonnull__ (2, 3))); | |
6658 | extern int pthread_setschedprio (pthread_t __target_thread, int __prio) | |
6659 | throw (); | |
6660 | extern int pthread_getconcurrency (void) throw (); | |
6661 | extern int pthread_setconcurrency (int __level) throw (); | |
6662 | extern int pthread_yield (void) throw (); | |
6663 | extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize, | |
6664 | __const cpu_set_t *__cpuset) | |
6665 | throw () __attribute__ ((__nonnull__ (3))); | |
6666 | extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize, | |
6667 | cpu_set_t *__cpuset) | |
6668 | throw () __attribute__ ((__nonnull__ (3))); | |
6669 | extern int pthread_once (pthread_once_t *__once_control, | |
6670 | void (*__init_routine) (void)) __attribute__ ((__nonnull__ (1, 2))); | |
6671 | extern int pthread_setcancelstate (int __state, int *__oldstate); | |
6672 | extern int pthread_setcanceltype (int __type, int *__oldtype); | |
6673 | extern int pthread_cancel (pthread_t __th); | |
6674 | extern void pthread_testcancel (void); | |
6675 | typedef struct | |
6676 | { | |
6677 | struct | |
6678 | { | |
6679 | __jmp_buf __cancel_jmp_buf; | |
6680 | int __mask_was_saved; | |
6681 | } __cancel_jmp_buf[1]; | |
6682 | void *__pad[4]; | |
6683 | } __pthread_unwind_buf_t __attribute__ ((__aligned__)); | |
6684 | struct __pthread_cleanup_frame | |
6685 | { | |
6686 | void (*__cancel_routine) (void *); | |
6687 | void *__cancel_arg; | |
6688 | int __do_it; | |
6689 | int __cancel_type; | |
6690 | }; | |
6691 | class __pthread_cleanup_class | |
6692 | { | |
6693 | void (*__cancel_routine) (void *); | |
6694 | void *__cancel_arg; | |
6695 | int __do_it; | |
6696 | int __cancel_type; | |
6697 | public: | |
6698 | __pthread_cleanup_class (void (*__fct) (void *), void *__arg) | |
6699 | : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { } | |
6700 | ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); } | |
6701 | void __setdoit (int __newval) { __do_it = __newval; } | |
6702 | void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, | |
6703 | &__cancel_type); } | |
6704 | void __restore () const { pthread_setcanceltype (__cancel_type, 0); } | |
6705 | }; | |
6706 | struct __jmp_buf_tag; | |
6707 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) throw (); | |
6708 | extern int pthread_mutex_init (pthread_mutex_t *__mutex, | |
6709 | __const pthread_mutexattr_t *__mutexattr) | |
6710 | throw () __attribute__ ((__nonnull__ (1))); | |
6711 | extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) | |
6712 | throw () __attribute__ ((__nonnull__ (1))); | |
6713 | extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) | |
6714 | throw () __attribute__ ((__nonnull__ (1))); | |
6715 | extern int pthread_mutex_lock (pthread_mutex_t *__mutex) | |
6716 | throw () __attribute__ ((__nonnull__ (1))); | |
6717 | extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, | |
6718 | __const struct timespec *__restrict | |
6719 | __abstime) throw () __attribute__ ((__nonnull__ (1, 2))); | |
6720 | extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) | |
6721 | throw () __attribute__ ((__nonnull__ (1))); | |
6722 | extern int pthread_mutex_getprioceiling (__const pthread_mutex_t * | |
6723 | __restrict __mutex, | |
6724 | int *__restrict __prioceiling) | |
6725 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6726 | extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, | |
6727 | int __prioceiling, | |
6728 | int *__restrict __old_ceiling) | |
6729 | throw () __attribute__ ((__nonnull__ (1, 3))); | |
6730 | extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) | |
6731 | throw () __attribute__ ((__nonnull__ (1))); | |
6732 | extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) | |
6733 | throw () __attribute__ ((__nonnull__ (1))); | |
6734 | extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) | |
6735 | throw () __attribute__ ((__nonnull__ (1))); | |
6736 | extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t * | |
6737 | __restrict __attr, | |
6738 | int *__restrict __pshared) | |
6739 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6740 | extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, | |
6741 | int __pshared) | |
6742 | throw () __attribute__ ((__nonnull__ (1))); | |
6743 | extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict | |
6744 | __attr, int *__restrict __kind) | |
6745 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6746 | extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) | |
6747 | throw () __attribute__ ((__nonnull__ (1))); | |
6748 | extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t * | |
6749 | __restrict __attr, | |
6750 | int *__restrict __protocol) | |
6751 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6752 | extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, | |
6753 | int __protocol) | |
6754 | throw () __attribute__ ((__nonnull__ (1))); | |
6755 | extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t * | |
6756 | __restrict __attr, | |
6757 | int *__restrict __prioceiling) | |
6758 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6759 | extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, | |
6760 | int __prioceiling) | |
6761 | throw () __attribute__ ((__nonnull__ (1))); | |
6762 | extern int pthread_mutexattr_getrobust_np (__const pthread_mutexattr_t *__attr, | |
6763 | int *__robustness) | |
6764 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6765 | extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr, | |
6766 | int __robustness) | |
6767 | throw () __attribute__ ((__nonnull__ (1))); | |
6768 | extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, | |
6769 | __const pthread_rwlockattr_t *__restrict | |
6770 | __attr) throw () __attribute__ ((__nonnull__ (1))); | |
6771 | extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) | |
6772 | throw () __attribute__ ((__nonnull__ (1))); | |
6773 | extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) | |
6774 | throw () __attribute__ ((__nonnull__ (1))); | |
6775 | extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) | |
6776 | throw () __attribute__ ((__nonnull__ (1))); | |
6777 | extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, | |
6778 | __const struct timespec *__restrict | |
6779 | __abstime) throw () __attribute__ ((__nonnull__ (1, 2))); | |
6780 | extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) | |
6781 | throw () __attribute__ ((__nonnull__ (1))); | |
6782 | extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) | |
6783 | throw () __attribute__ ((__nonnull__ (1))); | |
6784 | extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, | |
6785 | __const struct timespec *__restrict | |
6786 | __abstime) throw () __attribute__ ((__nonnull__ (1, 2))); | |
6787 | extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) | |
6788 | throw () __attribute__ ((__nonnull__ (1))); | |
6789 | extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) | |
6790 | throw () __attribute__ ((__nonnull__ (1))); | |
6791 | extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) | |
6792 | throw () __attribute__ ((__nonnull__ (1))); | |
6793 | extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t * | |
6794 | __restrict __attr, | |
6795 | int *__restrict __pshared) | |
6796 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6797 | extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, | |
6798 | int __pshared) | |
6799 | throw () __attribute__ ((__nonnull__ (1))); | |
6800 | extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t * | |
6801 | __restrict __attr, | |
6802 | int *__restrict __pref) | |
6803 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6804 | extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, | |
6805 | int __pref) throw () __attribute__ ((__nonnull__ (1))); | |
6806 | extern int pthread_cond_init (pthread_cond_t *__restrict __cond, | |
6807 | __const pthread_condattr_t *__restrict | |
6808 | __cond_attr) throw () __attribute__ ((__nonnull__ (1))); | |
6809 | extern int pthread_cond_destroy (pthread_cond_t *__cond) | |
6810 | throw () __attribute__ ((__nonnull__ (1))); | |
6811 | extern int pthread_cond_signal (pthread_cond_t *__cond) | |
6812 | throw () __attribute__ ((__nonnull__ (1))); | |
6813 | extern int pthread_cond_broadcast (pthread_cond_t *__cond) | |
6814 | throw () __attribute__ ((__nonnull__ (1))); | |
6815 | extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, | |
6816 | pthread_mutex_t *__restrict __mutex) | |
6817 | __attribute__ ((__nonnull__ (1, 2))); | |
6818 | extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, | |
6819 | pthread_mutex_t *__restrict __mutex, | |
6820 | __const struct timespec *__restrict | |
6821 | __abstime) __attribute__ ((__nonnull__ (1, 2, 3))); | |
6822 | extern int pthread_condattr_init (pthread_condattr_t *__attr) | |
6823 | throw () __attribute__ ((__nonnull__ (1))); | |
6824 | extern int pthread_condattr_destroy (pthread_condattr_t *__attr) | |
6825 | throw () __attribute__ ((__nonnull__ (1))); | |
6826 | extern int pthread_condattr_getpshared (__const pthread_condattr_t * | |
6827 | __restrict __attr, | |
6828 | int *__restrict __pshared) | |
6829 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6830 | extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, | |
6831 | int __pshared) throw () __attribute__ ((__nonnull__ (1))); | |
6832 | extern int pthread_condattr_getclock (__const pthread_condattr_t * | |
6833 | __restrict __attr, | |
6834 | __clockid_t *__restrict __clock_id) | |
6835 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6836 | extern int pthread_condattr_setclock (pthread_condattr_t *__attr, | |
6837 | __clockid_t __clock_id) | |
6838 | throw () __attribute__ ((__nonnull__ (1))); | |
6839 | extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) | |
6840 | throw () __attribute__ ((__nonnull__ (1))); | |
6841 | extern int pthread_spin_destroy (pthread_spinlock_t *__lock) | |
6842 | throw () __attribute__ ((__nonnull__ (1))); | |
6843 | extern int pthread_spin_lock (pthread_spinlock_t *__lock) | |
6844 | throw () __attribute__ ((__nonnull__ (1))); | |
6845 | extern int pthread_spin_trylock (pthread_spinlock_t *__lock) | |
6846 | throw () __attribute__ ((__nonnull__ (1))); | |
6847 | extern int pthread_spin_unlock (pthread_spinlock_t *__lock) | |
6848 | throw () __attribute__ ((__nonnull__ (1))); | |
6849 | extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, | |
6850 | __const pthread_barrierattr_t *__restrict | |
6851 | __attr, unsigned int __count) | |
6852 | throw () __attribute__ ((__nonnull__ (1))); | |
6853 | extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) | |
6854 | throw () __attribute__ ((__nonnull__ (1))); | |
6855 | extern int pthread_barrier_wait (pthread_barrier_t *__barrier) | |
6856 | throw () __attribute__ ((__nonnull__ (1))); | |
6857 | extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) | |
6858 | throw () __attribute__ ((__nonnull__ (1))); | |
6859 | extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) | |
6860 | throw () __attribute__ ((__nonnull__ (1))); | |
6861 | extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t * | |
6862 | __restrict __attr, | |
6863 | int *__restrict __pshared) | |
6864 | throw () __attribute__ ((__nonnull__ (1, 2))); | |
6865 | extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, | |
6866 | int __pshared) | |
6867 | throw () __attribute__ ((__nonnull__ (1))); | |
6868 | extern int pthread_key_create (pthread_key_t *__key, | |
6869 | void (*__destr_function) (void *)) | |
6870 | throw () __attribute__ ((__nonnull__ (1))); | |
6871 | extern int pthread_key_delete (pthread_key_t __key) throw (); | |
6872 | extern void *pthread_getspecific (pthread_key_t __key) throw (); | |
6873 | extern int pthread_setspecific (pthread_key_t __key, | |
6874 | __const void *__pointer) throw () ; | |
6875 | extern int pthread_getcpuclockid (pthread_t __thread_id, | |
6876 | __clockid_t *__clock_id) | |
6877 | throw () __attribute__ ((__nonnull__ (2))); | |
6878 | extern int pthread_atfork (void (*__prepare) (void), | |
6879 | void (*__parent) (void), | |
6880 | void (*__child) (void)) throw (); | |
6881 | extern __inline __attribute__ ((__gnu_inline__)) int | |
6882 | pthread_equal (pthread_t __thread1, pthread_t __thread2) throw () | |
6883 | { | |
6884 | return __thread1 == __thread2; | |
6885 | } | |
6886 | } | |
6887 | namespace cimg_library { | |
6888 | template<typename T=float> struct CImg; | |
6889 | template<typename T=float> struct CImgList; | |
6890 | struct CImgDisplay; | |
6891 | struct CImgException; | |
6892 | namespace cimg { | |
6893 | inline void info(); | |
6894 | inline unsigned int& exception_mode(); | |
6895 | inline int dialog(const char *title, const char *msg, const char *button1_txt="OK", | |
6896 | const char *button2_txt=0, const char *button3_txt=0, | |
6897 | const char *button4_txt=0, const char *button5_txt=0, | |
6898 | const char *button6_txt=0, const bool centering=false); | |
6899 | template<typename tfunc, typename tp, typename tf> | |
6900 | inline void marching_cubes(const tfunc& func, const float isovalue, | |
6901 | const float x0, const float y0, const float z0, | |
6902 | const float x1, const float y1, const float z1, | |
6903 | const float resx, const float resy, const float resz, | |
6904 | CImgList<tp>& points, CImgList<tf>& primitives, | |
6905 | const bool invert_faces=false); | |
6906 | template<typename tfunc, typename tp, typename tf> | |
6907 | inline void marching_squares(const tfunc& func, const float isovalue, | |
6908 | const float x0, const float y0, | |
6909 | const float x1, const float y1, | |
6910 | const float resx, const float resy, | |
6911 | CImgList<tp>& points, CImgList<tf>& primitives); | |
6912 | } | |
6913 | struct CImgException { | |
6914 | char message[1024]; | |
6915 | CImgException() { message[0]='\0'; } | |
6916 | CImgException(const char *format, ...) { std::va_list ap; __builtin_va_start(ap,format); std::vsprintf(message,format,ap); __builtin_va_end(ap); if (cimg::exception_mode()>=1) { if (cimg::exception_mode()>=2 && true) { try { cimg::dialog("CImgException",message,"Abort"); } catch (CImgException&) { std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgException",message); } } else std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgException",message); } if (cimg::exception_mode()>=3) cimg_library::cimg::info();; } | |
6917 | }; | |
6918 | struct CImgInstanceException : public CImgException { | |
6919 | CImgInstanceException(const char *format, ...) { std::va_list ap; __builtin_va_start(ap,format); std::vsprintf(message,format,ap); __builtin_va_end(ap); if (cimg::exception_mode()>=1) { if (cimg::exception_mode()>=2 && true) { try { cimg::dialog("CImgInstanceException",message,"Abort"); } catch (CImgException&) { std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgInstanceException",message); } } else std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgInstanceException",message); } if (cimg::exception_mode()>=3) cimg_library::cimg::info();; } | |
6920 | }; | |
6921 | struct CImgArgumentException : public CImgException { | |
6922 | CImgArgumentException(const char *format, ...) { std::va_list ap; __builtin_va_start(ap,format); std::vsprintf(message,format,ap); __builtin_va_end(ap); if (cimg::exception_mode()>=1) { if (cimg::exception_mode()>=2 && true) { try { cimg::dialog("CImgArgumentException",message,"Abort"); } catch (CImgException&) { std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgArgumentException",message); } } else std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgArgumentException",message); } if (cimg::exception_mode()>=3) cimg_library::cimg::info();; } | |
6923 | }; | |
6924 | struct CImgIOException : public CImgException { | |
6925 | CImgIOException(const char *format, ...) { std::va_list ap; __builtin_va_start(ap,format); std::vsprintf(message,format,ap); __builtin_va_end(ap); if (cimg::exception_mode()>=1) { if (cimg::exception_mode()>=2 && true) { try { cimg::dialog("CImgIOException",message,"Abort"); } catch (CImgException&) { std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgIOException",message); } } else std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgIOException",message); } if (cimg::exception_mode()>=3) cimg_library::cimg::info();; } | |
6926 | }; | |
6927 | struct CImgDisplayException : public CImgException { | |
6928 | CImgDisplayException(const char *format, ...) { std::va_list ap; __builtin_va_start(ap,format); std::vsprintf(message,format,ap); __builtin_va_end(ap); if (cimg::exception_mode()>=1) { if (cimg::exception_mode()>=2 && false) { try { cimg::dialog("CImgDisplayException",message,"Abort"); } catch (CImgException&) { std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgDisplayException",message); } } else std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgDisplayException",message); } if (cimg::exception_mode()>=3) cimg_library::cimg::info();; } | |
6929 | }; | |
6930 | struct CImgWarningException : public CImgException { | |
6931 | CImgWarningException(const char *format, ...) { std::va_list ap; __builtin_va_start(ap,format); std::vsprintf(message,format,ap); __builtin_va_end(ap); if (cimg::exception_mode()>=1) { if (cimg::exception_mode()>=2 && false) { try { cimg::dialog("CImgWarningException",message,"Abort"); } catch (CImgException&) { std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgWarningException",message); } } else std::fprintf(stderr,"\n# %s :\n%s\n\n","CImgWarningException",message); } if (cimg::exception_mode()>=3) cimg_library::cimg::info();; } | |
6932 | }; | |
6933 | namespace cimg { | |
6934 | template<typename T> struct type { | |
6935 | static const char* string() { | |
6936 | static const char* s[] = { "unknown", "unknown8", "unknown16", "unknown24", | |
6937 | "unknown32", "unknown40", "unknown48", "unknown56", | |
6938 | "unknown64", "unknown72", "unknown80", "unknown88", | |
6939 | "unknown96", "unknown104", "unknown112", "unknown120", | |
6940 | "unknown128" }; | |
6941 | return s[(sizeof(T)<17)?sizeof(T):0]; | |
6942 | } | |
6943 | static bool is_float() { return false; } | |
6944 | static T min() { return (T)-1>0?(T)0:(T)-1<<(8*sizeof(T)-1); } | |
6945 | static T max() { return (T)-1>0?(T)-1:~((T)-1<<(8*sizeof(T)-1)); } | |
6946 | static const char* format() { return "%s"; } | |
6947 | static const char* format(const T val) { static const char *s = "unknown"; return s; } | |
6948 | }; | |
6949 | template<> struct type<bool> { | |
6950 | static const char* string() { static const char *const s = "bool"; return s; } | |
6951 | static bool is_float() { return false; } | |
6952 | static bool min() { return false; } | |
6953 | static bool max() { return true; } | |
6954 | static const char* format() { return "%s"; } | |
6955 | static const char* format(const bool val) { static const char* s[] = { "false", "true" }; return s[val?1:0]; } | |
6956 | }; | |
6957 | template<> struct type<unsigned char> { | |
6958 | static const char* string() { static const char *const s = "unsigned char"; return s; } | |
6959 | static bool is_float() { return false; } | |
6960 | static unsigned char min() { return 0; } | |
6961 | static unsigned char max() { return (unsigned char)~0U; } | |
6962 | static const char* format() { return "%u"; } | |
6963 | static unsigned int format(const unsigned char val) { return (unsigned int)val; } | |
6964 | }; | |
6965 | template<> struct type<char> { | |
6966 | static const char* string() { static const char *const s = "char"; return s; } | |
6967 | static bool is_float() { return false; } | |
6968 | static char min() { return (char)(-1L<<(8*sizeof(char)-1)); } | |
6969 | static char max() { return ~((char)(-1L<<(8*sizeof(char)-1))); } | |
6970 | static const char* format() { return "%d"; } | |
6971 | static int format(const char val) { return (int)val; } | |
6972 | }; | |
6973 | template<> struct type<unsigned short> { | |
6974 | static const char* string() { static const char *const s = "unsigned short"; return s; } | |
6975 | static bool is_float() { return false; } | |
6976 | static unsigned short min() { return 0; } | |
6977 | static unsigned short max() { return (unsigned short)~0U; } | |
6978 | static const char* format() { return "%u"; } | |
6979 | static unsigned int format(const unsigned short val) { return (unsigned int)val; } | |
6980 | }; | |
6981 | template<> struct type<short> { | |
6982 | static const char* string() { static const char *const s = "short"; return s; } | |
6983 | static bool is_float() { return false; } | |
6984 | static short min() { return (short)(-1L<<(8*sizeof(short)-1)); } | |
6985 | static short max() { return ~((short)(-1L<<(8*sizeof(short)-1))); } | |
6986 | static const char* format() { return "%d"; } | |
6987 | static int format(const short val) { return (int)val; } | |
6988 | }; | |
6989 | template<> struct type<unsigned int> { | |
6990 | static const char* string() { static const char *const s = "unsigned int"; return s; } | |
6991 | static bool is_float() { return false; } | |
6992 | static unsigned int min() { return 0; } | |
6993 | static unsigned int max() { return (unsigned int)~0U; } | |
6994 | static const char* format() { return "%u"; } | |
6995 | static unsigned int format(const unsigned int val) { return val; } | |
6996 | }; | |
6997 | template<> struct type<int> { | |
6998 | static const char* string() { static const char *const s = "int"; return s; } | |
6999 | static bool is_float() { return false; } | |
7000 | static int min() { return (int)(-1L<<(8*sizeof(int)-1)); } | |
7001 | static int max() { return ~((int)(-1L<<(8*sizeof(int)-1))); } | |
7002 | static const char* format() { return "%d"; } | |
7003 | static int format(const int val) { return val; } | |
7004 | }; | |
7005 | template<> struct type<unsigned long> { | |
7006 | static const char* string() { static const char *const s = "unsigned long"; return s; } | |
7007 | static bool is_float() { return false; } | |
7008 | static unsigned long min() { return 0; } | |
7009 | static unsigned long max() { return (unsigned long)~0UL; } | |
7010 | static const char* format() { return "%lu"; } | |
7011 | static unsigned long format(const unsigned long val) { return val; } | |
7012 | }; | |
7013 | template<> struct type<long> { | |
7014 | static const char* string() { static const char *const s = "long"; return s; } | |
7015 | static bool is_float() { return false; } | |
7016 | static long min() { return (long)(-1L<<(8*sizeof(long)-1)); } | |
7017 | static long max() { return ~((long)(-1L<<(8*sizeof(long)-1))); } | |
7018 | static const char* format() { return "%ld"; } | |
7019 | static long format(const long val) { return val; } | |
7020 | }; | |
7021 | template<> struct type<float> { | |
7022 | static const char* string() { static const char *const s = "float"; return s; } | |
7023 | static bool is_float() { return true; } | |
7024 | static float min() { return -3.4E38f; } | |
7025 | static float max() { return 3.4E38f; } | |
7026 | static const char* format() { return "%g"; } | |
7027 | static double format(const float val) { return (double)val; } | |
7028 | }; | |
7029 | template<> struct type<double> { | |
7030 | static const char* string() { static const char *const s = "double"; return s; } | |
7031 | static bool is_float() { return true; } | |
7032 | static double min() { return -1.7E308; } | |
7033 | static double max() { return 1.7E308; } | |
7034 | static const char* format() { return "%g"; } | |
7035 | static double format(const double val) { return val; } | |
7036 | }; | |
7037 | template<typename T, typename t> struct superset { typedef T type; }; | |
7038 | template<> struct superset<bool,unsigned char> { typedef unsigned char type; }; | |
7039 | template<> struct superset<bool,char> { typedef char type; }; | |
7040 | template<> struct superset<bool,unsigned short> { typedef unsigned short type; }; | |
7041 | template<> struct superset<bool,short> { typedef short type; }; | |
7042 | template<> struct superset<bool,unsigned int> { typedef unsigned int type; }; | |
7043 | template<> struct superset<bool,int> { typedef int type; }; | |
7044 | template<> struct superset<bool,unsigned long> { typedef unsigned long type; }; | |
7045 | template<> struct superset<bool,long> { typedef long type; }; | |
7046 | template<> struct superset<bool,float> { typedef float type; }; | |
7047 | template<> struct superset<bool,double> { typedef double type; }; | |
7048 | template<> struct superset<unsigned char,char> { typedef short type; }; | |
7049 | template<> struct superset<unsigned char,unsigned short> { typedef unsigned short type; }; | |
7050 | template<> struct superset<unsigned char,short> { typedef short type; }; | |
7051 | template<> struct superset<unsigned char,unsigned int> { typedef unsigned int type; }; | |
7052 | template<> struct superset<unsigned char,int> { typedef int type; }; | |
7053 | template<> struct superset<unsigned char,unsigned long> { typedef unsigned long type; }; | |
7054 | template<> struct superset<unsigned char,long> { typedef long type; }; | |
7055 | template<> struct superset<unsigned char,float> { typedef float type; }; | |
7056 | template<> struct superset<unsigned char,double> { typedef double type; }; | |
7057 | template<> struct superset<char,unsigned char> { typedef short type; }; | |
7058 | template<> struct superset<char,unsigned short> { typedef int type; }; | |
7059 | template<> struct superset<char,short> { typedef short type; }; | |
7060 | template<> struct superset<char,unsigned int> { typedef long type; }; | |
7061 | template<> struct superset<char,int> { typedef int type; }; | |
7062 | template<> struct superset<char,unsigned long> { typedef long type; }; | |
7063 | template<> struct superset<char,long> { typedef long type; }; | |
7064 | template<> struct superset<char,float> { typedef float type; }; | |
7065 | template<> struct superset<char,double> { typedef double type; }; | |
7066 | template<> struct superset<unsigned short,char> { typedef int type; }; | |
7067 | template<> struct superset<unsigned short,short> { typedef int type; }; | |
7068 | template<> struct superset<unsigned short,unsigned int> { typedef unsigned int type; }; | |
7069 | template<> struct superset<unsigned short,int> { typedef int type; }; | |
7070 | template<> struct superset<unsigned short,unsigned long> { typedef unsigned long type; }; | |
7071 | template<> struct superset<unsigned short,long> { typedef long type; }; | |
7072 | template<> struct superset<unsigned short,float> { typedef float type; }; | |
7073 | template<> struct superset<unsigned short,double> { typedef double type; }; | |
7074 | template<> struct superset<short,unsigned short> { typedef int type; }; | |
7075 | template<> struct superset<short,unsigned int> { typedef long type; }; | |
7076 | template<> struct superset<short,int> { typedef int type; }; | |
7077 | template<> struct superset<short,unsigned long> { typedef long type; }; | |
7078 | template<> struct superset<short,long> { typedef long type; }; | |
7079 | template<> struct superset<short,float> { typedef float type; }; | |
7080 | template<> struct superset<short,double> { typedef double type; }; | |
7081 | template<> struct superset<unsigned int,char> { typedef long type; }; | |
7082 | template<> struct superset<unsigned int,short> { typedef long type; }; | |
7083 | template<> struct superset<unsigned int,int> { typedef long type; }; | |
7084 | template<> struct superset<unsigned int,unsigned long> { typedef unsigned long type; }; | |
7085 | template<> struct superset<unsigned int,long> { typedef long type; }; | |
7086 | template<> struct superset<unsigned int,float> { typedef float type; }; | |
7087 | template<> struct superset<unsigned int,double> { typedef double type; }; | |
7088 | template<> struct superset<int,unsigned int> { typedef long type; }; | |
7089 | template<> struct superset<int,unsigned long> { typedef long type; }; | |
7090 | template<> struct superset<int,long> { typedef long type; }; | |
7091 | template<> struct superset<int,float> { typedef float type; }; | |
7092 | template<> struct superset<int,double> { typedef double type; }; | |
7093 | template<> struct superset<unsigned long,char> { typedef long type; }; | |
7094 | template<> struct superset<unsigned long,short> { typedef long type; }; | |
7095 | template<> struct superset<unsigned long,int> { typedef long type; }; | |
7096 | template<> struct superset<unsigned long,long> { typedef long type; }; | |
7097 | template<> struct superset<unsigned long,float> { typedef float type; }; | |
7098 | template<> struct superset<unsigned long,double> { typedef double type; }; | |
7099 | template<> struct superset<long,float> { typedef float type; }; | |
7100 | template<> struct superset<long,double> { typedef double type; }; | |
7101 | template<> struct superset<float,double> { typedef double type; }; | |
7102 | template<typename t1, typename t2, typename t3> struct superset2 { | |
7103 | typedef typename superset<t1, typename superset<t2,t3>::type>::type type; | |
7104 | }; | |
7105 | template<typename t1, typename t2, typename t3, typename t4> struct superset3 { | |
7106 | typedef typename superset<t1, typename superset2<t2,t3,t4>::type>::type type; | |
7107 | }; | |
7108 | template<typename t1, typename t2> struct last { typedef t2 type; }; | |
7109 | struct X11info { | |
7110 | volatile unsigned int nb_wins; | |
7111 | pthread_t* event_thread; | |
7112 | CImgDisplay* wins[1024]; | |
7113 | Display* display; | |
7114 | unsigned int nb_bits; | |
7115 | GC* gc; | |
7116 | bool blue_first; | |
7117 | bool byte_order; | |
7118 | bool shm_enabled; | |
7119 | X11info():nb_wins(0),event_thread(0),display(0), | |
7120 | nb_bits(0),gc(0),blue_first(false),byte_order(false),shm_enabled(false) { | |
7121 | } | |
7122 | }; | |
7123 | inline X11info& X11attr() { static X11info val; return val; } | |
7124 | inline unsigned int& exception_mode() { static unsigned int mode = 1; return mode; } | |
7125 | const char t_normal[] = { 0x1b,'[','0',';','0',';','0','m','\0' }; | |
7126 | const char t_red[] = { 0x1b,'[','4',';','3','1',';','5','9','m','\0' }; | |
7127 | const char t_bold[] = { 0x1b,'[','1','m','\0' }; | |
7128 | const char t_purple[] = { 0x1b,'[','0',';','3','5',';','5','9','m','\0' }; | |
7129 | const unsigned int keyESC = 0xff1b; | |
7130 | const unsigned int keyF1 = 0xffbe; | |
7131 | const unsigned int keyF2 = 0xffbf; | |
7132 | const unsigned int keyF3 = 0xffc0; | |
7133 | const unsigned int keyF4 = 0xffc1; | |
7134 | const unsigned int keyF5 = 0xffc2; | |
7135 | const unsigned int keyF6 = 0xffc3; | |
7136 | const unsigned int keyF7 = 0xffc4; | |
7137 | const unsigned int keyF8 = 0xffc5; | |
7138 | const unsigned int keyF9 = 0xffc6; | |
7139 | const unsigned int keyF10 = 0xffc7; | |
7140 | const unsigned int keyF11 = 0xffc8; | |
7141 | const unsigned int keyF12 = 0xffc9; | |
7142 | const unsigned int keyPAUSE = 0xff13; | |
7143 | const unsigned int key1 = 0x0031; | |
7144 | const unsigned int key2 = 0x0032; | |
7145 | const unsigned int key3 = 0x0033; | |
7146 | const unsigned int key4 = 0x0034; | |
7147 | const unsigned int key5 = 0x0035; | |
7148 | const unsigned int key6 = 0x0036; | |
7149 | const unsigned int key7 = 0x0037; | |
7150 | const unsigned int key8 = 0x0038; | |
7151 | const unsigned int key9 = 0x0039; | |
7152 | const unsigned int key0 = 0x0030; | |
7153 | const unsigned int keyBACKSPACE = 0xff08; | |
7154 | const unsigned int keyINSERT = 0xff63; | |
7155 | const unsigned int keyHOME = 0xff50; | |
7156 | const unsigned int keyPAGEUP = 0xff55; | |
7157 | const unsigned int keyTAB = 0xff09; | |
7158 | const unsigned int keyQ = 0x0071; | |
7159 | const unsigned int keyW = 0x0077; | |
7160 | const unsigned int keyE = 0x0065; | |
7161 | const unsigned int keyR = 0x0072; | |
7162 | const unsigned int keyT = 0x0074; | |
7163 | const unsigned int keyY = 0x0079; | |
7164 | const unsigned int keyU = 0x0075; | |
7165 | const unsigned int keyI = 0x0069; | |
7166 | const unsigned int keyO = 0x006f; | |
7167 | const unsigned int keyP = 0x0070; | |
7168 | const unsigned int keyDELETE = 0xffff; | |
7169 | const unsigned int keyEND = 0xff57; | |
7170 | const unsigned int keyPAGEDOWN = 0xff56; | |
7171 | const unsigned int keyCAPSLOCK = 0xffe5; | |
7172 | const unsigned int keyA = 0x0061; | |
7173 | const unsigned int keyS = 0x0073; | |
7174 | const unsigned int keyD = 0x0064; | |
7175 | const unsigned int keyF = 0x0066; | |
7176 | const unsigned int keyG = 0x0067; | |
7177 | const unsigned int keyH = 0x0068; | |
7178 | const unsigned int keyJ = 0x006a; | |
7179 | const unsigned int keyK = 0x006b; | |
7180 | const unsigned int keyL = 0x006c; | |
7181 | const unsigned int keyENTER = 0xff0d; | |
7182 | const unsigned int keySHIFTLEFT = 0xffe1; | |
7183 | const unsigned int keyZ = 0x007a; | |
7184 | const unsigned int keyX = 0x0078; | |
7185 | const unsigned int keyC = 0x0063; | |
7186 | const unsigned int keyV = 0x0076; | |
7187 | const unsigned int keyB = 0x0062; | |
7188 | const unsigned int keyN = 0x006e; | |
7189 | const unsigned int keyM = 0x006d; | |
7190 | const unsigned int keySHIFTRIGHT = 0xffe2; | |
7191 | const unsigned int keyARROWUP = 0xff52; | |
7192 | const unsigned int keyCTRLLEFT = 0xffe3; | |
7193 | const unsigned int keyAPPLEFT = 0xffeb; | |
7194 | const unsigned int keySPACE = 0x0020; | |
7195 | const unsigned int keyALTGR = 0xffea; | |
7196 | const unsigned int keyAPPRIGHT = 0xffec; | |
7197 | const unsigned int keyMENU = 0xff67; | |
7198 | const unsigned int keyCTRLRIGHT = 0xffe4; | |
7199 | const unsigned int keyARROWLEFT = 0xff51; | |
7200 | const unsigned int keyARROWDOWN = 0xff54; | |
7201 | const unsigned int keyARROWRIGHT = 0xff53; | |
7202 | const unsigned int keyPAD0 = 0xffb0; | |
7203 | const unsigned int keyPAD1 = 0xffb1; | |
7204 | const unsigned int keyPAD2 = 0xffb2; | |
7205 | const unsigned int keyPAD3 = 0xffb3; | |
7206 | const unsigned int keyPAD4 = 0xffb4; | |
7207 | const unsigned int keyPAD5 = 0xffb5; | |
7208 | const unsigned int keyPAD6 = 0xffb6; | |
7209 | const unsigned int keyPAD7 = 0xffb7; | |
7210 | const unsigned int keyPAD8 = 0xffb8; | |
7211 | const unsigned int keyPAD9 = 0xffb9; | |
7212 | const unsigned int keyPADADD = 0xffab; | |
7213 | const unsigned int keyPADSUB = 0xffad; | |
7214 | const unsigned int keyPADMUL = 0xffaa; | |
7215 | const unsigned int keyPADDIV = 0xffaf; | |
7216 | const double valuePI = 3.14159265358979323846; | |
7217 | const unsigned int font7x11[7*11*256/32] = { | |
7218 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7219 | 0x0,0x0,0x0,0x0,0x0,0x0,0x90,0x0,0x7f0000,0x40000,0x0,0x0,0x4010c0a4,0x82000040,0x11848402,0x18480050,0x80430292,0x8023,0x9008000, | |
7220 | 0x40218140,0x4000040,0x21800402,0x18000051,0x1060500,0x8083,0x10000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24002,0x4031,0x80000000,0x10000, | |
7221 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x81c0400,0x40020000,0x80070080,0x40440e00,0x0,0x0,0x1,0x88180000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7222 | 0x0,0x200000,0x0,0x0,0x80000,0x0,0x0,0x20212140,0x5000020,0x22400204,0x240000a0,0x40848500,0x4044,0x80010038,0x20424285,0xa000020, | |
7223 | 0x42428204,0x2428e0a0,0x82090a14,0x4104,0x85022014,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10240a7,0x88484040,0x40800000,0x270c3,0x87811e0e, | |
7224 | 0x7c70e000,0x78,0x3c23c1ef,0x1f3e1e89,0xf1c44819,0xa23cf0f3,0xc3cff120,0xc18307f4,0x4040400,0x20000,0x80080080,0x40200,0x0, | |
7225 | 0x40000,0x2,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8188,0x50603800,0xf3c00000,0x1c004003,0xc700003e,0x18180,0xc993880,0x10204081, | |
7226 | 0x2071ef9,0xf3e7cf9f,0x3e7c7911,0xe3c78f1e,0x7d1224,0x48906048,0x0,0x4000000,0x0,0x9000,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0, | |
7227 | 0x0,0x10240aa,0x14944080,0x23610000,0x68940,0x40831010,0x8891306,0x802044,0x44522208,0x90202088,0x40448819,0xb242890a,0x24011111, | |
7228 | 0x49448814,0x4040a00,0xe2c3c7,0x8e3f3cb9,0xc1c44216,0xee38b0f2,0xe78f9120,0xc18507e2,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7229 | 0x101c207,0x88a04001,0x9c00000,0x2200a041,0x8200113a,0x8240,0x50a3110,0x2850a142,0x850c2081,0x2040204,0x8104592,0x142850a1, | |
7230 | 0x42cd1224,0x4888bc48,0x70e1c387,0xe3b3c70,0xe1c38e1c,0x38707171,0xc3870e1c,0x10791224,0x48906c41,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7231 | 0x10003ee,0x15140080,0x21810000,0x48840,0x40851020,0x8911306,0x31fd804,0x9c522408,0x90204088,0x4045081a,0xba42890a,0x24011111, | |
7232 | 0x49285024,0x2041b00,0x132408,0x910844c8,0x4044821b,0x7244c913,0x24041111,0x49488822,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7233 | 0x28204,0x85006001,0x6a414000,0x3a004043,0xc700113a,0x8245,0x50a3a00,0x2850a142,0x850c4081,0x2040204,0x81045d2,0x142850a1, | |
7234 | 0x24951224,0x48852250,0x8102040,0x81054089,0x12244204,0x8108992,0x24489122,0x991224,0x4888b222,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7235 | 0x1000143,0xa988080,0x2147c01f,0x88840,0x83091c2c,0x1070f000,0xc000608,0xa48bc408,0x9e3c46f8,0x40460816,0xaa42f10b,0xc3811111, | |
7236 | 0x35102044,0x1041100,0xf22408,0x9f084488,0x40470212,0x62448912,0x6041111,0x55308846,0x8061c80,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7237 | 0x1028704,0x8f805801,0x4be28fdf,0x220001f0,0x111a,0x60000182,0x82c5c710,0x44891224,0x489640f1,0xe3c78204,0x810e552,0x142850a1, | |
7238 | 0x18a51224,0x48822250,0x78f1e3c7,0x8f1f40f9,0xf3e7c204,0x8108912,0x24489122,0x7ea91224,0x4888a222,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7239 | 0x10007e2,0x85648080,0x20010000,0x88841,0x8f8232,0x20881000,0xc1fc610,0xbefa2408,0x90204288,0x40450816,0xa642810a,0x4041110a, | |
7240 | 0x36282084,0x1042080,0x1122408,0x90084488,0x40450212,0x62448912,0x184110a,0x55305082,0x8042700,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7241 | 0x1028207,0x82004801,0x68050040,0x1c000040,0x110a,0x60000001,0x45484d10,0x7cf9f3e7,0xcf944081,0x2040204,0x8104532,0x142850a1, | |
7242 | 0x18a51224,0x48822248,0x89122448,0x91244081,0x2040204,0x8108912,0x24489122,0xc91224,0x48852214,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x282, | |
7243 | 0x89630080,0x20010c00,0x30108842,0x810222,0x20882306,0x3001800,0x408a2208,0x90202288,0x40448814,0xa642810a,0x2041110a,0x26442104, | |
7244 | 0x840000,0x1122408,0x90084488,0x40448212,0x62448912,0x84130a,0x36485102,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x101c208,0x4f802801, | |
7245 | 0x8028040,0x40,0x130a,0x2,0x85e897a0,0x44891224,0x489c2081,0x2040204,0x8104532,0x142850a1,0x24cd1224,0x48823c44,0x89122448, | |
7246 | 0x91244081,0x2040204,0x8108912,0x24489122,0xc93264,0xc9852214,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100028f,0x109f0080,0x20010c00, | |
7247 | 0x303071f3,0xc7011c1c,0x4071c306,0x802010,0x3907c1ef,0x1f201e89,0xf3844f90,0xa23c80f2,0x17810e04,0x228223f4,0x840000,0xfbc3c7, | |
7248 | 0x8f083c88,0x40444212,0x6238f0f2,0x7039d04,0x228423e2,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1008780,0x2201800,0xf0014000,0x1f0, | |
7249 | 0x1d0a,0x5,0x851e140,0x83060c18,0x30671ef9,0xf3e7cf9f,0x3e7c7911,0xe3c78f1e,0x42f8e1c3,0x8702205c,0x7cf9f3e7,0xcf9b3c78,0xf1e3c204, | |
7250 | 0x8107111,0xc3870e1c,0x10f1d3a7,0x4e823c08,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x40,0x40000400,0x200000,0x0,0x2,0x0,0x0,0x0,0x0,0x18, | |
7251 | 0x0,0x4,0x44007f,0x0,0x400,0x400000,0x8010,0x0,0x6002,0x8040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x200800,0x0,0x0,0x100a, | |
7252 | 0x400000,0x44,0x0,0x400,0x0,0x0,0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x0,0x62018,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x80000800, | |
7253 | 0x400000,0x0,0x4,0x0,0x0,0x0,0x0,0xc,0x0,0x7,0x3c0000,0x0,0x3800,0x3800000,0x8010,0x0,0x1c001,0x881c0000,0x0,0x0,0x0,0x0,0x0,0x0, | |
7254 | 0x0,0x0,0x207000,0x0,0x0,0x100a,0xc00000,0x3c,0x0,0xc00,0x0,0x0,0x0,0x0,0x0,0x0,0x1800,0x0,0x0,0x0,0x0,0x1c2070 | |
7255 | }; | |
7256 | const unsigned int font10x13[256*10*13/32] = { | |
7257 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7258 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80100c0, | |
7259 | 0x68000300,0x801,0xc00010,0x100c000,0x68100,0x100c0680,0x2,0x403000,0x1000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7260 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7261 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc,0x0,0x0,0x0,0x0,0x0,0x4020120, | |
7262 | 0x58120480,0x402,0x1205008,0x2012050,0x58080,0x20120581,0x40000001,0x804812,0x2000000,0x0,0x300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7263 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x140,0x80000,0x200402,0x800000,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7264 | 0x0,0x7010,0x7000000,0x8000200,0x20000,0xc0002000,0x8008,0x0,0x0,0x0,0x0,0x808,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7265 | 0x0,0x0,0x80000000,0x0,0x0,0x0,0x40000,0x0,0x0,0x0,0x0,0x480,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x70,0x80100c0,0x68000480,0x1001, | |
7266 | 0xc00010,0x1018000,0x68100,0x100c0680,0x4,0x403000,0x1020000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20140,0x28081883,0x200801, | |
7267 | 0x2a00000,0x10,0x1c0201c0,0x70040f80,0xc0f81c07,0x0,0x70,0x3e0303c0,0x3c3c0f83,0xe03c2107,0xe08810,0x18c31070,0x3c0703c0, | |
7268 | 0x783e0842,0x22222208,0x83e04010,0x1008000,0x4000200,0x20001,0x2002,0x408008,0x0,0x0,0x100000,0x0,0x1008,0x2000000,0x0,0x0,0x0, | |
7269 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20080,0x38000880,0x8078140f,0x81c00000,0x3e000,0xc020180,0x60080001,0xe0000002,0xc00042,0x108e2010, | |
7270 | 0xc0300c0,0x300c0303,0xf83c3e0f,0x83e0f81c,0x701c070,0x3c0c41c0,0x701c0701,0xc0001d08,0x42108421,0x8820088,0x4020120,0x58140480, | |
7271 | 0x802,0x1205008,0x3014050,0xc058080,0x20120581,0x40000002,0x804814,0x2020050,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20140, | |
7272 | 0x281e2484,0x80200801,0x1c02000,0x10,0x22060220,0x880c0801,0x82208,0x80000001,0x20008,0x41030220,0x40220802,0x402102,0x209010, | |
7273 | 0x18c31088,0x22088220,0x80080842,0x22222208,0x80204010,0x1014000,0x200,0x20001,0x2000,0x8008,0x0,0x0,0x100000,0x0,0x1008, | |
7274 | 0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x40000500,0x80800010,0x40200000,0x41000,0x12020040,0x10000003,0xa0000006, | |
7275 | 0x12000c4,0x31014000,0xc0300c0,0x300c0302,0x80402008,0x2008008,0x2008020,0x220c4220,0x88220882,0x20002208,0x42108421,0x8820088, | |
7276 | 0x0,0x300,0x0,0x0,0x0,0x14000000,0x0,0x200200,0x0,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0xfc282504,0x80001000, | |
7277 | 0x82a02000,0x20,0x22020020,0x8140802,0x102208,0x80801006,0x18008,0x9c848220,0x80210802,0x802102,0x20a010,0x15429104,0x22104220, | |
7278 | 0x80080842,0x22221405,0x404008,0x1022000,0x703c0,0x381e0701,0xc0783c02,0xc09008,0x1d83c070,0x3c078140,0x381c0882,0x21242208, | |
7279 | 0x81e01008,0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x201e0,0x40220500,0x80800027,0x20e02800,0x9c800,0x12020040, | |
7280 | 0x20000883,0xa0200002,0x120a044,0x11064010,0x12048120,0x48120484,0x80802008,0x2008008,0x2008020,0x210a4411,0x4411044,0x10884508, | |
7281 | 0x42108421,0x503c0b0,0x1c0701c0,0x701c0707,0x70381c07,0x1c07008,0x2008020,0x20f01c0,0x701c0701,0xc0201c08,0x82208822,0x883c088, | |
7282 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x50281903,0x20001000,0x80802000,0x20,0x22020040,0x30240f03,0xc0101c08,0x80801018, | |
7283 | 0x1fc06010,0xa48483c0,0x80210f03,0xe0803f02,0x20c010,0x15429104,0x22104220,0x70080841,0x41540805,0x804008,0x1041000,0x8220, | |
7284 | 0x40220881,0x882202,0x40a008,0x12422088,0x22088180,0x40100882,0x21241408,0x80201008,0x2031000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7285 | 0x0,0x20280,0x401c0200,0x700028,0x21205000,0x92800,0xc1fc080,0x10000883,0xa0200002,0x1205049,0x12c19010,0x12048120,0x48120484, | |
7286 | 0xf0803c0f,0x3c0f008,0x2008020,0x790a4411,0x4411044,0x10504908,0x42108421,0x5022088,0x2008020,0x8020080,0x88402208,0x82208808, | |
7287 | 0x2008020,0x1e088220,0x88220882,0x20002608,0x82208822,0x8822088,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x501c0264, | |
7288 | 0xa0001000,0x8001fc00,0x7000020,0x22020080,0x83e0082,0x20202207,0x80000020,0x1020,0xa4848220,0x80210802,0x9c2102,0x20c010, | |
7289 | 0x12425104,0x3c1043c0,0x8080841,0x41540802,0x804008,0x1000000,0x78220,0x40220f81,0x882202,0x40c008,0x12422088,0x22088100, | |
7290 | 0x60100881,0x41540805,0x406008,0x1849000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20280,0xf0140200,0x880028,0x20e0a03f,0x709c800, | |
7291 | 0x201c0,0x60000881,0xa0000007,0xc0284b,0x122eb020,0x12048120,0x48120487,0x80802008,0x2008008,0x2008020,0x21094411,0x4411044, | |
7292 | 0x10204908,0x42108421,0x2022088,0x1e0781e0,0x781e0787,0xf8403e0f,0x83e0f808,0x2008020,0x22088220,0x88220882,0x21fc2a08,0x82208822, | |
7293 | 0x5022050,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20001,0xf80a0294,0x40001000,0x80002000,0x20,0x22020100,0x8040082,0x20202200, | |
7294 | 0x80000018,0x1fc06020,0xa48fc220,0x80210802,0x842102,0x20a010,0x12425104,0x20104240,0x8080841,0x41541402,0x1004008,0x1000000, | |
7295 | 0x88220,0x40220801,0x882202,0x40a008,0x12422088,0x22088100,0x18100881,0x41540805,0x801008,0x2046000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7296 | 0x0,0x0,0x0,0x20280,0x401c0f80,0x80880028,0x20005001,0x94800,0x20000,0x880,0xa0000000,0x5015,0x4215040,0x3f0fc3f0,0xfc3f0fc8, | |
7297 | 0x80802008,0x2008008,0x2008020,0x21094411,0x4411044,0x10505108,0x42108421,0x203c088,0x22088220,0x88220888,0x80402008,0x2008008, | |
7298 | 0x2008020,0x22088220,0x88220882,0x20002a08,0x82208822,0x5022050,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xa00a0494,0x60001000, | |
7299 | 0x80002004,0x8020,0x22020200,0x88040882,0x20402201,0x801006,0x18000,0x9f084220,0x40220802,0x442102,0x209010,0x10423088,0x20088220, | |
7300 | 0x8080840,0x80882202,0x2004008,0x1000000,0x88220,0x40220881,0x882202,0x409008,0x12422088,0x22088100,0x8100880,0x80881402, | |
7301 | 0x1001008,0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20280,0x40220200,0x80700027,0x20002801,0x92800,0x1fc000,0x980, | |
7302 | 0xa0000000,0xa017,0x84417840,0x21084210,0x84210848,0x80402008,0x2008008,0x2008020,0x2208c220,0x88220882,0x20882208,0x42108421, | |
7303 | 0x2020088,0x22088220,0x88220888,0xc8402208,0x82208808,0x2008020,0x22088220,0x88220882,0x20203208,0x82208822,0x2022020,0x0,0x0,0x0, | |
7304 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0xa03c0463,0x90000801,0x2004,0x8040,0x1c0703e0,0x70040701,0xc0401c06,0x801001,0x20020, | |
7305 | 0x400843c0,0x3c3c0f82,0x3c2107,0x1c0881e,0x10423070,0x20070210,0xf0080780,0x80882202,0x3e04004,0x1000000,0x783c0,0x381e0701, | |
7306 | 0x782202,0x408808,0x12422070,0x3c078100,0x700c0780,0x80882202,0x1e01008,0x2000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x201e0, | |
7307 | 0xf8000200,0x80080010,0x40000001,0x41000,0x0,0xe80,0xa0000000,0x21,0x8e21038,0x21084210,0x84210848,0xf83c3e0f,0x83e0f81c, | |
7308 | 0x701c070,0x3c08c1c0,0x701c0701,0xc0005c07,0x81e0781e,0x20200b0,0x1e0781e0,0x781e0787,0x30381c07,0x1c07008,0x2008020,0x1c0881c0, | |
7309 | 0x701c0701,0xc0201c07,0x81e0781e,0x203c020,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000,0x801,0x4,0x40,0x0,0x0,0x0,0x1000, | |
7310 | 0x0,0x3c000000,0x0,0x0,0x0,0x0,0x10000,0x0,0x0,0x4004,0x1000000,0x0,0x0,0x80000,0x400000,0x0,0x20008000,0x0,0x4,0x1008,0x2000000, | |
7311 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x8008000f,0x80000000,0x3e000,0x0,0x800,0xa0000400,0x0,0x0,0x0,0x0,0x80000,0x0, | |
7312 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100000,0x0,0x0,0x0,0x0,0x2000,0x0,0x4020040,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000, | |
7313 | 0x402,0x8,0x40,0x0,0x0,0x0,0x2000,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,0x0,0x7004,0x70000fc,0x0,0x0,0x700000,0x800000,0x0,0x20008000, | |
7314 | 0x0,0x4,0x808,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x80f00000,0x0,0x0,0x0,0x800,0xa0001800,0x0,0x0,0x0,0x0, | |
7315 | 0x300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600000,0x0,0x0,0x0,0x0,0x0,0x0,0x4020040 | |
7316 | }; | |
7317 | const unsigned int font8x17[8*17*256/32] = { | |
7318 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7319 | 0x0,0x0,0x0,0x2400,0x2400,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20081834,0x1c0000,0x20081800,0x20081800,0x342008, | |
7320 | 0x18340000,0x200818,0x80000,0x0,0x180000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4200000,0x0,0x0, | |
7321 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x380000,0x4000,0x2000c00,0x40100840,0x70000000,0x0,0x0,0x1c,0x10700000,0x7,0x0, | |
7322 | 0x1800,0x1800,0x0,0x0,0x0,0x14,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1010242c,0x14140000,0x10102414,0x10102414,0x2c1010,0x242c1400, | |
7323 | 0x101024,0x14100038,0x0,0x240000,0x0,0x0,0x30000000,0x0,0x0,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x12,0x0,0x8100000,0x0, | |
7324 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x80000,0x10004000,0x2001000,0x40000040,0x10000000,0x0,0x0,0x10,0x10100000,0x4, | |
7325 | 0x0,0x18000000,0x0,0x0,0x0,0x34002400,0x2400,0x0,0x0,0x0,0x3c,0x0,0x8000000,0x0,0x60607800,0x0,0x140000,0x0,0x0,0x0,0x0,0x0, | |
7326 | 0x44,0x10081834,0x240000,0x10081800,0x10081800,0x1c341008,0x18340000,0x100818,0x84000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x102812, | |
7327 | 0x8601c10,0x8100800,0x2,0x1c383e3e,0x67e1e7f,0x3e3c0000,0x38,0x1e087e1e,0x7c7f7f1e,0x417c1c42,0x4063611c,0x7e1c7e3e,0xfe414181, | |
7328 | 0x63827f10,0x40081000,0x8004000,0x2001000,0x40000040,0x10000000,0x0,0x10000000,0x10,0x10100000,0x3c000008,0x0,0x24003e00, | |
7329 | 0x3f007f00,0x0,0x0,0x2ce91800,0x1882,0x10101c,0xc2103c,0x143c3c00,0x3c00,0x18003c3c,0x10001f00,0x181c00,0x20200810,0x8080808, | |
7330 | 0x8083e1e,0x7f7f7f7f,0x7c7c7c7c,0x7c611c1c,0x1c1c1c00,0x1e414141,0x41824044,0x810242c,0x14180000,0x8102414,0x8102414,0x382c0810, | |
7331 | 0x242c1400,0x81024,0x14104014,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x102816,0x3e902010,0x10084910,0x4,0x22084343,0xa402102,0x41620000, | |
7332 | 0x44,0x33144121,0x42404021,0x41100444,0x40636122,0x43224361,0x10416381,0x22440310,0x20082800,0x4000,0x2001000,0x40000040, | |
7333 | 0x10000000,0x0,0x10000000,0x10,0x10100000,0x24000008,0x0,0x606100,0x68000300,0x8106c,0x34000000,0x4f0000,0x44,0x101020,0x441040, | |
7334 | 0x420200,0x4200,0x24000404,0x7d00,0x82200,0x20203010,0x14141414,0x14082821,0x40404040,0x10101010,0x42612222,0x22222200,0x23414141, | |
7335 | 0x41447e48,0x0,0x0,0x0,0x0,0x4000000,0x18,0x0,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10287f,0x49902010,0x10083e10,0x4,0x41080101, | |
7336 | 0x1a404002,0x41411818,0x1004004,0x21144140,0x41404040,0x41100448,0x40555141,0x41414140,0x10412281,0x14280610,0x20084400,0x1c7c1c, | |
7337 | 0x3e3c7c3a,0x5c703844,0x107f5c3c,0x7c3e3c3c,0x7e424281,0x66427e10,0x10100000,0x40100008,0x1010,0xa04000,0x48100610,0x100c3024, | |
7338 | 0x24000000,0x4f3c00,0x2c107e28,0x3820,0x42281060,0x9d1e12,0xbd00,0x24100818,0x427d00,0x82248,0x20200800,0x14141414,0x14142840, | |
7339 | 0x40404040,0x10101010,0x41514141,0x41414142,0x43414141,0x41284350,0x1c1c1c1c,0x1c1c6c1c,0x3c3c3c3c,0x70707070,0x3c5c3c3c, | |
7340 | 0x3c3c3c18,0x3e424242,0x42427c42,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x102824,0x48623010,0x10081c10,0x8,0x41080103,0x127c5e04, | |
7341 | 0x41411818,0xe7f3808,0x4f144140,0x41404040,0x41100450,0x40555141,0x41414160,0x1041225a,0x1c280410,0x1008c600,0x226622,0x66661066, | |
7342 | 0x62100848,0x10496266,0x66663242,0x10426681,0x24220260,0x100c0000,0xf8280008,0x1010,0x606000,0x48280428,0x28042014,0x48000000, | |
7343 | 0x494200,0x52280228,0x105420,0x3cee1058,0xa12236,0xa500,0x18101004,0x427d00,0x8226c,0x76767e10,0x14141414,0x14142840,0x40404040, | |
7344 | 0x10101010,0x41514141,0x41414124,0x45414141,0x41284150,0x22222222,0x22221222,0x66666666,0x10101010,0x66626666,0x66666600, | |
7345 | 0x66424242,0x42226622,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100024,0x381c4900,0x10086bfe,0x8,0x4908021c,0x22036304,0x3e630000, | |
7346 | 0x70000710,0x51227e40,0x417f7f43,0x7f100470,0x40554941,0x43417e3e,0x1041225a,0x8100810,0x10080000,0x24240,0x42421042,0x42100850, | |
7347 | 0x10494242,0x42422040,0x1042245a,0x18240410,0x10103900,0x407c003e,0x1818,0x1c3e10,0x4f7c087c,0x7c002010,0x48000000,0x4008, | |
7348 | 0x527c0410,0x105078,0x2410104c,0xa13e6c,0x7f00b900,0xfe3c3c,0x421d18,0x1c1c36,0x38383810,0x22222222,0x22144e40,0x7f7f7f7f, | |
7349 | 0x10101010,0xf1494141,0x41414118,0x49414141,0x4110435c,0x2020202,0x2021240,0x42424242,0x10101010,0x42424242,0x424242ff,0x4e424242, | |
7350 | 0x42244224,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000fe,0xe664d00,0x10080810,0x380010,0x41080c03,0x42014108,0x633d0000,0x70000710, | |
7351 | 0x51224140,0x41404041,0x41100448,0x40494541,0x7e414203,0x1041145a,0x14101010,0x10080000,0x3e4240,0x427e1042,0x42100870,0x10494242, | |
7352 | 0x4242203c,0x1042245a,0x18241810,0x10104600,0xf8f60008,0x1010,0x600320,0x48f610f6,0xf6000000,0x187eff,0x3c04,0x5ef61810,0x105020, | |
7353 | 0x24fe0064,0x9d006c,0x138ad00,0x100000,0x420518,0x36,0xc0c0c020,0x22222222,0x22224840,0x40404040,0x10101010,0x41454141,0x41414118, | |
7354 | 0x51414141,0x41107e46,0x3e3e3e3e,0x3e3e7e40,0x7e7e7e7e,0x10101010,0x42424242,0x42424200,0x5a424242,0x42244224,0x0,0x0,0x0, | |
7355 | 0x0,0x0,0x0,0x0,0x0,0x28,0x9094500,0x10080010,0x10,0x41081801,0x7f014118,0x41010000,0xe7f3800,0x513e4140,0x41404041,0x41100444, | |
7356 | 0x40414541,0x40414101,0x10411466,0x36103010,0x8080000,0x424240,0x42401042,0x42100848,0x10494242,0x42422002,0x10423c5a,0x18142010, | |
7357 | 0x10100000,0x407c0010,0x1010,0x260140,0x487c307c,0x7c000000,0x180000,0x202,0x507c2010,0x105020,0x3c10003c,0x423e36,0x1004200, | |
7358 | 0x100000,0x420500,0x3e6c,0x41e0440,0x3e3e3e3e,0x3e3e7840,0x40404040,0x10101010,0x41454141,0x41414124,0x61414141,0x41104042, | |
7359 | 0x42424242,0x42425040,0x40404040,0x10101010,0x42424242,0x42424218,0x72424242,0x42144214,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100048, | |
7360 | 0x49096200,0x8100010,0x18001810,0x22082043,0x2432310,0x61421818,0x1004010,0x4f634121,0x42404021,0x41104444,0x40414322,0x40234143, | |
7361 | 0x10411466,0x22106010,0x8080000,0x466622,0x66621066,0x42100844,0x10494266,0x66662042,0x10461824,0x24184010,0x10100000,0x24381010, | |
7362 | 0x34001018,0xda4320,0x68386038,0x38000000,0x0,0x4204,0x50384010,0x105420,0x4210100c,0x3c0012,0x3c00,0x0,0x460500,0x48,0xc020c44, | |
7363 | 0x63636363,0x63228821,0x40404040,0x10101010,0x42432222,0x22222242,0x62414141,0x41104042,0x46464646,0x46465022,0x62626262, | |
7364 | 0x10101010,0x66426666,0x66666618,0x66464646,0x46186618,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100048,0x3e063d00,0x8100000,0x18001820, | |
7365 | 0x1c3e7f3e,0x23c1e20,0x3e3c1818,0x10,0x20417e1e,0x7c7f401e,0x417c3842,0x7f41431c,0x401e40be,0x103e0866,0x41107f10,0x4080000, | |
7366 | 0x3a5c1c,0x3a3c103a,0x427c0842,0xe49423c,0x7c3e203c,0xe3a1824,0x66087e10,0x10100000,0x3c103010,0x245a1010,0x5a3e10,0x3f107f10, | |
7367 | 0x10000000,0x0,0x3c08,0x2e107e10,0x1038fc,0x101004,0x0,0x0,0xfe0000,0x7f0500,0x0,0x14041438,0x41414141,0x41418e1e,0x7f7f7f7f, | |
7368 | 0x7c7c7c7c,0x7c431c1c,0x1c1c1c00,0xbc3e3e3e,0x3e10405c,0x3a3a3a3a,0x3a3a6e1c,0x3c3c3c3c,0x7c7c7c7c,0x3c423c3c,0x3c3c3c00, | |
7369 | 0x7c3a3a3a,0x3a087c08,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x4200000,0x10000020,0x0,0x0,0x10,0x0,0x30000000,0x0, | |
7370 | 0x0,0x0,0x60000,0x0,0x1c,0x4380000,0x0,0x2,0x800,0x0,0x40020000,0x0,0x8000c,0x10600000,0x2010,0x48000000,0x240000,0x0,0x0, | |
7371 | 0x0,0x0,0x0,0x1000,0x1078,0x0,0x0,0x0,0x400500,0x0,0x1e081e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7372 | 0x84008,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0x20000040,0x0,0x0,0x20,0x0,0x1e000000,0x0,0x0,0x0,0x20000,0x0, | |
7373 | 0x0,0x2000000,0x0,0x26,0x800,0x0,0x40020000,0x0,0x100000,0x10000000,0x2030,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x1000,0x0, | |
7374 | 0x0,0x0,0x400000,0x8000000,0x41e0400,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x104010,0x0,0x0,0x0,0x0, | |
7375 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe,0x0,0x1c,0x7000,0x0,0x40020000,0x0,0x300000, | |
7376 | 0x0,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x400000,0x38000000,0x0,0x0,0x1c,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7377 | 0x1c,0x0,0x0,0x0,0x0,0x0,0x304030,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7378 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7379 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7380 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7381 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }; | |
7382 | const unsigned int font10x19[10*19*256/32] = { | |
7383 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7384 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3600000,0x36000,0x0,0x0,0x0,0x0,0x6c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7385 | 0x0,0x180181c0,0xe81b0300,0x1801,0x81c06c18,0x181c06c,0xe8180,0x181c0e81,0xb0000006,0x60701b,0x1800000,0x0,0x0,0x0,0x0,0x0, | |
7386 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7387 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00000,0x1c000,0x0,0x0,0x0,0x0,0x6c,0x0,0x0,0x0,0x0, | |
7388 | 0x0,0x0,0x0,0x0,0x0,0x0,0xc030360,0xb81b0480,0xc03,0x3606c0c,0x303606c,0xb80c0,0x30360b81,0xb0000003,0xc0d81b,0x3000000,0x0, | |
7389 | 0x300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7390 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x0,0x0,0x2200000, | |
7391 | 0x22000,0x0,0x0,0x0,0x0,0x0,0x0,0x30000,0x0,0xe0,0x38078000,0x0,0x480,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000c080,0x480,0x3000, | |
7392 | 0xc0800030,0xc08000,0x300,0xc080000,0xc,0x302000,0xc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x41c01,0xe020060c, | |
7393 | 0x800000,0x4,0x1e0703e0,0xf8060fc1,0xe1fe1e07,0x80000000,0x78,0x307e0,0x3c7c1fe7,0xf83c408f,0x80f10440,0x18660878,0x7e0787e0, | |
7394 | 0x78ff9024,0xa0140a0,0x27f83840,0x700e000,0x18000400,0x8000,0x70004002,0x410078,0x0,0x0,0x0,0x0,0x1808,0xc000000,0xf000000, | |
7395 | 0xe000000,0x1400,0x1e0001f,0x8007f800,0x0,0x0,0x3a3b,0x61400000,0x14202,0x20000,0x38002020,0x3c1b00,0x3e00000,0xf8,0x1c0001c0, | |
7396 | 0x78060001,0xf800000e,0x1e00020,0x8004020,0xc0300c0,0x300c0301,0xf83c7f9f,0xe7f9fe3e,0xf83e0f8,0x7c1821e0,0x781e0781,0xe0001f10, | |
7397 | 0x24090240,0xa02400f8,0x18018140,0xe81b0480,0x1801,0x81406c18,0x181406c,0x190e8180,0x18140e81,0xb0000006,0x60501b,0x184006c, | |
7398 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x26042202,0x200c06,0x800000,0x8,0x210d0611,0x40e0803,0x10026188,0x40000000, | |
7399 | 0x8c,0xf030418,0xc6431004,0xc64082,0x110840,0x18660884,0x41084410,0x8c081024,0xa012110,0x40082020,0x101b000,0xc000400,0x8000, | |
7400 | 0x80004002,0x410008,0x0,0x0,0x100000,0x0,0x2008,0x2000000,0x18800000,0x10000000,0x2200,0x2300024,0x800,0x0,0x0,0x2e13,0x60800000, | |
7401 | 0x8104,0x20040,0x64001040,0x80401b07,0x80100000,0x1e000,0x22000020,0x40c0003,0xc8000002,0x3300020,0x8004020,0xc0300c0,0x300c0301, | |
7402 | 0x40c64010,0x4010008,0x2008020,0x43182210,0x84210842,0x10002190,0x24090240,0x9044018c,0xc030220,0xb81b0300,0xc03,0x2206c0c, | |
7403 | 0x302206c,0x1e0b80c0,0x30220b81,0xb0000003,0xc0881b,0x304006c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x241f2202, | |
7404 | 0x200802,0x4900000,0x8,0x21010408,0x20a0802,0x44090,0x20000000,0x4,0x11878408,0x80411004,0x804082,0x111040,0x1ce50986,0x40986409, | |
7405 | 0x81022,0x12012108,0x80102020,0x1031800,0x400,0x8000,0x80004000,0x10008,0x0,0x0,0x100000,0x0,0x2008,0x2000000,0x10000000, | |
7406 | 0x10000000,0x18,0x4000044,0x1000,0x30180,0xd81b0000,0x13,0xe0000000,0x88,0x40,0x400018c0,0x80400018,0x61f00000,0x61800,0x22020020, | |
7407 | 0x4000007,0xc8000002,0x2100020,0x8038000,0x1e0781e0,0x781e0301,0x40804010,0x4010008,0x2008020,0x41142619,0x86619866,0x18002190, | |
7408 | 0x24090240,0x8887e104,0x0,0x0,0x0,0x0,0x0,0x2000000,0x0,0x0,0x0,0x40000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20120,0x2434a202, | |
7409 | 0x200802,0x3e00000,0x10,0x40810008,0x21a0804,0x44090,0x20000000,0x80040004,0x20848409,0x409004,0x1004082,0x112040,0x14a50902, | |
7410 | 0x40902409,0x81022,0x11321208,0x80202010,0x1060c00,0x7c5e0,0x781e8783,0xf07a5f0e,0x1c10808,0xfc5f078,0x5e07a170,0x7c7e1024, | |
7411 | 0xa016190,0x27f82008,0x2000000,0x20000000,0x10000000,0x80200024,0x4000044,0x2000,0x18180,0xc8320000,0x12,0xa1f00037,0x7f888, | |
7412 | 0x1e0,0x40410880,0x80600017,0xa2100000,0x5e800,0x22020040,0x38001027,0xc8000002,0x2100020,0x8004020,0x12048120,0x48120482, | |
7413 | 0x41004010,0x4010008,0x2008020,0x40942409,0x2409024,0x9044390,0x24090240,0x88841918,0x1f07c1f0,0x7c1f07c3,0x70781e07,0x81e07838, | |
7414 | 0xe0380e0,0x1f17c1e0,0x781e0781,0xe0001f90,0x24090240,0x9025e102,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20001,0xff241c41, | |
7415 | 0x1001,0x1c02000,0x10,0x40810008,0x6120f85,0xe0086190,0x20c03007,0x8007800c,0x27848419,0x409004,0x1004082,0x114040,0x14a48902, | |
7416 | 0x40902409,0x81022,0x11321205,0x602010,0x1000000,0x86610,0x84218840,0x80866182,0x411008,0x9261884,0x61086189,0x82101022,0x12012108, | |
7417 | 0x40082008,0x2000000,0x20030000,0x20000000,0x80200024,0x4000044,0x3006030,0xc018100,0x4c260000,0x12,0x26080048,0x83000850, | |
7418 | 0x20250,0x403e0500,0x8078002c,0x12302200,0x92400,0x1c0200c0,0x4001027,0xc8000002,0x3308820,0x8004020,0x12048120,0x48120482, | |
7419 | 0x41004010,0x4010008,0x2008020,0x40922409,0x2409024,0x8884690,0x24090240,0x85040920,0x21886218,0x86218860,0x88842108,0x42108408, | |
7420 | 0x2008020,0x21186210,0x84210842,0x10302190,0x24090240,0x88461084,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x4c240182, | |
7421 | 0x80001001,0x6b02000,0x20,0x4c810010,0x78220846,0x10081e10,0x20c0301c,0x1fe0e018,0x4d8487e1,0x409fe7,0xf9007f82,0x11a040, | |
7422 | 0x13248902,0x41102418,0xe0081022,0x11320c05,0x402008,0x1000000,0x2409,0x409020,0x81024082,0x412008,0x9240902,0x40902101,0x101022, | |
7423 | 0x11321208,0x40102008,0x2000000,0x7e0c8000,0xfc000003,0xf0fc0018,0x43802047,0x8c8040c8,0x32008300,0x44240000,0x0,0x4000048, | |
7424 | 0x8c801050,0x20440,0x40221dc0,0x808c0028,0x11d0667f,0x8009c400,0x1fc180,0x4001023,0xc8300002,0x1e0ccfb,0x3ec7b020,0x12048120, | |
7425 | 0x48120482,0x79007f9f,0xe7f9fe08,0x2008020,0xf0922409,0x2409024,0x8504490,0x24090240,0x85040920,0x802008,0x2008020,0x89004090, | |
7426 | 0x24090208,0x2008020,0x40902409,0x2409024,0x8304390,0x24090240,0x88440884,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000, | |
7427 | 0x481c0606,0xc8001001,0x802000,0x20,0x4c810020,0x4220024,0x8102108,0x60000070,0x3820,0x48884419,0x409004,0x10e4082,0x112040, | |
7428 | 0x13244902,0x7e1027e0,0x3c081021,0x21320c02,0x802008,0x1000000,0x7e409,0x409020,0x81024082,0x414008,0x9240902,0x40902101, | |
7429 | 0x80101022,0x11320c08,0x40202008,0x2038800,0x200bc000,0x20000000,0x80200003,0x80f04044,0xbc080bc,0x2f000200,0x0,0x0,0x6001048, | |
7430 | 0x8bc02020,0x20441,0xf8220200,0x80820028,0x1000cc00,0x80094400,0x201e0,0x78001021,0xc830000f,0x8000663c,0xf03c0c0,0x21084210, | |
7431 | 0x84210846,0x41004010,0x4010008,0x2008020,0x40912409,0x2409024,0x8204890,0x24090240,0x82040930,0x1f87e1f8,0x7e1f87e0,0x89004090, | |
7432 | 0x24090208,0x2008020,0x40902409,0x2409024,0x8004690,0x24090240,0x88440884,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000, | |
7433 | 0x480719c4,0x48001001,0x81fc00,0x7800020,0x40810040,0x2420024,0x8104087,0xa0000070,0x3820,0x48884409,0x409004,0x1024082,0x111040, | |
7434 | 0x13244902,0x40102410,0x2081021,0x214a1202,0x1802008,0x1000000,0x182409,0x409fe0,0x81024082,0x41a008,0x9240902,0x40902100, | |
7435 | 0xf8101021,0x214a0c04,0x80c0c008,0x1847000,0x7c1ee000,0x20000000,0x8020000c,0x8c044,0x1ee181ee,0x7b800000,0x707,0xf3ff0000, | |
7436 | 0x3e0084f,0x9ee0c020,0x20440,0x40221fc0,0xc2002c,0x13f11000,0x87892400,0x20000,0x1020,0x48000000,0x3f011c6,0x31cc6180,0x21084210, | |
7437 | 0x84210844,0x41004010,0x4010008,0x2008020,0x40912409,0x2409024,0x8505090,0x24090240,0x8204191c,0x60982609,0x82609823,0xf9007f9f, | |
7438 | 0xe7f9fe08,0x2008020,0x40902409,0x2409024,0x9fe4c90,0x24090240,0x84840848,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xfe048224, | |
7439 | 0x28001001,0x2000,0x40,0x40810080,0x27f8024,0x8104080,0x2000001c,0x1fe0e020,0x488fc409,0x409004,0x1024082,0x110840,0x10242902, | |
7440 | 0x40102408,0x2081021,0x214a1202,0x1002004,0x1000000,0x102409,0x409000,0x81024082,0x411008,0x9240902,0x40902100,0x6101021, | |
7441 | 0x214a0c04,0x81002008,0x2000000,0x201dc000,0x20000000,0x80200000,0x98044,0x1dc101dc,0x77000000,0x700,0x0,0x180448,0x1dc10020, | |
7442 | 0x20440,0x403e0200,0x620017,0xa000cc00,0x80052800,0x20000,0x1020,0x48000000,0x6606,0x206100,0x3f0fc3f0,0xfc3f0fc7,0xc1004010, | |
7443 | 0x4010008,0x2008020,0x4090a409,0x2409024,0x8886090,0x24090240,0x8207e106,0x40902409,0x2409024,0x81004010,0x4010008,0x2008020, | |
7444 | 0x40902409,0x2409024,0x8005890,0x24090240,0x84840848,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x98048224,0x30001001,0x2000, | |
7445 | 0x40,0x21010100,0x2020024,0x8204080,0x40000007,0x80078000,0x48884408,0x80411004,0x824082,0x110840,0x10242986,0x40086409,0x2081021, | |
7446 | 0xe14a2102,0x2002004,0x1000000,0x106409,0x409000,0x81024082,0x410808,0x9240902,0x40902100,0x2101021,0x214a1202,0x82002008, | |
7447 | 0x2000000,0x300f8000,0x20000000,0x80fc001d,0xe4088044,0xf8200f8,0x3e000000,0x300,0x0,0x80c48,0xf820020,0x20640,0x40410200, | |
7448 | 0x803c0018,0x60006600,0x61800,0x0,0x1020,0x48000000,0xcc0a,0x20a100,0x21084210,0x84210844,0x40804010,0x4010008,0x2008020, | |
7449 | 0x4110a619,0x86619866,0x19046110,0x24090240,0x82040102,0x41906419,0x6419064,0x81004010,0x4010008,0x2008020,0x40902409,0x2409024, | |
7450 | 0x8307090,0x24090240,0x82840828,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000,0x90248222,0x30000802,0x200c,0xc080,0x21010301, | |
7451 | 0x4021042,0x10202108,0xc0c03000,0x80040020,0x4d902418,0xc6431004,0xc24082,0x6210440,0x10241884,0x40084409,0x86080840,0xc0842102, | |
7452 | 0x4002002,0x1000000,0x18e610,0x84218820,0x80864082,0x410408,0x9240884,0x61086101,0x6101860,0xc0842103,0x4002008,0x2000000, | |
7453 | 0x10850180,0x20330000,0x80200013,0x26184024,0x5040050,0x14000000,0x0,0x0,0x4180848,0x85040020,0x20350,0x40000200,0x800c0007, | |
7454 | 0x80002200,0x1e000,0x0,0x1860,0x48000000,0x880a,0x40a188,0x40902409,0x2409028,0x40c64010,0x4010008,0x2008020,0x43106210,0x84210842, | |
7455 | 0x10006108,0x42108421,0x2040102,0x6398e639,0x8e6398e4,0x88842088,0x22088208,0x2008020,0x21102210,0x84210842,0x10306118,0x66198661, | |
7456 | 0x83061030,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20001,0x901f01c1,0xe8000802,0xc,0xc080,0x1e07c7f8,0xf8020f81,0xe0401e07, | |
7457 | 0x80c03000,0x20,0x279027e0,0x3c7c1fe4,0x3c408f,0x83c1027f,0x90241878,0x4007c404,0xf8080780,0xc0844082,0x7f82002,0x1000000, | |
7458 | 0xfa5e0,0x781e87c0,0x807a409f,0xc0410207,0x9240878,0x5e07a100,0xf80e0fa0,0xc0846183,0x7f82008,0x2000000,0xf020100,0x40321360, | |
7459 | 0x80200014,0xa3e0201f,0x8207f820,0x8000000,0x0,0x0,0x3e01037,0x207f820,0x201e1,0xfc000200,0x80040000,0x0,0x0,0x1fc000,0x17b0, | |
7460 | 0x48000000,0x12,0xc120f0,0x40902409,0x2409028,0x783c7f9f,0xe7f9fe3e,0xf83e0f8,0x7c1061e0,0x781e0781,0xe000be07,0x81e0781e, | |
7461 | 0x204017c,0x3e8fa3e8,0xfa3e8fa3,0x70781f07,0xc1f07c7f,0x1fc7f1fc,0x1e1021e0,0x781e0781,0xe0007e0f,0xa3e8fa3e,0x8305e030,0x0, | |
7462 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000,0xc06,0xc,0x100,0x0,0x0,0x0,0x3000,0x0,0x20000000,0x0,0x0,0x0,0x0,0xc000, | |
7463 | 0x0,0x0,0x2001,0x1000000,0x0,0x0,0x20000,0x400000,0x0,0x40002000,0x0,0x1,0x2008,0x2000000,0x100,0x40240000,0x80200008,0x40000000, | |
7464 | 0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x80040000,0x0,0x0,0x0,0x1000,0x48000000,0x1f,0x181f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7465 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1040010,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000,0x60c,0x18,0x0, | |
7466 | 0x0,0x0,0x0,0x6000,0x0,0x10000000,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,0x3800,0x7000000,0x0,0x0,0x840000,0x400000,0x0,0x40002000, | |
7467 | 0x0,0x2,0x2008,0x2000000,0x200,0x40440000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x80780000,0x0,0x0,0x0,0x1000,0x48000400, | |
7468 | 0x2,0x1e02000,0x0,0x0,0x80000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000,0x0,0x0,0x0,0x0,0x0,0x0,0x2040020,0x0,0x0,0x0,0x0, | |
7469 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x4000,0x0,0xf000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7470 | 0x780000,0x3800000,0x0,0x40002000,0x0,0xe,0x1808,0xc000000,0x3,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80000000, | |
7471 | 0x0,0x0,0x0,0x1000,0x1c00,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0xe0400e0, | |
7472 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3fc, | |
7473 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7474 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }; | |
7475 | const unsigned int font12x24[12*24*256/32] = { | |
7476 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7477 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x19,0x80000000,0x198000,0x0,0x0,0x0,0x0, | |
7478 | 0x0,0x198,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc001806,0xc81980,0x60000000,0xc001806,0x1980c00,0x18060198,0xc80c, | |
7479 | 0x180600,0xc8198000,0xc001,0x80601980,0x18000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7480 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7481 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0x0,0xf0000,0x0,0x0,0x0,0x0,0x0,0x198,0x0,0x0,0x0,0x0,0x0,0x0, | |
7482 | 0x0,0x0,0x0,0x0,0x0,0x0,0x600300f,0x1301980,0x90000000,0x600300f,0x1980600,0x300f0198,0x13006,0x300f01,0x30198000,0x6003, | |
7483 | 0xf01980,0x30000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7484 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7485 | 0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7007,0x3c0000,0x3006019, | |
7486 | 0x80000000,0x90000000,0x3006019,0x80000300,0x60198000,0x3,0x601980,0x0,0x3006,0x1980000,0x60000000,0x0,0x0,0xe0000000,0x0, | |
7487 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7488 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000000, | |
7489 | 0x0,0x0,0x0,0x0,0x0,0xc800019,0x80000000,0x198000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0x0,0x0,0x1001,0x420000,0x0,0x0,0x90000000, | |
7490 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18000c06,0xc80001,0x10000000,0x18000c06,0x1800,0xc060000,0xc818,0xc0600,0xc8000000, | |
7491 | 0x18000,0xc0600000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x80660207,0x800f8060,0x300c004,0x0,0x6, | |
7492 | 0xe00703f,0x3f00383,0xf80f07fc,0x1f01f000,0x0,0xf8,0x607f,0x7c7e07,0xfe7fe0f8,0x6063fc1f,0x86066007,0xe7060f0,0x7f80f07f, | |
7493 | 0x81f8fff6,0x6606c03,0x70ee077f,0xe0786000,0xf0070000,0xc000060,0xc0,0x3e000,0x60006003,0x600fc00,0x0,0x0,0x0,0x0,0x0,0x3c0603, | |
7494 | 0xc0000000,0x7800000,0xf0000,0x0,0xf00001f,0x80001fe0,0x7fe000,0x0,0x0,0x0,0x168fe609,0x0,0x90e07,0x6000,0x3c000e,0x70000f8, | |
7495 | 0x1980001f,0x0,0x1f8,0xf00000f,0xf00180,0xfe000,0xe00e,0x1001,0x20060,0x6006006,0x600600,0x600fe07c,0x7fe7fe7f,0xe7fe3fc3, | |
7496 | 0xfc3fc3fc,0x7e07060f,0xf00f00,0xf00f0000,0xf360660,0x6606606e,0x76001e0,0xc00180f,0x1681981,0x10000000,0xc00180f,0x1980c00, | |
7497 | 0x180f0198,0x3801680c,0x180f01,0x68198000,0xc001,0x80f01980,0x18600198,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019, | |
7498 | 0x8044020c,0xc01f8060,0x2004004,0x0,0xc,0x3f81f07f,0x87f80383,0xf81f87fc,0x3f83f800,0x0,0x1fc,0x780607f,0x81fe7f87,0xfe7fe1fc, | |
7499 | 0x6063fc1f,0x860c6007,0xe7061f8,0x7fc1f87f,0xc3fcfff6,0x6606c03,0x30c6067f,0xe0783000,0xf00d8000,0x6000060,0xc0,0x7e000,0x60006003, | |
7500 | 0x600fc00,0x0,0x0,0xc00,0x0,0x0,0x7c0603,0xe0000000,0xfc00000,0x1f0000,0x0,0x900003f,0xc0003fe0,0x7fe000,0x0,0x0,0x0,0x1302660f, | |
7501 | 0x0,0xf0606,0x6004,0x7e0006,0x60601f8,0x19800001,0x80000000,0x1f8,0x19800010,0x81080300,0x3f2000,0x2011,0x1001,0x1c0060,0x6006006, | |
7502 | 0x600600,0x601fe1fe,0x7fe7fe7f,0xe7fe3fc3,0xfc3fc3fc,0x7f87061f,0x81f81f81,0xf81f8000,0x3fa60660,0x66066066,0x66003f0,0x6003009, | |
7503 | 0x1301981,0x10000000,0x6003009,0x1980600,0x30090198,0x1f013006,0x300901,0x30198000,0x6003,0x901980,0x30600198,0x0,0x0,0x0, | |
7504 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x80cc0f8c,0xc0180060,0x6006044,0x40000000,0xc,0x3181b041,0xc41c0783,0x388018, | |
7505 | 0x71c71800,0x0,0x106,0x18c0f061,0xc38261c6,0x600384,0x60606001,0x86186007,0xe78630c,0x60e30c60,0xe7040606,0x630cc03,0x39c30c00, | |
7506 | 0xc0603000,0x3018c000,0x3000060,0xc0,0x60000,0x60000000,0x6000c00,0x0,0x0,0xc00,0x0,0x0,0x600600,0x60000000,0x18400000,0x180000, | |
7507 | 0x0,0x19800070,0x40003600,0xc000,0x0,0x0,0x0,0x25a06,0x0,0x6030c,0x4,0xe20007,0xe060180,0xf000,0x80000000,0xf0000,0x10800000, | |
7508 | 0x80080600,0x7f2000,0x2020,0x80001001,0x20000,0xf00f00f,0xf00f00,0x601b0382,0x60060060,0x6000600,0x60060060,0x61c78630,0xc30c30c3, | |
7509 | 0xc30c000,0x30e60660,0x66066063,0xc600738,0x3006019,0x80000000,0xe0000000,0x3006019,0x80000300,0x60198000,0x3e000003,0x601980, | |
7510 | 0x0,0x3006,0x1980000,0x60600000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x80cc1fcc,0xc0180060,0x6006035,0x80000000, | |
7511 | 0x18,0x71c03000,0xc00c0583,0x300018,0x60c60c00,0x0,0x6,0x3060f060,0xc30060c6,0x600300,0x60606001,0x86306007,0x9e78670e,0x60670e60, | |
7512 | 0x66000606,0x630c606,0x19830c01,0xc0601800,0x30306000,0x60,0xc0,0x60000,0x60000000,0x6000c00,0x0,0x0,0xc00,0x0,0x0,0x600600, | |
7513 | 0x60000000,0x18000000,0x300000,0x0,0x78060,0x6600,0x1c000,0x300c,0x39819c0,0x0,0x25a00,0x0,0x30c,0x4,0xc00003,0xc060180,0x30c1f, | |
7514 | 0x80000000,0x30c000,0x10800001,0x80700000,0x7f2000,0x2020,0x80001001,0x20060,0xf00f00f,0xf00f00,0xf01b0300,0x60060060,0x6000600, | |
7515 | 0x60060060,0x60c78670,0xe70e70e7,0xe70e000,0x70c60660,0x66066063,0xc7f8618,0x0,0x0,0x0,0x0,0x0,0x0,0x7000000,0x0,0x0,0x0, | |
7516 | 0x0,0x600000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6019,0x87ff3a4c,0xc0180060,0x400600e,0x600000,0x18,0x60c03000, | |
7517 | 0xc00c0d83,0x700018,0x60c60c00,0x20,0x400006,0x3060f060,0xc6006066,0x600600,0x60606001,0x86606006,0x966c6606,0x60660660,0x66000606, | |
7518 | 0x630c666,0xf019801,0x80601800,0x30603000,0x1f06f,0xf01ec0,0xf03fe1ec,0x6703e01f,0x61c0c06,0xdc6701f0,0x6f01ec0c,0xe1f87fc6, | |
7519 | 0xc60cc03,0x71c60c7f,0xc0600600,0x60000000,0x30000000,0x300000,0x40040,0x88060,0x6600,0x18000,0x300c,0x1981980,0x0,0x2421f, | |
7520 | 0x80003ce0,0x7fc198,0x601f,0xc02021,0x980600c0,0x40230,0x80000000,0x402000,0x19806003,0x80006,0xc7f2000,0x2020,0x80001001, | |
7521 | 0x420060,0xf00f00f,0xf00f00,0xf01b0600,0x60060060,0x6000600,0x60060060,0x6066c660,0x66066066,0x6606208,0x60e60660,0x66066061, | |
7522 | 0x987fc670,0x1f01f01f,0x1f01f01,0xf039c0f0,0xf00f00f,0xf03e03,0xe03e03e0,0x1f06701f,0x1f01f01,0xf01f0060,0x1e660c60,0xc60c60c6, | |
7523 | 0xc6f060c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x7ff3207,0x8c0c0000,0xc00300e,0x600000,0x30,0x60c03000, | |
7524 | 0xc01c0983,0xf0600030,0x31860c06,0x6001e0,0x78000e,0x23e1f861,0xc6006066,0x600600,0x60606001,0x86c06006,0x966c6606,0x60660660, | |
7525 | 0xe7000606,0x630c666,0xf01f803,0x600c00,0x30000000,0x3f87f,0x83f83fc3,0xf83fe3fc,0x7f83e01f,0x6380c07,0xfe7f83f8,0x7f83fc0d, | |
7526 | 0xf3fc7fc6,0xc71cc03,0x3183187f,0xc0600600,0x60000000,0xff806000,0x300000,0x40040,0x88070,0x6600,0x60030060,0x6001818,0x1883180, | |
7527 | 0x0,0x2423f,0xc0007ff0,0x607fc1f8,0x603f,0x80c01fc1,0xf80601e0,0x5f220,0x80420000,0x5f2000,0xf006006,0x80006,0xc7f2000,0x2020, | |
7528 | 0x82107c07,0xc03c0060,0x1f81f81f,0x81f81f80,0xf03b0600,0x60060060,0x6000600,0x60060060,0x6066c660,0x66066066,0x660671c,0x61660660, | |
7529 | 0x66066061,0xf860e6c0,0x3f83f83f,0x83f83f83,0xf87fe3f8,0x3f83f83f,0x83f83e03,0xe03e03e0,0x3f87f83f,0x83f83f83,0xf83f8060, | |
7530 | 0x3fc60c60,0xc60c60c3,0x187f8318,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x883200,0x300c0000,0xc003035,0x80600000, | |
7531 | 0x30,0x66c03001,0xc0f81983,0xf86f0030,0x1f071c06,0x600787,0xfe1e001c,0x6261987f,0x86006067,0xfe7fc600,0x7fe06001,0x87c06006, | |
7532 | 0xf6646606,0x60e6067f,0xc3e00606,0x61986f6,0x600f007,0x600c00,0x30000000,0x21c71,0x830831c3,0x1c06031c,0x71c06003,0x6700c06, | |
7533 | 0x6671c318,0x71831c0f,0x16040c06,0xc318606,0x1b031803,0x80600600,0x60000000,0x30009000,0x300000,0x40040,0x7003e,0x67e0,0x90070090, | |
7534 | 0x9001818,0x8c3100,0x0,0x60,0x4000e730,0x900380f0,0x6034,0x80c018c7,0xfe060338,0xb0121,0x80c60000,0x909000,0x6008,0x1080006, | |
7535 | 0xc3f2000,0x2011,0x3180060,0x60060e0,0x19819819,0x81981981,0x9833c600,0x7fe7fe7f,0xe7fe0600,0x60060060,0x60664660,0x66066066, | |
7536 | 0x66063b8,0x62660660,0x66066060,0xf06066c0,0x21c21c21,0xc21c21c2,0x1c466308,0x31c31c31,0xc31c0600,0x60060060,0x31871c31,0x83183183, | |
7537 | 0x18318000,0x71860c60,0xc60c60c3,0x18718318,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x1981a00,0xe03e0000,0xc003044, | |
7538 | 0x40600000,0x60,0x66c03001,0x80f03182,0x1c7f8030,0x3f83fc06,0x601e07,0xfe078038,0x6661987f,0x86006067,0xfe7fc61e,0x7fe06001, | |
7539 | 0x87e06006,0x66666606,0x7fc6067f,0x81f80606,0x61986f6,0x6006006,0x600600,0x30000000,0xc60,0xc60060c6,0xc06060c,0x60c06003, | |
7540 | 0x6e00c06,0x6660c60c,0x60c60c0e,0x6000c06,0xc318666,0x1f031803,0x600600,0x603c2000,0x30016800,0x1fe0000,0x1f81f8,0x1c1f,0x804067e1, | |
7541 | 0x68060168,0x16800810,0xc42300,0x0,0x60,0x20c331,0x68030060,0x6064,0x3fc1040,0xf006031c,0xa011e,0x818c7fe0,0x909000,0x7fe1f, | |
7542 | 0x80f00006,0xc0f2060,0xf80e,0x18c0780,0x780781c0,0x19819819,0x81981981,0x9833c600,0x7fe7fe7f,0xe7fe0600,0x60060060,0xfc666660, | |
7543 | 0x66066066,0x66061f0,0x66660660,0x66066060,0x606066e0,0xc00c00,0xc00c00c0,0xc066600,0x60c60c60,0xc60c0600,0x60060060,0x60c60c60, | |
7544 | 0xc60c60c6,0xc60c000,0x61c60c60,0xc60c60c3,0x1860c318,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x1980f81,0x80373000, | |
7545 | 0xc003004,0x7fe0001,0xf0000060,0x60c03003,0x183180,0xc71c060,0x3181ec00,0x7000,0xe070,0x66619860,0xc6006066,0x60061e,0x60606001, | |
7546 | 0x87606006,0x66626606,0x7f860661,0xc01c0606,0x6198696,0xf00600e,0x600600,0x30000000,0x1fc60,0xc60060c7,0xfc06060c,0x60c06003, | |
7547 | 0x7c00c06,0x6660c60c,0x60c60c0c,0x7f00c06,0xc3b8666,0xe01b007,0x3c00600,0x3c7fe000,0xff03ec00,0x1fe0000,0x40040,0xe001,0xc0806603, | |
7548 | 0xec0e03ec,0x3ec00010,0x0,0x60000000,0x7f,0x10c3f3,0xec070060,0x6064,0x3fc1040,0x6000030c,0xa0100,0x3187fe1,0xf09f1000,0x7fe00, | |
7549 | 0x6,0xc012060,0x0,0xc63c03,0xc03c0380,0x19819819,0x81981981,0x98330600,0x60060060,0x6000600,0x60060060,0xfc662660,0x66066066, | |
7550 | 0x66060e0,0x6c660660,0x66066060,0x6060e630,0x1fc1fc1f,0xc1fc1fc1,0xfc3fe600,0x7fc7fc7f,0xc7fc0600,0x60060060,0x60c60c60,0xc60c60c6, | |
7551 | 0xc60c7fe,0x62c60c60,0xc60c60c1,0xb060c1b0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0xffe02c6,0x3c633000,0xc003004, | |
7552 | 0x7fe0001,0xf00000c0,0x60c03006,0xc6180,0xc60c060,0x60c00c00,0x7000,0xe060,0x66639c60,0x66006066,0x600606,0x60606001,0x86306006, | |
7553 | 0x66636606,0x60060660,0xc0060606,0x61f8696,0xf00600c,0x600300,0x30000000,0x3fc60,0xc60060c7,0xfc06060c,0x60c06003,0x7c00c06, | |
7554 | 0x6660c60c,0x60c60c0c,0x1f80c06,0xc1b0666,0xe01b00e,0x3c00600,0x3c43c000,0x3007de00,0x600000,0x40040,0x30000,0x61006607,0xde0c07de, | |
7555 | 0x7de00000,0x0,0xf07fefff,0x1f,0x8008c3f7,0xde0e0060,0x6064,0xc01047,0xfe00018c,0xb013f,0x86300061,0xf0911000,0x6000,0x6, | |
7556 | 0xc012060,0x3f,0x8063c0cc,0x3cc0c700,0x39c39c39,0xc39c39c1,0x98630600,0x60060060,0x6000600,0x60060060,0x60663660,0x66066066, | |
7557 | 0x66061f0,0x78660660,0x66066060,0x607fc618,0x3fc3fc3f,0xc3fc3fc3,0xfc7fe600,0x7fc7fc7f,0xc7fc0600,0x60060060,0x60c60c60,0xc60c60c6, | |
7558 | 0xc60c7fe,0x64c60c60,0xc60c60c1,0xb060c1b0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0xffe0260,0x6661b000,0xc003000, | |
7559 | 0x600000,0xc0,0x60c0300c,0xc7fe0,0xc60c060,0x60c01c00,0x1e07,0xfe078060,0x6663fc60,0x66006066,0x600606,0x60606001,0x86386006, | |
7560 | 0x6636606,0x60060660,0xe0060606,0x60f039c,0x1b806018,0x600300,0x30000000,0x70c60,0xc60060c6,0x6060c,0x60c06003,0x7600c06, | |
7561 | 0x6660c60c,0x60c60c0c,0x1c0c06,0xc1b03fc,0xe01f01c,0xe00600,0x70000000,0x3007fc00,0x600000,0x40040,0x0,0x62006607,0xfc1807fc, | |
7562 | 0x7fc00000,0x0,0xf0000000,0x1,0xc004c307,0xfc1c0060,0x6064,0xc018c0,0x600000d8,0x5f200,0x3180060,0x50a000,0x6000,0x6,0xc012000, | |
7563 | 0x0,0xc601c0,0x4201c600,0x3fc3fc3f,0xc3fc3fc3,0xfc7f0600,0x60060060,0x6000600,0x60060060,0x60663660,0x66066066,0x66063b8, | |
7564 | 0x70660660,0x66066060,0x607f860c,0x70c70c70,0xc70c70c7,0xcc60600,0x60060060,0x6000600,0x60060060,0x60c60c60,0xc60c60c6,0xc60c000, | |
7565 | 0x68c60c60,0xc60c60c1,0xf060c1f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3300260,0x6661e000,0xc003000,0x600000, | |
7566 | 0x180,0x71c03018,0xc7fe0,0xc60c0c0,0x60c01800,0x787,0xfe1e0060,0x6663fc60,0x630060c6,0x600306,0x60606001,0x86186006,0x661e70e, | |
7567 | 0x60070c60,0x60060606,0x60f039c,0x19806038,0x600180,0x30000000,0x60c60,0xc60060c6,0x6060c,0x60c06003,0x6700c06,0x6660c60c, | |
7568 | 0x60c60c0c,0xc0c06,0xc1b039c,0x1f00e018,0x600600,0x60000000,0x1803f800,0x600000,0x40040,0x39e00,0x63006603,0xf83803f8,0x3f800000, | |
7569 | 0x0,0x60000000,0x0,0xc00cc303,0xf8180060,0x6064,0xc01fc0,0x60060070,0x40200,0x18c0060,0x402000,0x6000,0x6,0xc012000,0x0,0x18c0140, | |
7570 | 0x2014600,0x3fc3fc3f,0xc3fc3fc3,0xfc7f0300,0x60060060,0x6000600,0x60060060,0x60c61e70,0xe70e70e7,0xe70e71c,0x60e60660,0x66066060, | |
7571 | 0x6060060c,0x60c60c60,0xc60c60c6,0xcc60600,0x60060060,0x6000600,0x60060060,0x60c60c60,0xc60c60c6,0xc60c000,0x70c60c60,0xc60c60c0, | |
7572 | 0xe060c0e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x33022e0,0x6670c000,0xc003000,0x600600,0x60180,0x31803030, | |
7573 | 0x41c0184,0x1831c0c0,0x71c23806,0x6001e0,0x780000,0x62630c60,0xe38261c6,0x600386,0x60606043,0x860c6006,0x661e30c,0x60030c60, | |
7574 | 0x740e0607,0xe0f039c,0x31c06030,0x600180,0x30000000,0x61c71,0x830831c3,0x406031c,0x60c06003,0x6300c06,0x6660c318,0x71831c0c, | |
7575 | 0x41c0c07,0x1c0e039c,0x1b00e030,0x600600,0x60000000,0x1c41b00e,0x601cc0,0x401f8,0x45240,0xe1803601,0xb03001b0,0x1b000000, | |
7576 | 0x0,0x0,0x41,0xc008e711,0xb0300060,0x6034,0x80c02020,0x60060030,0x30c00,0xc60000,0x30c000,0x0,0x7,0x1c012000,0x0,0x3180240, | |
7577 | 0x6024608,0x30c30c30,0xc30c30c3,0xc630382,0x60060060,0x6000600,0x60060060,0x61c61e30,0xc30c30c3,0xc30c208,0x70c70e70,0xe70e70e0, | |
7578 | 0x6060068c,0x61c61c61,0xc61c61c6,0x1cc62308,0x30430430,0x43040600,0x60060060,0x31860c31,0x83183183,0x18318060,0x31c71c71, | |
7579 | 0xc71c71c0,0xe07180e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x2203fc0,0x663f6000,0x6006000,0x600600,0x60300, | |
7580 | 0x3f81fe7f,0xc7f80187,0xf83f80c0,0x3f83f006,0x600020,0x400060,0x33e6067f,0xc1fe7f87,0xfe6001fe,0x6063fc7f,0x60e7fe6,0x660e3f8, | |
7581 | 0x6001f860,0x37fc0603,0xfc06030c,0x30c0607f,0xe06000c0,0x30000000,0x7fc7f,0x83f83fc3,0xfc0603fc,0x60c7fe03,0x61807c6,0x6660c3f8, | |
7582 | 0x7f83fc0c,0x7f80fc3,0xfc0e039c,0x3180607f,0xc0600600,0x60000000,0xfc0e00c,0x601986,0x66040040,0x4527f,0xc0803fe0,0xe07fe0e0, | |
7583 | 0xe000000,0x0,0x0,0x7f,0x80107ff0,0xe07fc060,0x603f,0x83fe0000,0x60060018,0xf000,0x420000,0xf0000,0x7fe00,0x7,0xfe012000, | |
7584 | 0x0,0x2100640,0xc0643f8,0x60660660,0x66066067,0xec3e1fe,0x7fe7fe7f,0xe7fe3fc3,0xfc3fc3fc,0x7f860e3f,0x83f83f83,0xf83f8000, | |
7585 | 0x5fc3fc3f,0xc3fc3fc0,0x606006fc,0x7fc7fc7f,0xc7fc7fc7,0xfcffe3f8,0x3fc3fc3f,0xc3fc7fe7,0xfe7fe7fe,0x3f860c3f,0x83f83f83, | |
7586 | 0xf83f8060,0x7f83fc3f,0xc3fc3fc0,0x607f8060,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x2201f80,0x3c1e7000,0x6006000, | |
7587 | 0x600,0x60300,0xe01fe7f,0xc3f00183,0xe01f0180,0x1f01e006,0x600000,0x60,0x3006067f,0x807c7e07,0xfe6000f8,0x6063fc3e,0x6067fe6, | |
7588 | 0x660e0f0,0x6000f060,0x3bf80601,0xf806030c,0x60e0607f,0xe06000c0,0x30000000,0x1ec6f,0xf01ec0,0xf80601ec,0x60c7fe03,0x61c03c6, | |
7589 | 0x6660c1f0,0x6f01ec0c,0x3f007c1,0xcc0e030c,0x71c0c07f,0xc0600600,0x60000000,0x7804018,0xe01186,0x66040040,0x39e3f,0x80401fe0, | |
7590 | 0x407fe040,0x4000000,0x0,0x0,0x3f,0x203ce0,0x407fc060,0x601f,0x3fe0000,0x60060018,0x0,0x0,0x0,0x7fe00,0x6,0xe6012000,0x0, | |
7591 | 0x7e0,0x1807e1f0,0x60660660,0x66066066,0x6c3e07c,0x7fe7fe7f,0xe7fe3fc3,0xfc3fc3fc,0x7e060e0f,0xf00f00,0xf00f0000,0x8f01f81f, | |
7592 | 0x81f81f80,0x60600670,0x1ec1ec1e,0xc1ec1ec1,0xec79c0f0,0xf80f80f,0x80f87fe7,0xfe7fe7fe,0x1f060c1f,0x1f01f01,0xf01f0000,0x4f01cc1c, | |
7593 | 0xc1cc1cc0,0xc06f00c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x6006000,0x600,0x600,0x0,0x0,0x0,0x0, | |
7594 | 0x600000,0x0,0x18000000,0x0,0x0,0x0,0x0,0x0,0x1800,0x0,0x0,0x0,0x600060,0x30000000,0x0,0x0,0xc,0x3,0x0,0x0,0x60000c00,0x0, | |
7595 | 0x0,0xc000,0x600600,0x60000000,0x18,0xc03100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x601f8,0x0,0x0,0x0,0x0,0x6, | |
7596 | 0x12000,0x2000000,0x40,0x20004000,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7597 | 0x0,0xc06000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x2004000,0xc00,0x0,0x0,0x0,0x0,0x0,0xc00000, | |
7598 | 0x0,0x1c000000,0x0,0x0,0x0,0x0,0x0,0xc00,0x0,0x0,0x0,0x780000,0xf0000000,0x0,0x0,0x21c,0x3,0x0,0x0,0x60000c00,0x0,0x0,0xc000, | |
7599 | 0x7c0603,0xe0000000,0x10,0xc02300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x601f0,0x0,0x0,0x0,0x0,0x6,0x12000,0x1000000, | |
7600 | 0x40,0x7e004000,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc06000c0,0x0, | |
7601 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200,0x0,0x300c000,0xc00,0x0,0x0,0x0,0x0,0x0,0xc00000,0x0,0x7800000,0x0, | |
7602 | 0x0,0x0,0x0,0x0,0x800,0x0,0x0,0x0,0x780000,0xf0000000,0x0,0x0,0x3f8,0x3e,0x0,0x0,0x60000c00,0x0,0x0,0x38000,0x3c0603,0xc0000000, | |
7603 | 0x10,0xfc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x60000,0x0,0x0,0x0,0x0,0x6,0x0,0x1000000,0x0,0x0,0x0,0x0, | |
7604 | 0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x80600380,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7605 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffc,0x0, | |
7606 | 0x0,0x1f0,0x3c,0x0,0x0,0x60000c00,0x0,0x0,0x38000,0x600,0x0,0x0,0xf000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7607 | 0x0,0x0,0x0,0x0,0x0,0x6,0x0,0xe000000,0x0,0x0,0x0,0x0,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x70,0x0,0x0,0x0,0x0, | |
7608 | 0x0,0x0,0x0,0x3,0x80600380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7609 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xffc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7610 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7611 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }; | |
7612 | const unsigned int font16x32[16*32*256/32] = { | |
7613 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7614 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7615 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc300000,0x0,0xc300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7616 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x70000e0,0x3c00730,0xe7001c0,0x0,0x70000e0,0x3c00e70,0x70000e0,0x3c00e70,0x730,0x70000e0,0x3c00730, | |
7617 | 0xe700000,0x700,0xe003c0,0xe7000e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7618 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7619 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7620 | 0x0,0x0,0x6600000,0x0,0x6600000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7621 | 0x0,0x0,0x18001c0,0x6600ff0,0xe7003e0,0x0,0x18001c0,0x6600e70,0x18001c0,0x6600e70,0xff0,0x18001c0,0x6600ff0,0xe700000,0x180, | |
7622 | 0x1c00660,0xe7001c0,0x0,0x0,0x0,0x380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7623 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7624 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000, | |
7625 | 0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00380, | |
7626 | 0xc300ce0,0xe700630,0x0,0x1c00380,0xc300e70,0x1c00380,0xc300e70,0xce0,0x1c00380,0xc300ce0,0xe700000,0x1c0,0x3800c30,0xe700380, | |
7627 | 0x0,0x0,0x0,0x7c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7628 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7629 | 0x0,0x0,0x0,0x0,0xe000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0x0, | |
7630 | 0x0,0x0,0x0,0x0,0x0,0xc300000,0x0,0xc300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x700000,0x0,0x0,0x0,0x7c007c00,0x3e000000, | |
7631 | 0x0,0x0,0x630,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe000070,0x1800000,0xc60,0x0,0xe000070,0x1800000,0xe000070, | |
7632 | 0x1800000,0x0,0xe000070,0x1800000,0x0,0xe00,0x700180,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7633 | 0x0,0x0,0x0,0x800000,0x0,0x600600,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7634 | 0x0,0x0,0x3f0,0xfc0,0x0,0x7000000,0x38000000,0x1c0000,0xfc0000,0x380001c0,0xe01c00,0x7f800000,0x0,0x0,0x0,0x0,0x0,0x0,0x7c, | |
7635 | 0x1801f00,0x0,0x0,0x1c,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7300000,0x6600000,0x0,0x6600000,0x0,0x0,0x0,0x0,0xe700000, | |
7636 | 0x0,0x0,0x0,0x0,0x0,0xe00000,0x0,0x0,0x0,0xc000c00,0x43800000,0x0,0x0,0x630,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7637 | 0xf80,0x70000e0,0x3c00730,0xe700c60,0x0,0x70000e0,0x3c00e70,0x70000e0,0x3c00e70,0xe000730,0x70000e0,0x3c00730,0xe700000,0x700, | |
7638 | 0xe003c0,0xe7000e0,0x38000e70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6300000,0x803c00,0x7c00180, | |
7639 | 0xc00300,0x1000000,0x0,0x1c,0x3c007c0,0xfc007e0,0xe01ff8,0x3f03ffc,0x7e007c0,0x0,0x0,0x7c0,0x1c0,0x7f8003f0,0x7f007ff8,0x7ff803f0, | |
7640 | 0x70381ffc,0xff0700e,0x7000783c,0x783807c0,0x7fc007c0,0x7fc00fc0,0x7fff7038,0x700ee007,0x780f780f,0x7ffc03f0,0x70000fc0,0x3c00000, | |
7641 | 0x3000000,0x38000000,0x1c0000,0x1fc0000,0x380001c0,0xe01c00,0x7f800000,0x0,0x0,0x0,0x0,0x0,0x0,0xfc,0x1801f80,0x0,0x1f80000, | |
7642 | 0x7e,0x0,0x0,0x2400000,0xfc00000,0x7ff0000,0x7ffc0000,0x0,0x0,0x0,0x0,0xf30fb0c,0x2400000,0x0,0x240780f,0x1c0,0xfc,0x780f, | |
7643 | 0x18003f0,0xe700000,0x7c00000,0x0,0xff0,0x3c00000,0x78007c0,0xc00000,0xff80000,0xf80,0x7c00000,0xc000c00,0x18001c0,0x1c001c0, | |
7644 | 0x1c001c0,0x1c003e0,0x7fe03f0,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,0x1ffc1ffc,0x7f007838,0x7c007c0,0x7c007c0,0x7c00000,0x7c67038, | |
7645 | 0x70387038,0x7038780f,0x70001fe0,0x30000c0,0x2400f30,0xe700c60,0x0,0x30000c0,0x2400e70,0x30000c0,0x2400e70,0xf700f30,0x30000c0, | |
7646 | 0x2400f30,0xe700000,0x300,0xc00240,0xe7000c0,0x38000e70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0, | |
7647 | 0x630018c,0x807e00,0xfe00180,0xc00300,0x1000000,0x0,0x38,0xff01fc0,0x3ff01ff0,0x1e01ff8,0x7f83ffc,0x1ff80ff0,0x0,0x0,0xff0, | |
7648 | 0x1f003e0,0x7fe00ff8,0x7fc07ff8,0x7ff80ff8,0x70381ffc,0xff0701c,0x7000783c,0x78381ff0,0x7fe01ff0,0x7fe01ff0,0x7fff7038,0x781ee007, | |
7649 | 0x3c1e380e,0x7ffc0380,0x380001c0,0x3c00000,0x1800000,0x38000000,0x1c0000,0x3c00000,0x380001c0,0xe01c00,0x3800000,0x0,0x0, | |
7650 | 0x0,0x7000000,0x0,0x0,0x1e0,0x18003c0,0x0,0x3fc0000,0x70,0x0,0x0,0x6600000,0x1ff00000,0x1fff0000,0x7ffc0000,0x0,0x0,0x0,0x0, | |
7651 | 0xcf0239c,0x3c00000,0x0,0x3c0380e,0x1c0,0x2001fe,0x380e,0x18007f8,0xe700000,0x8600000,0x0,0xff0,0x7e00000,0x8c00870,0x1800000, | |
7652 | 0x1ff80000,0x180,0xc600000,0xc000c00,0x38001c0,0x3e003e0,0x3e003e0,0x3e001c0,0x7fe0ff8,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,0x1ffc1ffc, | |
7653 | 0x7fc07838,0x1ff01ff0,0x1ff01ff0,0x1ff00000,0x1fec7038,0x70387038,0x7038380e,0x70003ce0,0x1800180,0x6600cf0,0xe7007c0,0x0, | |
7654 | 0x1800180,0x6600e70,0x1800180,0x6600e70,0x7c00cf0,0x1800180,0x6600cf0,0xe700000,0x180,0x1800660,0xe700180,0x38000e70,0x0, | |
7655 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x630030c,0x3f0e700,0x1e200180,0x1800180,0x21100000,0x0, | |
7656 | 0x38,0x1e7819c0,0x38781038,0x1e01c00,0xf080038,0x1c381c38,0x0,0x0,0x1878,0x7fc03e0,0x70e01e18,0x70e07000,0x70001e18,0x703801c0, | |
7657 | 0x707038,0x70007c7c,0x7c381c70,0x70701c70,0x70703830,0x1c07038,0x381ce007,0x1c1c3c1e,0x3c0380,0x380001c0,0x7e00000,0xc00000, | |
7658 | 0x38000000,0x1c0000,0x3800000,0x38000000,0x1c00,0x3800000,0x0,0x0,0x0,0x7000000,0x0,0x0,0x1c0,0x18001c0,0x0,0x70c0000,0xe0, | |
7659 | 0x0,0x0,0xc300000,0x38300000,0x3c700000,0x3c0000,0x0,0x0,0x0,0x0,0xce022f4,0x1800000,0x0,0x1803c1e,0x1c0,0x2003c2,0x3c1e, | |
7660 | 0x1800e08,0x7e0,0x300000,0x0,0x7e00000,0xe700000,0x600030,0x3000000,0x3f980000,0x180,0x18200000,0xc000c00,0x1e0001c0,0x3e003e0, | |
7661 | 0x3e003e0,0x3e003e0,0xfe01e18,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70e07c38,0x1c701c70,0x1c701c70,0x1c700000,0x3c787038, | |
7662 | 0x70387038,0x70383c1e,0x70003870,0xc00300,0xc300ce0,0x380,0x0,0xc00300,0xc300000,0xc00300,0xc300000,0xfc00ce0,0xc00300,0xc300ce0, | |
7663 | 0x0,0xc0,0x3000c30,0x300,0x38000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x630031c,0xff8c300, | |
7664 | 0x1c000180,0x1800180,0x39380000,0x0,0x70,0x1c3801c0,0x203c001c,0x3e01c00,0x1c000038,0x381c3838,0x0,0x0,0x1038,0xe0e03e0,0x70703c08, | |
7665 | 0x70707000,0x70003808,0x703801c0,0x707070,0x70007c7c,0x7c383838,0x70383838,0x70387010,0x1c07038,0x381c700e,0x1e3c1c1c,0x780380, | |
7666 | 0x1c0001c0,0xe700000,0x0,0x38000000,0x1c0000,0x3800000,0x38000000,0x1c00,0x3800000,0x0,0x0,0x0,0x7000000,0x0,0x0,0x1c0,0x18001c0, | |
7667 | 0x0,0xe000000,0xe0,0x0,0x1000100,0x3800,0x70100000,0x38700000,0x780000,0x1c0,0x7801ce0,0xe380000,0x0,0x2264,0x0,0x0,0x1c1c, | |
7668 | 0x0,0x200780,0x1c1c,0x1800c00,0x1818,0x7f00000,0x0,0x18180000,0xc300000,0x600070,0x0,0x7f980000,0x180,0x18300000,0xc000c00, | |
7669 | 0x3000000,0x3e003e0,0x3e003e0,0x3e003e0,0xee03c08,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70707c38,0x38383838,0x38383838, | |
7670 | 0x38380000,0x38387038,0x70387038,0x70381c1c,0x7fc03870,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xbc00000,0x0,0x0,0x0,0x0,0x0,0x0, | |
7671 | 0x38000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6300318,0xe88c300,0x1c000180,0x38001c0, | |
7672 | 0xfe00180,0x0,0x70,0x1c3801c0,0x1c001c,0x6e01c00,0x1c000078,0x381c3818,0x0,0x40000,0x40000038,0x1c0607e0,0x70703800,0x70707000, | |
7673 | 0x70003800,0x703801c0,0x7070e0,0x70007c7c,0x7c383838,0x70383838,0x70387000,0x1c07038,0x381c700e,0xf780e38,0x700380,0x1c0001c0, | |
7674 | 0x1c380000,0x0,0x38000000,0x1c0000,0x3800000,0x38000000,0x1c00,0x3800000,0x0,0x0,0x0,0x7000000,0x0,0x0,0x1c0,0x18001c0,0x0, | |
7675 | 0xe000000,0xe0,0x0,0x1000100,0x4400,0x70000000,0x38700000,0x700000,0xe0,0x7001c70,0xe380000,0x0,0x2264,0x0,0x0,0xe38,0x0, | |
7676 | 0x200700,0xe38,0x1800c00,0x300c,0xc300000,0x0,0x300c0000,0xc300180,0x6003c0,0x0,0x7f980000,0x180,0x18300000,0xc000c00,0x1800000, | |
7677 | 0x7e007e0,0x7e007e0,0x7e003e0,0xee03800,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70707c38,0x38383838,0x38383838,0x38380000, | |
7678 | 0x38387038,0x70387038,0x70380e38,0x7ff039f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e00000,0x0,0x0,0x0,0x40000,0x0,0x0,0x38000000, | |
7679 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6300318,0x1c80e700,0x1c000180,0x38001c0,0x3800180, | |
7680 | 0x0,0xe0,0x381c01c0,0x1c001c,0x6e01c00,0x38000070,0x381c381c,0x0,0x3c0000,0x78000078,0x38030770,0x70707800,0x70387000,0x70007000, | |
7681 | 0x703801c0,0x7071c0,0x7000745c,0x7638701c,0x7038701c,0x70387000,0x1c07038,0x1c38718e,0x7700f78,0xf00380,0xe0001c0,0x381c0000, | |
7682 | 0x7e0,0x39e003e0,0x79c03f0,0x3ffc079c,0x39e01fc0,0xfe01c1e,0x3807778,0x39e007e0,0x39e0079c,0x73c07e0,0x7ff83838,0x701ce007, | |
7683 | 0x783c701c,0x1ffc01c0,0x18001c0,0x0,0x1c000100,0xe0,0x0,0x1000100,0x4200,0x70000000,0x70700100,0xf00100,0x10000e0,0x7000c70, | |
7684 | 0xc700000,0x0,0x2204,0x7e00000,0x1e380100,0x1ffc0f78,0x0,0xf80700,0xf78,0x1800e00,0x63e6,0x18300000,0x0,0x6fe60000,0xe700180, | |
7685 | 0xc00060,0x3838,0x7f980000,0x180,0x18300000,0xc000c00,0x18001c0,0x7700770,0x7700770,0x77007f0,0xee07800,0x70007000,0x70007000, | |
7686 | 0x1c001c0,0x1c001c0,0x70387638,0x701c701c,0x701c701c,0x701c1008,0x707c7038,0x70387038,0x70380f78,0x707039c0,0x7e007e0,0x7e007e0, | |
7687 | 0x7e007e0,0x1f3c03e0,0x3f003f0,0x3f003f0,0x1fc01fc0,0x1fc01fc0,0x7f039e0,0x7e007e0,0x7e007e0,0x7e00380,0x7ce3838,0x38383838, | |
7688 | 0x3838701c,0x39e0701c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x6307fff,0x1c807e0c,0xe000180, | |
7689 | 0x30000c0,0x3800180,0x0,0xe0,0x381c01c0,0x1c001c,0xce01fe0,0x38000070,0x381c381c,0x3800380,0xfc0000,0x7e0000f0,0x30030770, | |
7690 | 0x70707000,0x70387000,0x70007000,0x703801c0,0x707380,0x700076dc,0x7638701c,0x7038701c,0x70387800,0x1c07038,0x1c3873ce,0x7f00770, | |
7691 | 0xe00380,0xe0001c0,0x700e0000,0x1ff8,0x3ff00ff0,0xffc0ff8,0x3ffc0ffc,0x3bf01fc0,0xfe01c3c,0x3807f78,0x3bf00ff0,0x3ff00ffc, | |
7692 | 0x77e0ff0,0x7ff83838,0x3838e007,0x3c783838,0x1ffc01c0,0x18001c0,0x0,0x7ff00380,0x1e0,0x0,0x1000100,0x4200,0x78000000,0x70700380, | |
7693 | 0xe00380,0x3800060,0xe000e30,0x1c600000,0x0,0x2204,0xff00000,0x7f7c0380,0x1ffc0770,0x1c0,0x3fc0700,0x18040770,0x1800780,0x4e12, | |
7694 | 0x18300104,0x0,0x4c320000,0x7e00180,0x1c00030,0x3838,0x7f980000,0x180,0x18302080,0xc000c00,0x18001c0,0x7700770,0x7700770, | |
7695 | 0x7700770,0x1ee07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70387638,0x701c701c,0x701c701c,0x701c381c,0x705c7038,0x70387038, | |
7696 | 0x70380770,0x70383b80,0x1ff81ff8,0x1ff81ff8,0x1ff81ff8,0x3fbe0ff0,0xff80ff8,0xff80ff8,0x1fc01fc0,0x1fc01fc0,0xff83bf0,0xff00ff0, | |
7697 | 0xff00ff0,0xff00380,0xffc3838,0x38383838,0x38383838,0x3ff03838,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7698 | 0x0,0x1c0,0x7fff,0x1c803c38,0xf000000,0x70000e0,0xfe00180,0x0,0x1c0,0x381c01c0,0x3c0078,0xce01ff0,0x39e000f0,0x1c38381c,0x3800380, | |
7699 | 0x3e07ffc,0xf8001f0,0x307b0770,0x70e07000,0x70387000,0x70007000,0x703801c0,0x707700,0x700076dc,0x7638701c,0x7038701c,0x70387e00, | |
7700 | 0x1c07038,0x1c3873ce,0x3e007f0,0x1e00380,0x70001c0,0x0,0x1038,0x3c381e18,0x1c7c1e3c,0x3801e3c,0x3c7801c0,0xe01c78,0x380739c, | |
7701 | 0x3c781c38,0x3c381c3c,0x7c21e10,0x7003838,0x3838700e,0x1ef03838,0x3c01c0,0x18001c0,0x0,0x7fe007c0,0x1c0,0x0,0x1000100,0x6400, | |
7702 | 0x7e000000,0x707007c0,0x1e007c0,0x7c00070,0xe000638,0x18600000,0x0,0x0,0x1e100000,0x73ce07c0,0x3c07f0,0x1c0,0x7240700,0x1ddc3ffe, | |
7703 | 0x1800de0,0x8c01,0x1870030c,0x0,0x8c310000,0x3c00180,0x3800030,0x3838,0x7f980000,0x180,0x183030c0,0xc000c00,0x430001c0,0x7700770, | |
7704 | 0x7700770,0x7700770,0x1ce07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x70387638,0x701c701c,0x701c701c,0x701c1c38,0x70dc7038, | |
7705 | 0x70387038,0x703807f0,0x70383b80,0x10381038,0x10381038,0x10381038,0x21e71e18,0x1e3c1e3c,0x1e3c1e3c,0x1c001c0,0x1c001c0,0x1e383c78, | |
7706 | 0x1c381c38,0x1c381c38,0x1c380380,0x1c383838,0x38383838,0x38383838,0x3c383838,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7707 | 0x0,0x0,0x0,0x0,0x0,0x1c0,0x630,0x1e8000e0,0x1f000000,0x70000e0,0x39380180,0x0,0x1c0,0x3b9c01c0,0x3c07f0,0x18e01078,0x3bf800e0, | |
7708 | 0x7e0383c,0x3800380,0x1f807ffc,0x3f001c0,0x61ff0e38,0x7fc07000,0x70387ff0,0x7ff07000,0x7ff801c0,0x707f00,0x7000729c,0x7338701c, | |
7709 | 0x7070701c,0x70703fc0,0x1c07038,0x1e7873ce,0x1c003e0,0x3c00380,0x70001c0,0x0,0x1c,0x3c381c00,0x1c3c1c1c,0x3801c3c,0x383801c0, | |
7710 | 0xe01cf0,0x380739c,0x38381c38,0x3c381c3c,0x7801c00,0x7003838,0x3838700e,0xfe03c78,0x7801c0,0x18001c0,0x0,0x1c000c20,0xff8, | |
7711 | 0x0,0x1ff01ff0,0x3818,0x3fc00100,0x707e0c20,0x3c00c20,0xc200030,0xc000618,0x18c00000,0x0,0x0,0x1c000080,0xe1ce0c20,0x7803e0, | |
7712 | 0x1c0,0xe200700,0xff83ffe,0x1801878,0x9801,0x1cf0071c,0x7ffc0000,0x8c310000,0x7ffe,0x7000030,0x3838,0x3f980380,0x180,0xc6038e0, | |
7713 | 0x7f9c7f9c,0x3e1c01c0,0xe380e38,0xe380e38,0xe380f78,0x1cfc7000,0x7ff07ff0,0x7ff07ff0,0x1c001c0,0x1c001c0,0xfe387338,0x701c701c, | |
7714 | 0x701c701c,0x701c0e70,0x719c7038,0x70387038,0x703803e0,0x70383b80,0x1c001c,0x1c001c,0x1c001c,0xe71c00,0x1c1c1c1c,0x1c1c1c1c, | |
7715 | 0x1c001c0,0x1c001c0,0x1c383838,0x1c381c38,0x1c381c38,0x1c380000,0x3c383838,0x38383838,0x38383c78,0x3c383c78,0x0,0x0,0x0,0x0, | |
7716 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x630,0xf800380,0x3f830000,0x70000e0,0x31080180,0x0,0x380,0x3b9c01c0, | |
7717 | 0x7807e0,0x38e00038,0x3c3800e0,0xff01c3c,0x3800380,0x7c000000,0x7c03c0,0x61870e38,0x7fc07000,0x70387ff0,0x7ff070fc,0x7ff801c0, | |
7718 | 0x707f80,0x7000739c,0x7338701c,0x7ff0701c,0x7fe00ff0,0x1c07038,0xe7073ce,0x1c003e0,0x3800380,0x38001c0,0x0,0x1c,0x381c3800, | |
7719 | 0x381c380e,0x380381c,0x383801c0,0xe01de0,0x380739c,0x3838381c,0x381c381c,0x7001e00,0x7003838,0x1c70718e,0x7e01c70,0xf00380, | |
7720 | 0x18001e0,0x1e000000,0x1c001bb0,0xff8,0x0,0x1000100,0xe0,0xff00300,0x707e1bb0,0x3801bb0,0x1bb00010,0x8000308,0x30c00000,0x0, | |
7721 | 0x0,0x1e0000c0,0xe1ce1bb0,0xf003e0,0x1c0,0x1c203ff8,0x63003e0,0x180181c,0x9801,0xfb00e38,0x7ffc0000,0x8fc10000,0x7ffe,0xe000860, | |
7722 | 0x3838,0x1f980380,0x180,0x7c01c70,0x1f001f0,0x1f003c0,0xe380e38,0xe380e38,0xe380e38,0x1cfc7000,0x7ff07ff0,0x7ff07ff0,0x1c001c0, | |
7723 | 0x1c001c0,0xfe387338,0x701c701c,0x701c701c,0x701c07e0,0x731c7038,0x70387038,0x703803e0,0x70383980,0x1c001c,0x1c001c,0x1c001c, | |
7724 | 0xe73800,0x380e380e,0x380e380e,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0000,0x387c3838,0x38383838,0x38381c70, | |
7725 | 0x381c1c70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0xc30,0x7f00e00,0x33c30000,0x70000e0,0x1007ffe, | |
7726 | 0x0,0x380,0x3b9c01c0,0xf00078,0x30e0001c,0x3c1c01c0,0x1c381fdc,0x0,0x70000000,0x1c0380,0x63030e38,0x70707000,0x70387000,0x700070fc, | |
7727 | 0x703801c0,0x707b80,0x7000739c,0x7338701c,0x7fc0701c,0x7fc001f0,0x1c07038,0xe703e5c,0x3e001c0,0x7800380,0x38001c0,0x0,0x7fc, | |
7728 | 0x381c3800,0x381c380e,0x380381c,0x383801c0,0xe01fe0,0x380739c,0x3838381c,0x381c381c,0x7001fc0,0x7003838,0x1c70718e,0x7c01c70, | |
7729 | 0xe01f00,0x180007c,0x7f8c0000,0x7fc03fb8,0x1c0,0x0,0x1000100,0x700,0x1f00600,0x70703fb8,0x7803fb8,0x3fb80000,0x8000000,0x180, | |
7730 | 0x0,0x0,0x1fc00060,0xe1ce3fb8,0xe001c0,0x1c0,0x1c203ff8,0xc1801c0,0x180c,0x9801,0x1c70,0xc0000,0x8cc10000,0x180,0xfe007c0, | |
7731 | 0x3838,0x7980380,0xff0,0xe38,0x3e003e00,0x3e000380,0xe380e38,0xe380e38,0xe380e38,0x38e07000,0x70007000,0x70007000,0x1c001c0, | |
7732 | 0x1c001c0,0x70387338,0x701c701c,0x701c701c,0x701c03c0,0x731c7038,0x70387038,0x703801c0,0x703838e0,0x7fc07fc,0x7fc07fc,0x7fc07fc, | |
7733 | 0xe73800,0x380e380e,0x380e380e,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c7ffc,0x38dc3838,0x38383838,0x38381c70, | |
7734 | 0x381c1c70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0xc60,0xf83878,0x71e30000,0x70000e0,0x1007ffe, | |
7735 | 0x7f0,0x380,0x381c01c0,0x1e0003c,0x60e0001c,0x381c01c0,0x381c079c,0x0,0x7c000000,0x7c0380,0x63031c1c,0x70307000,0x70387000, | |
7736 | 0x7000701c,0x703801c0,0x7071c0,0x7000739c,0x71b8701c,0x7000701c,0x71e00078,0x1c07038,0xe703e7c,0x7e001c0,0xf000380,0x38001c0, | |
7737 | 0x0,0x1ffc,0x381c3800,0x381c3ffe,0x380381c,0x383801c0,0xe01fc0,0x380739c,0x3838381c,0x381c381c,0x7000ff0,0x7003838,0x1ef03bdc, | |
7738 | 0x3800ee0,0x1e01f00,0x180007c,0x61fc0000,0x7fc07f3c,0x1c0,0x0,0x1000100,0x1800,0x780c00,0x70707f3c,0xf007f3c,0x7f3c0000,0x0, | |
7739 | 0x3c0,0x3ffcffff,0x0,0xff00030,0xe1fe7f3c,0x1e001c0,0x1c0,0x1c200700,0xc183ffe,0xe0c,0x9801,0x1ff038e0,0xc07f0,0x8c610000, | |
7740 | 0x180,0x0,0x3838,0x1980380,0x0,0x1ff0071c,0xe000e000,0xe0000f80,0x1c1c1c1c,0x1c1c1c1c,0x1c1c1e38,0x38e07000,0x70007000,0x70007000, | |
7741 | 0x1c001c0,0x1c001c0,0x703871b8,0x701c701c,0x701c701c,0x701c03c0,0x761c7038,0x70387038,0x703801c0,0x70703870,0x1ffc1ffc,0x1ffc1ffc, | |
7742 | 0x1ffc1ffc,0xfff3800,0x3ffe3ffe,0x3ffe3ffe,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c7ffc,0x389c3838,0x38383838, | |
7743 | 0x38380ee0,0x381c0ee0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0xfffc,0xbc60fc,0x70e30000,0x70000e0, | |
7744 | 0x180,0x7f0,0x700,0x381c01c0,0x3e0001c,0x7ffc001c,0x381c03c0,0x381c001c,0x0,0x1f807ffc,0x3f00380,0x63031ffc,0x70387000,0x70387000, | |
7745 | 0x7000701c,0x703801c0,0x7071e0,0x7000701c,0x71b8701c,0x7000701c,0x70f00038,0x1c07038,0x7e03e7c,0x77001c0,0xe000380,0x1c001c0, | |
7746 | 0x0,0x3c1c,0x381c3800,0x381c3ffe,0x380381c,0x383801c0,0xe01fe0,0x380739c,0x3838381c,0x381c381c,0x70003f8,0x7003838,0xee03bdc, | |
7747 | 0x3c00ee0,0x3c00380,0x18000e0,0xf00000,0x1c007e7c,0x3c0,0x0,0x1000100,0x0,0x381800,0x70707e7c,0xe007e7c,0x7e7c0000,0x0,0x7c0, | |
7748 | 0x0,0x0,0x3f80018,0xe1fe7e7c,0x3c001c0,0x1c0,0x1c200700,0xc183ffe,0xf0c,0x8c01,0x38e0,0xc07f0,0x8c710000,0x180,0x0,0x3838, | |
7749 | 0x1980000,0x0,0x71c,0x7000f0,0x700f00,0x1ffc1ffc,0x1ffc1ffc,0x1ffc1ffc,0x3fe07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0, | |
7750 | 0x703871b8,0x701c701c,0x701c701c,0x701c07e0,0x7c1c7038,0x70387038,0x703801c0,0x7ff03838,0x3c1c3c1c,0x3c1c3c1c,0x3c1c3c1c, | |
7751 | 0x3fff3800,0x3ffe3ffe,0x3ffe3ffe,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0000,0x391c3838,0x38383838,0x38380ee0, | |
7752 | 0x381c0ee0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffc,0x9c01ce,0x70f60000,0x70000e0,0x180, | |
7753 | 0x0,0x700,0x381c01c0,0x780001c,0x7ffc001c,0x381c0380,0x381c003c,0x0,0x3e07ffc,0xf800380,0x63031ffc,0x70387000,0x70387000, | |
7754 | 0x7000701c,0x703801c0,0x7070f0,0x7000701c,0x71b8701c,0x7000701c,0x70700038,0x1c07038,0x7e03e7c,0xf7801c0,0x1e000380,0x1c001c0, | |
7755 | 0x0,0x381c,0x381c3800,0x381c3800,0x380381c,0x383801c0,0xe01fe0,0x380739c,0x3838381c,0x381c381c,0x7000078,0x7003838,0xee03a5c, | |
7756 | 0x7c00fe0,0x78001c0,0x18001c0,0x0,0x1c003ef8,0x380,0x0,0x1000100,0x810,0x383000,0x70703ef8,0x1e003ef8,0x3ef80000,0x0,0x7c0, | |
7757 | 0x0,0x0,0x78000c,0xe1c03ef8,0x78001c0,0x1c0,0x1c200700,0x63001c0,0x18003f8,0x4e12,0x1c70,0xc0000,0x4c320000,0x180,0x0,0x3838, | |
7758 | 0x1980000,0x0,0xe38,0x700118,0x701e00,0x1ffc1ffc,0x1ffc1ffc,0x1ffc1ffc,0x7fe07000,0x70007000,0x70007000,0x1c001c0,0x1c001c0, | |
7759 | 0x703871b8,0x701c701c,0x701c701c,0x701c0e70,0x7c1c7038,0x70387038,0x703801c0,0x7fc0381c,0x381c381c,0x381c381c,0x381c381c, | |
7760 | 0x78e03800,0x38003800,0x38003800,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0000,0x3b1c3838,0x38383838,0x38380fe0, | |
7761 | 0x381c0fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1860,0x9c0186,0x707e0000,0x30000c0,0x180, | |
7762 | 0x0,0xe00,0x183801c0,0xf00001c,0xe0001c,0x181c0380,0x381c0038,0x0,0xfc0000,0x7e000000,0x61873c1e,0x70383800,0x70707000,0x7000381c, | |
7763 | 0x703801c0,0x707070,0x7000701c,0x70f83838,0x70003838,0x70780038,0x1c07038,0x7e03c3c,0xe3801c0,0x1c000380,0xe001c0,0x0,0x381c, | |
7764 | 0x381c3800,0x381c3800,0x380381c,0x383801c0,0xe01ef0,0x380739c,0x3838381c,0x381c381c,0x7000038,0x7003838,0xfe03e7c,0xfe007c0, | |
7765 | 0x70001c0,0x18001c0,0x0,0xe001ff0,0x380,0x0,0x1000100,0x162c,0x381800,0x30701ff0,0x1c001ff0,0x1ff00000,0x0,0x3c0,0x0,0x0, | |
7766 | 0x380018,0xe1c01ff0,0x70001c0,0x1c0,0x1c200700,0xff801c0,0x18000f0,0x63e6,0xe38,0x0,0x6c3e0000,0x0,0x0,0x3838,0x1980000,0x0, | |
7767 | 0x1c70,0xf0000c,0xf01c00,0x3c1e3c1e,0x3c1e3c1e,0x3c1e3c1c,0x70e03800,0x70007000,0x70007000,0x1c001c0,0x1c001c0,0x707070f8, | |
7768 | 0x38383838,0x38383838,0x38381c38,0x38387038,0x70387038,0x703801c0,0x7000381c,0x381c381c,0x381c381c,0x381c381c,0x70e03800, | |
7769 | 0x38003800,0x38003800,0x1c001c0,0x1c001c0,0x381c3838,0x381c381c,0x381c381c,0x381c0380,0x3e1c3838,0x38383838,0x383807c0,0x381c07c0, | |
7770 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18c0,0x9c0186,0x783c0000,0x38001c0,0x180,0x3800000, | |
7771 | 0x3800e00,0x1c3801c0,0x1e00003c,0xe00038,0x1c1c0780,0x381c0038,0x3800380,0x3c0000,0x78000000,0x61ff380e,0x70383808,0x70707000, | |
7772 | 0x7000381c,0x703801c0,0x40707078,0x7000701c,0x70f83838,0x70003838,0x70384038,0x1c07038,0x7e03c3c,0x1e3c01c0,0x3c000380,0xe001c0, | |
7773 | 0x0,0x383c,0x3c381c00,0x1c3c1c00,0x3801c3c,0x383801c0,0xe01c78,0x380739c,0x38381c38,0x3c381c3c,0x7000038,0x7003878,0x7c01e78, | |
7774 | 0x1ef007c0,0xf0001c0,0x18001c0,0x0,0xe000ee0,0x7800380,0xe380000,0x1001ff0,0x2242,0x40380c00,0x38700ee0,0x3c000ee0,0xee00000, | |
7775 | 0x0,0x0,0x0,0x0,0x380030,0xe1c00ee0,0xf0001c0,0x1c0,0xe200700,0xdd801c0,0x1800038,0x300c,0x71c,0x0,0x300c0000,0x0,0x0,0x3838, | |
7776 | 0x1980000,0x0,0x38e0,0xb0000c,0xb01c08,0x380e380e,0x380e380e,0x380e380e,0x70e03808,0x70007000,0x70007000,0x1c001c0,0x1c001c0, | |
7777 | 0x707070f8,0x38383838,0x38383838,0x3838381c,0x38387038,0x70387038,0x703801c0,0x7000381c,0x383c383c,0x383c383c,0x383c383c, | |
7778 | 0x70e01c00,0x1c001c00,0x1c001c00,0x1c001c0,0x1c001c0,0x1c383838,0x1c381c38,0x1c381c38,0x1c380380,0x1c383878,0x38783878,0x387807c0, | |
7779 | 0x3c3807c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x18c0,0x10b801ce,0x3c3e0000,0x38001c0,0x180, | |
7780 | 0x3800000,0x3801c00,0x1e7801c0,0x3c002078,0xe02078,0x1c380700,0x1c3810f0,0x3800380,0x40000,0x40000380,0x307b380e,0x70701e18, | |
7781 | 0x70e07000,0x70001c1c,0x703801c0,0x60e0703c,0x7000701c,0x70f83c78,0x70003c70,0x703c70f0,0x1c03870,0x3c01c3c,0x3c1c01c0,0x78000380, | |
7782 | 0x7001c0,0x0,0x3c7c,0x3c381e18,0x1c7c1e0c,0x3801c3c,0x383801c0,0xe01c38,0x3c0739c,0x38381c38,0x3c381c3c,0x7001078,0x7803c78, | |
7783 | 0x7c01c38,0x1c780380,0x1e0001c0,0x18001c0,0x0,0x70c06c0,0x7000380,0xe300000,0x1000100,0x2142,0x70f00600,0x3c7006c0,0x780006c0, | |
7784 | 0x6c00000,0x0,0x0,0x0,0x0,0x10780060,0x73e206c0,0x1e0001c0,0x1c0,0x7240700,0x180c01c0,0x1800018,0x1818,0x30c,0x0,0x18180000, | |
7785 | 0x0,0x0,0x3c78,0x1980000,0x0,0x30c0,0x130000c,0x1301c18,0x380e380e,0x380e380e,0x380e380e,0x70e01e18,0x70007000,0x70007000, | |
7786 | 0x1c001c0,0x1c001c0,0x70e070f8,0x3c783c78,0x3c783c78,0x3c781008,0x7c783870,0x38703870,0x387001c0,0x70003a3c,0x3c7c3c7c,0x3c7c3c7c, | |
7787 | 0x3c7c3c7c,0x79f11e18,0x1e0c1e0c,0x1e0c1e0c,0x1c001c0,0x1c001c0,0x1c783838,0x1c381c38,0x1c381c38,0x1c380380,0x1c383c78,0x3c783c78, | |
7788 | 0x3c780380,0x3c380380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x38c0,0x1ff800fc,0x1fee0000, | |
7789 | 0x1800180,0x180,0x3800000,0x3801c00,0xff01ffc,0x3ffc3ff0,0xe03ff0,0xff00700,0x1ff81fe0,0x3800380,0x0,0x380,0x3000780f,0x7ff00ff8, | |
7790 | 0x7fc07ff8,0x70000ffc,0x70381ffc,0x7fe0701c,0x7ff8701c,0x70781ff0,0x70001ff0,0x701c7ff0,0x1c01fe0,0x3c01c38,0x380e01c0,0x7ffc0380, | |
7791 | 0x7001c0,0x0,0x1fdc,0x3ff00ff0,0xffc0ffc,0x3800fdc,0x38383ffe,0xe01c3c,0x1fc739c,0x38380ff0,0x3ff00ffc,0x7001ff0,0x3f81fb8, | |
7792 | 0x7c01c38,0x3c3c0380,0x1ffc01c0,0x18001c0,0x0,0x3fc0380,0x7000380,0xc70718c,0x1000100,0x2244,0x7ff00200,0x1fff0380,0x7ffc0380, | |
7793 | 0x3800000,0x0,0x0,0x0,0x0,0x1ff000c0,0x7f7e0380,0x1ffc01c0,0x1c0,0x3fc3ffe,0x1c0,0x1800018,0x7e0,0x104,0x0,0x7e00000,0x7ffe, | |
7794 | 0x0,0x3fde,0x1980000,0x0,0x2080,0x3300018,0x3300ff0,0x780f780f,0x780f780f,0x780f780e,0xf0fe0ff8,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc, | |
7795 | 0x1ffc1ffc,0x7fc07078,0x1ff01ff0,0x1ff01ff0,0x1ff00000,0x7ff01fe0,0x1fe01fe0,0x1fe001c0,0x70003bf8,0x1fdc1fdc,0x1fdc1fdc, | |
7796 | 0x1fdc1fdc,0x3fbf0ff0,0xffc0ffc,0xffc0ffc,0x3ffe3ffe,0x3ffe3ffe,0xff03838,0xff00ff0,0xff00ff0,0xff00000,0x3ff01fb8,0x1fb81fb8, | |
7797 | 0x1fb80380,0x3ff00380,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0,0x31c0,0x7e00078,0x7cf0000,0x1800180, | |
7798 | 0x0,0x3800000,0x3803800,0x3c01ffc,0x3ffc0fe0,0xe01fc0,0x3e00e00,0x7e00f80,0x3800380,0x0,0x380,0x18007007,0x7fc003f0,0x7f007ff8, | |
7799 | 0x700003f0,0x70381ffc,0x3f80701e,0x7ff8701c,0x707807c0,0x700007c0,0x701e1fc0,0x1c00fc0,0x3c01818,0x780f01c0,0x7ffc0380,0x3801c0, | |
7800 | 0x0,0xf9c,0x39e003e0,0x79c03f0,0x380079c,0x38383ffe,0xe01c1e,0x7c739c,0x383807e0,0x39e0079c,0x7000fc0,0x1f80f38,0x3801c38, | |
7801 | 0x781e0380,0x1ffc01c0,0x18001c0,0x0,0x1f80100,0xe000700,0x1c60718c,0x1000100,0x1e3c,0x1fc00100,0x7ff0100,0x7ffc0100,0x1000000, | |
7802 | 0x0,0x0,0x0,0x0,0xfc00080,0x3e3c0100,0x1ffc01c0,0x1c0,0xf83ffe,0x1c0,0x1800838,0x0,0x0,0x0,0x0,0x7ffe,0x0,0x3b9e,0x1980000, | |
7803 | 0x0,0x0,0x2300038,0x23003e0,0x70077007,0x70077007,0x70077007,0xe0fe03f0,0x7ff87ff8,0x7ff87ff8,0x1ffc1ffc,0x1ffc1ffc,0x7f007078, | |
7804 | 0x7c007c0,0x7c007c0,0x7c00000,0xc7c00fc0,0xfc00fc0,0xfc001c0,0x700039f0,0xf9c0f9c,0xf9c0f9c,0xf9c0f9c,0x1f1e03e0,0x3f003f0, | |
7805 | 0x3f003f0,0x3ffe3ffe,0x3ffe3ffe,0x7e03838,0x7e007e0,0x7e007e0,0x7e00000,0x63e00f38,0xf380f38,0xf380380,0x39e00380,0x0,0x0, | |
7806 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0,0xc00300,0x0,0x3000000,0x3800,0x0,0x0,0x0,0x0, | |
7807 | 0x0,0x300,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe0,0x0,0x0,0x0,0x0,0x380,0x3801c0,0x0,0x0,0x0,0x0,0x1c,0x0,0xe00000, | |
7808 | 0x0,0x0,0x3800001c,0x0,0x0,0x0,0x700,0x1c0,0x18001c0,0x0,0x0,0xe000700,0x18600000,0x1000100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7809 | 0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x1800ff0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x1980000,0x1800000,0x0,0x6300070,0x6300000,0x0, | |
7810 | 0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000, | |
7811 | 0x0,0x700,0x38000700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0,0xc00300,0x0,0x7000000, | |
7812 | 0x7000,0x0,0x0,0x0,0x0,0x0,0x700,0x0,0x0,0xf040000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0x0,0x0,0x0,0x0,0x3f0,0x1c0fc0,0x0,0x0, | |
7813 | 0x0,0x0,0x1c,0x0,0xe00000,0x0,0x0,0x3800001c,0x0,0x0,0x0,0x700,0x1e0,0x18003c0,0x0,0x0,0xc000700,0x18c00000,0x1000000,0x0, | |
7814 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x18007e0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x1980000,0xc00000, | |
7815 | 0x0,0x7f800e0,0x7f80000,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0, | |
7816 | 0x0,0x0,0x0,0x0,0x0,0x0,0x700,0x38000700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000, | |
7817 | 0x0,0x600600,0x0,0x6000000,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x7fc0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0, | |
7818 | 0x3f0,0xfc0,0x0,0x0,0x0,0x0,0x838,0x0,0x1e00000,0x0,0x0,0x3800001c,0x0,0x0,0x0,0xf00,0xfc,0x1801f80,0x0,0x0,0x8008e00,0x30c00000, | |
7819 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x1800000,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x1980000,0xc00000, | |
7820 | 0x0,0x3001c0,0x300000,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0, | |
7821 | 0x0,0x0,0x0,0x0,0x0,0xf00,0x38000f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0, | |
7822 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7823 | 0x0,0x0,0xff0,0x0,0x1fc00000,0x0,0x0,0x3800001c,0x0,0x0,0x0,0x3e00,0x7c,0x1801f00,0x0,0x0,0x800fe00,0x0,0x0,0x0,0x0,0x0,0x0, | |
7824 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x0,0x1800000,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x7c00000,0x0,0x3001fc,0x300000, | |
7825 | 0x0,0x0,0x0,0x3e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7826 | 0x3e00,0x38003e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7827 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfff8,0x0,0x0,0x0,0x7e0,0x0,0x1f000000, | |
7828 | 0x0,0x0,0x3800001c,0x0,0x0,0x0,0x3c00,0x0,0x1800000,0x0,0x0,0x7800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7829 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x7800000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7830 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00,0x38003c00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7831 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7832 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfff8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0x0,0x0, | |
7833 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7834 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7835 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7836 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7837 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7838 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7839 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7840 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7841 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7842 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7843 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0 }; | |
7844 | const unsigned int font19x38[19*38*256/32] = { | |
7845 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7846 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7847 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c380000,0x0,0x1c380,0x0,0x0,0x0,0x0,0x0, | |
7848 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800007,0x3c003,0x86000000, | |
7849 | 0x1e00000,0x3,0x80000700,0x3c00000,0x380000,0x70003c00,0x0,0xe1800e,0x1c00,0xf000e18,0x0,0x0,0x700000e0,0x780000,0x7000,0x0, | |
7850 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7851 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7852 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7853 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe700000,0x0,0xe700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7854 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c0000e,0x7e003,0xe60071c0,0x7f80000,0x1,0xc0000e00,0x7e0038e,0x1c0000, | |
7855 | 0xe0007e00,0x38e00000,0xf98007,0x3800,0x1f800f98,0x1c70000,0x0,0x380001c0,0xfc0071,0xc000e000,0x0,0x0,0x0,0x0,0x3e00000,0x0, | |
7856 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7857 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7858 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7859 | 0x0,0x0,0x0,0x7e00000,0x0,0x7e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7860 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe0001c,0xe7006,0x7c0071c0,0xe180000,0x0,0xe0001c00,0xe70038e,0xe0001,0xc000e700,0x38e00000, | |
7861 | 0x19f0003,0x80007000,0x39c019f0,0x1c70000,0x0,0x1c000380,0x1ce0071,0xc001c000,0x0,0x0,0x0,0x0,0x7f00000,0x0,0x0,0x0,0x0,0x0, | |
7862 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7863 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7864 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000, | |
7865 | 0x0,0x3c00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7866 | 0x0,0x0,0x700038,0x1c3806,0x3c0071c0,0xc0c0000,0x0,0x70003800,0x1c38038e,0x70003,0x8001c380,0x38e00000,0x18f0001,0xc000e000, | |
7867 | 0x70e018f0,0x1c70000,0x0,0xe000700,0x3870071,0xc0038000,0x0,0x0,0x0,0x0,0xe380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7868 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7869 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7870 | 0xe000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60000000,0x0,0x0, | |
7871 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c38,0x0,0x1,0xc3800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00000,0x0,0x0,0x0, | |
7872 | 0x0,0x0,0x0,0x0,0x0,0x0,0xc0c0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe000003,0x80018000,0x0,0xc180000, | |
7873 | 0xe,0x380,0x1800000,0xe00000,0x38001800,0x0,0x38,0xe00,0x6000000,0x0,0x1,0xc0000070,0x300000,0x3800,0x0,0x0,0x0,0x0,0x0,0x0, | |
7874 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7875 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7000000,0x0,0x0,0x0,0x0,0x0,0x0, | |
7876 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78c00,0xc30, | |
7877 | 0x0,0x0,0xc3000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800000,0x0,0x0,0x0,0xe0,0x1c000f,0xc0000000,0x0,0x0, | |
7878 | 0x0,0xc0c0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7000007,0x3c003,0xc6000000,0xc180000,0x7,0x700, | |
7879 | 0x3c00000,0x700000,0x70003c00,0x0,0xf1801c,0x1c00,0xf000f18,0x0,0x0,0xe00000e0,0x780000,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7880 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x1c007000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7881 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe0000,0xfe000,0x0,0x3800000,0x700000,0x38, | |
7882 | 0x7,0xe000001c,0x1c00,0x1c00700,0x7fc0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf800e,0x3e0000,0x0,0x0,0x0,0x1e00000,0x0,0x1, | |
7883 | 0xf8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7cc00,0x660,0x0,0x0,0x66000000,0x0,0x0,0x0,0x0,0x7,0x1c000000,0x0,0x0,0x0,0x3fe00000, | |
7884 | 0x0,0x0,0x7000000,0x0,0x0,0x0,0x3e0,0x7c001f,0xe0000000,0x0,0x0,0x0,0xe1c0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7885 | 0x0,0x0,0x0,0x1f80,0x380000e,0x7e007,0xe60071c0,0xc180000,0x3,0x80000e00,0x7e0038e,0x380000,0xe0007e00,0x38e00f00,0x1f9800e, | |
7886 | 0x3800,0x1f801f98,0x1c70000,0x0,0x700001c0,0xfc0071,0xc000e007,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7887 | 0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0x61c00600,0x1e00007e,0x70000,0x18003000,0x1800000,0x0,0x0,0x1c01f0,0x7e003f,0xc003f800, | |
7888 | 0x1e03ffc,0x7f01ff,0xfc03f000,0x7e000000,0x0,0x0,0xfc0,0x1e,0x7fe000,0x7e03fe00,0x3fff07ff,0xe007e038,0x383ffe0,0xff81c01, | |
7889 | 0xe1c000f8,0xf8f00e0,0xfc01ffc,0x3f00ff,0xc000fe07,0xfffc7007,0x1c007700,0x73c01ef,0x78ffff,0xfe0380,0xfe000,0x38000000,0x1800000, | |
7890 | 0x700000,0x38,0x1f,0xe000001c,0x1c00,0x1c00700,0x7fc0000,0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x3f800e,0x3f8000,0x0,0xfc0000, | |
7891 | 0x0,0x7f00000,0x0,0x1,0x98000000,0x7f00000,0x3ffe00,0xffff0,0x0,0x0,0x0,0x0,0x0,0xcf81f,0xee3807e0,0x0,0x0,0x7e03c01e,0x1c, | |
7892 | 0x0,0x1f800000,0xf0078038,0xfc007,0x1c000000,0xfe00000,0x0,0x0,0x3fe000f0,0xf,0xc001f800,0x6000000,0xffc000,0x0,0x1c0007e0, | |
7893 | 0x360,0x6c0010,0x70000700,0xf0001e,0x3c000,0x78000f00,0x7f800ff,0xf007e01f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83fc0, | |
7894 | 0x7807007,0xe000fc00,0x1f8003f0,0x7e0000,0x1f867,0x70e00e,0x1c01c380,0x38f00787,0x3fe0,0x180000c,0x66006,0x7c0071c0,0xe380000, | |
7895 | 0x1,0x80000c00,0x660038e,0x180000,0xc0006600,0x38e0078e,0x19f0006,0x3000,0x198019f0,0x1c70000,0x0,0x30000180,0xcc0071,0xc000c007, | |
7896 | 0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0x61800600,0x7f8001ff,0x70000, | |
7897 | 0x38003800,0x1800000,0x0,0x0,0x3807fc,0x1fe00ff,0xf00ffe00,0x3e03ffc,0xff81ff,0xfc07fc01,0xff800000,0x0,0x0,0x3fe0,0xfe001e, | |
7898 | 0x7ff801,0xff83ff80,0x3fff07ff,0xe01ff838,0x383ffe0,0xff81c03,0xc1c000f8,0xf8f80e0,0x3ff01fff,0xffc0ff,0xf003ff87,0xfffc7007, | |
7899 | 0x1e00f700,0x71c03c7,0x70ffff,0xfe01c0,0xfe000,0x7c000000,0xc00000,0x700000,0x38,0x3f,0xe000001c,0x1c00,0x1c00700,0x7fc0000, | |
7900 | 0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x3f800e,0x3f8000,0x0,0x3fe0000,0x0,0xff00000,0x0,0x3,0xc000000,0x1ffc0000,0xfffe00, | |
7901 | 0xffff0,0x0,0x0,0x0,0x0,0x0,0xc781f,0xee3803c0,0x0,0x0,0x3c01c01c,0x1c,0xc000,0x7fc00000,0x70070038,0x3fe007,0x1c000000,0x1ff80000, | |
7902 | 0x0,0x0,0x3fe003fc,0x1f,0xe003fc00,0xc000000,0x3ffc000,0x0,0x7c000ff0,0x60,0xc0000,0x30000700,0xf0001e,0x3c000,0x78000f00, | |
7903 | 0x3f000ff,0xf01ff81f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ff8,0x7c0701f,0xf803ff00,0x7fe00ffc,0x1ff8000,0x7fe67, | |
7904 | 0x70e00e,0x1c01c380,0x38700707,0x7ff0,0xc00018,0xc3006,0x3c0071c0,0x7f00000,0x0,0xc0001800,0xc30038e,0xc0001,0x8000c300,0x38e003fc, | |
7905 | 0x18f0003,0x6000,0x30c018f0,0x1c70000,0x0,0x18000300,0x1860071,0xc0018007,0x38e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7906 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0xe1801fc0,0x618001ff,0x70000,0x30001800,0x21840000,0x0,0x0,0x380ffe,0x1fe00ff, | |
7907 | 0xfc0fff00,0x3e03ffc,0x1ff81ff,0xfc0ffe03,0xffc00000,0x0,0x0,0x7ff0,0x3ff803f,0x7ffc03,0xffc3ffc0,0x3fff07ff,0xe03ffc38,0x383ffe0, | |
7908 | 0xff81c07,0x81c000f8,0xf8f80e0,0x7ff81fff,0x81ffe0ff,0xf80fff87,0xfffc7007,0xe00e700,0x70e0387,0x80f0ffff,0xe001c0,0xe000, | |
7909 | 0xfe000000,0xe00000,0x700000,0x38,0x3c,0x1c,0x1c00,0x1c00700,0x1c0000,0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x78000e,0x3c000, | |
7910 | 0x0,0x7ff0000,0x0,0xf100000,0x0,0x7,0xe000000,0x7ffc0000,0x1fffe00,0xffff0,0x0,0x0,0x0,0x0,0x0,0x3,0xf780180,0x0,0x0,0x1801e03c, | |
7911 | 0x1c,0xc000,0xffc00000,0x780f0038,0x786000,0x7f00,0x18380000,0x0,0xfe00,0x30c,0x10,0x70020e00,0x1c000000,0x7f8c000,0x0,0x6c001c38, | |
7912 | 0x60,0xc0000,0x70000700,0x1f8003f,0x7e000,0xfc001f80,0x3f000ff,0xf03ffc1f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ffc, | |
7913 | 0x7c0703f,0xfc07ff80,0xfff01ffe,0x3ffc000,0xffec7,0x70e00e,0x1c01c380,0x38780f07,0xf070,0xe00038,0x1c3800,0x0,0x3e00000,0x0, | |
7914 | 0xe0003800,0x1c380000,0xe0003,0x8001c380,0x3e0,0x3,0x8000e000,0x70e00000,0x0,0x0,0x1c000700,0x3870000,0x38007,0x0,0x0,0x0, | |
7915 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0xe3807ff0,0xc0c003c1,0x70000,0x70001c00, | |
7916 | 0x718e0000,0x0,0x0,0x700f1e,0x1ce00c0,0x3c0c0f80,0x7e03800,0x3e08000,0x381e0f03,0xc1e00000,0x0,0x0,0x7078,0x783c03f,0x701e07, | |
7917 | 0xc1c383e0,0x38000700,0x7c1c38,0x3801c00,0x381c0f,0x1c000fc,0x1f8f80e0,0x78781c07,0x81e1e0e0,0x780f0180,0xe007007,0xe00e380, | |
7918 | 0xe0f0783,0x80e0000e,0xe000e0,0xe001,0xef000000,0x0,0x700000,0x38,0x38,0x1c,0x0,0x700,0x1c0000,0x0,0x0,0x0,0x0,0x1c000000, | |
7919 | 0x0,0x0,0x0,0x70000e,0x1c000,0x0,0xf830000,0x0,0x1e000000,0x0,0x0,0x10000,0x780c0000,0x3e38000,0xe0,0x0,0x0,0x0,0x0,0x0,0x3, | |
7920 | 0xd580000,0x0,0x0,0xe038,0x1c,0xc000,0xf0400000,0x380e0038,0x702000,0x1ffc0,0xc0000,0x0,0x3ff80,0x606,0x0,0x30000600,0x0, | |
7921 | 0x7f8c000,0x0,0xc001818,0x60,0xc0003,0xe0000700,0x1f8003f,0x7e000,0xfc001f80,0x73801ee,0x7c1c1c,0x38000,0x70000e00,0xe0001, | |
7922 | 0xc0003800,0x700383e,0x7c0703c,0x3c078780,0xf0f01e1e,0x3c3c000,0xf0f87,0x70e00e,0x1c01c380,0x38380e07,0xe038,0x0,0x0,0x0, | |
7923 | 0x0,0x0,0x0,0x0,0x0,0x0,0xff0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7924 | 0x0,0x0,0x0,0x0,0x0,0x1c,0x1c7000,0xc380fff0,0xc0c00380,0x70000,0x70001c00,0x3dbc0070,0x0,0x0,0x701e0f,0xe0000,0x1e000380, | |
7925 | 0x6e03800,0x7800000,0x781c0707,0x80e00000,0x0,0x0,0x4038,0xe00c03f,0x700e07,0x4380f0,0x38000700,0x700438,0x3801c00,0x381c0e, | |
7926 | 0x1c000ec,0x1b8fc0e0,0xf03c1c03,0xc3c0f0e0,0x3c1e0000,0xe007007,0xe00e380,0xe070703,0xc1e0001e,0xe000e0,0xe001,0xc7000000, | |
7927 | 0x0,0x700000,0x38,0x38,0x1c,0x0,0x700,0x1c0000,0x0,0x0,0x0,0x0,0x1c000000,0x0,0x0,0x0,0x70000e,0x1c000,0x0,0xe010000,0x0, | |
7928 | 0x1c000000,0x10,0x20000,0x6c000,0xf0000000,0x3838000,0x1e0,0x0,0xf000f,0xf1e00,0x78f00000,0x0,0x3,0xdd80000,0x0,0x0,0xf078, | |
7929 | 0x0,0xc001,0xe0000000,0x1c1c0038,0x700000,0x3c1e0,0xc0000,0x0,0x783c0,0x606,0x0,0x30000e00,0x0,0xff8c000,0x0,0xc00300c,0x60, | |
7930 | 0xc0003,0xe0000000,0x1f8003f,0x7e000,0xfc001f80,0x73801ce,0x70041c,0x38000,0x70000e00,0xe0001,0xc0003800,0x700380f,0x7e07078, | |
7931 | 0x1e0f03c1,0xe0783c0f,0x781e000,0x1c0787,0x70e00e,0x1c01c380,0x383c1e07,0xff00e038,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x878, | |
7932 | 0x0,0x0,0x0,0x7,0x80000080,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c, | |
7933 | 0x1c7000,0xc301e630,0xc0c00380,0x70000,0xe0000e00,0xff00070,0x0,0x0,0xe01c07,0xe0000,0xe000380,0xce03800,0x7000000,0x701c0707, | |
7934 | 0x600000,0x0,0x4000010,0x38,0x1c00e07f,0x80700e0e,0x38070,0x38000700,0xe00038,0x3801c00,0x381c1c,0x1c000ec,0x1b8ec0e0,0xe01c1c01, | |
7935 | 0xc38070e0,0x1c1c0000,0xe007007,0x701c380,0xe078e01,0xc1c0003c,0xe00070,0xe003,0x83800000,0x7f,0x71f000,0x3e003e38,0x3f007ff, | |
7936 | 0xe01f1c1c,0x7801fc00,0x3fc00701,0xe01c0077,0x8f071e00,0xf801c7c,0x7c700e,0x3e01fc03,0xfff8380e,0xe007700,0x73c0787,0x387ffc, | |
7937 | 0x70000e,0x1c000,0x0,0xe000000,0x0,0x1c000000,0x10,0x20000,0xc2000,0xe0000000,0x3838000,0x3c0,0x0,0xf000f,0x78e00,0x70e00000, | |
7938 | 0x0,0x3,0xc980fe0,0x1f0,0xf8000007,0xffc07070,0x0,0x3f801,0xc0000000,0x1e3c0038,0x700000,0x70070,0x7fc0000,0x0,0xe00e0,0x606, | |
7939 | 0x1c0000,0x70007c00,0x380e,0xff8c000,0x0,0xc00300c,0x60,0xc0000,0x70000000,0x3fc007f,0x800ff001,0xfe003fc0,0x73801ce,0xe0001c, | |
7940 | 0x38000,0x70000e00,0xe0001,0xc0003800,0x7003807,0x7607070,0xe0e01c1,0xc0383807,0x700e000,0x1c0387,0x70e00e,0x1c01c380,0x381c1c07, | |
7941 | 0xffc0e0f8,0x3f8007f,0xfe001,0xfc003f80,0x7f007e3,0xe003e001,0xf8003f00,0x7e000fc,0xfe001f,0xc003f800,0x7f00003c,0x38f0007, | |
7942 | 0xc000f800,0x1f0003e0,0x7c0007,0x8003f0c3,0x80e0701c,0xe0381c0,0x70700387,0x1f01c00e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7943 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c701f,0xfff1c600,0xc0c00380,0x70000,0xe0000e00,0x3c00070,0x0,0x0,0xe03c07, | |
7944 | 0x800e0000,0xe000380,0x1ce03800,0x7000000,0x701c0707,0x7003c0,0x780000,0x3c00001e,0x38,0x18006073,0x80700e0e,0x38070,0x38000700, | |
7945 | 0xe00038,0x3801c00,0x381c38,0x1c000ee,0x3b8ee0e1,0xe01e1c01,0xc78078e0,0x1c1c0000,0xe007007,0x701c387,0xe03de00,0xe3800038, | |
7946 | 0xe00070,0xe007,0x1c00000,0x1ff,0xc077f801,0xff807fb8,0xff807ff,0xe03fdc1d,0xfc01fc00,0x3fc00703,0xc01c007f,0xdf877f00,0x3fe01dfe, | |
7947 | 0xff700e,0xff07ff03,0xfff8380e,0x700f700,0x71e0f03,0x80707ffc,0x70000e,0x1c000,0x0,0x1c000008,0x0,0x1c000000,0x10,0x20000, | |
7948 | 0x82000,0xe0000000,0x7038000,0x80000380,0x2000040,0x7000e,0x38700,0xf1e00000,0x0,0x3,0xc183ff8,0x3fd,0xfc008007,0xffc038e0, | |
7949 | 0x0,0xffc01,0xc0008008,0xe380038,0x380000,0xe3e38,0x1ffc0040,0x80000000,0x1cfc70,0x606,0x1c0000,0xe0007c00,0x380e,0xff8c000, | |
7950 | 0x0,0xc00300c,0x8100060,0xc0000,0x30000700,0x39c0073,0x800e7001,0xce0039c0,0x73801ce,0xe0001c,0x38000,0x70000e00,0xe0001, | |
7951 | 0xc0003800,0x7003807,0x77070f0,0xf1e01e3,0xc03c7807,0x8f00f080,0x83c0787,0x70e00e,0x1c01c380,0x380e3807,0xffe0e1c0,0xffe01ff, | |
7952 | 0xc03ff807,0xff00ffe0,0x1ffc0ff7,0xf01ff807,0xfc00ff80,0x1ff003fe,0xfe001f,0xc003f800,0x7f0003fc,0x3bf801f,0xf003fe00,0x7fc00ff8, | |
7953 | 0x1ff0007,0x8007fd83,0x80e0701c,0xe0381c0,0x70380707,0x7f80e01c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7954 | 0x0,0x0,0x0,0x0,0x1c,0x1c701f,0xfff1c600,0x618081c0,0x70000,0xe0000e00,0x3c00070,0x0,0x0,0xe03803,0x800e0000,0xe000380,0x18e03800, | |
7955 | 0xf000000,0xf01c0707,0x7003c0,0x780000,0xfc00001f,0x80000078,0x301e6073,0x80700e1c,0x38038,0x38000700,0x1c00038,0x3801c00, | |
7956 | 0x381c70,0x1c000e6,0x338ee0e1,0xc00e1c01,0xc70038e0,0x1c1c0000,0xe007007,0x701c387,0xe01dc00,0xf7800078,0xe00070,0xe00e,0xe00000, | |
7957 | 0x3ff,0xe07ffc03,0xffc0fff8,0x1ffc07ff,0xe07ffc1d,0xfe01fc00,0x3fc00707,0x801c007f,0xdf877f80,0x7ff01fff,0x1fff00e,0xff07ff03, | |
7958 | 0xfff8380e,0x700e380,0xe0e0e03,0x80707ffc,0x70000e,0x1c000,0x0,0x7ffc001c,0x0,0x1c000000,0x10,0x20000,0x82000,0xe0000000, | |
7959 | 0x7038001,0xc0000780,0x70000e0,0x3800e,0x38700,0xe1c00000,0x0,0x3,0xc183ff8,0x7ff,0xfc01c007,0xffc03de0,0x0,0x1ffc01,0xc001c01c, | |
7960 | 0xf780038,0x3c0000,0xcff18,0x380c00c1,0x80000000,0x18fe30,0x30c,0x1c0001,0xc0000e00,0x380e,0xff8c000,0x0,0xc00300c,0xc180060, | |
7961 | 0xc0000,0x30000700,0x39c0073,0x800e7001,0xce0039c0,0xe1c038e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x877070e0, | |
7962 | 0x71c00e3,0x801c7003,0x8e0071c0,0x1c380fc7,0x70e00e,0x1c01c380,0x380f7807,0x1e0e380,0x1fff03ff,0xe07ffc0f,0xff81fff0,0x3ffe0fff, | |
7963 | 0xf03ffc0f,0xfe01ffc0,0x3ff807ff,0xfe001f,0xc003f800,0x7f0007fe,0x3bfc03f,0xf807ff00,0xffe01ffc,0x3ff8007,0x800fff83,0x80e0701c, | |
7964 | 0xe0381c0,0x70380707,0xffc0e01c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1c701f, | |
7965 | 0xfff1c600,0x7f8381e0,0x70000,0xc0000600,0xff00070,0x0,0x0,0x1c03803,0x800e0000,0xe000f00,0x38e03fe0,0xe000000,0xe00e0e07, | |
7966 | 0x7003c0,0x780007,0xf0ffff87,0xf00000f0,0x307fe0f3,0xc0703c1c,0x38038,0x38000700,0x1c00038,0x3801c00,0x381ce0,0x1c000e6,0x338e70e1, | |
7967 | 0xc00e1c01,0xc70038e0,0x3c1e0000,0xe007007,0x783c38f,0x8e01fc00,0x770000f0,0xe00038,0xe01c,0x700000,0x381,0xe07c1e07,0xc0c1e0f8, | |
7968 | 0x3c1e0038,0xf07c1f,0xe001c00,0x1c0070f,0x1c0079,0xf3c7c380,0xf0781f07,0x83c1f00f,0xc10f0300,0x1c00380e,0x700e380,0xe0f1e03, | |
7969 | 0xc0f00078,0x70000e,0x1c000,0x0,0xfff8003e,0x0,0x3c000000,0x10,0x20000,0xc6000,0xf0000000,0x7038003,0xe0000f00,0xf8001f0, | |
7970 | 0x3801c,0x18300,0xe1800000,0x0,0x3,0xc187818,0x70f,0x9e03e000,0x7801dc0,0x1c,0x3cc401,0xc000efb8,0x7f7f0038,0x3f0000,0x1ce11c, | |
7971 | 0x300c01c3,0x80000000,0x38c638,0x3fc,0x1c0003,0x80000600,0x380e,0xff8c000,0x0,0xc00300c,0xe1c0060,0xc0010,0x70000700,0x79e00f3, | |
7972 | 0xc01e7803,0xcf0079e0,0xe1c038e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x873870e0,0x71c00e3,0x801c7003, | |
7973 | 0x8e0070e0,0x38381dc7,0x70e00e,0x1c01c380,0x38077007,0xf0e700,0x1c0f0381,0xe0703c0e,0x781c0f0,0x381e083e,0x787c0c1e,0xf03c1e0, | |
7974 | 0x783c0f07,0x800e0001,0xc0003800,0x7000fff,0x3e1c078,0x3c0f0781,0xe0f03c1e,0x783c000,0x1e0f03,0x80e0701c,0xe0381c0,0x70380f07, | |
7975 | 0xc1e0e03c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x1,0x8701c600,0x1e0f01e0,0x1, | |
7976 | 0xc0000700,0x3dbc0070,0x0,0x0,0x1c03803,0x800e0000,0x1e01fe00,0x70e03ff8,0xe3e0001,0xe007fc07,0x80f003c0,0x78001f,0xc0ffff81, | |
7977 | 0xfc0001e0,0x30e1e0e1,0xc07ff81c,0x38038,0x3ffe07ff,0xc1c0003f,0xff801c00,0x381de0,0x1c000e7,0x738e70e1,0xc00e1c03,0xc70038e0, | |
7978 | 0x780f8000,0xe007007,0x383838d,0x8e00f800,0x7f0000e0,0xe00038,0xe000,0x0,0x200,0xf0780e07,0x8041c078,0x380e0038,0xe03c1e, | |
7979 | 0xf001c00,0x1c0071e,0x1c0070,0xe1c783c0,0xe0381e03,0x8380f00f,0xe0000,0x1c00380e,0x381c380,0xe07bc01,0xc0e00078,0x70000e, | |
7980 | 0x1c000,0x0,0x1c000061,0x0,0x38000000,0x10,0x20000,0x7c000,0x7c000000,0x703fc06,0x10000e00,0x18400308,0x1801c,0x1c381,0xc3800000, | |
7981 | 0x0,0x0,0x7000,0xe0f,0xe061000,0x7801fc0,0x1c,0x38c001,0xc0007ff0,0x7fff0038,0x77c000,0x19c00c,0x301c0387,0x0,0x30c618,0xf0, | |
7982 | 0x1c0007,0x600,0x380e,0x7f8c007,0x80000000,0xc001818,0x70e03fc,0x387f871f,0xe0e00700,0x70e00e1,0xc01c3803,0x870070e0,0xe1c038f, | |
7983 | 0xe1c0001f,0xff03ffe0,0x7ffc0fff,0x800e0001,0xc0003800,0x7003803,0x873870e0,0x71c00e3,0x801c7003,0x8e007070,0x703839c7,0x70e00e, | |
7984 | 0x1c01c380,0x3807f007,0x70e700,0x10078200,0xf0401e08,0x3c10078,0x200f001c,0x3878041c,0x70380e0,0x701c0e03,0x800e0001,0xc0003800, | |
7985 | 0x7001e0f,0x3c1e070,0x1c0e0381,0xc070380e,0x701c000,0x1c0f03,0x80e0701c,0xe0381c0,0x701c0e07,0x80e07038,0x0,0x0,0x0,0x0,0x0, | |
7986 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3,0x8600e600,0x7803f0,0x1,0xc0000700,0x718e0070,0x0,0x0,0x38038c3, | |
7987 | 0x800e0000,0x3c01f800,0x60e03ffc,0xeff8001,0xc001f003,0xc1f003c0,0x7800fe,0xffff80,0x3f8003c0,0x60c0e0e1,0xc07fe01c,0x38038, | |
7988 | 0x3ffe07ff,0xc1c07e3f,0xff801c00,0x381fe0,0x1c000e3,0x638e30e1,0xc00e1c07,0x870038ff,0xf00ff800,0xe007007,0x38381cd,0x9c007000, | |
7989 | 0x3e0001e0,0xe0001c,0xe000,0x0,0x0,0x70780f0f,0x3c078,0x70070038,0x1e03c1c,0x7001c00,0x1c0073c,0x1c0070,0xe1c701c1,0xe03c1e03, | |
7990 | 0xc780f00f,0xe0000,0x1c00380e,0x381c387,0xe03f801,0xc0e000f0,0x70000e,0x1c007,0xe0100000,0x1c0000cd,0x80000003,0xffc00000, | |
7991 | 0x3ff,0x807ff000,0xe0,0x7fc00060,0x703fc0c,0xd8001e00,0x3360066c,0x1c018,0xc181,0x83000000,0x0,0x0,0x7000,0x300e07,0xe0cd800, | |
7992 | 0xf000f80,0x1c,0x78c00f,0xff0038e0,0x3e00038,0xe1e000,0x19800c,0x383c070e,0x7fffc00,0x30fc18,0x0,0xffff80e,0x20e00,0x380e, | |
7993 | 0x7f8c007,0x80000000,0xc001c38,0x38703ff,0xf87fff0f,0xcfe00f00,0x70e00e1,0xc01c3803,0x870070e0,0x1e1e078f,0xe1c0001f,0xff03ffe0, | |
7994 | 0x7ffc0fff,0x800e0001,0xc0003800,0x700ff83,0x871870e0,0x71c00e3,0x801c7003,0x8e007038,0xe03871c7,0x70e00e,0x1c01c380,0x3803e007, | |
7995 | 0x70e700,0x38000,0x70000e00,0x1c00038,0x7001c,0x38f00038,0x3870070,0xe00e1c01,0xc00e0001,0xc0003800,0x7001c07,0x380e0f0,0x1e1e03c3, | |
7996 | 0xc078780f,0xf01e000,0x3c0f03,0x80e0701c,0xe0381c0,0x701c0e07,0x80f07038,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
7997 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3,0x8600ff00,0x1e00778,0x38000001,0xc0000700,0x21843fff,0xe0000000,0x0,0x38039e3,0x800e0000, | |
7998 | 0x7c01fe00,0xe0e0203e,0xeffc001,0xc00ffe03,0xff700000,0x7f0,0x0,0x7f00380,0x618060e1,0xc07ffc1c,0x38038,0x3ffe07ff,0xc1c07e3f, | |
7999 | 0xff801c00,0x381ff0,0x1c000e3,0x638e38e1,0xc00e1fff,0x870038ff,0xc003fe00,0xe007007,0x38381cd,0x9c00f800,0x3e0003c0,0xe0001c, | |
8000 | 0xe000,0x0,0x0,0x7070070e,0x38038,0x70070038,0x1c01c1c,0x7001c00,0x1c00778,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0xfc000, | |
8001 | 0x1c00380e,0x381c3c7,0x1e01f001,0xe1e001e0,0xf0000e,0x1e01f,0xf8300000,0x1c00019c,0xc0000003,0xffc00000,0x10,0x20000,0x700, | |
8002 | 0x1ff000c0,0x703fc19,0xcc003c00,0x67300ce6,0xc038,0xc181,0x83000000,0x0,0x0,0x7e00,0x180e07,0xe19cc00,0x1e000f80,0x1c,0x70c00f, | |
8003 | 0xff007070,0x3e00038,0xe0f000,0x19800c,0x1fec0e1c,0x7fffc00,0x30f818,0x0,0xffff81f,0xf003fc00,0x380e,0x3f8c007,0x80000000, | |
8004 | 0x7f800ff0,0x1c3803f,0xe007fc00,0xff800e00,0x70e00e1,0xc01c3803,0x870070e0,0x1c0e070f,0xe1c0001f,0xff03ffe0,0x7ffc0fff,0x800e0001, | |
8005 | 0xc0003800,0x700ff83,0x871c70e0,0x71c00e3,0x801c7003,0x8e00701d,0xc038e1c7,0x70e00e,0x1c01c380,0x3803e007,0x70e3c0,0x38000, | |
8006 | 0x70000e00,0x1c00038,0x7001c,0x38e00038,0x3870070,0xe00e1c01,0xc00e0001,0xc0003800,0x7003c07,0x8380e0e0,0xe1c01c3,0x80387007, | |
8007 | 0xe00e1ff,0xfe381b83,0x80e0701c,0xe0381c0,0x701e1e07,0x707878,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8008 | 0x0,0x0,0x0,0x0,0x1c,0x3,0xe007fe0,0x7800e3c,0x38000001,0xc0000700,0x1803fff,0xe0000000,0x0,0x70039c3,0x800e0000,0xf8000f80, | |
8009 | 0xc0e0000e,0xf83c003,0xc01e0f01,0xff700000,0x7c0,0x0,0x1f00780,0x618061c0,0xe0701e1c,0x38038,0x38000700,0x1c07e38,0x3801c00, | |
8010 | 0x381e78,0x1c000e3,0xe38e18e1,0xc00e1fff,0x70038ff,0xe0007f80,0xe007007,0x1c701dd,0x9c00f800,0x1c000780,0xe0000e,0xe000,0x0, | |
8011 | 0x7f,0xf070070e,0x38038,0x7fff0038,0x1c01c1c,0x7001c00,0x1c007f8,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x7fc00,0x1c00380e, | |
8012 | 0x1c381c7,0x1c01f000,0xe1c001c0,0xfe0000e,0xfe1f,0xfff00000,0x7ff003fc,0xe0000003,0xffc00000,0x10,0x20000,0x3800,0x3fc0180, | |
8013 | 0x703803f,0xce007800,0xff381fe7,0x30,0x0,0xc0,0x0,0x0,0x3fe0,0xc0e07,0xfe3fce00,0x1c000700,0x1c,0x70c00f,0xff006030,0x1c00000, | |
8014 | 0xe07800,0x19800c,0xfcc1c38,0x7fffc00,0x30d818,0x0,0xffff81f,0xf001f800,0x380e,0xf8c007,0x80000000,0x7f8007e0,0xe1c3fe,0x7fc00f, | |
8015 | 0xf8001e00,0xe0701c0,0xe0381c07,0x380e070,0x1c0e070e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x700ff83,0x870c70e0, | |
8016 | 0x71c00e3,0x801c7003,0x8e00700f,0x8038c1c7,0x70e00e,0x1c01c380,0x3801c007,0xf0e3e0,0x3ff807f,0xf00ffe01,0xffc03ff8,0x7ff03ff, | |
8017 | 0xf8e0003f,0xff87fff0,0xfffe1fff,0xc00e0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e1ff,0xfe383383,0x80e0701c, | |
8018 | 0xe0381c0,0x700e1c07,0x703870,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3,0xc000ff0, | |
8019 | 0x3c1e1c1c,0x38000001,0xc0000700,0x1803fff,0xe0000007,0xf8000000,0x7003803,0x800e0001,0xf0000381,0xc0e00007,0xf01e003,0x801c0700, | |
8020 | 0x7c700000,0x7c0,0x0,0x1f00700,0x618061c0,0xe0700e1c,0x38038,0x38000700,0x1c00e38,0x3801c00,0x381e38,0x1c000e1,0xc38e1ce1, | |
8021 | 0xc00e1ffc,0x70038e0,0xf0000780,0xe007007,0x1c701dd,0xdc01fc00,0x1c000780,0xe0000e,0xe000,0x0,0x1ff,0xf070070e,0x38038,0x7fff0038, | |
8022 | 0x1c01c1c,0x7001c00,0x1c007f8,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x3ff00,0x1c00380e,0x1c381cd,0x9c00e000,0xe1c003c0, | |
8023 | 0xf80000e,0x3e18,0x3ff00000,0xffe007fd,0xf0000000,0x38000000,0x10,0x20000,0x1c000,0x3c0300,0x703807f,0xdf007801,0xff7c3fef, | |
8024 | 0x80000000,0x0,0x3e0,0x7ffe7ff,0xff000000,0x1ff8,0x60e07,0xfe7fdf00,0x3c000700,0x1c,0x70c001,0xc0006030,0x7fff0000,0xf03800, | |
8025 | 0x19800c,0x1c38,0x1c07,0xf830cc18,0x0,0x1c0000,0x0,0x380e,0x18c007,0x80000000,0x0,0xe1cfe0,0x1fc003f,0x80003c00,0xe0701c0, | |
8026 | 0xe0381c07,0x380e070,0x1c0e070e,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x870e70e0,0x71c00e3,0x801c7003, | |
8027 | 0x8e007007,0x3981c7,0x70e00e,0x1c01c380,0x3801c007,0x1e0e0f8,0xfff81ff,0xf03ffe07,0xffc0fff8,0x1fff07ff,0xf8e0003f,0xff87fff0, | |
8028 | 0xfffe1fff,0xc00e0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e1ff,0xfe386383,0x80e0701c,0xe0381c0,0x700e1c07, | |
8029 | 0x703870,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x7f,0xffc00678,0x707f9c1e,0x38000001, | |
8030 | 0xc0000700,0x70,0x7,0xf8000000,0xe003803,0x800e0003,0xe00001c3,0x80e00007,0xe00e007,0x80380380,0x700000,0x7f0,0x0,0x7f00700, | |
8031 | 0x618061ff,0xe070071c,0x38038,0x38000700,0x1c00e38,0x3801c00,0x381c3c,0x1c000e1,0xc38e1ce1,0xc00e1c00,0x70038e0,0x700003c0, | |
8032 | 0xe007007,0x1c701d8,0xdc03dc00,0x1c000f00,0xe00007,0xe000,0x0,0x3ff,0xf070070e,0x38038,0x7fff0038,0x1c01c1c,0x7001c00,0x1c007fc, | |
8033 | 0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x3f00,0x1c00380e,0x1c381cd,0x9c01f000,0x73800780,0xfe0000e,0xfe10,0x7c00000,0x1c000ffb, | |
8034 | 0xf8000000,0x38000000,0x10,0x20000,0x20000,0x1e0700,0x70380ff,0xbf80f003,0xfefe7fdf,0xc0000000,0x0,0x3f0,0x7ffe7ff,0xff000000, | |
8035 | 0x1f8,0x30e07,0xfeffbf80,0x78000700,0x1c,0x70c001,0xc0006030,0x7fff0000,0x783800,0x1ce11c,0xe1c,0x1c07,0xf838ce38,0x0,0x1c0000, | |
8036 | 0x0,0x380e,0x18c000,0x0,0x0,0x1c38c00,0x1800030,0x7800,0xfff01ff,0xe03ffc07,0xff80fff0,0x3fff0ffe,0x1c0001c,0x38000,0x70000e00, | |
8037 | 0xe0001,0xc0003800,0x7003803,0x870e70e0,0x71c00e3,0x801c7003,0x8e00700f,0x803b81c7,0x70e00e,0x1c01c380,0x3801c007,0xffe0e03c, | |
8038 | 0x1fff83ff,0xf07ffe0f,0xffc1fff8,0x3fff0fff,0xf8e0003f,0xff87fff0,0xfffe1fff,0xc00e0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3, | |
8039 | 0x80387007,0xe00e000,0x38c383,0x80e0701c,0xe0381c0,0x70073807,0x701ce0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8040 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xffc0063c,0x40619c0f,0x30000001,0xc0000700,0x70,0x7,0xf8000000,0xe003803,0x800e0007,0xc00001c3, | |
8041 | 0xfffc0007,0xe00e007,0x380380,0xf00000,0xfe,0xffff80,0x3f800700,0x618063ff,0xf070071c,0x38038,0x38000700,0x1c00e38,0x3801c00, | |
8042 | 0x381c1e,0x1c000e0,0x38e0ee1,0xc00e1c00,0x70038e0,0x380001c0,0xe007007,0x1ef01d8,0xdc038e00,0x1c001e00,0xe00007,0xe000,0x0, | |
8043 | 0x7c0,0x7070070e,0x38038,0x70000038,0x1c01c1c,0x7001c00,0x1c0079e,0x1c0070,0xe1c701c1,0xc01c1c01,0xc700700e,0x780,0x1c00380e, | |
8044 | 0xe701cd,0x9c01f000,0x73800f00,0xe0000e,0xe000,0x0,0x1c0007f7,0xf0000000,0x70000000,0x10,0x20000,0x0,0xe0e00,0x703807f,0x7f01e001, | |
8045 | 0xfdfc3fbf,0x80000000,0x0,0x7f0,0x0,0x0,0x3c,0x18e07,0x7f7f00,0xf0000700,0x1c,0x70c001,0xc0007070,0x1c00000,0x3e7000,0xcff18, | |
8046 | 0x3ffc070e,0x1c07,0xf818c630,0x0,0x1c0000,0x0,0x380e,0x18c000,0x0,0x3ffc,0x3870000,0xe000fc00,0x380f000,0x1fff83ff,0xf07ffe0f, | |
8047 | 0xffc1fff8,0x3fff0ffe,0x1c0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003803,0x870770e0,0x71c00e3,0x801c7003,0x8e00701d, | |
8048 | 0xc03f01c7,0x70e00e,0x1c01c380,0x3801c007,0xffc0e01c,0x3e0387c0,0x70f80e1f,0x1c3e038,0x7c071e1c,0xe00038,0x70000,0xe0001c00, | |
8049 | 0xe0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e000,0x398383,0x80e0701c,0xe0381c0,0x70073807,0x701ce0, | |
8050 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xffc0061c,0xc0dc07,0xf0000001,0xc0000700, | |
8051 | 0x70,0x0,0x0,0x1c003c07,0x800e000f,0x1c3,0xfffc0007,0xe00e007,0x380380,0xe00000,0x1f,0xc0ffff81,0xfc000700,0x618063ff,0xf070070e, | |
8052 | 0x38070,0x38000700,0xe00e38,0x3801c00,0x381c0e,0x1c000e0,0x38e0ee1,0xe01e1c00,0x78078e0,0x380001c0,0xe007007,0xee01f8,0xfc078f00, | |
8053 | 0x1c001c00,0xe00003,0x8000e000,0x0,0x700,0x7070070e,0x38038,0x70000038,0x1c01c1c,0x7001c00,0x1c0070e,0x1c0070,0xe1c701c1, | |
8054 | 0xc01c1c01,0xc700700e,0x380,0x1c00380e,0xe700ed,0xb803f800,0x77800f00,0x70000e,0x1c000,0x0,0xe0003f7,0xe0000000,0x70000000, | |
8055 | 0x10,0x20000,0x1c0e0,0xe1c00,0x703803f,0x7e01c000,0xfdf81fbf,0x0,0x0,0x3f0,0x0,0x0,0x1c,0x1ce07,0x3f7e00,0xf0000700,0x1c, | |
8056 | 0x70c001,0xc00038e0,0x1c00038,0xf7000,0xe3e38,0x3ffc0387,0x1c00,0x1cc770,0x0,0x1c0000,0x0,0x380e,0x18c000,0x0,0x3ffc,0x70e0001, | |
8057 | 0xe001fe00,0x780e000,0x1fff83ff,0xf07ffe0f,0xffc1fff8,0x3fff0ffe,0xe0001c,0x38000,0x70000e00,0xe0001,0xc0003800,0x7003807, | |
8058 | 0x70770f0,0xf1e01e3,0xc03c7807,0x8f00f038,0xe03e03c7,0x70e00e,0x1c01c380,0x3801c007,0xff00e00e,0x38038700,0x70e00e1c,0x1c38038, | |
8059 | 0x70071c1c,0xe00038,0x70000,0xe0001c00,0xe0001,0xc0003800,0x7003803,0x8380e0e0,0xe1c01c3,0x80387007,0xe00e000,0x3b0383,0x80e0701c, | |
8060 | 0xe0381c0,0x70077807,0x701de0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x1c00061c, | |
8061 | 0xc0de03,0xe0000001,0xc0000700,0x70,0x0,0x0,0x1c001c07,0xe001e,0x1c3,0xfffc0007,0x600e00e,0x380380,0xe00000,0x7,0xf0ffff87, | |
8062 | 0xf0000000,0x60c0e380,0x7070070e,0x38070,0x38000700,0xe00e38,0x3801c00,0x381c0f,0x1c000e0,0x38e06e0,0xe01c1c00,0x38070e0, | |
8063 | 0x1c0001c0,0xe007007,0xee00f8,0xf80f0700,0x1c003c00,0xe00003,0x8000e000,0x0,0x700,0x70780f0f,0x3c078,0x70000038,0x1e03c1c, | |
8064 | 0x7001c00,0x1c0070f,0x1c0070,0xe1c701c1,0xe03c1e03,0xc780f00e,0x380,0x1c00380e,0xe700f8,0xf807bc00,0x3f001e00,0x70000e,0x1c000, | |
8065 | 0x0,0xe0001ff,0xc0000000,0x70000000,0x10,0x20000,0x33110,0xe0e00,0x383801f,0xfc03c000,0x7ff00ffe,0x0,0x0,0x3e0,0x0,0x0,0x1c, | |
8066 | 0x38e07,0x1ffc01,0xe0000700,0x1c,0x78c001,0xc0007ff0,0x1c00038,0x7c000,0x70070,0x1c3,0x80001c00,0xe00e0,0x0,0x1c0000,0x0, | |
8067 | 0x380e,0x18c000,0x0,0x0,0xe1c0001,0xe0010700,0x780e000,0x1c038380,0x70700e0e,0x1c1c038,0x78070e0e,0xe0001c,0x38000,0x70000e00, | |
8068 | 0xe0001,0xc0003800,0x7003807,0x7037070,0xe0e01c1,0xc0383807,0x700e070,0x701c0387,0x70e00e,0x1c01c380,0x3801c007,0xe00e,0x38038700, | |
8069 | 0x70e00e1c,0x1c38038,0x70071c1c,0xf00038,0x70000,0xe0001c00,0xe0001,0xc0003800,0x7003c07,0x8380e0f0,0x1e1e03c3,0xc078780f, | |
8070 | 0xf01e007,0x803e0783,0x80e0701c,0xe0381c0,0x7003f007,0x80f00fc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8071 | 0x0,0x0,0x0,0x0,0x0,0x6,0x1800061c,0xc0de01,0xc0000000,0xc0000e00,0x70,0xf0000,0x3c00,0x38001c0f,0xe003c,0x3c0,0xe0000e,0x701e00e, | |
8072 | 0x3c0780,0x1e003c0,0x780000,0xfc00001f,0x80000000,0x60e1e780,0x78700f07,0x4380f0,0x38000700,0xf00e38,0x3801c00,0xc0781c07, | |
8073 | 0x81c000e0,0x38e07e0,0xe03c1c00,0x380f0e0,0x1e0003c0,0xe00780f,0xee00f0,0x780e0780,0x1c007800,0xe00001,0xc000e000,0x0,0x700, | |
8074 | 0xf0780e07,0x8041c078,0x38020038,0xe03c1c,0x7001c00,0x1c00707,0x801c0070,0xe1c701c0,0xe0381e03,0x8380f00e,0x80380,0x1c003c1e, | |
8075 | 0x7e00f8,0xf80f1e00,0x3f003c00,0x70000e,0x1c000,0x0,0xf0100f7,0x80078000,0x700078f0,0x10,0x7ff000,0x61208,0x1e0700,0x383800f, | |
8076 | 0x78078000,0x3de007bc,0x0,0x0,0x0,0x0,0x0,0x401c,0x70e0f,0xf7803,0xc0000700,0x1c,0x38c001,0xc000efb8,0x1c00038,0x1e000,0x3c1e0, | |
8077 | 0xc1,0x80000000,0x783c0,0x0,0x0,0x0,0x3c1e,0x18c000,0x0,0x0,0xc180003,0x60000300,0xd80e010,0x3c03c780,0x78f00f1e,0x1e3c03c, | |
8078 | 0x70039c0e,0x70041c,0x38000,0x70000e00,0xe0001,0xc0003800,0x700380f,0x703f070,0x1e0e03c1,0xc078380f,0x701e0e0,0x381c0787, | |
8079 | 0x80f0f01e,0x1e03c3c0,0x7801c007,0xe00e,0x38078700,0xf0e01e1c,0x3c38078,0x700f1c1c,0x78041c,0x1038020,0x70040e00,0x800e0001, | |
8080 | 0xc0003800,0x7001c07,0x380e070,0x1c0e0381,0xc070380e,0x701c007,0x801e0703,0xc1e0783c,0xf0781e0,0xf003f007,0x80e00fc0,0x0, | |
8081 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xe,0x1801867c,0xc0cf83,0xe0000000,0xe0000e00, | |
8082 | 0x70,0xf0000,0x3c00,0x38000f1e,0xe0070,0x180780,0xe0603e,0x783c01e,0x1e0f01,0x7c003c0,0x780000,0x3c00001e,0x700,0x307fe700, | |
8083 | 0x38701e07,0xc1c383e0,0x38000700,0x7c1e38,0x3801c00,0xe0f01c03,0x81c000e0,0x38e03e0,0x78781c00,0x1e1e0e0,0xe180780,0xe003c1e, | |
8084 | 0x7c00f0,0x781e03c0,0x1c007000,0xe00001,0xc000e000,0x0,0x783,0xf07c1e07,0xc0c1e0f8,0x3e0e0038,0xf07c1c,0x7001c00,0x1c00703, | |
8085 | 0xc01e0070,0xe1c701c0,0xf0781f07,0x83c1f00e,0xe0f80,0x1e003c3e,0x7e00f8,0xf80e0e00,0x3f003800,0x70000e,0x1c000,0x0,0x7830077, | |
8086 | 0xf0000,0x700078f0,0x10,0x20000,0x41208,0xc03c0380,0x3c38007,0x70070000,0x1dc003b8,0x0,0x0,0x0,0x0,0x0,0x707c,0x6070f,0x86077003, | |
8087 | 0x80000700,0x1c,0x3ec401,0xc001c01c,0x1c00038,0xf000,0x1ffc0,0x40,0x80000000,0x3ff80,0x0,0x0,0x0,0x3e3e,0x18c000,0x0,0x0, | |
8088 | 0x8100006,0x60000300,0x1980f070,0x3801c700,0x38e0071c,0xe3801c,0x70039c0e,0x7c1c1c,0x38000,0x70000e00,0xe0001,0xc0003800, | |
8089 | 0x700383e,0x701f03c,0x3c078780,0xf0f01e1e,0x3c3c1c0,0x1c3f0f03,0xc1e0783c,0xf0781e0,0xf001c007,0xe81e,0x3c1f8783,0xf0f07e1e, | |
8090 | 0xfc3c1f8,0x783f1e3e,0x187c0c1f,0x703e0e0,0x7c1c0f83,0x800e0001,0xc0003800,0x7001e0f,0x380e078,0x3c0f0781,0xe0f03c1e,0x783c007, | |
8091 | 0x801e0f03,0xc3e0787c,0xf0f81e1,0xf003f007,0xc1e00fc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8092 | 0x0,0x0,0x1c,0xe,0x3801fff8,0x6187ff,0xe0000000,0xe0000e00,0x70,0xf0000,0x3c00,0x38000ffe,0x1fff0ff,0xfe1fff80,0xe07ffc,0x3ffc01c, | |
8093 | 0x1fff01,0xff8003c0,0x780000,0x4000010,0x700,0x301e6700,0x387ffe03,0xffc3ffc0,0x3fff0700,0x3ffe38,0x383ffe0,0xfff01c03,0xc1fff8e0, | |
8094 | 0x38e03e0,0x7ff81c00,0x1ffe0e0,0xf1fff80,0xe003ffe,0x7c00f0,0x781c01c0,0x1c00ffff,0xe00001,0xc000e000,0x0,0x3ff,0x707ffc03, | |
8095 | 0xffc0fff8,0x1ffe0038,0x7ffc1c,0x707fff0,0x1c00701,0xc00ff070,0xe1c701c0,0x7ff01fff,0x1fff00e,0xfff00,0xff81fee,0x7e00f0, | |
8096 | 0x781e0f00,0x1e007ffc,0x70000e,0x1c000,0x0,0x3ff003e,0xf0000,0xe00070e0,0x60830010,0x20000,0x41208,0xfffc01c0,0x1fffe03,0xe00ffff0, | |
8097 | 0xf8001f0,0x0,0x0,0x0,0x0,0x0,0x7ff8,0xc07fd,0xfe03e007,0xffc00700,0x1c,0x1ffc1f,0xffc08008,0x1c00038,0x7000,0x7f00,0x0,0x0, | |
8098 | 0xfe00,0x0,0xffff800,0x0,0x3ff7,0x8018c000,0x0,0x0,0x6,0x60000700,0x19807ff0,0x3801c700,0x38e0071c,0xe3801c,0x70039c0f,0xf03ffc1f, | |
8099 | 0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ffc,0x701f03f,0xfc07ff80,0xfff01ffe,0x3ffc080,0x83fff03,0xffe07ffc,0xfff81ff, | |
8100 | 0xf001c007,0xeffc,0x1ffb83ff,0x707fee0f,0xfdc1ffb8,0x3ff70ff7,0xf83ffc0f,0xff01ffe0,0x3ffc07ff,0x83fff87f,0xff0fffe1,0xfffc0ffe, | |
8101 | 0x380e03f,0xf807ff00,0xffe01ffc,0x3ff8007,0x803ffe01,0xfee03fdc,0x7fb80ff,0x7001e007,0xffc00780,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8102 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xc,0x3801fff0,0x7f83fe,0x70000000,0xe0000e00,0x0,0xf0000,0x3c00,0x700007fc, | |
8103 | 0x1fff0ff,0xfe1ffe00,0xe07ff8,0x1ff801c,0xffe01,0xff0003c0,0x780000,0x0,0x700,0x38000f00,0x3c7ffc01,0xff83ff80,0x3fff0700, | |
8104 | 0x1ffc38,0x383ffe0,0x7fe01c01,0xe1fff8e0,0x38e03e0,0x3ff01c00,0xffc0e0,0x71fff00,0xe001ffc,0x7c00f0,0x783c01e0,0x1c00ffff, | |
8105 | 0xe00000,0xe000e000,0x0,0x1ff,0x7077f801,0xff807fb8,0xffc0038,0x3fdc1c,0x707fff0,0x1c00701,0xe007f070,0xe1c701c0,0x3fe01dfe, | |
8106 | 0xff700e,0x7fe00,0xff80fee,0x3c0070,0x703c0780,0x1e007ffc,0x70000e,0x1c000,0x0,0x1fe001c,0xe0000,0xe000e1c0,0x71c78010,0x20000, | |
8107 | 0x21318,0xfff800c0,0xfffe01,0xc00ffff0,0x70000e0,0x0,0x0,0x0,0x0,0x0,0x3ff0,0x1803fd,0xfe01c007,0xffc00700,0x1c,0xffc1f,0xffc00000, | |
8108 | 0x1c00038,0x7000,0x0,0x0,0x0,0x0,0x0,0xffff800,0x0,0x3ff7,0x8018c000,0x0,0x0,0xc,0x60000e00,0x31803fe0,0x7801ef00,0x3de007bc, | |
8109 | 0xf7801e,0xf003fc0f,0xf01ff81f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83ff8,0x701f01f,0xf803ff00,0x7fe00ffc,0x1ff8000, | |
8110 | 0x67fe01,0xffc03ff8,0x7ff00ff,0xe001c007,0xeff8,0xffb81ff,0x703fee07,0xfdc0ffb8,0x1ff70ff7,0xf81ff807,0xfe00ffc0,0x1ff803ff, | |
8111 | 0x3fff87f,0xff0fffe1,0xfffc07fc,0x380e01f,0xf003fe00,0x7fc00ff8,0x1ff0000,0x37fc00,0xfee01fdc,0x3fb807f,0x7001e007,0x7f800780, | |
8112 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xc,0x30007fc0,0x1e00f8,0x78000000,0x70001c00, | |
8113 | 0x0,0xe0000,0x3c00,0x700001f0,0x1fff0ff,0xfe07f800,0xe01fe0,0x7e0038,0x3f800,0xfc0003c0,0x700000,0x0,0x700,0x18000e00,0x1c7ff000, | |
8114 | 0x7e03fe00,0x3fff0700,0x7f038,0x383ffe0,0x1f801c00,0xf1fff8e0,0x38e01e0,0xfc01c00,0x3f80e0,0x787fc00,0xe0007f0,0x7c00f0,0x387800f0, | |
8115 | 0x1c00ffff,0xe00000,0xe000e000,0x0,0xfc,0x7071f000,0x3f003e38,0x3f00038,0x1f1c1c,0x707fff0,0x1c00700,0xf003f070,0xe1c701c0, | |
8116 | 0x1f801c7c,0x7c700e,0x1f800,0x3f8078e,0x3c0070,0x707803c0,0x1c007ffc,0x70000e,0x1c000,0x0,0x7c0008,0x1e0000,0xe000e1c0,0x71c30010, | |
8117 | 0x20000,0x1e1f0,0x3fe00020,0x3ffe00,0x800ffff0,0x2000040,0x0,0x0,0x0,0x0,0x0,0xfc0,0x3001f0,0x78008007,0xffc00700,0x1c,0x3f81f, | |
8118 | 0xffc00000,0x1c00038,0x407000,0x0,0x0,0x0,0x0,0x0,0xffff800,0x0,0x39c7,0x18c000,0x0,0x0,0x18,0x60001c00,0x61801f80,0x7000ee00, | |
8119 | 0x1dc003b8,0x77000e,0xe001f80f,0xf007e01f,0xff83fff0,0x7ffe0fff,0xc1fff03f,0xfe07ffc0,0xfff83fc0,0x700f007,0xe000fc00,0x1f8003f0, | |
8120 | 0x7e0000,0xe1f800,0x7f000fe0,0x1fc003f,0x8001c007,0xe7f0,0x7e380fc,0x701f8e03,0xf1c07e38,0xfc703c1,0xe003f001,0xf8003f00, | |
8121 | 0x7e000fc,0x3fff87f,0xff0fffe1,0xfffc03f8,0x380e00f,0xc001f800,0x3f0007e0,0xfc0000,0x61f800,0x78e00f1c,0x1e3803c,0x7001c007, | |
8122 | 0x1f000700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x70001c00,0x0, | |
8123 | 0x1c0000,0x0,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0xe00000,0x0,0x0,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0, | |
8124 | 0x0,0x0,0x0,0x0,0xe00000,0x7000e000,0x0,0x0,0x0,0x0,0x0,0x1c00,0x0,0x1c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x1c000000, | |
8125 | 0x70000e,0x1c000,0x0,0x0,0x1c0000,0xe000c180,0x10,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000, | |
8126 | 0x0,0x38,0x70e000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x18c000,0x2000,0x0,0x1f,0xf8003800,0x7fe00000,0x0,0x0,0x0,0x0,0x4000, | |
8127 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000, | |
8128 | 0x0,0x0,0x1c007,0x700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x30001800, | |
8129 | 0x0,0x1c0000,0x0,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0xe00000,0x0,0x0,0xe000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e000, | |
8130 | 0x0,0x0,0x0,0x0,0x0,0xe00000,0x7000e000,0x0,0x0,0x0,0x0,0x0,0x1c00,0x0,0x1c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x1c000000, | |
8131 | 0x70000e,0x1c000,0x0,0x0,0x1c0001,0xe001c380,0x10,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000, | |
8132 | 0x0,0x38,0x7fe000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x18c000,0x3000,0x0,0x1f,0xf8007000,0x7fe00000,0x0,0x0,0x0,0x0,0x6000, | |
8133 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8134 | 0x0,0x1c007,0x700,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x38003800, | |
8135 | 0x0,0x380000,0x1,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x1c00000,0x0,0x0,0x3c18000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf000, | |
8136 | 0x0,0x0,0x0,0x0,0x0,0xfe0000,0x380fe000,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x1c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x38000000, | |
8137 | 0x78000e,0x3c000,0x0,0x0,0x180001,0xc0018300,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0, | |
8138 | 0x38,0x1f8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x18c000,0x1800,0x0,0x0,0x6000e000,0x1800000,0x0,0x0,0x0,0x0,0x3000,0x0, | |
8139 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8140 | 0x38007,0xe00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x18003000, | |
8141 | 0x0,0x300000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0x1ff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x0,0x0, | |
8142 | 0x0,0x0,0x0,0xfe0000,0xfe000,0x0,0x0,0x0,0x0,0x0,0x607800,0x0,0x3c00000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x0,0x78000000, | |
8143 | 0x3f800e,0x3f8000,0x0,0x0,0x300043,0xc0018200,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000, | |
8144 | 0x0,0x38,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x11800,0x0,0x0,0x6001ff00,0x1800000,0x0,0x0,0x0,0x0,0x23000,0x0,0x0, | |
8145 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x23000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78007, | |
8146 | 0x1e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x600,0x0,0x0,0x1c007000,0x0,0x0, | |
8147 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe0000, | |
8148 | 0xfe000,0x0,0x0,0x0,0x0,0x0,0x7ff000,0x0,0x7f800000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x3,0xf8000000,0x3f800e,0x3f8000,0x0, | |
8149 | 0x0,0x10007f,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,0x38,0x0,0x0,0x0,0x0, | |
8150 | 0x0,0x0,0x0,0x0,0x3800,0x0,0x1f800,0x0,0x0,0x6001ff00,0x1800000,0x0,0x0,0x0,0x0,0x3f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8151 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f8007,0xfe00,0x0,0x0,0x0,0x0, | |
8152 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8153 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fff8,0x0,0x0,0x0,0x0,0x7fe000,0x0, | |
8154 | 0x7f000000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x3,0xf0000000,0xf800e,0x3e0000,0x0,0x0,0x7f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8155 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3800,0x0,0x1f000,0x0,0x0,0x0,0x0,0x0, | |
8156 | 0x0,0x0,0x0,0x3e000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e000,0x0,0x0,0x0,0x0,0x0,0x0, | |
8157 | 0x0,0x0,0x0,0x0,0x0,0x0,0x3f0007,0xfc00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8158 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8159 | 0x0,0x0,0x0,0x0,0x7fff8,0x0,0x0,0x0,0x0,0x1fc000,0x0,0x7e000000,0x0,0x0,0x1c00,0x7000,0x0,0x0,0x0,0x3,0xc0000000,0xe,0x0, | |
8160 | 0x0,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8161 | 0x0,0x0,0x3800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8162 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c0007,0xf000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8163 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8164 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fff8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8165 | 0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8166 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8167 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }; | |
8168 | const unsigned int font29x57[29*57*256/32] = { | |
8169 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8170 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8171 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8172 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8173 | 0x0,0x781e00,0x0,0x0,0x7,0x81e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8174 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c0000,0xf8000,0x7e00000,0x0,0x7, | |
8175 | 0xc0000000,0x0,0x7c00,0xf80,0x7e000,0x0,0x7c00000,0xf80000,0x7e000000,0x0,0x0,0x1f00,0x3e0,0x1f800,0x0,0x0,0x0,0x3,0xe0000000, | |
8176 | 0x7c00003f,0x0,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8177 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8178 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8179 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8180 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8181 | 0x0,0x0,0x0,0x0,0x0,0x0,0x3c3c00,0x0,0x0,0x3,0xc3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00, | |
8182 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e0000, | |
8183 | 0x1f0000,0x7e00000,0xf838001f,0xf80001f,0xf0000000,0x0,0x3e00,0x1f00,0x7e000,0x3e1f000,0x3e00000,0x1f00000,0x7e00003e,0x1f000000, | |
8184 | 0x3e0,0xe0000f80,0x7c0,0x1f800,0x3e0e00,0x7c3e000,0x0,0x1,0xf0000000,0xf800003f,0x1f0f,0x800001f0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8185 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8186 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8187 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8188 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8189 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e7800,0x0,0x0, | |
8190 | 0x1,0xe7800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8191 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e0000,0x1e0000,0xff00001,0xfe38001f,0xf80003f, | |
8192 | 0xf8000000,0x0,0x1e00,0x1e00,0xff000,0x3e1f000,0x1e00000,0x1e00000,0xff00003e,0x1f000000,0x7f8,0xe0000780,0x780,0x3fc00,0x7f8e00, | |
8193 | 0x7c3e000,0x0,0x0,0xf0000000,0xf000007f,0x80001f0f,0x800001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8194 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8195 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8196 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8197 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8198 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xef000,0x0,0x0,0x0,0xef000000,0x0,0x0,0x0,0x0,0x0,0x0, | |
8199 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8200 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000,0x3c0000,0x1e780003,0xfff8001f,0xf80003c,0x78000000,0x0,0xf00,0x3c00,0x1e7800, | |
8201 | 0x3e1f000,0xf00000,0x3c00001,0xe780003e,0x1f000000,0xfff,0xe00003c0,0xf00,0x79e00,0xfffe00,0x7c3e000,0x0,0x0,0x78000001,0xe00000f3, | |
8202 | 0xc0001f0f,0x800003c0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8203 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8204 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8205 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8206 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8207 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7e000,0x0,0x0,0x0,0x7e000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8208 | 0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8209 | 0x0,0x78000,0x780000,0x3c3c0003,0x8ff0001f,0xf800078,0x3c000000,0x0,0x780,0x7800,0x3c3c00,0x3e1f000,0x780000,0x7800003,0xc3c0003e, | |
8210 | 0x1f000000,0xe3f,0xc00001e0,0x1e00,0xf0f00,0xe3fc00,0x7c3e000,0x0,0x0,0x3c000003,0xc00001e1,0xe0001f0f,0x80000780,0x0,0x0, | |
8211 | 0x0,0x0,0x0,0x0,0x1f,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8212 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8213 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8214 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8215 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8216 | 0x0,0x7e000,0x0,0x0,0x0,0x7e000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0, | |
8217 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc00,0x7e000,0xfe000,0x0,0x3c000,0xf00000,0x781e0003, | |
8218 | 0x83e0001f,0xf800070,0x1c000000,0x0,0x3c0,0xf000,0x781e00,0x3e1f000,0x3c0000,0xf000007,0x81e0003e,0x1f000000,0xe0f,0x800000f0, | |
8219 | 0x3c00,0x1e0780,0xe0f800,0x7c3e000,0x0,0x0,0x1e000007,0x800003c0,0xf0001f0f,0x80000f00,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8000000, | |
8220 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8221 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8222 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8223 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8224 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8225 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8226 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3fc00,0x1fe000,0x3ff800,0x0,0x0,0x0,0x0,0x0,0x70,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8227 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x78000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8228 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8229 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8230 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8231 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8232 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8233 | 0x0,0x0,0x78,0xf000000,0x0,0x0,0x780f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c0, | |
8234 | 0x0,0x0,0x0,0x0,0x0,0x0,0x3fc00,0x1fe000,0x3ffc00,0x0,0x0,0x0,0x0,0x0,0x70,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8235 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f00000,0x3e000,0x3e00000,0x0,0x78,0x3c000000,0x0,0x1f000,0x3e0, | |
8236 | 0x3e000,0x0,0x1f000000,0x3e0000,0x3e000000,0x0,0x0,0x7c00,0xf8,0xf800,0x0,0x0,0x0,0xf,0x80000000,0x1f00001f,0x0,0x3e,0x0, | |
8237 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8238 | 0x0,0x0,0x0,0x30000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8239 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80000, | |
8240 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8241 | 0x0,0x0,0x0,0x0,0xf80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x781c0000,0x38,0xe000000,0x0,0x0,0x380e0,0x0, | |
8242 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80,0x0,0x0,0x0,0x0,0x0,0x0,0x39c00,0x1ce000,0x303e00, | |
8243 | 0x0,0x0,0x0,0x0,0x0,0x78,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x0,0x0,0x0,0x0, | |
8244 | 0x0,0x0,0xf80000,0x7c000,0x3e00000,0xf0380000,0x70,0x1c000000,0x0,0xf800,0x7c0,0x3e000,0x0,0xf800000,0x7c0000,0x3e000000, | |
8245 | 0x0,0x3c0,0xe0003e00,0x1f0,0xf800,0x3c0e00,0x0,0x0,0x7,0xc0000000,0x3e00001f,0x0,0x7c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8246 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0xff,0x0, | |
8247 | 0xf8,0xf8000,0x1c000,0x0,0x0,0x0,0x0,0x1f,0xc0000000,0x1ff8,0xff00,0x0,0x0,0x3fe000,0x0,0x1fc00001,0xfe000000,0x0,0x0,0x0, | |
8248 | 0x0,0x7f800,0x0,0x0,0x0,0xff00000,0x0,0x0,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xf8000000,0xfe,0x0,0x7f80,0x0,0x0,0x0,0x0,0x0, | |
8249 | 0x0,0x3f,0xf0000000,0x7fe0,0x0,0x0,0x780000,0x1,0xe0000000,0x0,0x780000,0x3,0xfe000000,0x78000,0x3c00,0xf000,0x7800003,0xffe00000, | |
8250 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfc0000f0,0x3f000,0x0,0x0,0x3fc00,0x0,0x0,0x1fc000,0x0,0x0,0x0,0x1fc0, | |
8251 | 0x0,0xff000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfe1c0000,0x1c,0x1c000000,0x0,0x0,0x1c1c0,0x0,0x0,0x0,0x0,0x1fe0000, | |
8252 | 0x0,0x0,0x1ff,0x1f0f8,0x0,0xff000,0x0,0x0,0x0,0x3f,0xff00000f,0x80000000,0xfe0,0x3f80,0xf00,0x0,0x0,0x0,0x1,0xf8000003,0xe0000000, | |
8253 | 0x1c00,0xe000,0xe00,0x0,0x0,0x0,0x0,0x0,0x3c,0x78000000,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f0,0x3f80,0x1fc00,0xfe000, | |
8254 | 0x7f0000,0x0,0x1fc07000,0x0,0x0,0x0,0x0,0x0,0x3f800,0x780000,0x78000,0x7f00001,0xfc38001f,0xf800070,0x1c000000,0x0,0x7800, | |
8255 | 0x780,0x7f000,0x3e1f000,0x7800000,0x780000,0x7f00003e,0x1f0003f0,0x7f0,0xe0001e00,0x1e0,0x1fc00,0x7f0e00,0x7c3e000,0x0,0x3, | |
8256 | 0xc0000000,0x3c00003f,0x80001f0f,0x80000078,0x1e0000,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8257 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x1e078000,0x30000000,0x3ff,0xc00001e0,0xf0, | |
8258 | 0x78000,0x1c000,0x0,0x0,0x0,0x0,0x1e0007f,0xf000007e,0x1ffff,0x7ffe0,0x1f80,0x3ffff80,0xfff803,0xfffff800,0xfff80007,0xff800000, | |
8259 | 0x0,0x0,0x0,0x0,0x1ffe00,0x0,0xfe0003,0xfff80000,0x3ffe01ff,0xe00003ff,0xffe01fff,0xff0003ff,0xe01e0007,0x803ffff0,0xfff80, | |
8260 | 0x3c000fc0,0x7800001f,0x8003f07e,0x1e000f,0xfe0007ff,0xf00003ff,0x8007ffe0,0x1fff8,0x7fffffe,0xf0003c1,0xe000079e,0xf1f,0x1f3e0, | |
8261 | 0x1f01ff,0xfff8003f,0xf003c000,0x7fe0,0x3f00,0x0,0x3c0000,0x1,0xe0000000,0x0,0x780000,0xf,0xfe000000,0x78000,0x3c00,0xf000, | |
8262 | 0x7800003,0xffe00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xfc0000f0,0x3fe00,0x0,0x0,0xfff00,0x0,0x0,0x3fe000, | |
8263 | 0x0,0x0,0x0,0x1dc0,0x0,0x3fff00,0x0,0x3ffff80,0x1f,0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff1c07ff,0x3c0f001e,0x3c000000, | |
8264 | 0x0,0x0,0x1e3c0,0xf80007c,0x0,0x780000,0x0,0xfff8000,0x3e00,0x1f00000,0x7ff,0xc001f0f8,0x0,0x3ffc00,0x0,0x0,0x0,0x3f,0xff00003f, | |
8265 | 0xe0000000,0x3ff8,0xffe0,0x1e00,0x0,0xfffc00,0x0,0x7,0xf800000f,0xf8000000,0x1c00,0xe000,0xe00,0xf000,0x1fc000,0xfe0000,0x7f00000, | |
8266 | 0x3f800001,0xfc00003f,0xf80000ff,0xffc003ff,0xe007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01ffc, | |
8267 | 0xfc00,0x3c001ffc,0xffe0,0x7ff00,0x3ff800,0x1ffc000,0x0,0x7ff8f0f0,0x3c0780,0x1e03c00,0xf01e000,0x783e0001,0xf01e0000,0xffe00, | |
8268 | 0x3c0000,0xf0000,0x7700001,0xfe38001f,0xf800070,0x1c000000,0x0,0x3c00,0xf00,0x77000,0x3e1f000,0x3c00000,0xf00000,0x7700003e, | |
8269 | 0x1f0000f8,0xc0007f8,0xe0000f00,0x3c0,0x1dc00,0x7f8e00,0x7c3e000,0x0,0x1,0xe0000000,0x7800003b,0x80001f0f,0x800000f0,0x1e0000, | |
8270 | 0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8271 | 0x0,0x0,0x780000,0x3c1e0000,0x1e070000,0x300001f0,0x7ff,0xc00001e0,0x1e0,0x7c000,0x1c000,0x0,0x0,0x0,0x0,0x3c000ff,0xf80007fe, | |
8272 | 0x3ffff,0x801ffff8,0x1f80,0x3ffff80,0x3fff803,0xfffff801,0xfffc000f,0xffc00000,0x0,0x0,0x0,0x0,0x7fff80,0x0,0xfe0003,0xffff0000, | |
8273 | 0xffff01ff,0xfc0003ff,0xffe01fff,0xff000fff,0xf01e0007,0x803ffff0,0xfff80,0x3c001f80,0x7800001f,0xc007f07e,0x1e001f,0xff0007ff, | |
8274 | 0xfc0007ff,0xc007fffc,0x3fffc,0x7fffffe,0xf0003c1,0xf0000f9e,0xf0f,0x8003e1e0,0x1e01ff,0xfff8003f,0xf001e000,0x7fe0,0x3f00, | |
8275 | 0x0,0x1e0000,0x1,0xe0000000,0x0,0x780000,0x1f,0xfe000000,0x78000,0x3c00,0xf000,0x7800003,0xffe00000,0x0,0x0,0x0,0x0,0x0,0x0, | |
8276 | 0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x1fff80,0x0,0x0,0xffe000,0x0,0x0,0x0,0x3de0,0x0,0x7fff80,0x0,0xfffff80, | |
8277 | 0x1f,0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xe7bc07ff,0x3e1f000f,0x78000000,0x0,0x0,0xf780,0x7800078,0x0,0x780000,0x180000, | |
8278 | 0x1fff8000,0x1e00,0x1e0003c,0xfff,0xc001f0f8,0x0,0x7ffe00,0x0,0x0,0x0,0x3f,0xff00007f,0xf0000000,0x3ffc,0xfff0,0x3c00,0x0, | |
8279 | 0x7fffc00,0x0,0x7,0xf800003f,0xfe000000,0x1c00,0xe000,0xe00,0xf000,0x1fc000,0xfe0000,0x7f00000,0x3f800001,0xfc00001f,0xe00001ff, | |
8280 | 0xffc00fff,0xf007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xc000fc00,0x3c003ffe,0x1fff0, | |
8281 | 0xfff80,0x7ffc00,0x3ffe000,0x0,0xfffce0f0,0x3c0780,0x1e03c00,0xf01e000,0x781e0001,0xe01e0000,0x3fff00,0x1e0000,0x1e0000,0xf780003, | |
8282 | 0xcf78001f,0xf800078,0x3c000000,0x0,0x1e00,0x1e00,0xf7800,0x3e1f000,0x1e00000,0x1e00000,0xf780003e,0x1f0000fc,0x7c000f3d, | |
8283 | 0xe0000780,0x780,0x3de00,0xf3de00,0x7c3e000,0x0,0x0,0xf0000000,0xf000007b,0xc0001f0f,0x800001e0,0x1e0000,0x3e1f00,0x0,0x0, | |
8284 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000, | |
8285 | 0x3c1e0000,0x1e0f0000,0x300007fc,0xfff,0xc00001e0,0x1e0,0x3c000,0x1c000,0x0,0x0,0x0,0x0,0x3c001ff,0xfc001ffe,0x3ffff,0xc01ffffc, | |
8286 | 0x3f80,0x3ffff80,0x7fff803,0xfffff803,0xfffe001f,0xffe00000,0x0,0x0,0x0,0x0,0xffff80,0x7f800,0xfe0003,0xffff8001,0xffff01ff, | |
8287 | 0xff0003ff,0xffe01fff,0xff001fff,0xf01e0007,0x803ffff0,0xfff80,0x3c003f00,0x7800001f,0xc007f07f,0x1e003f,0xff8007ff,0xff000fff, | |
8288 | 0xe007ffff,0x7fffc,0x7fffffe,0xf0003c0,0xf0000f1e,0xf07,0x8003c1f0,0x3e01ff,0xfff8003f,0xf001e000,0x7fe0,0x7f80,0x0,0xe0000, | |
8289 | 0x1,0xe0000000,0x0,0x780000,0x1f,0xfe000000,0x78000,0x3c00,0xf000,0x7800003,0xffe00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0, | |
8290 | 0x0,0x0,0x0,0x0,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x3fff80,0x0,0x0,0xffe000,0x0,0x0,0x0,0x78f0,0x0,0xffff80,0x0,0x3fffff80,0x1f, | |
8291 | 0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xc7f80070,0x3e1f0007,0x70000000,0x0,0x0,0x7700,0x7c000f8,0x0,0x780000,0x180000, | |
8292 | 0x3fff8000,0x1f00,0x3e0003c,0x1f03,0xc001f0f8,0x0,0x703f00,0x0,0x0,0x0,0x3f,0xff0000f0,0xf8000000,0x303e,0xc0f8,0x7800,0x0, | |
8293 | 0xffffc00,0x0,0x7,0x3800003e,0x3e000000,0x1c00,0xe000,0x3c00,0xf000,0x1fc000,0xfe0000,0x7f00000,0x3f800001,0xfc00000f,0xe00001ff, | |
8294 | 0xffc01fff,0xf007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xf000fe00,0x3c007fff,0x3fff8, | |
8295 | 0x1fffc0,0xfffe00,0x7fff000,0x1,0xffffc0f0,0x3c0780,0x1e03c00,0xf01e000,0x781f0003,0xe01e0000,0x3fff80,0xe0000,0x3c0000,0x1e3c0003, | |
8296 | 0x8ff0001f,0xf80003c,0x78000000,0x0,0xe00,0x3c00,0x1e3c00,0x3e1f000,0xe00000,0x3c00001,0xe3c0003e,0x1f00007f,0xf8000e3f,0xc0000380, | |
8297 | 0xf00,0x78f00,0xe3fc00,0x7c3e000,0x0,0x0,0x70000001,0xe00000f1,0xe0001f0f,0x800003c0,0x1e0000,0x3e1f00,0x0,0x0,0x0,0x0,0x0, | |
8298 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x3c0f0000, | |
8299 | 0x30000ffe,0xf80,0xc00001e0,0x3c0,0x1e000,0x101c040,0x0,0x0,0x0,0x0,0x78003f0,0x7e001ffe,0x3f807,0xe01f00fe,0x3f80,0x3ffff80, | |
8300 | 0x7e01803,0xfffff007,0xe03f003f,0x3f00000,0x0,0x0,0x0,0x0,0xfc0fc0,0x3ffe00,0xfe0003,0xffffc003,0xf81f01ff,0xff8003ff,0xffe01fff, | |
8301 | 0xff003f01,0xf01e0007,0x803ffff0,0xfff80,0x3c007e00,0x7800001f,0xc007f07f,0x1e007e,0xfc007ff,0xff801f83,0xf007ffff,0x800fc07c, | |
8302 | 0x7fffffe,0xf0003c0,0xf0000f0f,0x1e07,0xc007c0f8,0x7c01ff,0xfff8003c,0xf000,0x1e0,0xffc0,0x0,0xf0000,0x1,0xe0000000,0x0,0x780000, | |
8303 | 0x3e,0x0,0x78000,0x3c00,0xf000,0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1f,0x800000f0,0x1f80, | |
8304 | 0x0,0x0,0x7e0780,0x0,0x0,0x1f82000,0x0,0x0,0x0,0x7070,0x0,0x1f80f80,0x0,0x7fffff80,0x1f,0xffff8000,0x0,0x0,0x0,0x0,0x0,0x0, | |
8305 | 0x0,0x1,0xc3f80070,0x3f3f0007,0xf0000000,0x0,0x0,0x7f00,0x3e001f0,0x0,0x780000,0x180000,0x7f018000,0xf80,0x7c0003c,0x3e00, | |
8306 | 0x4001f0f8,0xfe00,0x400f00,0x0,0x0,0x0,0x7f000000,0xe0,0x38000000,0x1e,0x38,0x7800,0x0,0x1ffe1c00,0x0,0x0,0x38000078,0xf000000, | |
8307 | 0x1c00,0xe000,0x7f800,0xf000,0x1fc000,0xfe0000,0x7f00000,0x3f800001,0xfc00001f,0xf00001ff,0xffc03f81,0xf007ffff,0xc03ffffe, | |
8308 | 0x1fffff0,0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xf800fe00,0x3c00fc1f,0x8007e0fc,0x3f07e0,0x1f83f00,0xfc1f800, | |
8309 | 0x3,0xf07fc0f0,0x3c0780,0x1e03c00,0xf01e000,0x780f8007,0xc01e0000,0x7e0fc0,0xf0000,0x3c0000,0x1c1c0003,0x87f0001f,0xf80003f, | |
8310 | 0xf8000000,0x0,0xf00,0x3c00,0x1c1c00,0x3e1f000,0xf00000,0x3c00001,0xc1c0003e,0x1f00003f,0xc0000e1f,0xc00003c0,0xf00,0x70700, | |
8311 | 0xe1fc00,0x7c3e000,0x0,0x0,0x78000001,0xe00000e0,0xe0001f0f,0x800003c0,0x1e0000,0x3e1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8312 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x3c0f0001,0xff801e0f, | |
8313 | 0x1f00,0x1e0,0x3c0,0x1e000,0x3c1c1e0,0x0,0x0,0x0,0x0,0x78007c0,0x1f001f9e,0x3c001,0xf010003e,0x7780,0x3c00000,0xf800000,0xf007, | |
8314 | 0xc01f007c,0x1f80000,0x0,0x0,0x0,0x0,0xe003e0,0x7fff00,0x1ef0003,0xc007e007,0xc00301e0,0x1fc003c0,0x1e00,0x7c00,0x301e0007, | |
8315 | 0x80007800,0x780,0x3c00fc00,0x7800001f,0xe00ff07f,0x1e00f8,0x3e00780,0x1fc03e00,0xf807801f,0xc01f001c,0xf000,0xf0003c0,0xf0000f0f, | |
8316 | 0x1e03,0xc00f8078,0x780000,0xf0003c,0xf000,0x1e0,0x1f3e0,0x0,0x78000,0x1,0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0, | |
8317 | 0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1f,0xf0,0xf80,0x0,0x0,0xf80180,0x0,0x0,0x1e00000, | |
8318 | 0x0,0x0,0x0,0xe038,0x0,0x3e00380,0x0,0xfe0f0000,0x0,0xf0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xc0f00070,0x3b370003,0xe0000000, | |
8319 | 0x0,0x0,0x3e00,0x1e001e0,0x0,0x780000,0x180000,0x7c000000,0x780,0x780003c,0x3c00,0x0,0x7ffc0,0x780,0x0,0x0,0x3,0xffe00000, | |
8320 | 0x1c0,0x3c000000,0xe,0x38,0xf000,0x0,0x3ffe1c00,0x0,0x0,0x38000078,0xf000000,0x1c00,0xe000,0x7f000,0xf000,0x3de000,0x1ef0000, | |
8321 | 0xf780000,0x7bc00003,0xde00001e,0xf00003e7,0x80007c00,0x30078000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001, | |
8322 | 0xe0001e03,0xfc00fe00,0x3c01f007,0xc00f803e,0x7c01f0,0x3e00f80,0x1f007c00,0x7,0xc01f80f0,0x3c0780,0x1e03c00,0xf01e000,0x78078007, | |
8323 | 0x801e0000,0x7803c0,0x78000,0x780000,0x380e0003,0x81e00000,0x1f,0xf0000000,0x0,0x780,0x7800,0x380e00,0x0,0x780000,0x7800003, | |
8324 | 0x80e00000,0x1ff,0x80000e07,0x800001e0,0x1e00,0xe0380,0xe07800,0x0,0x0,0x0,0x3c000003,0xc00001c0,0x70000000,0x780,0x1e0000, | |
8325 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8326 | 0x780000,0x3c1e0000,0x3c0e0007,0xfff01c07,0x1e00,0x1e0,0x780,0xf000,0x3e1c3e0,0x0,0x0,0x0,0x0,0xf0007c0,0x1f00181e,0x20000, | |
8327 | 0xf000001f,0xf780,0x3c00000,0x1f000000,0x1f00f,0x800f8078,0xf80000,0x0,0x0,0x0,0x0,0x8003e0,0x1fc0f80,0x1ef0003,0xc001e007, | |
8328 | 0x800101e0,0x7e003c0,0x1e00,0x7800,0x101e0007,0x80007800,0x780,0x3c00f800,0x7800001e,0xe00ef07f,0x801e00f0,0x1e00780,0x7c03c00, | |
8329 | 0x78078007,0xc01e0004,0xf000,0xf0003c0,0x78001e0f,0x1e03,0xe00f807c,0xf80000,0x1f0003c,0x7800,0x1e0,0x3e1f0,0x0,0x3c000,0x1, | |
8330 | 0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0, | |
8331 | 0x1e,0xf0,0x780,0x0,0x0,0x1f00080,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x1e03c,0x0,0x3c00080,0x0,0xf80f0000,0x0,0x1f0000,0x0,0x0, | |
8332 | 0x0,0x0,0x0,0x0,0x0,0x0,0x70,0x3bf70003,0xe0000000,0x0,0x0,0x3e00,0x1f003e0,0x0,0x780000,0x180000,0x78000000,0x7c0,0xf80003c, | |
8333 | 0x3c00,0x0,0x1f01f0,0x780,0x0,0x0,0xf,0x80f80000,0x1c0,0x1c000000,0xe,0x38,0x1e000,0x0,0x7ffe1c00,0x0,0x0,0x380000f0,0x7800000, | |
8334 | 0x1c00,0xe000,0x7fc00,0xf000,0x3de000,0x1ef0000,0xf780000,0x7bc00003,0xde00001e,0xf00003c7,0x80007800,0x10078000,0x3c0000, | |
8335 | 0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x7e00ff00,0x3c01e003,0xc00f001e,0x7800f0,0x3c00780,0x1e003c00, | |
8336 | 0x7,0x800f00f0,0x3c0780,0x1e03c00,0xf01e000,0x7807c00f,0x801e0000,0xf803c0,0x3c000,0xf00000,0x780f0000,0x0,0x7,0xc0000000, | |
8337 | 0x0,0x3c0,0xf000,0x780f00,0x0,0x3c0000,0xf000007,0x80f00000,0x7ff,0xc0000000,0xf0,0x3c00,0x1e03c0,0x0,0x0,0x0,0x0,0x1e000007, | |
8338 | 0x800003c0,0x78000000,0xf00,0x1e0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8339 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x3c1e001f,0xfff03803,0x80001e00,0x1e0,0x780,0xf000,0xf9cf80, | |
8340 | 0x0,0x0,0x0,0x0,0xf000780,0xf00001e,0x0,0xf800000f,0xe780,0x3c00000,0x1e000000,0x1e00f,0x78078,0x7c0000,0x0,0x0,0x0,0x0,0x1e0, | |
8341 | 0x3f003c0,0x1ef0003,0xc000f00f,0x800001e0,0x1f003c0,0x1e00,0xf000,0x1e0007,0x80007800,0x780,0x3c01f000,0x7800001e,0xe00ef07f, | |
8342 | 0x801e01f0,0x1e00780,0x3c07c00,0x78078003,0xc03e0000,0xf000,0xf0003c0,0x78001e0f,0x1e01,0xf01f003c,0xf00000,0x3e0003c,0x7800, | |
8343 | 0x1e0,0x7c0f8,0x0,0x0,0x1,0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,0x7800000,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x3c000, | |
8344 | 0x0,0x0,0x0,0x0,0x0,0x1e,0xf0,0x780,0x0,0x0,0x1e00000,0x0,0x0,0x3c00000,0x0,0x8,0x40,0x0,0x7e0000,0x7c00000,0x1,0xf00f0000, | |
8345 | 0x0,0x3e0000,0x0,0x3f,0xfc0,0xfc3f0,0xfc3f0,0x0,0x0,0x0,0x70,0x39e70000,0x0,0x0,0x0,0x0,0xf003c0,0x0,0x0,0x180000,0xf8000000, | |
8346 | 0x3c0,0xf00003c,0x3c00,0x0,0x3c0078,0x7ff80,0x0,0x0,0x1e,0x3c0000,0x1c0,0x1c000000,0xe,0xf0,0x0,0x0,0x7ffe1c00,0x0,0x0,0x380000f0, | |
8347 | 0x7800000,0x1c00,0xe000,0x3c00,0x0,0x3de000,0x1ef0000,0xf780000,0x7bc00003,0xde00001e,0xf00003c7,0x8000f800,0x78000,0x3c0000, | |
8348 | 0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x1f00ff00,0x3c03e003,0xc01f001e,0xf800f0,0x7c00780,0x3e003c00, | |
8349 | 0xf,0x800f80f0,0x3c0780,0x1e03c00,0xf01e000,0x7803c00f,0x1fffc0,0xf001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8350 | 0x0,0x0,0x307,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1e0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8351 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000,0x781e003f,0xfff03803, | |
8352 | 0x80001e00,0x1e0,0xf80,0xf000,0x3dde00,0x0,0x0,0x0,0x0,0xf000f00,0x780001e,0x0,0x7800000f,0x1e780,0x3c00000,0x3e000000,0x3e00f, | |
8353 | 0x780f0,0x7c0000,0x0,0x0,0x0,0x0,0x1e0,0x7c001e0,0x3ef8003,0xc000f00f,0x1e0,0xf003c0,0x1e00,0xf000,0x1e0007,0x80007800,0x780, | |
8354 | 0x3c03e000,0x7800001e,0xf01ef07b,0xc01e01e0,0xf00780,0x3e07800,0x3c078003,0xe03c0000,0xf000,0xf0003c0,0x78001e0f,0x1e00,0xf01e003e, | |
8355 | 0x1f00000,0x3c0003c,0x7800,0x1e0,0x78078,0x0,0x0,0x1,0xe0000000,0x0,0x780000,0x3c,0x0,0x78000,0x0,0x0,0x7800000,0x1e00000, | |
8356 | 0x0,0x0,0x0,0x0,0x0,0x0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1e,0xf0,0x780,0x0,0x0,0x1e00000,0x0,0x0,0x3c00000,0x0,0x18,0xc0,0x0, | |
8357 | 0xe70000,0x7800000,0x1,0xe00f0000,0x0,0x3c0000,0x0,0x3f,0xfc0,0xfc1f0,0x1f83f0,0x0,0x0,0x0,0x70,0x39e70000,0x0,0x0,0x0,0x0, | |
8358 | 0xf807c0,0x0,0x0,0x180000,0xf0000000,0x3e0,0x1f00003c,0x3e00,0x0,0x70001c,0x3fff80,0x0,0x0,0x38,0xe0000,0x1c0,0x1c000078, | |
8359 | 0x1c,0x1fe0,0x0,0x0,0xfffe1c00,0x0,0x0,0x380000f0,0x7800000,0x1c00,0xe000,0xe00,0x0,0x7df000,0x3ef8000,0x1f7c0000,0xfbe00007, | |
8360 | 0xdf00003c,0x780003c7,0x8000f000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0xf00f780, | |
8361 | 0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,0xf,0xf80f0,0x3c0780,0x1e03c00,0xf01e000,0x7803e01f,0x1ffff8,0xf001e0, | |
8362 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0xc000,0x0,0x0,0x0,0x0,0x1e0000, | |
8363 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8364 | 0x780000,0x3c1e0000,0x781e003e,0x30703803,0x80001e00,0x1e0,0xf00,0x7800,0xff800,0x1e0000,0x0,0x0,0x0,0x1e000f00,0x780001e, | |
8365 | 0x0,0x7800000f,0x3c780,0x3c00000,0x3c000000,0x3c00f,0x780f0,0x3c0000,0x0,0x0,0x2000000,0x800000,0x1e0,0x78000e0,0x3c78003, | |
8366 | 0xc000f01e,0x1e0,0xf803c0,0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c07c000,0x7800001e,0x701cf07b,0xc01e01e0,0xf00780,0x1e07800, | |
8367 | 0x3c078001,0xe03c0000,0xf000,0xf0003c0,0x7c003e0f,0x1e00,0xf83e001e,0x1e00000,0x7c0003c,0x3c00,0x1e0,0xf807c,0x0,0x0,0x1fe0001, | |
8368 | 0xe1fc0000,0x7f00003,0xf8780007,0xf000003c,0x7f0,0x783f0,0x0,0x0,0x7800000,0x1e00000,0x3e0f8000,0xfc00007,0xf8000007,0xf00001fc, | |
8369 | 0xf,0xc0003fc0,0x3c000,0x0,0x0,0x0,0x0,0x0,0x1e,0xf0,0x780,0x0,0x0,0x3c00000,0x0,0x0,0x3c00000,0x0,0x18,0xc0,0x0,0x1818000, | |
8370 | 0x7800000,0x1,0xe00f0000,0x0,0x7c0000,0x0,0x1f,0x80001f80,0x7c1f8,0x1f83e0,0x0,0x0,0x0,0x70,0x38c70007,0xf8000000,0x7f03, | |
8371 | 0xf0000000,0x0,0x780780,0x0,0x0,0xfe0000,0xf0000000,0x1e0,0x1e00003c,0x3f00,0x0,0xe07f0e,0x7fff80,0x0,0x0,0x70,0x70000,0x1c0, | |
8372 | 0x1c000078,0x3c,0x1fc0,0x0,0x0,0xfffe1c00,0x0,0x0,0x380000f0,0x7800000,0x1c00,0xe000,0xe00,0x0,0x78f000,0x3c78000,0x1e3c0000, | |
8373 | 0xf1e00007,0x8f00003c,0x78000787,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00, | |
8374 | 0xf80f780,0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,0xf,0x1f80f0,0x3c0780,0x1e03c00,0xf01e000,0x7801e01e,0x1ffffc, | |
8375 | 0xf007e0,0x3fc000,0x1fe0000,0xff00000,0x7f800003,0xfc00001f,0xe0000fc0,0xfc00007f,0xfe0,0x7f00,0x3f800,0x1fc000,0x0,0x0,0x0, | |
8376 | 0x1,0xf000001f,0x80000ff0,0x7f80,0x3fc00,0x1fe000,0xff0000,0x1f80000,0x1fc1e000,0x0,0x0,0x0,0x0,0x1e1fc0,0x0,0x0,0x0,0x0, | |
8377 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e0000, | |
8378 | 0x781c007c,0x30003803,0x80001f00,0x1e0,0xf00,0x7800,0x7f000,0x1e0000,0x0,0x0,0x0,0x1e000f00,0x780001e,0x0,0x7800000f,0x3c780, | |
8379 | 0x3c00000,0x3c000000,0x3c00f,0x780f0,0x3c0000,0x0,0x0,0x1e000000,0xf00000,0x3e0,0xf0000e0,0x3c78003,0xc000f01e,0x1e0,0x7803c0, | |
8380 | 0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c0f8000,0x7800001e,0x701cf079,0xe01e01e0,0xf00780,0x1e07800,0x3c078001,0xe03c0000, | |
8381 | 0xf000,0xf0003c0,0x3c003c0f,0x3e00,0x787c001f,0x3e00000,0xf80003c,0x3c00,0x1e0,0x1f003e,0x0,0x0,0x1fffc001,0xe7ff0000,0x3ffe000f, | |
8382 | 0xfe78003f,0xfc001fff,0xfe001ffc,0xf0078ffc,0x1ffc00,0x7ff000,0x7800f80,0x1e0000f,0x7f1fc01e,0x3ff0001f,0xfe00079f,0xfc0007ff, | |
8383 | 0x3c003c7f,0xf001fff8,0x1fffff0,0x3c003c0,0xf0000f1e,0xf1f,0x7c1f0,0x1f00ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x3c00000,0x100000, | |
8384 | 0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1818000,0x7800000,0x1,0xe00f0000,0x1000000,0xf80000,0x40000002,0xf,0x80001f00,0x7e0f8,0x1f07c0, | |
8385 | 0x0,0x0,0x0,0x70,0x38c7003f,0xff000000,0xff8f,0xf8000100,0xffffe,0x7c0f80,0x0,0x0,0x3ffc000,0xf0000020,0x1001f0,0x3c00003c, | |
8386 | 0x1f80,0x0,0x1c3ffc7,0x7c0780,0x0,0x0,0xe3,0xff038000,0xe0,0x38000078,0x78,0x1ff0,0x0,0x3c003c0,0xfffe1c00,0x0,0x0,0x380000f0, | |
8387 | 0x7800000,0x1c00,0xe000,0xe00,0xf000,0x78f000,0x3c78000,0x1e3c0000,0xf1e00007,0x8f00003c,0x78000787,0x8001e000,0x78000,0x3c0000, | |
8388 | 0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f3c0,0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00, | |
8389 | 0x4000200f,0x3f80f0,0x3c0780,0x1e03c00,0xf01e000,0x7801f03e,0x1ffffe,0xf01fe0,0x3fff800,0x1fffc000,0xfffe0007,0xfff0003f, | |
8390 | 0xff8001ff,0xfc003ff3,0xfe0003ff,0xe0007ff8,0x3ffc0,0x1ffe00,0xfff000,0x3ff80001,0xffc0000f,0xfe00007f,0xf000003f,0xf8003c7f, | |
8391 | 0xe0003ffc,0x1ffe0,0xfff00,0x7ff800,0x3ffc000,0x1f80000,0xfff1c03c,0x3c01e0,0x1e00f00,0xf007800,0x781f0001,0xf01e7ff0,0x7c0007c, | |
8392 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000, | |
8393 | 0x3c1e003f,0xfffff078,0x30003803,0x80000f00,0x1e0,0x1f00,0x7800,0x7f000,0x1e0000,0x0,0x0,0x0,0x3c000f00,0x780001e,0x0,0x7800000f, | |
8394 | 0x78780,0x3c00000,0x3c000000,0x7c00f,0x780f0,0x3c0007,0xe000003f,0x0,0xfe000000,0xfe0000,0x3c0,0x1f000070,0x7c7c003,0xc000f01e, | |
8395 | 0x1e0,0x7803c0,0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c1f0000,0x7800001e,0x783cf079,0xe01e03c0,0xf00780,0x1e0f000,0x3c078001, | |
8396 | 0xe03c0000,0xf000,0xf0003c0,0x3c003c07,0x81f03c00,0x7c7c000f,0x87c00000,0xf00003c,0x1e00,0x1e0,0x3e001f,0x0,0x0,0x3fffe001, | |
8397 | 0xefff8000,0x7fff001f,0xff78007f,0xfe001fff,0xfe003ffe,0xf0079ffe,0x1ffc00,0x7ff000,0x7801f00,0x1e0000f,0xffbfe01e,0x7ff8003f, | |
8398 | 0xff0007bf,0xfe000fff,0xbc003cff,0xf803fffc,0x1fffff0,0x3c003c0,0x78001e1e,0xf0f,0x800f80f0,0x1e00ff,0xffe0001e,0xf0,0x780, | |
8399 | 0x0,0x0,0x3c00000,0x380000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1008000,0x7800000,0x3,0xe00f0000,0x3800000,0xf00000,0xe0000007, | |
8400 | 0xf,0x80001f00,0x3e0f8,0x1e07c0,0x0,0x0,0x0,0x70,0x3807007f,0xff800000,0x1ffdf,0xfc000380,0xffffe,0x3e1f00,0x0,0x0,0xfffe000, | |
8401 | 0xf0000030,0x3800f8,0x7c00003c,0xfc0,0x0,0x18780c3,0xf00780,0x80100,0x0,0xc3,0xffc18000,0xf0,0x78000078,0xf0,0xf0,0x0,0x3c003c0, | |
8402 | 0xfffe1c00,0x0,0x0,0x380000f0,0x7800801,0x1c00,0xe000,0x1e00,0xf000,0xf8f800,0x7c7c000,0x3e3e0001,0xf1f0000f,0x8f80007c,0x7c000787, | |
8403 | 0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f3c0,0x3c078001,0xe03c000f, | |
8404 | 0x1e00078,0xf0003c0,0x78001e00,0xe000701f,0x3fc0f0,0x3c0780,0x1e03c00,0xf01e000,0x7800f87c,0x1e007f,0xf07e00,0x7fffc00,0x3fffe001, | |
8405 | 0xffff000f,0xfff8007f,0xffc003ff,0xfe007ff7,0xff0007ff,0xf000fffc,0x7ffe0,0x3fff00,0x1fff800,0x3ff80001,0xffc0000f,0xfe00007f, | |
8406 | 0xf00000ff,0xf8003cff,0xf0007ffe,0x3fff0,0x1fff80,0xfffc00,0x7ffe000,0x1f80001,0xfffb803c,0x3c01e0,0x1e00f00,0xf007800,0x780f0001, | |
8407 | 0xe01efff8,0x3c00078,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8408 | 0x0,0x0,0x0,0x0,0x0,0x780000,0x3c1e003f,0xfffff078,0x30001c07,0xf80,0x1e0,0x1e00,0x3c00,0xff800,0x1e0000,0x0,0x0,0x0,0x3c001e00, | |
8409 | 0x3c0001e,0x0,0x7800001e,0x70780,0x3c00000,0x78000000,0x78007,0x800f00f0,0x3e0007,0xe000003f,0x3,0xfe000000,0xff8000,0x7c0, | |
8410 | 0x1e000070,0x783c003,0xc001f01e,0x1e0,0x7803c0,0x1e00,0x1e000,0x1e0007,0x80007800,0x780,0x3c3e0000,0x7800001e,0x3838f079, | |
8411 | 0xe01e03c0,0x780780,0x1e0f000,0x1e078001,0xe03c0000,0xf000,0xf0003c0,0x3c007c07,0x81f03c00,0x3ef80007,0x87800000,0x1f00003c, | |
8412 | 0x1e00,0x1e0,0x7c000f,0x80000000,0x0,0x3ffff001,0xffffc000,0xffff003f,0xff7800ff,0xff001fff,0xfe007ffe,0xf007bffe,0x1ffc00, | |
8413 | 0x7ff000,0x7803e00,0x1e0000f,0xffffe01e,0xfff8007f,0xff8007ff,0xff001fff,0xbc003dff,0xf807fffc,0x1fffff0,0x3c003c0,0x78001e0f, | |
8414 | 0x1e07,0xc01f00f0,0x1e00ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x7c00000,0x7c0000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1018000,0x7800000, | |
8415 | 0x3,0xc00f0000,0x7c00000,0x1f00001,0xf000000f,0x80000007,0xc0003e00,0x1e07c,0x3e0780,0x0,0x0,0x0,0x70,0x380700ff,0xff800000, | |
8416 | 0x3ffff,0xfe0007c0,0xffffe,0x1e1e00,0x0,0x780000,0x1fffe000,0xf0000078,0x7c0078,0x7800003c,0xff0,0x0,0x38e0003,0x80f00780, | |
8417 | 0x180300,0x0,0x1c3,0x81e1c000,0x7f,0xf0000078,0x1e0,0x38,0x0,0x3c003c0,0xfffe1c00,0x0,0x0,0x380000f0,0x7800c01,0x80001c00, | |
8418 | 0xe000,0x603e00,0xf000,0xf07800,0x783c000,0x3c1e0001,0xe0f0000f,0x7800078,0x3c000f87,0x8001e000,0x78000,0x3c0000,0x1e00000, | |
8419 | 0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f3c0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f01,0xf000f81e, | |
8420 | 0x7bc0f0,0x3c0780,0x1e03c00,0xf01e000,0x78007878,0x1e001f,0xf0f800,0x7fffe00,0x3ffff001,0xffff800f,0xfffc007f,0xffe003ff, | |
8421 | 0xff007fff,0xff800fff,0xf001fffe,0xffff0,0x7fff80,0x3fffc00,0x3ff80001,0xffc0000f,0xfe00007f,0xf00001ff,0xfc003dff,0xf000ffff, | |
8422 | 0x7fff8,0x3fffc0,0x1fffe00,0xffff000,0x1f80003,0xffff803c,0x3c01e0,0x1e00f00,0xf007800,0x780f0001,0xe01ffffc,0x3c00078,0x0, | |
8423 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000, | |
8424 | 0x3c1e003f,0xfffff078,0x30001e0f,0x300780,0x1e0,0x1e00,0x3c00,0x3dde00,0x1e0000,0x0,0x0,0x0,0x78001e00,0x3c0001e,0x0,0xf800003e, | |
8425 | 0xf0780,0x3dfc000,0x783f8000,0xf8007,0xc01f00f0,0x3e0007,0xe000003f,0x1f,0xfc000000,0x7ff000,0xf80,0x3e007c70,0x783c003,0xc001e03c, | |
8426 | 0x1e0,0x3c03c0,0x1e00,0x3c000,0x1e0007,0x80007800,0x780,0x3c7c0000,0x7800001e,0x3878f078,0xf01e03c0,0x780780,0x1e0f000,0x1e078001, | |
8427 | 0xe03e0000,0xf000,0xf0003c0,0x1e007807,0x83f03c00,0x3ef00007,0xcf800000,0x3e00003c,0xf00,0x1e0,0xf80007,0xc0000000,0x0,0x3e01f801, | |
8428 | 0xfe07e001,0xf80f007e,0x7f801f8,0x1f801fff,0xfe00fc0f,0xf007f83f,0x1ffc00,0x7ff000,0x7807c00,0x1e0000f,0x87e1e01f,0xe0fc00fc, | |
8429 | 0xfc007f8,0x1f803f03,0xfc003df0,0x3807e03c,0x1fffff0,0x3c003c0,0x78003e0f,0x1e03,0xe03e00f8,0x3e00ff,0xffe0001e,0xf0,0x780, | |
8430 | 0x0,0x0,0x7800000,0xfe0000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0x1818000,0x7c00000,0x3,0xc00f0000,0xfe00000,0x3e00003,0xf800001f, | |
8431 | 0xc0000007,0xc0003e00,0x1e03c,0x3c0f80,0x0,0x0,0x0,0x70,0x380700fc,0x7800000,0x7c1fe,0x3e000fe0,0xffffe,0x1f3e00,0x0,0x780000, | |
8432 | 0x3f98e000,0xf000003c,0xfcf8007c,0xf800003c,0x3ffc,0x0,0x31c0001,0x80f00f80,0x380700,0x0,0x183,0x80e0c000,0x3f,0xe0000078, | |
8433 | 0x3c0,0x38,0x0,0x3c003c0,0xfffe1c00,0x0,0x0,0x38000078,0xf000e01,0xc003ffe0,0x1fff00,0x7ffc00,0xf000,0xf07800,0x783c000,0x3c1e0001, | |
8434 | 0xe0f0000f,0x7800078,0x3c000f07,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00, | |
8435 | 0x3c0f1e0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0xf801f01e,0xf3c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78007cf8, | |
8436 | 0x1e000f,0x80f0f000,0x7c03f00,0x3e01f801,0xf00fc00f,0x807e007c,0x3f003e0,0x1f80707f,0x8f801f80,0xf003f03f,0x1f81f8,0xfc0fc0, | |
8437 | 0x7e07e00,0x3ff80001,0xffc0000f,0xfe00007f,0xf00003ff,0xfc003fc1,0xf801f81f,0x800fc0fc,0x7e07e0,0x3f03f00,0x1f81f800,0x1f80007, | |
8438 | 0xe07f003c,0x3c01e0,0x1e00f00,0xf007800,0x780f8003,0xe01fe07e,0x3e000f8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8439 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3f,0xfffff078,0x30000ffe,0x1f007c0,0x0,0x1e00, | |
8440 | 0x3c00,0xf9cf80,0x1e0000,0x0,0x0,0x0,0x78001e00,0x3c0001e,0x0,0xf00000fc,0x1e0780,0x3fff800,0x78ffe000,0xf0003,0xe03e00f0, | |
8441 | 0x3e0007,0xe000003f,0x7f,0xe01fffff,0xf00ffc00,0x1f80,0x3c01ff70,0x783c003,0xc007e03c,0x1e0,0x3c03c0,0x1e00,0x3c000,0x1e0007, | |
8442 | 0x80007800,0x780,0x3cfc0000,0x7800001e,0x3c78f078,0xf01e03c0,0x780780,0x3e0f000,0x1e078003,0xc01f0000,0xf000,0xf0003c0,0x1e007807, | |
8443 | 0x83f83c00,0x1ff00003,0xcf000000,0x3e00003c,0xf00,0x1e0,0x0,0x0,0x0,0x20007801,0xfc03e003,0xe003007c,0x3f803e0,0x7c0003c, | |
8444 | 0xf807,0xf007e00f,0x3c00,0xf000,0x780f800,0x1e0000f,0x87e1f01f,0x803c00f8,0x7c007f0,0xf803e01,0xfc003f80,0x80f8004,0x3c000, | |
8445 | 0x3c003c0,0x3c003c0f,0x1e03,0xe03e0078,0x3c0000,0x7c0001e,0xf0,0x780,0x0,0x0,0x3ffff800,0x1ff0000,0x0,0x7800000,0x0,0x18, | |
8446 | 0xc0,0x0,0x1818000,0x3e00000,0x3,0xc00f0000,0x1ff00000,0x3e00007,0xfc00003f,0xe0000003,0xc0003c00,0xf03c,0x3c0f00,0x0,0x0, | |
8447 | 0x0,0x70,0x380701f0,0x800000,0x780fc,0x1e001ff0,0x7c,0xf3c00,0x0,0x780000,0x7e182000,0xf000001f,0xfff00ffc,0xffc0003c,0x3cfe, | |
8448 | 0x0,0x31c0001,0x80f01f80,0x780f00,0x0,0x183,0x80e0c000,0xf,0x80000078,0x780,0x38,0x0,0x3c003c0,0x7ffe1c00,0x0,0x0,0x38000078, | |
8449 | 0xf000f01,0xe003ffe0,0x1fff00,0x7ff800,0xf000,0xf07800,0x783c000,0x3c1e0001,0xe0f0000f,0x78000f8,0x3e000f07,0x8003c000,0x78000, | |
8450 | 0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x3c0f1e0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0, | |
8451 | 0x78000f00,0x7c03e01e,0x1e3c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78003cf0,0x1e0007,0x80f1e000,0x4000f00,0x20007801,0x3c008, | |
8452 | 0x1e0040,0xf00200,0x780403f,0x7803e00,0x3007c00f,0x803e007c,0x1f003e0,0xf801f00,0x780000,0x3c00000,0x1e000000,0xf00007f0, | |
8453 | 0x3e003f00,0x7801f00f,0x800f807c,0x7c03e0,0x3e01f00,0x1f00f800,0x1f80007,0xc03e003c,0x3c01e0,0x1e00f00,0xf007800,0x78078003, | |
8454 | 0xc01fc03e,0x1e000f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8455 | 0x0,0x0,0x0,0x0,0x0,0x780000,0x0,0xf078007c,0x300007fc,0x7e00fe0,0x0,0x1e00,0x3c00,0x3e1c3e0,0x1e0000,0x0,0x0,0x0,0xf0001e00, | |
8456 | 0x3c0001e,0x1,0xf000fff8,0x1e0780,0x3fffe00,0x79fff000,0x1f0001,0xfffc00f0,0x7e0007,0xe000003f,0x3ff,0x801fffff,0xf003ff80, | |
8457 | 0x3f00,0x3c03fff0,0xf01e003,0xffffc03c,0x1e0,0x3c03ff,0xffc01fff,0xfe03c000,0x1fffff,0x80007800,0x780,0x3df80000,0x7800001e, | |
8458 | 0x1c70f078,0x781e03c0,0x780780,0x3c0f000,0x1e078007,0xc01f8000,0xf000,0xf0003c0,0x1e007807,0x83f83c00,0xfe00003,0xff000000, | |
8459 | 0x7c00003c,0x780,0x1e0,0x0,0x0,0x0,0x7c01,0xf801f007,0xc00100f8,0x1f803c0,0x3c0003c,0x1f003,0xf007c00f,0x80003c00,0xf000, | |
8460 | 0x783f000,0x1e0000f,0x3c0f01f,0x3e01f0,0x3e007e0,0x7c07c00,0xfc003f00,0xf0000,0x3c000,0x3c003c0,0x3c003c0f,0x1e01,0xf07c007c, | |
8461 | 0x7c0000,0xfc0001e,0xf0,0x780,0x0,0x0,0x3ffff000,0x3838000,0x0,0x7800000,0x0,0x18,0xc0,0x0,0xff0000,0x3f00000,0x3,0xc00fff00, | |
8462 | 0x38380000,0x7c0000e,0xe000070,0x70000001,0xe0003c00,0xf01e,0x780e00,0x0,0x0,0x0,0x0,0x1e0,0x0,0x780f8,0xf003838,0xfc,0xffc00, | |
8463 | 0x0,0x780000,0x7c180000,0xf000000f,0xffe00fff,0xffc0003c,0x783f,0x80000000,0x6380000,0xc0f83f80,0xf81f00,0x0,0x303,0x80e06000, | |
8464 | 0x0,0x78,0xf00,0x78,0x0,0x3c003c0,0x7ffe1c00,0x0,0x0,0x3800003c,0x3e000f81,0xf003ffe0,0x1fff00,0x1fc000,0xf000,0x1e03c00, | |
8465 | 0xf01e000,0x780f0003,0xc078001e,0x3c000f0,0x1e000f07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,0xfffff00,0xf00000,0x7800000, | |
8466 | 0x3c000001,0xe0001e00,0x3c0f0f0,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x3e07c01e,0x1e3c0f0,0x3c0780,0x1e03c00, | |
8467 | 0xf01e000,0x78003ff0,0x1e0007,0x80f1e000,0xf80,0x7c00,0x3e000,0x1f0000,0xf80000,0x7c0001e,0x3c07c00,0x10078007,0x803c003c, | |
8468 | 0x1e001e0,0xf000f00,0x780000,0x3c00000,0x1e000000,0xf00007c0,0x1e003e00,0x7c03e007,0xc01f003e,0xf801f0,0x7c00f80,0x3e007c00, | |
8469 | 0xf,0x801f003c,0x3c01e0,0x1e00f00,0xf007800,0x7807c007,0xc01f801f,0x1f001f0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8470 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x0,0xe078003c,0x300001f0,0x3f801ff0,0x0, | |
8471 | 0x3c00,0x1e00,0x3c1c1e0,0x1e0000,0x0,0x0,0x0,0xf0001e0f,0x3c0001e,0x3,0xe000fff0,0x3c0780,0x3ffff00,0x7bfff800,0x1e0000,0x7ff00078, | |
8472 | 0x7e0007,0xe000003f,0x1ffc,0x1fffff,0xf0007ff0,0x7e00,0x3c07c3f0,0xf01e003,0xffff003c,0x1e0,0x3c03ff,0xffc01fff,0xfe03c000, | |
8473 | 0x1fffff,0x80007800,0x780,0x3ffc0000,0x7800001e,0x1ef0f078,0x781e03c0,0x780780,0x7c0f000,0x1e07801f,0x800ff000,0xf000,0xf0003c0, | |
8474 | 0xf00f807,0x83b83c00,0xfc00001,0xfe000000,0xf800003c,0x780,0x1e0,0x0,0x0,0x0,0x3c01,0xf000f007,0xc00000f0,0xf80780,0x3c0003c, | |
8475 | 0x1e001,0xf007c007,0x80003c00,0xf000,0x787e000,0x1e0000f,0x3c0f01f,0x1e01e0,0x1e007c0,0x3c07800,0x7c003f00,0xf0000,0x3c000, | |
8476 | 0x3c003c0,0x3e007c07,0x80003c00,0xf8f8003c,0x780000,0xf80001e,0xf0,0x780,0x0,0x0,0x7ffff000,0x601c000,0x3,0xffff0000,0x0, | |
8477 | 0xfff,0xf8007fff,0xc0000000,0x7e003c,0x1fe0000,0xc0003,0xc00fff00,0x601c0000,0xf800018,0x70000c0,0x38000001,0xe0007800,0x701e, | |
8478 | 0x701e00,0x0,0x0,0x0,0x0,0x1e0,0x6,0x700f8,0xf00601c,0xf8,0x7f800,0x0,0x780000,0xf8180000,0xf000000f,0x87c00fff,0xffc0003c, | |
8479 | 0xf01f,0xc0000000,0x6380000,0xc07ff780,0x1f03e03,0xfffffe00,0x303,0x81c06000,0x0,0x1ffff,0xfe001e00,0x180f8,0x0,0x3c003c0, | |
8480 | 0x3ffe1c00,0x3f00000,0x0,0x3800003f,0xfe0007c0,0xf8000000,0x18000000,0xc0000006,0x1f000,0x1e03c00,0xf01e000,0x780f0003,0xc078001e, | |
8481 | 0x3c000f0,0x1e001f07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,0xfffff00,0xf00000,0x7800000,0x3c000001,0xe000fff8,0x3c0f0f0, | |
8482 | 0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x1f0f801e,0x3c3c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78001fe0,0x1e0007, | |
8483 | 0x80f1e000,0x780,0x3c00,0x1e000,0xf0000,0x780000,0x3c0001e,0x3c07c00,0xf0007,0x8078003c,0x3c001e0,0x1e000f00,0x780000,0x3c00000, | |
8484 | 0x1e000000,0xf0000f80,0x1f003e00,0x3c03c003,0xc01e001e,0xf000f0,0x7800780,0x3c003c00,0xf,0x3f003c,0x3c01e0,0x1e00f00,0xf007800, | |
8485 | 0x7803c007,0x801f000f,0xf001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8486 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1,0xe078003f,0xb0000000,0xfc003cf0,0x0,0x3c00,0x1e00,0x101c040,0x1e0000,0x0,0x0,0x1, | |
8487 | 0xe0001e1f,0x83c0001e,0x7,0xe000fff0,0x3c0780,0x3c03f80,0x7fc0fc00,0x1e0000,0xfff80078,0xfe0007,0xe000003f,0x7fe0,0x1fffff, | |
8488 | 0xf0000ffc,0xfc00,0x780f81f0,0xf01e003,0xffff003c,0x1e0,0x3c03ff,0xffc01fff,0xfe03c000,0x1fffff,0x80007800,0x780,0x3ffc0000, | |
8489 | 0x7800001e,0x1ef0f078,0x3c1e03c0,0x780780,0x1fc0f000,0x1e07ffff,0x7ff00,0xf000,0xf0003c0,0xf00f007,0xc3b87c00,0x7c00001,0xfe000000, | |
8490 | 0xf800003c,0x3c0,0x1e0,0x0,0x0,0x0,0x3c01,0xf000f007,0x800000f0,0xf80780,0x1e0003c,0x1e001,0xf0078007,0x80003c00,0xf000,0x78fc000, | |
8491 | 0x1e0000f,0x3c0f01e,0x1e01e0,0x1e007c0,0x3c07800,0x7c003e00,0xf0000,0x3c000,0x3c003c0,0x1e007807,0x80003c00,0x7df0003c,0x780000, | |
8492 | 0x1f00001e,0xf0,0x780,0x0,0x0,0x7800000,0xe7ce000,0x3,0xffff0000,0x0,0xfff,0xf8007fff,0xc0000000,0x1f0,0xffe000,0x1c0003, | |
8493 | 0xc00fff00,0xe7ce0000,0xf800039,0xf38001cf,0x9c000000,0xe0007800,0x780e,0x701c00,0x0,0x0,0x0,0x0,0x1e0,0x7,0xf0078,0xf00e7ce, | |
8494 | 0x1f0,0x7f800,0x0,0x780000,0xf0180000,0xf000000e,0x1c0001f,0xe000003c,0xf007,0xe0000000,0x6380000,0xc03fe780,0x3e07c03,0xfffffe00, | |
8495 | 0x303,0xffc06000,0x0,0x1ffff,0xfe003ffe,0x1fff0,0x0,0x3c003c0,0x1ffe1c00,0x3f00000,0x7,0xffc0001f,0xfc0003e0,0x7c000001,0xfc00000f, | |
8496 | 0xe000007f,0x1e000,0x1e03c00,0xf01e000,0x780f0003,0xc078001e,0x3c000f0,0x1e001e07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0, | |
8497 | 0xfffff00,0xf00000,0x7800000,0x3c000001,0xe000fff8,0x3c0f078,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0xf9f001e, | |
8498 | 0x783c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78001fe0,0x1e0007,0x80f1e000,0x780,0x3c00,0x1e000,0xf0000,0x780000,0x3c0001e,0x3c07800, | |
8499 | 0xf0003,0xc078001e,0x3c000f0,0x1e000780,0x780000,0x3c00000,0x1e000000,0xf0000f00,0xf003c00,0x3c03c003,0xc01e001e,0xf000f0, | |
8500 | 0x7800780,0x3c003c00,0xf,0x7f003c,0x3c01e0,0x1e00f00,0xf007800,0x7803c007,0x801f000f,0xf001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8501 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1,0xe070001f,0xf8000007, | |
8502 | 0xf0007cf8,0x7800000,0x3c00,0x1e00,0x1c000,0x1e0000,0x0,0x0,0x1,0xe0001e1f,0x83c0001e,0xf,0xc000fff8,0x780780,0x2000f80,0x7f803e00, | |
8503 | 0x3e0003,0xfffe007c,0x1fe0000,0x0,0x3ff00,0x0,0x1ff,0x8001f000,0x780f00f0,0x1f00f003,0xffffc03c,0x1e0,0x3c03ff,0xffc01fff, | |
8504 | 0xfe03c00f,0xf81fffff,0x80007800,0x780,0x3ffe0000,0x7800001e,0xee0f078,0x3c1e03c0,0x7807ff,0xff80f000,0x1e07fffe,0x3ffe0, | |
8505 | 0xf000,0xf0003c0,0xf00f003,0xc7bc7800,0xfc00000,0xfc000001,0xf000003c,0x3c0,0x1e0,0x0,0x0,0x0,0x3c01,0xe000f80f,0x800001e0, | |
8506 | 0xf80f00,0x1e0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x79f8000,0x1e0000f,0x3c0f01e,0x1e03c0,0x1f00780,0x3e0f000,0x7c003e00, | |
8507 | 0xf0000,0x3c000,0x3c003c0,0x1e007807,0x81e03c00,0x7df0003e,0xf80000,0x3e00003e,0xf0,0x7c0,0xfc000,0x80000000,0x7800000,0x1e7cf000, | |
8508 | 0x3,0xffff0000,0x0,0x18,0xc0,0x0,0xf80,0x7ffc00,0x380003,0xc00fff01,0xe7cf0000,0x1f000079,0xf3c003cf,0x9e000000,0xe0007000, | |
8509 | 0x380e,0xe01c00,0x0,0x0,0x0,0x0,0x1e0,0x3,0x800f0078,0xf01e7cf,0x3e0,0x3f000,0x0,0x780000,0xf018001f,0xfff8001e,0x1e0000f, | |
8510 | 0xc000003c,0xf003,0xe0000000,0x6380000,0xc00fc780,0x7c0f803,0xfffffe00,0x303,0xfe006000,0x0,0x1ffff,0xfe003ffe,0x1ffe0,0x0, | |
8511 | 0x3c003c0,0xffe1c00,0x3f00000,0x7,0xffc00007,0xf00001f0,0x3e00001f,0xfc0000ff,0xe00007ff,0x3e000,0x3e01e00,0x1f00f000,0xf8078007, | |
8512 | 0xc03c003e,0x1e001e0,0xf001e07,0xff83c000,0x7ffff,0x803ffffc,0x1ffffe0,0xfffff00,0xf00000,0x7800000,0x3c000001,0xe000fff8, | |
8513 | 0x3c0f078,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x7fe001e,0xf03c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78000fc0, | |
8514 | 0x1e0007,0x80f1f000,0x780,0x3c00,0x1e000,0xf0000,0x780000,0x3c0001e,0x3c0f800,0x1e0003,0xc0f0001e,0x78000f0,0x3c000780,0x780000, | |
8515 | 0x3c00000,0x1e000000,0xf0000f00,0xf003c00,0x3c078003,0xe03c001f,0x1e000f8,0xf0007c0,0x78003e00,0x1e,0xf7803c,0x3c01e0,0x1e00f00, | |
8516 | 0xf007800,0x7803e00f,0x801e000f,0x80f803e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8517 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1,0xe0f0000f,0xff00001f,0x8000f87c,0x7800000,0x3c00,0x1e00,0x1c000,0x7fffff80, | |
8518 | 0x0,0x0,0x3,0xc0001e1f,0x83c0001e,0x1f,0x800000fe,0xf00780,0x7c0,0x7f001e00,0x3c0007,0xe03f003f,0x3fe0000,0x0,0x3fc00,0x0, | |
8519 | 0x7f,0x8001e000,0x781f00f0,0x1e00f003,0xc007e03c,0x1e0,0x3c03c0,0x1e00,0x3c00f,0xf81e0007,0x80007800,0x780,0x3f9f0000,0x7800001e, | |
8520 | 0xfe0f078,0x3c1e03c0,0x7807ff,0xff00f000,0x1e07fff8,0xfff8,0xf000,0xf0003c0,0xf81f003,0xc7bc7800,0xfe00000,0x78000003,0xe000003c, | |
8521 | 0x1e0,0x1e0,0x0,0x0,0x0,0x1fffc01,0xe000780f,0x1e0,0x780f00,0x1e0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x7bf0000,0x1e0000f, | |
8522 | 0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0xf8000,0x3c000,0x3c003c0,0x1f00f807,0x81f03c00,0x3fe0001e,0xf00000,0x7c00007c, | |
8523 | 0xf0,0x3e0,0x3ff801,0x80000000,0x7800000,0x3cfcf800,0x3,0xffff0000,0x0,0x18,0xc0,0x0,0x7c00,0x1fff00,0x700003,0xc00f0003, | |
8524 | 0xcfcf8000,0x3e0000f3,0xf3e0079f,0x9f000000,0xf000,0x1000,0x0,0x0,0x0,0x0,0x0,0x1f0,0x1,0xc00f0078,0xf03cfcf,0x800007c0,0x1e000, | |
8525 | 0x0,0x780001,0xe018001f,0xfff8001c,0xe00007,0x8000003c,0xf001,0xf0000000,0x6380000,0xc0000000,0xf81f003,0xfffffe00,0x303, | |
8526 | 0x87006000,0x0,0x1ffff,0xfe003ffe,0x7f00,0x0,0x3c003c0,0x3fe1c00,0x3f00000,0x7,0xffc00000,0xf8,0x1f0001ff,0xf0000fff,0x80007ffc, | |
8527 | 0xfc000,0x3c01e00,0x1e00f000,0xf0078007,0x803c003c,0x1e001e0,0xf001e07,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000, | |
8528 | 0x7800000,0x3c000001,0xe000fff8,0x3c0f078,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x3fc001e,0x1e03c0f0,0x3c0780, | |
8529 | 0x1e03c00,0xf01e000,0x78000780,0x1e0007,0x80f0fc00,0x3fff80,0x1fffc00,0xfffe000,0x7fff0003,0xfff8001f,0xffc0001e,0x3c0f000, | |
8530 | 0x1e0003,0xc0f0001e,0x78000f0,0x3c000780,0x780000,0x3c00000,0x1e000000,0xf0001e00,0xf803c00,0x3c078001,0xe03c000f,0x1e00078, | |
8531 | 0xf0003c0,0x78001e07,0xfffffe1e,0x1e7803c,0x3c01e0,0x1e00f00,0xf007800,0x7801e00f,0x1e0007,0x807803c0,0x0,0x0,0x0,0x0,0x0, | |
8532 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x3,0xc0f00007, | |
8533 | 0xffc0007e,0xf03e,0x7800000,0x3c00,0x1e00,0x1c000,0x7fffff80,0x0,0x0,0x3,0xc0001e1f,0x83c0001e,0x3f,0x3e,0xf00780,0x3c0,0x7e001e00, | |
8534 | 0x7c000f,0x800f001f,0xffde0000,0x0,0x3e000,0x0,0xf,0x8003e000,0x781e0070,0x1e00f003,0xc001f03c,0x1e0,0x3c03c0,0x1e00,0x3c00f, | |
8535 | 0xf81e0007,0x80007800,0x780,0x3f1f0000,0x7800001e,0x7c0f078,0x1e1e03c0,0x7807ff,0xfc00f000,0x1e07fffe,0xffc,0xf000,0xf0003c0, | |
8536 | 0x781e003,0xc71c7800,0x1ff00000,0x78000003,0xe000003c,0x1e0,0x1e0,0x0,0x0,0x0,0xffffc01,0xe000780f,0x1e0,0x780fff,0xffe0003c, | |
8537 | 0x3c000,0xf0078007,0x80003c00,0xf000,0x7ff0000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x7f000,0x3c000, | |
8538 | 0x3c003c0,0xf00f007,0xc1f07c00,0x1fc0001f,0x1f00000,0xfc000ff8,0xf0,0x1ff,0xfffe07,0x80000000,0x7800000,0x7ffcfc00,0x0,0xf000000, | |
8539 | 0x0,0x18,0xc0,0x0,0x3e000,0x1ff80,0xe00003,0xc00f0007,0xffcfc000,0x3e0001ff,0xf3f00fff,0x9f800000,0x6000,0x0,0x0,0x7c000, | |
8540 | 0x0,0x0,0x0,0xfe,0x0,0xe00f007f,0xff07ffcf,0xc0000fc0,0x1e000,0x0,0x780001,0xe018001f,0xfff8001c,0xe00007,0x80000000,0xf800, | |
8541 | 0xf0000000,0x6380000,0xc0000000,0x1f03c000,0x1e00,0x303,0x83806000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xfe1c00,0x3f00000,0x0, | |
8542 | 0x0,0x3c,0xf801fff,0xfff8,0x7ffc0,0x1f8000,0x3c01e00,0x1e00f000,0xf0078007,0x803c003c,0x1e001e0,0xf003c07,0x8003c000,0x78000, | |
8543 | 0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x3c0f03c,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0, | |
8544 | 0x78000f00,0x1f8001e,0x1e03c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e000f,0x80f0ff00,0x1ffff80,0xffffc00,0x7fffe003, | |
8545 | 0xffff001f,0xfff800ff,0xffc007ff,0xffc0f000,0x1fffff,0xc0fffffe,0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,0xf0001e00, | |
8546 | 0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e07,0xfffffe1e,0x3c7803c,0x3c01e0,0x1e00f00,0xf007800,0x7801f01f, | |
8547 | 0x1e0007,0x807c07c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8548 | 0x0,0x0,0x0,0x0,0x780000,0x3,0xc0f00000,0xfff003f0,0x1f00f03e,0x7800000,0x3c00,0x1e00,0x1c000,0x7fffff80,0x0,0x7ff80000,0x3, | |
8549 | 0xc0001e0f,0x3c0001e,0x7e,0x1f,0x1e00780,0x3e0,0x7e000f00,0x78000f,0x7800f,0xff9e0000,0x0,0x3fc00,0x0,0x7f,0x8003c000,0x781e0070, | |
8550 | 0x3e00f803,0xc000f03c,0x1e0,0x3c03c0,0x1e00,0x3c00f,0xf81e0007,0x80007800,0x780,0x3e0f8000,0x7800001e,0x7c0f078,0x1e1e03c0, | |
8551 | 0x7807ff,0xf000f000,0x1e07807f,0xfe,0xf000,0xf0003c0,0x781e003,0xc71c7800,0x3ef00000,0x78000007,0xc000003c,0x1e0,0x1e0,0x0, | |
8552 | 0x0,0x0,0x1ffffc01,0xe000780f,0x1e0,0x780fff,0xffe0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x7ff0000,0x1e0000f,0x3c0f01e, | |
8553 | 0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x7ff80,0x3c000,0x3c003c0,0xf00f003,0xc1f07800,0x1fc0000f,0x1e00000,0xf8000ff0,0xf0, | |
8554 | 0xff,0xffffff,0x80000000,0x3fffc000,0xfff9fe00,0x0,0xf000000,0x0,0x18,0xc0,0x0,0x1f0000,0x1fc0,0x1c00003,0xc00f000f,0xff9fe000, | |
8555 | 0x7c0003ff,0xe7f81fff,0x3fc00000,0x0,0x0,0x0,0xfe000,0x1ffffc0f,0xfffffc00,0x0,0xff,0xf0000000,0x700f007f,0xff0fff9f,0xe0000f80, | |
8556 | 0x1e000,0x0,0x780001,0xe018001f,0xfff8001c,0xe00fff,0xffc00000,0xf800,0xf0000000,0x6380000,0xc0ffff80,0x3e078000,0x1e00,0x7ff80303, | |
8557 | 0x83c06000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x3f00000,0x0,0x7f,0xff00001e,0x7c1fff0,0xfff80,0x7ffc00,0x3f0000,0x7c01f00, | |
8558 | 0x3e00f801,0xf007c00f,0x803e007c,0x1f003e0,0xf803c07,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001, | |
8559 | 0xe0001e00,0x3c0f03c,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x1f8001e,0x3c03c0f0,0x3c0780,0x1e03c00,0xf01e000, | |
8560 | 0x78000780,0x1e001f,0xf07f80,0x3ffff80,0x1ffffc00,0xffffe007,0xffff003f,0xfff801ff,0xffc03fff,0xffc0f000,0x1fffff,0xc0fffffe, | |
8561 | 0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e07, | |
8562 | 0xfffffe1e,0x787803c,0x3c01e0,0x1e00f00,0xf007800,0x7800f01e,0x1e0007,0x803c0780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8563 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1ff,0xffff8000,0x3ff80fc0,0x7fc1e01f, | |
8564 | 0x7800000,0x3c00,0x1e00,0x0,0x7fffff80,0x0,0x7ff80000,0x7,0x80001e00,0x3c0001e,0xfc,0xf,0x1e00780,0x1e0,0x7c000f00,0x78000f, | |
8565 | 0x78007,0xff1e0000,0x0,0x3ff00,0x0,0x1ff,0x8003c000,0x781e0070,0x3c007803,0xc000f03c,0x1e0,0x3c03c0,0x1e00,0x3c000,0x781e0007, | |
8566 | 0x80007800,0x780,0x3c07c000,0x7800001e,0x7c0f078,0xf1e03c0,0x780780,0xf000,0x1e07801f,0x3e,0xf000,0xf0003c0,0x781e003,0xcf1c7800, | |
8567 | 0x3cf80000,0x7800000f,0x8000003c,0xf0,0x1e0,0x0,0x0,0x0,0x3ffffc01,0xe000780f,0x1e0,0x780fff,0xffe0003c,0x3c000,0xf0078007, | |
8568 | 0x80003c00,0xf000,0x7ff8000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x3fff0,0x3c000,0x3c003c0,0xf81f003, | |
8569 | 0xc3b87800,0xf80000f,0x1e00001,0xf0000ff0,0xf0,0xff,0xf03fff,0x80000000,0x3fff8001,0xfff1ff00,0x0,0xf000000,0x0,0x18,0xc0, | |
8570 | 0x0,0x380000,0x7c0,0x3c00003,0xc00f001f,0xff1ff000,0xf80007ff,0xc7fc3ffe,0x3fe00000,0x0,0x0,0x0,0x1ff000,0x7ffffe1f,0xffffff00, | |
8571 | 0x0,0x7f,0xfe000000,0x780f007f,0xff1fff1f,0xf0001f00,0x1e000,0x0,0x780001,0xe0180000,0xf000001c,0xe00fff,0xffc00000,0x7c00, | |
8572 | 0xf0000000,0x31c0001,0x80ffff80,0x3e078000,0x1e00,0x7ff80183,0x81c0c000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x3f00000, | |
8573 | 0x0,0x7f,0xff00001e,0x7c7ff03,0xc03ff8fe,0x1ffc0f0,0x7e0000,0x7800f00,0x3c007801,0xe003c00f,0x1e0078,0xf003c0,0x7803c07,0x8003c000, | |
8574 | 0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x3c0f01e,0x3c078000,0xf03c0007,0x81e0003c, | |
8575 | 0xf0001e0,0x78000f00,0x3fc001e,0x7803c0f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e007f,0xf03fe0,0x7ffff80,0x3ffffc01, | |
8576 | 0xffffe00f,0xffff007f,0xfff803ff,0xffc07fff,0xffc0f000,0x1fffff,0xc0fffffe,0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000, | |
8577 | 0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e07,0xfffffe1e,0x707803c,0x3c01e0,0x1e00f00,0xf007800, | |
8578 | 0x7800f01e,0x1e0007,0x803c0780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8579 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1ff,0xffff8000,0x30f81f00,0xffe1e00f,0x87800000,0x3c00,0x1e00,0x0,0x1e0000,0x0,0x7ff80000, | |
8580 | 0x7,0x80001e00,0x3c0001e,0x1f8,0x7,0x83c00780,0x1e0,0x7c000f00,0xf8001e,0x3c001,0xfc1e0000,0x0,0x7fe0,0x0,0xffc,0x3c000,0x781e0070, | |
8581 | 0x3ffff803,0xc000783c,0x1e0,0x3c03c0,0x1e00,0x3c000,0x781e0007,0x80007800,0x780,0x3c07c000,0x7800001e,0x380f078,0xf1e03c0, | |
8582 | 0x780780,0xf000,0x1e07800f,0x8000001e,0xf000,0xf0003c0,0x3c3c003,0xcf1e7800,0x7c780000,0x7800000f,0x8000003c,0xf0,0x1e0,0x0, | |
8583 | 0x0,0x0,0x7f003c01,0xe000780f,0x1e0,0x780fff,0xffe0003c,0x3c000,0xf0078007,0x80003c00,0xf000,0x7f7c000,0x1e0000f,0x3c0f01e, | |
8584 | 0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0xfff8,0x3c000,0x3c003c0,0x781e003,0xc3b87800,0x1fc00007,0x83e00003,0xe0000ff8,0xf0, | |
8585 | 0x1ff,0xc007fe,0x0,0x7fff8001,0xffe3ff00,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x0,0x3c0,0x7800003,0xc00f001f,0xfe3ff000,0xf80007ff, | |
8586 | 0x8ffc3ffc,0x7fe00000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x1f,0xff000000,0x3c0f007f,0xff1ffe3f,0xf0003e00,0x1e000,0x0,0x780001, | |
8587 | 0xe0180000,0xf000001e,0x1e00fff,0xffc00000,0x3f00,0xf0000000,0x31c0001,0x80ffff80,0x1f03c000,0x1e00,0x7ff80183,0x81c0c000, | |
8588 | 0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x7f,0xff00003c,0xf87f007,0xc03f83ff,0x81fc01f0,0x7c0000,0x7ffff00,0x3ffff801, | |
8589 | 0xffffc00f,0xfffe007f,0xfff003ff,0xff807fff,0x8003c000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001, | |
8590 | 0xe0001e00,0x3c0f01e,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0x7fe001e,0xf003c0f0,0x3c0780,0x1e03c00,0xf01e000, | |
8591 | 0x78000780,0x1ffffe,0xf00ff0,0xfe00780,0x7f003c03,0xf801e01f,0xc00f00fe,0x7807f0,0x3c0ffff,0xffc0f000,0x1fffff,0xc0fffffe, | |
8592 | 0x7fffff0,0x3fffff80,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00, | |
8593 | 0x1e,0xf07803c,0x3c01e0,0x1e00f00,0xf007800,0x7800783e,0x1e0007,0x801e0f80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8594 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1ff,0xffff8000,0x307c0801,0xe1f1e00f,0x87000000, | |
8595 | 0x3c00,0x1e00,0x0,0x1e0000,0x0,0x7ff80000,0xf,0x1e00,0x3c0001e,0x3f0,0x7,0x83fffffc,0x1e0,0x7c000f00,0xf0001e,0x3c000,0x3e0000, | |
8596 | 0x0,0x1ffc,0x1fffff,0xf0007ff0,0x3c000,0x781e0070,0x7ffffc03,0xc000781e,0x1e0,0x7803c0,0x1e00,0x3c000,0x781e0007,0x80007800, | |
8597 | 0x780,0x3c03e000,0x7800001e,0xf078,0x79e03c0,0x780780,0xf000,0x1e078007,0x8000000f,0xf000,0xf0003c0,0x3c3c001,0xee0ef000, | |
8598 | 0xf87c0000,0x7800001f,0x3c,0x78,0x1e0,0x0,0x0,0x0,0x7c003c01,0xe000780f,0x1e0,0x780f00,0x3c,0x3c000,0xf0078007,0x80003c00, | |
8599 | 0xf000,0x7e3e000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x1ffc,0x3c000,0x3c003c0,0x781e003,0xe3b8f800, | |
8600 | 0x1fc00007,0x83c00007,0xc00000fc,0xf0,0x3e0,0x8001f8,0x0,0x7800000,0xffc7fe00,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x0,0x1e0, | |
8601 | 0xf000003,0xc00f000f,0xfc7fe001,0xf00003ff,0x1ff81ff8,0xffc00000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x3,0xff800000,0x1e0f0078, | |
8602 | 0xffc7f,0xe0007c00,0x1e000,0x0,0x780001,0xe0180000,0xf000000e,0x1c00007,0x80000000,0x1f81,0xe0000000,0x38e0003,0x80000000, | |
8603 | 0xf81f000,0x1e00,0x7ff801c3,0x80e1c000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0xf8,0x1f070007,0xc03803ff,0xc1c001f0, | |
8604 | 0xf80000,0xfffff00,0x7ffff803,0xffffc01f,0xfffe00ff,0xfff007ff,0xffc07fff,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000, | |
8605 | 0xf00000,0x7800000,0x3c000001,0xe0001e00,0x780f00f,0x3c078000,0xf03c0007,0x81e0003c,0xf0001e0,0x78000f00,0xf9f001e,0xf003c0f0, | |
8606 | 0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1ffffc,0xf003f8,0xf800780,0x7c003c03,0xe001e01f,0xf00f8,0x7807c0,0x3c0fc1e,0xf000, | |
8607 | 0x1e0000,0xf00000,0x7800000,0x3c000000,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078, | |
8608 | 0xf0003c0,0x78001e00,0x1e,0x1e07803c,0x3c01e0,0x1e00f00,0xf007800,0x7800783c,0x1e0007,0x801e0f00,0x0,0x0,0x0,0x0,0x0,0x0, | |
8609 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0xffff8000,0x303c0001, | |
8610 | 0xc071e007,0xcf000000,0x3c00,0x1e00,0x0,0x1e0000,0x0,0x0,0xf,0xf00,0x780001e,0x7e0,0x7,0x83fffffc,0x1e0,0x7c000f00,0x1f0001e, | |
8611 | 0x3c000,0x3c0000,0x0,0x3ff,0x801fffff,0xf003ff80,0x3c000,0x781e0070,0x7ffffc03,0xc000781e,0x1e0,0x7803c0,0x1e00,0x1e000,0x781e0007, | |
8612 | 0x80007800,0x780,0x3c01f000,0x7800001e,0xf078,0x79e03c0,0xf00780,0xf000,0x3e078007,0xc000000f,0xf000,0xf0003c0,0x3c3c001, | |
8613 | 0xee0ef000,0xf03e0000,0x7800003e,0x3c,0x78,0x1e0,0x0,0x0,0x0,0xf8003c01,0xe000780f,0x1e0,0x780f00,0x3c,0x3c000,0xf0078007, | |
8614 | 0x80003c00,0xf000,0x7c3e000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0xfc,0x3c000,0x3c003c0,0x3c3e001,0xe7b8f000, | |
8615 | 0x3fe00007,0xc7c0000f,0xc000003e,0xf0,0x7c0,0x0,0x0,0x7c00000,0x7fcffc00,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x0,0x1e0,0x1e000003, | |
8616 | 0xc00f0007,0xfcffc003,0xe00001ff,0x3ff00ff9,0xff800000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x0,0x1f800000,0xf0f0078,0x7fcff, | |
8617 | 0xc000fc00,0x1e000,0x0,0x780001,0xe0180000,0xf000000f,0x87c00007,0x80000000,0xfe3,0xe0000000,0x18780c3,0x0,0x7c0f800,0x1e00, | |
8618 | 0xc3,0x80e18000,0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0x1f0,0x3e00000f,0xc0000303,0xe00003f0,0xf00000,0xfffff80, | |
8619 | 0x7ffffc03,0xffffe01f,0xffff00ff,0xfff807ff,0xffc07fff,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000, | |
8620 | 0x3c000001,0xe0001e00,0x780f00f,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00,0x1f0f801f,0xe00780f0,0x3c0780,0x1e03c00, | |
8621 | 0xf01e000,0x78000780,0x1ffff8,0xf000f8,0x1f000780,0xf8003c07,0xc001e03e,0xf01f0,0x780f80,0x3c1f01e,0xf000,0x1e0000,0xf00000, | |
8622 | 0x7800000,0x3c000000,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00, | |
8623 | 0x1e,0x3c07803c,0x3c01e0,0x1e00f00,0xf007800,0x78007c7c,0x1e0007,0x801f1f00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8624 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x81c00000,0x303c0003,0x8039e003,0xef000000, | |
8625 | 0x3c00,0x1e00,0x0,0x1e0000,0x0,0x0,0x1e,0xf00,0x780001e,0xfc0,0x7,0x83fffffc,0x1e0,0x3c000f00,0x1e0001e,0x3c000,0x3c0000, | |
8626 | 0x0,0x7f,0xe01fffff,0xf00ffc00,0x3c000,0x781f00f0,0x7ffffc03,0xc000781e,0x1e0,0x7803c0,0x1e00,0x1e000,0x781e0007,0x80007800, | |
8627 | 0x780,0x3c01f000,0x7800001e,0xf078,0x7de01e0,0xf00780,0x7800,0x3c078003,0xc000000f,0xf000,0xf0003c0,0x3e7c001,0xee0ef001, | |
8628 | 0xf01e0000,0x7800003e,0x3c,0x3c,0x1e0,0x0,0x0,0x0,0xf0003c01,0xe000780f,0x1e0,0x780f00,0x3c,0x3c000,0xf0078007,0x80003c00, | |
8629 | 0xf000,0x781f000,0x1e0000f,0x3c0f01e,0x1e03c0,0xf00780,0x1e0f000,0x3c003c00,0x3e,0x3c000,0x3c003c0,0x3c3c001,0xe71cf000,0x7df00003, | |
8630 | 0xc780000f,0x8000003e,0xf0,0x780,0x0,0x0,0x3c00000,0x3fcff800,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x1f00fc,0x1e0,0x1e000001, | |
8631 | 0xe00f0003,0xfcff8003,0xe00000ff,0x3fe007f9,0xff000000,0x0,0x0,0x0,0x1ff000,0x0,0x0,0x0,0x0,0x7c00000,0xf0f0078,0x3fcff,0x8000f800, | |
8632 | 0x1e000,0x0,0x780001,0xe0180000,0xf000001f,0xffe00007,0x8000003c,0x7ff,0xc0000000,0x1c3ffc7,0x0,0x3e07c00,0x1e00,0xe3,0x80738000, | |
8633 | 0x0,0x78,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0x3e0,0x7c00001d,0xc0000001,0xe0000770,0x1f00000,0xfffff80,0x7ffffc03, | |
8634 | 0xffffe01f,0xffff00ff,0xfff807ff,0xffc07fff,0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001, | |
8635 | 0xe0001e00,0x780f00f,0x3c03c001,0xe01e000f,0xf00078,0x78003c0,0x3c001e00,0x3e07c01f,0xc00780f0,0x3c0780,0x1e03c00,0xf01e000, | |
8636 | 0x78000780,0x1fffc0,0xf0007c,0x1e000780,0xf0003c07,0x8001e03c,0xf01e0,0x780f00,0x3c1e01e,0xf000,0x1e0000,0xf00000,0x7800000, | |
8637 | 0x3c000000,0x780000,0x3c00000,0x1e000000,0xf0001e00,0x7803c00,0x3c078001,0xe03c000f,0x1e00078,0xf0003c0,0x78001e00,0x1e,0x7807803c, | |
8638 | 0x3c01e0,0x1e00f00,0xf007800,0x78003c78,0x1e0007,0x800f1e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8639 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x83c00000,0x303c0003,0x8039e001,0xee000000,0x1e00,0x3c00, | |
8640 | 0x0,0x1e0000,0x0,0x0,0x1e,0xf00,0x780001e,0x1f80,0x7,0x83fffffc,0x1e0,0x3c000f00,0x1e0001e,0x3c000,0x3c0000,0x0,0x1f,0xfc1fffff, | |
8641 | 0xf07ff000,0x0,0x780f00f0,0x78003c03,0xc000781e,0x1e0,0xf803c0,0x1e00,0x1e000,0x781e0007,0x80007800,0x780,0x3c00f800,0x7800001e, | |
8642 | 0xf078,0x3de01e0,0xf00780,0x7800,0x3c078003,0xe000000f,0xf000,0xf0003c0,0x1e78001,0xfe0ff003,0xe01f0000,0x7800007c,0x3c,0x3c, | |
8643 | 0x1e0,0x0,0x0,0x0,0xf0007c01,0xe000f80f,0x800001e0,0xf80f00,0x3c,0x1e001,0xf0078007,0x80003c00,0xf000,0x780f800,0x1e0000f, | |
8644 | 0x3c0f01e,0x1e03c0,0x1f00780,0x3e0f000,0x7c003c00,0x1e,0x3c000,0x3c003c0,0x3c3c001,0xe71cf000,0xf8f80003,0xe780001f,0x1e, | |
8645 | 0xf0,0x780,0x0,0x0,0x3c00000,0x1ffff000,0x0,0x1e000000,0x0,0x18,0xc0,0x0,0x3bc1de,0x1e0,0xf000001,0xe00f0001,0xffff0007,0xc000007f, | |
8646 | 0xffc003ff,0xfe000000,0x0,0x0,0x0,0xfe000,0x0,0x0,0x0,0x0,0x3c00000,0x1e0f0078,0x1ffff,0x1f000,0x1e000,0x0,0x780000,0xf0180000, | |
8647 | 0xf000001f,0xfff00007,0x8000003c,0x1ff,0x80000000,0xe0ff0e,0x0,0x1f03e00,0x1e00,0x70,0x70000,0x0,0x78,0x0,0x0,0x0,0x3c003c0, | |
8648 | 0xe1c00,0x0,0x0,0x0,0x7c0,0xf8000019,0xc0000000,0xe0000670,0x1e00000,0xf000780,0x78003c03,0xc001e01e,0xf00f0,0x780780,0x3c0f807, | |
8649 | 0x8001e000,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0xf80f007,0xbc03c001,0xe01e000f, | |
8650 | 0xf00078,0x78003c0,0x3c001e00,0x7c03e00f,0x800780f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e0000,0xf0003c,0x1e000f80, | |
8651 | 0xf0007c07,0x8003e03c,0x1f01e0,0xf80f00,0x7c1e01e,0xf800,0x1e0000,0xf00000,0x7800000,0x3c000000,0x780000,0x3c00000,0x1e000000, | |
8652 | 0xf0001e00,0x7803c00,0x3c078003,0xe03c001f,0x1e000f8,0xf0007c0,0x78003e00,0x1f8001f,0xf00f803c,0x3c01e0,0x1e00f00,0xf007800, | |
8653 | 0x78003e78,0x1e000f,0x800f9e00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8654 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0x3c00000,0x303c0003,0x8039f001,0xfe000000,0x1e00,0x3c00,0x0,0x1e0000,0x0,0x0,0x3c,0xf00, | |
8655 | 0x780001e,0x3f00,0x7,0x80000780,0x3e0,0x3e000f00,0x3c0001e,0x3c000,0x7c0000,0x0,0x3,0xfe000000,0xff8000,0x0,0x3c0f81f0,0xf0001e03, | |
8656 | 0xc000780f,0x1e0,0xf003c0,0x1e00,0xf000,0x781e0007,0x80007800,0x780,0x3c007c00,0x7800001e,0xf078,0x3de01e0,0xf00780,0x7800, | |
8657 | 0x3c078001,0xe000000f,0xf000,0xf0003c0,0x1e78001,0xfc07f003,0xe00f0000,0x78000078,0x3c,0x1e,0x1e0,0x0,0x0,0x0,0xf0007c01, | |
8658 | 0xf000f007,0x800000f0,0xf80780,0x3c,0x1e001,0xf0078007,0x80003c00,0xf000,0x7807c00,0x1e0000f,0x3c0f01e,0x1e01e0,0x1e007c0, | |
8659 | 0x3c07800,0x7c003c00,0x1e,0x3c000,0x3c007c0,0x1e78001,0xe71df000,0xf8f80001,0xef80003e,0x1e,0xf0,0x780,0x0,0x0,0x3c00000, | |
8660 | 0xfffe000,0x0,0x3e000000,0x0,0x18,0x7fff,0xc0000000,0x60c306,0x1e0,0x7800001,0xe00f0000,0xfffe0007,0x8000003f,0xff8001ff, | |
8661 | 0xfc000000,0x0,0x0,0x0,0x7c000,0x0,0x0,0x0,0x0,0x3c00000,0x3c0f0078,0xfffe,0x3e000,0x1e000,0x0,0x780000,0xf0180000,0xf000003c, | |
8662 | 0xfcf80007,0x8000003c,0x7f,0x0,0x70001c,0x0,0xf81f00,0x0,0x38,0xe0000,0x0,0x0,0x0,0x0,0x0,0x3c003c0,0xe1c00,0x0,0x0,0x0,0xf81, | |
8663 | 0xf0000039,0xc0000000,0xe0000e70,0x1e00000,0x1e0003c0,0xf0001e07,0x8000f03c,0x781e0,0x3c0f00,0x1e0f007,0x8000f000,0x78000, | |
8664 | 0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0xf00f007,0xbc03c001,0xe01e000f,0xf00078,0x78003c0, | |
8665 | 0x3c001e00,0xf801f00f,0x800780f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e0000,0xf0003c,0x1e000f80,0xf0007c07,0x8003e03c, | |
8666 | 0x1f01e0,0xf80f00,0x7c1e01e,0x7800,0xf0000,0x780000,0x3c00000,0x1e000000,0x780000,0x3c00000,0x1e000000,0xf0000f00,0xf003c00, | |
8667 | 0x3c03c003,0xc01e001e,0xf000f0,0x7800780,0x3c003c00,0x1f8000f,0xe00f003c,0x7c01e0,0x3e00f00,0x1f007800,0xf8001ef8,0x1f000f, | |
8668 | 0x7be00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8669 | 0x0,0x0,0xf,0x3c00000,0x307c0003,0x8038f000,0xfc000000,0x1e00,0x3c00,0x0,0x1e0000,0xfc0000,0x0,0x7e00003c,0x780,0xf00001e, | |
8670 | 0x7e00,0xf,0x80000780,0x3c0,0x3e001e00,0x3c0001f,0x7c000,0x780007,0xe000003f,0x0,0xfe000000,0xfe0000,0x0,0x3c07c3f0,0xf0001e03, | |
8671 | 0xc000f80f,0x800001e0,0x1f003c0,0x1e00,0xf000,0x781e0007,0x80007800,0x4000f80,0x3c003c00,0x7800001e,0xf078,0x1fe01f0,0x1f00780, | |
8672 | 0x7c00,0x7c078001,0xf000001f,0xf000,0xf0003c0,0x1e78001,0xfc07f007,0xc00f8000,0x780000f8,0x3c,0x1e,0x1e0,0x0,0x0,0x0,0xf0007c01, | |
8673 | 0xf000f007,0xc00000f0,0xf80780,0x3c,0x1f003,0xf0078007,0x80003c00,0xf000,0x7807c00,0x1e0000f,0x3c0f01e,0x1e01e0,0x1e007c0, | |
8674 | 0x3c07800,0x7c003c00,0x1e,0x3c000,0x3c007c0,0x1e78000,0xfe0fe001,0xf07c0001,0xef00007c,0x1e,0xf0,0x780,0x0,0x0,0x1e00000, | |
8675 | 0x7cfc000,0xfc00000,0x3c00000f,0xc3f00000,0x18,0x7fff,0xc0000000,0x406303,0x3e0,0x3c00001,0xf00f0000,0x7cfc000f,0x8000001f, | |
8676 | 0x3f0000f9,0xf8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x780700f8,0x7cfc,0x7c000,0x1e000,0x0,0x780000,0xf8180000, | |
8677 | 0xf0000070,0x3c0007,0x8000003c,0x3f,0x80000000,0x3c0078,0x0,0x780f00,0x0,0x1e,0x3c0000,0x0,0x0,0x0,0x0,0x0,0x3e007c0,0xe1c00, | |
8678 | 0x0,0x0,0x0,0xf01,0xe0000071,0xc0000000,0xe0001c70,0x1e00000,0x1e0003c0,0xf0001e07,0x8000f03c,0x781e0,0x3c0f00,0x1e0f007, | |
8679 | 0x8000f800,0x78000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x1f00f003,0xfc03e003,0xe01f001f, | |
8680 | 0xf800f8,0x7c007c0,0x3e003e01,0xf000f80f,0xf00f0,0x3c0780,0x1e03c00,0xf01e000,0x78000780,0x1e0000,0xf0003c,0x1e000f80,0xf0007c07, | |
8681 | 0x8003e03c,0x1f01e0,0xf80f00,0x7c1e01e,0x7c00,0xf0000,0x780000,0x3c00000,0x1e000000,0x780000,0x3c00000,0x1e000000,0xf0000f00, | |
8682 | 0xf003c00,0x3c03c003,0xc01e001e,0xf000f0,0x7800780,0x3c003c00,0x1f8000f,0xc00f003c,0x7c01e0,0x3e00f00,0x1f007800,0xf8001ef0, | |
8683 | 0x1f000f,0x7bc00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8684 | 0x0,0x0,0x0,0x0,0x780000,0xf,0x3800040,0x30780003,0x8038f800,0x78000000,0x1e00,0x3c00,0x0,0x1e0000,0xfc0000,0x0,0x7e000078, | |
8685 | 0x780,0x1f00001e,0xfc00,0x20001f,0x780,0x80007c0,0x1f001e00,0x7c0000f,0x78000,0xf80007,0xe000003f,0x0,0x1e000000,0xf00000, | |
8686 | 0x3c000,0x3c03fff0,0xf0001e03,0xc001f007,0x800101e0,0x7e003c0,0x1e00,0x7800,0x781e0007,0x80007800,0x6000f00,0x3c003e00,0x7800001e, | |
8687 | 0xf078,0x1fe00f0,0x1e00780,0x3c00,0x78078000,0xf020001e,0xf000,0x7800780,0xff0001,0xfc07f00f,0x8007c000,0x780001f0,0x3c,0xf, | |
8688 | 0x1e0,0x0,0x0,0x0,0xf800fc01,0xf801f007,0xc00100f8,0x1f807c0,0x40003c,0xf807,0xf0078007,0x80003c00,0xf000,0x7803e00,0x1f0000f, | |
8689 | 0x3c0f01e,0x1e01f0,0x3e007e0,0x7c07c00,0xfc003c00,0x1e,0x3e000,0x3e007c0,0x1ff8000,0xfe0fe003,0xe03e0001,0xff0000fc,0x1e, | |
8690 | 0xf0,0x780,0x0,0x0,0x1f00080,0x3cf8000,0xfc00000,0x3c00001f,0x83f00000,0x18,0xc0,0x0,0xc06203,0x40003c0,0x1c00000,0xf80f0000, | |
8691 | 0x3cf8001f,0xf,0x3e000079,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x700780fc,0x3cf8,0xfc000,0x1e000,0x0,0x780000, | |
8692 | 0x7c180000,0xf0000020,0x100007,0x8000003c,0xf,0x80000000,0x1f01f0,0x0,0x380700,0x0,0xf,0x80f80000,0x0,0x0,0x0,0x0,0x0,0x3e007c0, | |
8693 | 0xe1c00,0x0,0x0,0x0,0xe01,0xc0000071,0xc0000001,0xc0001c70,0x1e00040,0x1e0003c0,0xf0001e07,0x8000f03c,0x781e0,0x3c0f00,0x1e0f007, | |
8694 | 0x80007800,0x10078000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e00,0x7e00f003,0xfc01e003,0xc00f001e, | |
8695 | 0x7800f0,0x3c00780,0x1e003c00,0xe000700f,0x800f0078,0x7803c0,0x3c01e00,0x1e00f000,0xf0000780,0x1e0000,0xf0003c,0x1f001f80, | |
8696 | 0xf800fc07,0xc007e03e,0x3f01f0,0x1f80f80,0xfc1e01f,0x7c00,0x100f8000,0x807c0004,0x3e00020,0x1f000100,0x780000,0x3c00000,0x1e000000, | |
8697 | 0xf0000f80,0x1f003c00,0x3c03e007,0xc01f003e,0xf801f0,0x7c00f80,0x3e007c00,0x1f8000f,0x801f003e,0x7c01f0,0x3e00f80,0x1f007c00, | |
8698 | 0xf8001ff0,0x1f801f,0x7fc00,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8699 | 0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0xf,0x7800078,0x31f80001,0xc070fc00,0xfc000000,0x1e00,0x7c00,0x0,0x1e0000,0xfc0000,0x0,0x7e000078, | |
8700 | 0x7c0,0x1f00001e,0x1f000,0x38003f,0x780,0xe000f80,0x1f803e00,0x780000f,0x800f8000,0x1f00007,0xe000003f,0x0,0x2000000,0x800000, | |
8701 | 0x3c000,0x3e01ff71,0xf0001f03,0xc007f007,0xc00301e0,0x1fc003c0,0x1e00,0x7c00,0x781e0007,0x80007800,0x7801f00,0x3c001f00,0x7800001e, | |
8702 | 0xf078,0xfe00f8,0x3e00780,0x3e00,0xf8078000,0xf838003e,0xf000,0x7c00f80,0xff0000,0xfc07e00f,0x8003c000,0x780001e0,0x3c,0xf, | |
8703 | 0x1e0,0x0,0x0,0x0,0xf801fc01,0xfc03e003,0xe003007c,0x3f803e0,0x1c0003c,0xfc0f,0xf0078007,0x80003c00,0xf000,0x7801f00,0xf8000f, | |
8704 | 0x3c0f01e,0x1e00f8,0x7c007f0,0xf803e01,0xfc003c00,0x8003e,0x1f000,0x1e00fc0,0xff0000,0xfe0fe007,0xc01f0000,0xfe0000f8,0x1e, | |
8705 | 0xf0,0x780,0x0,0x0,0xf80180,0x1cf0000,0x1f800000,0x3c00001f,0x83e00000,0x18,0xc0,0x0,0xc06203,0x70007c0,0xe00000,0x7e0f0000, | |
8706 | 0x1cf0001e,0x7,0x3c000039,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x7c00000,0xe00780fc,0x2001cf0,0xf8000,0x1e000,0x0, | |
8707 | 0x780000,0x7e182000,0xf0000000,0x7,0x8000003c,0x7,0xc0000000,0x7ffc0,0x0,0x180300,0x0,0x3,0xffe00000,0x0,0x0,0x0,0x0,0x0, | |
8708 | 0x3f00fc0,0xe1c00,0x0,0x0,0x0,0xc01,0x800000e1,0xc0000003,0xc0003870,0x1f001c0,0x3e0003e1,0xf0001f0f,0x8000f87c,0x7c3e0,0x3e1f00, | |
8709 | 0x1f1e007,0x80007c00,0x30078000,0x3c0000,0x1e00000,0xf000000,0xf00000,0x7800000,0x3c000001,0xe0001e03,0xfc00f001,0xfc01f007, | |
8710 | 0xc00f803e,0x7c01f0,0x3e00f80,0x1f007c00,0x4000201f,0xc01f007c,0xf803e0,0x7c01f00,0x3e00f801,0xf0000780,0x1e0000,0xf0007c, | |
8711 | 0x1f003f80,0xf801fc07,0xc00fe03e,0x7f01f0,0x3f80f80,0x1fc1f03f,0x803e00,0x3007c003,0x803e001c,0x1f000e0,0xf800700,0x780000, | |
8712 | 0x3c00000,0x1e000000,0xf00007c0,0x3e003c00,0x3c01f00f,0x800f807c,0x7c03e0,0x3e01f00,0x1f00f800,0x1f80007,0xc03e001e,0xfc00f0, | |
8713 | 0x7e00780,0x3f003c01,0xf8000fe0,0x1fc03e,0x3f800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8714 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0x780007f,0xfff00001,0xe0f07f03,0xfe000000,0xf00,0x7800,0x0, | |
8715 | 0x1e0000,0xfc0000,0x0,0x7e0000f0,0x3f0,0x7e000fff,0xfc03ffff,0xf83f00fe,0x780,0xfc03f80,0xfc0fc00,0xf800007,0xe03f0018,0x7e00007, | |
8716 | 0xe000003f,0x0,0x0,0x0,0x3c000,0x1e007c71,0xe0000f03,0xffffe003,0xf01f01ff,0xff8003ff,0xffe01e00,0x3f01,0xf81e0007,0x803ffff0, | |
8717 | 0x7e03f00,0x3c000f00,0x7ffffe1e,0xf078,0xfe007e,0xfc00780,0x1f83,0xf0078000,0x783f00fe,0xf000,0x3f03f00,0xff0000,0xfc07e01f, | |
8718 | 0x3e000,0x780003ff,0xfffc003c,0x7,0x800001e0,0x0,0x0,0x0,0x7e07fc01,0xfe07e001,0xf80f007e,0x7f801f8,0xfc0003c,0x7ffe,0xf0078007, | |
8719 | 0x807ffffe,0xf000,0x7801f00,0xfff00f,0x3c0f01e,0x1e00fc,0xfc007f8,0x1f803f03,0xfc003c00,0xf80fc,0x1fff0,0x1f83fc0,0xff0000, | |
8720 | 0xfc07e007,0xc01f0000,0xfe0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0xfe0780,0xfe0000,0x1f000000,0x3c00001f,0x7c00e03,0x81c00018, | |
8721 | 0xc0,0x0,0x406203,0x7e01fc0,0x700000,0x7fffff80,0xfe0003f,0xffffc003,0xf800001f,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f0, | |
8722 | 0x1f800001,0xc007c1fe,0x6000fe0,0x1ffffe,0x1e000,0x0,0x780000,0x3f98e03f,0xffff8000,0x7,0x8000003c,0x7,0xc0000000,0xfe00, | |
8723 | 0x0,0x80100,0x0,0x0,0x7f000000,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3f83fe8,0xe1c00,0x0,0x0,0x0,0x801,0xc1,0xc0000007,0x80003070, | |
8724 | 0xfc0fc0,0x3c0001e1,0xe0000f0f,0x7878,0x3c3c0,0x1e1e00,0xf1e007,0xffc03f01,0xf007ffff,0xc03ffffe,0x1fffff0,0xfffff80,0x7fffe003, | |
8725 | 0xffff001f,0xfff800ff,0xffc01fff,0xf800f001,0xfc00fc1f,0x8007e0fc,0x3f07e0,0x1f83f00,0xfc1f800,0x1f,0xf07e003f,0x3f001f8, | |
8726 | 0x1f800fc0,0xfc007e07,0xe0000780,0x1e0000,0xf301f8,0xfc0ff80,0x7e07fc03,0xf03fe01f,0x81ff00fc,0xff807e0,0x7fc0f87f,0x81801f80, | |
8727 | 0xf003f01f,0x801f80fc,0xfc07e0,0x7e03f00,0xfffffc07,0xffffe03f,0xffff01ff,0xfff807e0,0x7e003c00,0x3c01f81f,0x800fc0fc,0x7e07e0, | |
8728 | 0x3f03f00,0x1f81f800,0x1f8000f,0xe07e001f,0x83fc00fc,0x1fe007e0,0xff003f07,0xf8000fe0,0x1fe07e,0x3f800,0x0,0x0,0x0,0x0,0x0, | |
8729 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0x780007f, | |
8730 | 0xffe00000,0xffe03fff,0xdf000000,0xf00,0x7800,0x0,0x0,0xfc0000,0x0,0x7e0000f0,0x1ff,0xfc000fff,0xfc03ffff,0xf83ffffc,0x780, | |
8731 | 0xfffff00,0x7fff800,0xf000007,0xffff001f,0xffe00007,0xe000003f,0x0,0x0,0x0,0x3c000,0x1e000001,0xe0000f03,0xffffc001,0xffff01ff, | |
8732 | 0xff0003ff,0xffe01e00,0x1fff,0xf81e0007,0x803ffff0,0x7fffe00,0x3c000f80,0x7ffffe1e,0xf078,0xfe003f,0xff800780,0xfff,0xf0078000, | |
8733 | 0x7c3ffffc,0xf000,0x3ffff00,0xff0000,0xf803e01e,0x1e000,0x780003ff,0xfffc003c,0x7,0x800001e0,0x0,0x0,0x0,0x7fffbc01,0xffffc000, | |
8734 | 0xffff003f,0xfff800ff,0xffc0003c,0x3ffe,0xf0078007,0x807ffffe,0xf000,0x7800f80,0x7ff00f,0x3c0f01e,0x1e007f,0xff8007ff,0xff001fff, | |
8735 | 0xbc003c00,0xffffc,0x1fff0,0x1fffbc0,0xff0000,0x7c07c00f,0x800f8000,0x7e0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x7fff80,0x7c0000, | |
8736 | 0x1f000000,0x3c00001e,0x7c00f07,0xc1e00018,0xc0,0x0,0x60e303,0x7ffff80,0x380000,0x3fffff80,0x7c0003f,0xffffc001,0xf000000f, | |
8737 | 0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0xff800003,0x8003ffff,0xfe0007c0,0x1ffffe,0x1e000,0x0,0x780000,0x1fffe03f,0xffff8000, | |
8738 | 0x7,0x8000003c,0x3,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3fffdf8,0xe1c00,0x0,0x0,0x0,0x0,0x1c1, | |
8739 | 0xc000000f,0x7070,0x7fffc0,0x3c0001e1,0xe0000f0f,0x7878,0x3c3c0,0x1e1e00,0xf1e007,0xffc01fff,0xf007ffff,0xc03ffffe,0x1fffff0, | |
8740 | 0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xf000f001,0xfc007fff,0x3fff8,0x1fffc0,0xfffe00,0x7fff000,0x3b,0xfffc003f, | |
8741 | 0xfff001ff,0xff800fff,0xfc007fff,0xe0000780,0x1e0000,0xf3fff8,0xffff780,0x7fffbc03,0xfffde01f,0xffef00ff,0xff7807ff,0xfbc0ffff, | |
8742 | 0xff800fff,0xf001ffff,0x800ffffc,0x7fffe0,0x3ffff00,0xfffffc07,0xffffe03f,0xffff01ff,0xfff803ff,0xfc003c00,0x3c00ffff,0x7fff8, | |
8743 | 0x3fffc0,0x1fffe00,0xffff000,0x1f,0xfffc001f,0xffbc00ff,0xfde007ff,0xef003fff,0x780007e0,0x1ffffc,0x1f800,0x0,0x0,0x0,0x0, | |
8744 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0x700003f, | |
8745 | 0xffc00000,0x7fc01fff,0x9f800000,0xf80,0xf800,0x0,0x0,0xfc0000,0x0,0x7e0000f0,0xff,0xf8000fff,0xfc03ffff,0xf83ffff8,0x780, | |
8746 | 0xffffe00,0x7fff000,0xf000003,0xfffe001f,0xffc00007,0xe000003f,0x0,0x0,0x0,0x3c000,0xf000003,0xe0000f83,0xffff0000,0xffff01ff, | |
8747 | 0xfc0003ff,0xffe01e00,0xfff,0xf01e0007,0x803ffff0,0x7fffc00,0x3c0007c0,0x7ffffe1e,0xf078,0x7e003f,0xff000780,0x7ff,0xe0078000, | |
8748 | 0x3c3ffff8,0xf000,0x1fffe00,0x7e0000,0xf803e03e,0x1f000,0x780003ff,0xfffc003c,0x7,0x800001e0,0x0,0x0,0x0,0x3fff3c01,0xefff8000, | |
8749 | 0x7ffe001f,0xff78007f,0xff80003c,0x1ffc,0xf0078007,0x807ffffe,0xf000,0x78007c0,0x3ff00f,0x3c0f01e,0x1e003f,0xff0007bf,0xfe000fff, | |
8750 | 0xbc003c00,0xffff8,0xfff0,0xfff3c0,0x7e0000,0x7c07c01f,0x7c000,0x7c0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0x3fff80,0x380000, | |
8751 | 0x3e000000,0x7c00003e,0x7801f07,0xc1e00018,0xc0,0x0,0x39c1ce,0x7ffff00,0x1c0000,0xfffff80,0x380003f,0xffffc000,0xe0000007, | |
8752 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0xff000007,0x1ffcf,0xfe000380,0x1ffffe,0x1e000,0x0,0x780000,0xfffe03f,0xffff8000,0x7, | |
8753 | 0x8000003c,0x3,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3dffdf8,0xe1c00,0x0,0x0,0x0,0x0,0x381, | |
8754 | 0xc000001e,0xe070,0x7fff80,0x7c0001f3,0xe0000f9f,0x7cf8,0x3e7c0,0x1f3e00,0xfbe007,0xffc00fff,0xf007ffff,0xc03ffffe,0x1fffff0, | |
8755 | 0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01fff,0xc000f000,0xfc007ffe,0x3fff0,0x1fff80,0xfffc00,0x7ffe000,0x79,0xfff8001f, | |
8756 | 0xffe000ff,0xff0007ff,0xf8003fff,0xc0000780,0x1e0000,0xf3fff0,0x7ffe780,0x3fff3c01,0xfff9e00f,0xffcf007f,0xfe7803ff,0xf3c07ff3, | |
8757 | 0xff8007ff,0xe000ffff,0x7fff8,0x3fffc0,0x1fffe00,0xfffffc07,0xffffe03f,0xffff01ff,0xfff801ff,0xf8003c00,0x3c007ffe,0x3fff0, | |
8758 | 0x1fff80,0xfffc00,0x7ffe000,0x1d,0xfff8000f,0xff3c007f,0xf9e003ff,0xcf001ffe,0x780007c0,0x1efff8,0x1f000,0x0,0x0,0x0,0x0, | |
8759 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780000,0x1e,0xf000003, | |
8760 | 0xfe000000,0x1f000fff,0xfc00000,0x780,0xf000,0x0,0x0,0xf80000,0x0,0x7e0001e0,0x7f,0xf0000fff,0xfc03ffff,0xf81ffff0,0x780, | |
8761 | 0x7fff800,0x1ffe000,0x1f000000,0xfff8001f,0xff000007,0xe000003e,0x0,0x0,0x0,0x3c000,0xf800003,0xc0000783,0xfff80000,0x3ffe01ff, | |
8762 | 0xe00003ff,0xffe01e00,0x7ff,0xc01e0007,0x803ffff0,0x3fff800,0x3c0003c0,0x7ffffe1e,0xf078,0x7e000f,0xfe000780,0x3ff,0xc0078000, | |
8763 | 0x3e1fffe0,0xf000,0x7ff800,0x7e0000,0xf803e07c,0xf800,0x780003ff,0xfffc003c,0x3,0xc00001e0,0x0,0x0,0x0,0xffe3c01,0xe7ff0000, | |
8764 | 0x3ffc000f,0xfe78003f,0xfe00003c,0x7f0,0xf0078007,0x807ffffe,0xf000,0x78003e0,0xff00f,0x3c0f01e,0x1e001f,0xfe00079f,0xfc0007ff, | |
8765 | 0x3c003c00,0x7ffe0,0x1ff0,0x7fe3c0,0x7e0000,0x7c07c03e,0x3e000,0x7c0001ff,0xffe0001e,0xf0,0x780,0x0,0x0,0xfff00,0x100000, | |
8766 | 0x3e000000,0x7800003c,0xf800f07,0xc1e00018,0xc0,0x0,0x1f80fc,0x3fffc00,0xc0000,0x3ffff80,0x100003f,0xffffc000,0x40000002, | |
8767 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc000006,0xff87,0xfc000100,0x1ffffe,0x1e000,0x0,0x780000,0x3ffc03f,0xffff8000,0x7, | |
8768 | 0x8000003c,0x3,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ffff,0xfe000000,0x0,0x0,0x3dff9f8,0xe1c00,0x0,0x0,0x0,0x0,0x3ff, | |
8769 | 0xf800003c,0xfffe,0x1ffe00,0x780000f3,0xc000079e,0x3cf0,0x1e780,0xf3c00,0x7bc007,0xffc003ff,0xe007ffff,0xc03ffffe,0x1fffff0, | |
8770 | 0xfffff80,0x7fffe003,0xffff001f,0xfff800ff,0xffc01ffc,0xf000,0xfc001ffc,0xffe0,0x7ff00,0x3ff800,0x1ffc000,0x70,0xfff00007, | |
8771 | 0xff80003f,0xfc0001ff,0xe0000fff,0x780,0x1e0000,0xf3ffe0,0x1ffc780,0xffe3c00,0x7ff1e003,0xff8f001f,0xfc7800ff,0xe3c03fe1, | |
8772 | 0xff0003ff,0xc0007ffc,0x3ffe0,0x1fff00,0xfff800,0xfffffc07,0xffffe03f,0xffff01ff,0xfff800ff,0xf0003c00,0x3c003ffc,0x1ffe0, | |
8773 | 0xfff00,0x7ff800,0x3ffc000,0x38,0xfff00007,0xfe3c003f,0xf1e001ff,0x8f000ffc,0x780007c0,0x1e7ff0,0x1f000,0x0,0x0,0x0,0x0,0x0, | |
8774 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000, | |
8775 | 0x1fc,0x0,0x780,0xf000,0x0,0x0,0x1f80000,0x0,0x1e0,0x1f,0xc0000000,0x0,0x1ff80,0x0,0xffc000,0x7f8000,0x0,0x3fe00007,0xfc000000, | |
8776 | 0x7e,0x0,0x0,0x0,0x0,0x7c00000,0x0,0x0,0xff00000,0x0,0x0,0xfe,0x0,0x0,0x3fc000,0x0,0x0,0x0,0x3,0xf8000000,0xff,0xc0000000, | |
8777 | 0x1ff00,0x0,0x1fe000,0x0,0x0,0x0,0x0,0x3c,0x3,0xc00001e0,0x0,0x0,0x0,0x3f80000,0x1fc0000,0x7f00003,0xf8000007,0xf0000000, | |
8778 | 0x0,0xf0000000,0x0,0xf000,0x0,0x0,0x0,0x7,0xf8000787,0xf00001fc,0x3c000000,0x7f80,0x0,0x1f8000,0x0,0x0,0x0,0x7c000000,0x1e, | |
8779 | 0xf0,0x780,0x0,0x0,0x3fc00,0x0,0x3c000000,0x7800003c,0xf000601,0xc00018,0xc0,0x0,0x0,0x3fe000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8780 | 0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xf0000000,0x7e03,0xf0000000,0x0,0x0,0x0,0x0,0xfe0000,0x0,0x0,0x3c,0x2007,0x80000000,0x0,0x0, | |
8781 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c7e0f0,0xe1c00,0x0,0x3800000,0x0,0x0,0x3ff,0xf8000078,0xfffe,0x7f800,0x0,0x0,0x0,0x0, | |
8782 | 0x0,0x0,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f0,0x3f80,0x1fc00,0xfe000,0x7f0000,0x70,0x3fc00001,0xfe00000f,0xf000007f, | |
8783 | 0x800003fc,0x0,0x0,0xff00,0x7f0000,0x3f80000,0x1fc00000,0xfe000007,0xf000003f,0x80001f80,0xfc00007f,0xfe0,0x7f00,0x3f800, | |
8784 | 0x1fc000,0x0,0x0,0x0,0x3f,0xc0000000,0xff0,0x7f80,0x3fc00,0x1fe000,0xff0000,0x78,0x3fc00001,0xf800000f,0xc000007e,0x3f0,0x7c0, | |
8785 | 0x1e1fc0,0x1f000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8786 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x3c0,0x1e000,0x0,0x0,0x1f00000,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8787 | 0x0,0x0,0x7c,0x0,0x0,0x0,0x0,0x3e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xe0000000,0x0,0x0,0x0, | |
8788 | 0x0,0x0,0x0,0x0,0x3c,0x1,0xe00001e0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000000,0x0,0xf000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000, | |
8789 | 0x0,0x0,0x0,0x0,0x0,0x0,0x78000000,0x1e,0xf0,0x780,0x0,0x0,0x0,0x0,0x3c000000,0x78000078,0xf000000,0x18,0xc0,0x0,0x0,0x0, | |
8790 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x3c0f,0x80000000, | |
8791 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0xe1c00,0x0,0x1800000,0x0,0x0,0x3ff,0xf80000f0,0xfffe,0x0,0x0,0x0,0x0, | |
8792 | 0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8793 | 0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x780,0x1e0000,0x1e000,0x0,0x0,0x0, | |
8794 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000, | |
8795 | 0x0,0x0,0x3c0,0x1e000,0x0,0x0,0x1f00000,0x0,0x3c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c,0x0,0x0,0x0,0x0,0x1f80000, | |
8796 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xf0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x1,0xe00001e0,0x0, | |
8797 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xe0000000,0x0,0xf000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x0,0xf8000000, | |
8798 | 0x1f,0xf0,0xf80,0x0,0x0,0x0,0x0,0x78000000,0xf8000078,0x1e000000,0x8,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8799 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x3fff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8800 | 0x0,0x3c00000,0xe1c00,0x0,0x1c00000,0x0,0x0,0x1,0xc00001e0,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8801 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8802 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf80,0x1e0000,0x3e000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8803 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x1e0,0x3c000,0x0,0x0,0x1f00000, | |
8804 | 0x0,0x780,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7c,0x0,0x0,0x0,0x0,0xfe0100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8805 | 0x0,0x0,0x0,0x0,0xf8000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf0000000,0xf0007fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xe0000000, | |
8806 | 0x0,0xf000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x0,0xf0000000,0x1f,0x800000f0,0x1f80,0x0,0x0,0x0,0x0, | |
8807 | 0x78000000,0xf0000070,0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8808 | 0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x3ffe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0xe1c00,0x0,0xe00000, | |
8809 | 0x0,0x0,0x1,0xc00003ff,0xe0000070,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8810 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8811 | 0x0,0x0,0x0,0xf00,0x1e0000,0x3c000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8812 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0x1e0,0x7c000,0x0,0x0,0x1e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8813 | 0x0,0x0,0x0,0x0,0x0,0x78,0x0,0x0,0x0,0x0,0x7fff80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78000000, | |
8814 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf0000000,0x7fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4003,0xe0000000,0x0,0x1f000,0x0,0x0, | |
8815 | 0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x1,0xf0000000,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x0,0x0,0x70000001,0xf00000e0, | |
8816 | 0x1c000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000, | |
8817 | 0x0,0x0,0x3c,0xff8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0xe1c00,0x0,0xe00000,0x0,0x0,0x1,0xc00003ff, | |
8818 | 0xe0000070,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8819 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f00,0x1e0000, | |
8820 | 0x7c000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8821 | 0x0,0x0,0x0,0x0,0x30000000,0x0,0x0,0xf0,0x78000,0x0,0x0,0x3e00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf8,0x0, | |
8822 | 0x0,0x0,0x0,0x1fff80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f, | |
8823 | 0xf0000000,0x7fe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x780f,0xc0000000,0x0,0x3e000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0, | |
8824 | 0x0,0x0,0x0,0x0,0x3,0xe0000000,0xf,0xfc0000f0,0x3ff00,0x0,0x0,0x0,0x0,0xf0000103,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8825 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x0,0x0,0x0,0x0,0x0,0x0, | |
8826 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x21e00000,0x0,0x0,0x1,0xc00003ff,0xe0000070,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10f, | |
8827 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10f,0x0, | |
8828 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3e00,0x1e0000,0xf8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8829 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30000000,0x0,0x0, | |
8830 | 0xf8,0xf8000,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0x0,0x0,0x0,0x0,0x1fe00,0x0,0x0,0x0,0x0, | |
8831 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0xf0000000,0x7fe0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8832 | 0x0,0x0,0x7fff,0xc0000000,0x0,0x3ffe000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x7f,0xe0000000,0x7,0xfc0000f0, | |
8833 | 0x3fe00,0x0,0x0,0x0,0x0,0x600001ff,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8834 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x180000,0x0,0x0,0x3c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0, | |
8835 | 0x3fe00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8836 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1ff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8837 | 0x0,0x0,0x0,0x0,0x7fe00,0x1e0000,0x1ff8000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8838 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8839 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8840 | 0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fff,0x80000000,0x0,0x3ffc000,0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0, | |
8841 | 0x0,0x0,0x0,0x0,0x7f,0xc0000000,0x0,0xfc0000f0,0x3f000,0x0,0x0,0x0,0x0,0x1ff,0xc0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8842 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8843 | 0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x3fc00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fe,0x0,0x0,0x0,0x0,0x0, | |
8844 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fe,0x0,0x0,0x0,0x0,0x0,0x0, | |
8845 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7fc00,0x1e0000,0x1ff0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8846 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8847 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8848 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x3ffe,0x0,0x0,0x3ff8000,0x0,0x0,0x0, | |
8849 | 0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x7f,0x80000000,0x0,0xf0,0x0,0x0,0x0,0x0,0x0,0x1ff,0x80000000,0x0,0x0,0x0,0x0, | |
8850 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8851 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x3f800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fc,0x0, | |
8852 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fc,0x0,0x0, | |
8853 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f800,0x1e0000,0x1fe0000,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8854 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8855 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8856 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f8,0x0,0x0,0x3fe0000, | |
8857 | 0x0,0x0,0x0,0x0,0x780,0x0,0x3c000000,0x0,0x0,0x0,0x0,0x0,0x7e,0x0,0x0,0xf0,0x0,0x0,0x0,0x0,0x0,0xfe,0x0,0x0,0x0,0x0,0x0,0x0, | |
8858 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8859 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c00000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8860 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8861 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7e000,0x1e0000,0x1f80000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8862 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8863 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8864 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1fffffe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8865 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8866 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8867 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8868 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8869 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8870 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8871 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8872 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0x0,0x0,0x0, | |
8873 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8874 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8875 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, | |
8876 | 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }; | |
8877 | const unsigned char logo40x38[4576] = { | |
8878 | 177,200,200,200,3,123,123,0,36,200,200,200,1,123,123,0,2,255,255,0,1,189,189,189,1,0,0,0,34,200,200,200, | |
8879 | 1,123,123,0,4,255,255,0,1,189,189,189,1,0,0,0,1,123,123,123,32,200,200,200,1,123,123,0,5,255,255,0,1,0,0, | |
8880 | 0,2,123,123,123,30,200,200,200,1,123,123,0,6,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,29,200,200,200, | |
8881 | 1,123,123,0,7,255,255,0,1,0,0,0,2,123,123,123,28,200,200,200,1,123,123,0,8,255,255,0,1,189,189,189,1,0,0,0, | |
8882 | 2,123,123,123,27,200,200,200,1,123,123,0,9,255,255,0,1,0,0,0,2,123,123,123,26,200,200,200,1,123,123,0,10,255, | |
8883 | 255,0,1,189,189,189,1,0,0,0,2,123,123,123,25,200,200,200,1,123,123,0,3,255,255,0,1,189,189,189,3,0,0,0,1,189, | |
8884 | 189,189,3,255,255,0,1,0,0,0,2,123,123,123,24,200,200,200,1,123,123,0,4,255,255,0,5,0,0,0,3,255,255,0,1,189, | |
8885 | 189,189,1,0,0,0,2,123,123,123,23,200,200,200,1,123,123,0,4,255,255,0,5,0,0,0,4,255,255,0,1,0,0,0,2,123,123,123, | |
8886 | 22,200,200,200,1,123,123,0,5,255,255,0,5,0,0,0,4,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,21,200,200,200, | |
8887 | 1,123,123,0,5,255,255,0,5,0,0,0,5,255,255,0,1,0,0,0,2,123,123,123,20,200,200,200,1,123,123,0,6,255,255,0,5,0,0, | |
8888 | 0,5,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,19,200,200,200,1,123,123,0,6,255,255,0,1,123,123,0,3,0,0,0,1, | |
8889 | 123,123,0,6,255,255,0,1,0,0,0,2,123,123,123,18,200,200,200,1,123,123,0,7,255,255,0,1,189,189,189,3,0,0,0,1,189, | |
8890 | 189,189,6,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,17,200,200,200,1,123,123,0,8,255,255,0,3,0,0,0,8,255,255, | |
8891 | 0,1,0,0,0,2,123,123,123,16,200,200,200,1,123,123,0,9,255,255,0,1,123,123,0,1,0,0,0,1,123,123,0,8,255,255,0,1,189, | |
8892 | 189,189,1,0,0,0,2,123,123,123,15,200,200,200,1,123,123,0,9,255,255,0,1,189,189,189,1,0,0,0,1,189,189,189,9,255,255, | |
8893 | 0,1,0,0,0,2,123,123,123,14,200,200,200,1,123,123,0,11,255,255,0,1,0,0,0,10,255,255,0,1,189,189,189,1,0,0,0,2,123, | |
8894 | 123,123,13,200,200,200,1,123,123,0,23,255,255,0,1,0,0,0,2,123,123,123,12,200,200,200,1,123,123,0,11,255,255,0,1,189, | |
8895 | 189,189,2,0,0,0,1,189,189,189,9,255,255,0,1,189,189,189,1,0,0,0,2,123,123,123,11,200,200,200,1,123,123,0,11,255,255, | |
8896 | 0,4,0,0,0,10,255,255,0,1,0,0,0,2,123,123,123,10,200,200,200,1,123,123,0,12,255,255,0,4,0,0,0,10,255,255,0,1,189,189, | |
8897 | 189,1,0,0,0,2,123,123,123,9,200,200,200,1,123,123,0,12,255,255,0,1,189,189,189,2,0,0,0,1,189,189,189,11,255,255,0,1, | |
8898 | 0,0,0,2,123,123,123,9,200,200,200,1,123,123,0,27,255,255,0,1,0,0,0,3,123,123,123,8,200,200,200,1,123,123,0,26,255, | |
8899 | 255,0,1,189,189,189,1,0,0,0,3,123,123,123,9,200,200,200,1,123,123,0,24,255,255,0,1,189,189,189,1,0,0,0,4,123,123, | |
8900 | 123,10,200,200,200,1,123,123,0,24,0,0,0,5,123,123,123,12,200,200,200,27,123,123,123,14,200,200,200,25,123,123,123,86, | |
8901 | 200,200,200,91,49,124,118,124,71,32,124,95,49,56,114,52,82,121,0}; | |
8902 | inline void warn(const char *format, ...) { | |
8903 | if (cimg::exception_mode()>=1) { | |
8904 | char message[8192]; | |
8905 | std::va_list ap; | |
8906 | __builtin_va_start(ap,format); | |
8907 | std::vsprintf(message,format,ap); | |
8908 | __builtin_va_end(ap); | |
8909 | std::fprintf(stderr,"\n<CImg Warning> %s\n",message); | |
8910 | } | |
8911 | } | |
8912 | inline int xln(const int x) { | |
8913 | return x>0?(int)(1+std::log10((double)x)):1; | |
8914 | } | |
8915 | inline char uncase(const char x) { | |
8916 | return (char)((x<'A'||x>'Z')?x:x-'A'+'a'); | |
8917 | } | |
8918 | inline float atof(const char *str) { | |
8919 | float x = 0,y = 1; | |
8920 | if (!str) return 0; else { std::sscanf(str,"%g/%g",&x,&y); return x/y; } | |
8921 | } | |
8922 | inline int strlen(const char *s) { | |
8923 | if (s) { int k; for (k=0; s[k]; ++k) ; return k; } | |
8924 | return -1; | |
8925 | } | |
8926 | inline int strncmp(const char *s1, const char *s2, const int l) { | |
8927 | if (s1 && s2) { int n = 0; for (int k=0; k<l; ++k) n+=std::abs(s1[k] - s2[k]); return n; } | |
8928 | return 0; | |
8929 | } | |
8930 | inline int strncasecmp(const char *s1, const char *s2, const int l) { | |
8931 | if (s1 && s2) { int n = 0; for (int k=0; k<l; ++k) n+=std::abs(uncase(s1[k])-uncase(s2[k])); return n; } | |
8932 | return 0; | |
8933 | } | |
8934 | inline int strcmp(const char *s1, const char *s2) { | |
8935 | const int l1 = cimg::strlen(s1), l2 = cimg::strlen(s2); | |
8936 | return cimg::strncmp(s1,s2,1+(l1<l2?l1:l2)); | |
8937 | } | |
8938 | inline int strcasecmp(const char *s1, const char *s2) { | |
8939 | const int l1 = cimg::strlen(s1), l2 = cimg::strlen(s2); | |
8940 | return cimg::strncasecmp(s1,s2,1+(l1<l2?l1:l2)); | |
8941 | } | |
8942 | inline int strfind(const char *s, const char c) { | |
8943 | if (s) { | |
8944 | int l; for (l=cimg::strlen(s); l>=0 && s[l]!=c; --l) ; | |
8945 | return l; | |
8946 | } | |
8947 | return -1; | |
8948 | } | |
8949 | inline const char* basename(const char *s) { | |
8950 | return (1!=2)?(s?s+1+cimg::strfind(s,'/'):0):(s?s+1+cimg::strfind(s,'\\'):0); | |
8951 | } | |
8952 | inline bool endian() { | |
8953 | const int x=1; | |
8954 | return ((unsigned char*)&x)[0]?false:true; | |
8955 | } | |
8956 | inline unsigned long time() { | |
8957 | struct timeval st_time; | |
8958 | gettimeofday(&st_time,0); | |
8959 | return (unsigned long)(st_time.tv_usec/1000 + st_time.tv_sec*1000); | |
8960 | } | |
8961 | inline void sleep(const unsigned int milliseconds) { | |
8962 | struct timespec tv; | |
8963 | tv.tv_sec = milliseconds/1000; | |
8964 | tv.tv_nsec = (milliseconds%1000)*1000000; | |
8965 | nanosleep(&tv,0); | |
8966 | } | |
8967 | inline unsigned int wait(const unsigned int milliseconds, unsigned long& timer) { | |
8968 | if (!timer) timer = cimg::time(); | |
8969 | const unsigned long current_time = cimg::time(); | |
8970 | if (current_time>=timer+milliseconds) { timer = current_time; return 0; } | |
8971 | const unsigned long time_diff = timer + milliseconds - current_time; | |
8972 | timer = current_time + time_diff; | |
8973 | cimg::sleep(time_diff); | |
8974 | return (unsigned int)time_diff; | |
8975 | } | |
8976 | inline unsigned int wait(const unsigned int milliseconds) { | |
8977 | static unsigned long timer = 0; | |
8978 | if (!timer) timer = cimg::time(); | |
8979 | return wait(milliseconds,timer); | |
8980 | } | |
8981 | inline void srand() { | |
8982 | static bool first_time = true; | |
8983 | if (first_time) { | |
8984 | std::srand(cimg::time()); | |
8985 | unsigned char *const rand_mem = new unsigned char[1+std::rand()%2048]; | |
8986 | std::srand((unsigned int)(std::rand() + (unsigned long)rand_mem)); | |
8987 | delete[] rand_mem; | |
8988 | first_time = false; | |
8989 | } | |
8990 | } | |
8991 | inline const char* filenamerand() { | |
8992 | static char id[9] = { 0,0,0,0,0,0,0,0,0 }; | |
8993 | cimg::srand(); | |
8994 | for (unsigned int k=0; k<8; k++) { | |
8995 | const int v = (int)std::rand()%3; | |
8996 | id[k] = (char)(v==0?('0'+(std::rand()%10)):(v==1?('a'+(std::rand()%26)):('A'+(std::rand()%26)))); | |
8997 | } | |
8998 | return id; | |
8999 | } | |
9000 | inline void system(const char *command, const char *module_name=0) { | |
9001 | std::system(command); | |
9002 | command = module_name = 0; | |
9003 | } | |
9004 | inline void winformat_string(char *const) {} | |
9005 | inline const char* imagemagick_path() { | |
9006 | static char *st_imagemagick_path = 0; | |
9007 | if (!st_imagemagick_path) { | |
9008 | st_imagemagick_path = new char[1024]; | |
9009 | std::memset(st_imagemagick_path,0,1024); | |
9010 | bool path_found = false; | |
9011 | std::FILE *file = 0; | |
9012 | if (!path_found) { | |
9013 | std::sprintf(st_imagemagick_path,"./convert"); | |
9014 | if ((file=std::fopen(st_imagemagick_path,"r"))!=0) { std::fclose(file); path_found = true; } | |
9015 | } | |
9016 | if (!path_found) std::strcpy(st_imagemagick_path,"convert"); | |
9017 | winformat_string(st_imagemagick_path); | |
9018 | } | |
9019 | return st_imagemagick_path; | |
9020 | } | |
9021 | inline const char* graphicsmagick_path() { | |
9022 | static char *st_graphicsmagick_path = 0; | |
9023 | if (!st_graphicsmagick_path) { | |
9024 | st_graphicsmagick_path = new char[1024]; | |
9025 | std::memset(st_graphicsmagick_path,0,1024); | |
9026 | bool path_found = false; | |
9027 | std::FILE *file = 0; | |
9028 | if (!path_found) { | |
9029 | std::sprintf(st_graphicsmagick_path,"./gm"); | |
9030 | if ((file=std::fopen(st_graphicsmagick_path,"r"))!=0) { std::fclose(file); path_found = true; } | |
9031 | } | |
9032 | if (!path_found) std::strcpy(st_graphicsmagick_path,"gm"); | |
9033 | winformat_string(st_graphicsmagick_path); | |
9034 | } | |
9035 | return st_graphicsmagick_path; | |
9036 | } | |
9037 | inline const char* medcon_path() { | |
9038 | static char *st_medcon_path = 0; | |
9039 | if (!st_medcon_path) { | |
9040 | st_medcon_path = new char[1024]; | |
9041 | std::memset(st_medcon_path,0,1024); | |
9042 | bool path_found = false; | |
9043 | std::FILE *file = 0; | |
9044 | if (!path_found) { | |
9045 | std::sprintf(st_medcon_path,"./medcon"); | |
9046 | if ((file=std::fopen(st_medcon_path,"r"))!=0) { std::fclose(file); path_found = true; } | |
9047 | } | |
9048 | if (!path_found) std::strcpy(st_medcon_path,"medcon"); | |
9049 | winformat_string(st_medcon_path); | |
9050 | } | |
9051 | return st_medcon_path; | |
9052 | } | |
9053 | inline const char* temporary_path() { | |
9054 | static char *st_temporary_path = 0; | |
9055 | if (!st_temporary_path) { | |
9056 | st_temporary_path = new char[1024]; | |
9057 | std::memset(st_temporary_path,0,1024); | |
9058 | bool path_found = false; | |
9059 | char tmp[1024], filetmp[512]; | |
9060 | std::FILE *file = 0; | |
9061 | std::sprintf(filetmp,"%s.tmp",cimg::filenamerand()); | |
9062 | char *tmpPath = getenv("TMP"); | |
9063 | if (tmpPath==__null) { tmpPath = getenv("TEMP"); winformat_string(tmpPath); } | |
9064 | if (tmpPath!=__null) if (!path_found) { std::sprintf(st_temporary_path,"%s",tmpPath); std::sprintf(tmp,"%s%s%s",st_temporary_path,1==2?"\\":"/",filetmp); if ((file=std::fopen(tmp,"wb"))!=0) { std::fclose(file); std::remove(tmp); path_found = true; } }; | |
9065 | if (!path_found) { std::sprintf(st_temporary_path,"%s","/tmp"); std::sprintf(tmp,"%s%s%s",st_temporary_path,1==2?"\\":"/",filetmp); if ((file=std::fopen(tmp,"wb"))!=0) { std::fclose(file); std::remove(tmp); path_found = true; } }; | |
9066 | if (!path_found) { std::sprintf(st_temporary_path,"%s","/var/tmp"); std::sprintf(tmp,"%s%s%s",st_temporary_path,1==2?"\\":"/",filetmp); if ((file=std::fopen(tmp,"wb"))!=0) { std::fclose(file); std::remove(tmp); path_found = true; } }; | |
9067 | if (!path_found) { | |
9068 | st_temporary_path[0]='\0'; | |
9069 | std::strcpy(tmp,filetmp); | |
9070 | if ((file=std::fopen(tmp,"wb"))!=0) { std::fclose(file); std::remove(tmp); path_found = true; } | |
9071 | } | |
9072 | if (!path_found) | |
9073 | throw CImgIOException("cimg::temporary_path() : Unable to find a temporary path accessible for writing\n" | |
9074 | "you have to set the macro 'cimg_temporary_path' to a valid path where you have writing access :\n" | |
9075 | "#define cimg_temporary_path \"path\" (before including 'CImg.h')"); | |
9076 | } | |
9077 | return st_temporary_path; | |
9078 | } | |
9079 | inline const char *filename_split(const char *const filename, char *const body=0) { | |
9080 | if (!filename) { if (body) body[0]='\0'; return 0; } | |
9081 | int l = cimg::strfind(filename,'.'); | |
9082 | if (l>=0) { if (body) { std::strncpy(body,filename,l); body[l]='\0'; }} | |
9083 | else { if (body) std::strcpy(body,filename); l=(int)std::strlen(filename)-1; } | |
9084 | return filename+l+1; | |
9085 | } | |
9086 | inline char* filename_number(const char *const filename, const int number, const unsigned int n, char *const string) { | |
9087 | if (!filename) { if (string) string[0]='\0'; return 0; } | |
9088 | char format[1024],body[1024]; | |
9089 | const char *ext = cimg::filename_split(filename,body); | |
9090 | if (n>0) std::sprintf(format,"%s_%%.%ud.%s",body,n,ext); | |
9091 | else std::sprintf(format,"%s_%%d.%s",body,ext); | |
9092 | std::sprintf(string,format,number); | |
9093 | return string; | |
9094 | } | |
9095 | inline std::FILE *fopen(const char *const path, const char *const mode) { | |
9096 | if(!path || !mode) | |
9097 | throw CImgArgumentException("cimg::fopen() : File '%s' cannot be opened with mode '%s'.", | |
9098 | path?path:"(null)",mode?mode:"(null)"); | |
9099 | if (path[0]=='-') return (mode[0]=='r')?stdin:stdout; | |
9100 | std::FILE *dest = std::fopen(path,mode); | |
9101 | if (!dest) | |
9102 | throw CImgIOException("cimg::fopen() : File '%s' cannot be opened%s", | |
9103 | path,mode[0]=='r'?" for reading.":(mode[0]=='w'?" for writing.":"."),path); | |
9104 | return dest; | |
9105 | } | |
9106 | inline int fclose(std::FILE *file) { | |
9107 | if (!file) warn("cimg::fclose() : Can't close (null) file"); | |
9108 | if (!file || file==stdin || file==stdout) return 0; | |
9109 | const int errn = std::fclose(file); | |
9110 | if (errn!=0) warn("cimg::fclose() : Error %d during file closing",errn); | |
9111 | return errn; | |
9112 | } | |
9113 | template<typename T> inline int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream) { | |
9114 | if (!ptr || nmemb<=0 || !stream) | |
9115 | throw CImgArgumentException("cimg::fread() : Can't read %u x %u bytes of file pointer '%p' in buffer '%p'", | |
9116 | nmemb,sizeof(T),stream,ptr); | |
9117 | const unsigned long wlimitT = 63*1024*1024, wlimit = wlimitT/sizeof(T); | |
9118 | unsigned int toread = nmemb, alread = 0, ltoread = 0, lalread = 0; | |
9119 | do { | |
9120 | ltoread = (toread*sizeof(T))<wlimitT?toread:wlimit; | |
9121 | lalread = (unsigned int)std::fread((void*)(ptr+alread),sizeof(T),ltoread,stream); | |
9122 | alread+=lalread; | |
9123 | toread-=lalread; | |
9124 | } while (ltoread==lalread && toread>0); | |
9125 | if (toread>0) warn("cimg::fread() : File reading problems, only %u/%u elements read",alread,nmemb); | |
9126 | return alread; | |
9127 | } | |
9128 | template<typename T> inline int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream) { | |
9129 | if (!ptr || !stream) | |
9130 | throw CImgArgumentException("cimg::fwrite() : Can't write %u x %u bytes of file pointer '%p' from buffer '%p'", | |
9131 | nmemb,sizeof(T),stream,ptr); | |
9132 | if (nmemb<=0) return 0; | |
9133 | const unsigned long wlimitT = 63*1024*1024, wlimit = wlimitT/sizeof(T); | |
9134 | unsigned int towrite = nmemb, alwrite = 0, ltowrite = 0, lalwrite = 0; | |
9135 | do { | |
9136 | ltowrite = (towrite*sizeof(T))<wlimitT?towrite:wlimit; | |
9137 | lalwrite = (unsigned int)std::fwrite((void*)(ptr+alwrite),sizeof(T),ltowrite,stream); | |
9138 | alwrite+=lalwrite; | |
9139 | towrite-=lalwrite; | |
9140 | } while (ltowrite==lalwrite && towrite>0); | |
9141 | if (towrite>0) warn("cimg::fwrite() : File writing problems, only %u/%u elements written",alwrite,nmemb); | |
9142 | return alwrite; | |
9143 | } | |
9144 | template<typename T> inline void swap(T& a, T& b) { T t = a; a = b; b = t; } | |
9145 | template<typename T1, typename T2> inline void swap(T1& a1, T1& b1, T2& a2, T2& b2) { | |
9146 | cimg::swap(a1,b1); cimg::swap(a2,b2); | |
9147 | } | |
9148 | template<typename T1, typename T2, typename T3> inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3) { | |
9149 | cimg::swap(a1,b1,a2,b2); cimg::swap(a3,b3); | |
9150 | } | |
9151 | template<typename T1, typename T2, typename T3, typename T4> | |
9152 | inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4) { | |
9153 | cimg::swap(a1,b1,a2,b2,a3,b3); cimg::swap(a4,b4); | |
9154 | } | |
9155 | template<typename T1, typename T2, typename T3, typename T4, typename T5> | |
9156 | inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5) { | |
9157 | cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4); cimg::swap(a5,b5); | |
9158 | } | |
9159 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> | |
9160 | inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6) { | |
9161 | cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5); cimg::swap(a6,b6); | |
9162 | } | |
9163 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> | |
9164 | inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6, | |
9165 | T7& a7, T7& b7) { | |
9166 | cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6); cimg::swap(a7,b7); | |
9167 | } | |
9168 | template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> | |
9169 | inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6, | |
9170 | T7& a7, T7& b7, T8& a8, T8& b8) { | |
9171 | cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6,a7,b7); cimg::swap(a8,b8); | |
9172 | } | |
9173 | template<typename T> inline void endian_swap(T* const buffer, const unsigned int size) { | |
9174 | switch (sizeof(T)) { | |
9175 | case 1: break; | |
9176 | case 2: { | |
9177 | for (unsigned short *ptr = (unsigned short*)buffer+size; ptr>(unsigned short*)buffer; ) { | |
9178 | const unsigned short val = *(--ptr); | |
9179 | *ptr = (unsigned short)((val>>8)|((val<<8))); | |
9180 | } | |
9181 | } break; | |
9182 | case 4: { | |
9183 | for (unsigned int *ptr = (unsigned int*)buffer+size; ptr>(unsigned int*)buffer; ) { | |
9184 | const unsigned int val = *(--ptr); | |
9185 | *ptr = (val>>24)|((val>>8)&0xff00)|((val<<8)&0xff0000)|(val<<24); | |
9186 | } | |
9187 | } break; | |
9188 | default: { | |
9189 | for (T* ptr = buffer+size; ptr>buffer; ) { | |
9190 | unsigned char *pb = (unsigned char*)(--ptr), *pe = pb + sizeof(T); | |
9191 | for (int i=0; i<(int)sizeof(T)/2; ++i) cimg::swap(*(pb++),*(--pe)); | |
9192 | } break; | |
9193 | } | |
9194 | } | |
9195 | } | |
9196 | template<typename T> inline T& endian_swap(T& a) { | |
9197 | endian_swap(&a,1); | |
9198 | return a; | |
9199 | } | |
9200 | inline const char* option(const char *const name, const int argc, char **argv, | |
9201 | const char *defaut, const char *const usage=0) { | |
9202 | static bool first = true, visu = false; | |
9203 | const char *res = 0; | |
9204 | if (first) { | |
9205 | first=false; | |
9206 | visu = (cimg::option("-h",argc,argv,(char*)0)!=0); | |
9207 | visu |= (cimg::option("-help",argc,argv,(char*)0)!=0); | |
9208 | visu |= (cimg::option("--help",argc,argv,(char*)0)!=0); | |
9209 | } | |
9210 | if (!name && visu) { | |
9211 | if (usage) { | |
9212 | std::fprintf(stderr,"\n %s%s%s",cimg::t_red,cimg::basename(argv[0]),cimg::t_normal); | |
9213 | std::fprintf(stderr," : %s",usage); | |
9214 | std::fprintf(stderr," (%s, %s)\n\n","Jun 4 2008","19:16:48"); | |
9215 | } | |
9216 | if (defaut) std::fprintf(stderr,"%s\n",defaut); | |
9217 | } | |
9218 | if (name) { | |
9219 | if (argc>0) { | |
9220 | int k = 0; | |
9221 | while (k<argc && cimg::strcmp(argv[k],name)) ++k; | |
9222 | res = (k++==argc?defaut:(k==argc?argv[--k]:argv[k])); | |
9223 | } else res = defaut; | |
9224 | if (visu && usage) std::fprintf(stderr," %s%-8s%s = %-12s : %s%s%s\n", | |
9225 | cimg::t_bold,name,cimg::t_normal,res?res:"0",cimg::t_purple,usage,cimg::t_normal); | |
9226 | } | |
9227 | return res; | |
9228 | } | |
9229 | inline bool option(const char *const name, const int argc, char **argv, | |
9230 | const bool defaut, const char *const usage=0) { | |
9231 | const char *s = cimg::option(name,argc,argv,(char*)0); | |
9232 | const bool res = s?(cimg::strcasecmp(s,"false") && cimg::strcasecmp(s,"off") && cimg::strcasecmp(s,"0")):defaut; | |
9233 | cimg::option(name,0,0,res?"true":"false",usage); | |
9234 | return res; | |
9235 | } | |
9236 | inline int option(const char *const name, const int argc, char **argv, | |
9237 | const int defaut, const char *const usage=0) { | |
9238 | const char *s = cimg::option(name,argc,argv,(char*)0); | |
9239 | const int res = s?std::atoi(s):defaut; | |
9240 | char tmp[256]; | |
9241 | std::sprintf(tmp,"%d",res); | |
9242 | cimg::option(name,0,0,tmp,usage); | |
9243 | return res; | |
9244 | } | |
9245 | inline char option(const char *const name, const int argc, char **argv, | |
9246 | const char defaut, const char *const usage=0) { | |
9247 | const char *s = cimg::option(name,argc,argv,(char*)0); | |
9248 | const char res = s?s[0]:defaut; | |
9249 | char tmp[8]; | |
9250 | tmp[0] = res; | |
9251 | tmp[1] ='\0'; | |
9252 | cimg::option(name,0,0,tmp,usage); | |
9253 | return res; | |
9254 | } | |
9255 | inline float option(const char *const name, const int argc, char **argv, | |
9256 | const float defaut, const char *const usage=0) { | |
9257 | const char *s = cimg::option(name,argc,argv,(char*)0); | |
9258 | const float res = s?cimg::atof(s):defaut; | |
9259 | char tmp[256]; | |
9260 | std::sprintf(tmp,"%g",res); | |
9261 | cimg::option(name,0,0,tmp,usage); | |
9262 | return res; | |
9263 | } | |
9264 | inline double option(const char *const name, const int argc, char **argv, | |
9265 | const double defaut, const char *const usage=0) { | |
9266 | const char *s = cimg::option(name,argc,argv,(char*)0); | |
9267 | const double res = s?cimg::atof(s):defaut; | |
9268 | char tmp[256]; | |
9269 | std::sprintf(tmp,"%g",res); | |
9270 | cimg::option(name,0,0,tmp,usage); | |
9271 | return res; | |
9272 | } | |
9273 | inline const char* argument(const unsigned int nb, const int argc, char **argv, const unsigned int nb_singles=0, ...) { | |
9274 | for (int k=1, pos=0; k<argc;) { | |
9275 | const char *const item = argv[k]; | |
9276 | bool option = (*item=='-'), single_option = false; | |
9277 | if (option) { | |
9278 | va_list ap; | |
9279 | __builtin_va_start(ap,nb_singles); | |
9280 | for (unsigned int i=0; i<nb_singles; ++i) if (!cimg::strcasecmp(item,__builtin_va_arg(ap,char*))) { single_option = true; break; } | |
9281 | __builtin_va_end(ap); | |
9282 | } | |
9283 | if (option) { ++k; if (!single_option) ++k; } | |
9284 | else { if (pos++==(int)nb) return item; else ++k; } | |
9285 | } | |
9286 | return 0; | |
9287 | } | |
9288 | template<typename T> inline const T rol(const T a, const unsigned int n=1) { | |
9289 | return n?(T)((a<<n)|(a>>((sizeof(T)<<3)-n))):a; | |
9290 | } | |
9291 | template<typename T> inline const T ror(const T a, const unsigned int n=1) { | |
9292 | return n?(T)((a>>n)|(a<<((sizeof(T)<<3)-n))):a; | |
9293 | } | |
9294 | template<typename T> inline T abs(const T a) { | |
9295 | return a>=0?a:-a; | |
9296 | } | |
9297 | inline bool abs(const bool a) { | |
9298 | return a; | |
9299 | } | |
9300 | inline unsigned char abs(const unsigned char a) { | |
9301 | return a; | |
9302 | } | |
9303 | inline unsigned short abs(const unsigned short a) { | |
9304 | return a; | |
9305 | } | |
9306 | inline unsigned int abs(const unsigned int a) { | |
9307 | return a; | |
9308 | } | |
9309 | inline unsigned long abs(const unsigned long a) { | |
9310 | return a; | |
9311 | } | |
9312 | inline double abs(const double a) { | |
9313 | return std::fabs(a); | |
9314 | } | |
9315 | inline float abs(const float a) { | |
9316 | return (float)std::fabs((double)a); | |
9317 | } | |
9318 | inline int abs(const int a) { | |
9319 | return std::abs(a); | |
9320 | } | |
9321 | template<typename T> inline T sqr(const T val) { | |
9322 | return val*val; | |
9323 | } | |
9324 | template<typename t1, typename t2> inline typename cimg::superset<t1,t2>::type min(const t1& a, const t2& b) { | |
9325 | typedef typename cimg::superset<t1,t2>::type restype; | |
9326 | return (restype)(a<=b?a:b); | |
9327 | } | |
9328 | template<typename t1, typename t2, typename t3> inline typename cimg::superset2<t1,t2,t3>::type min(const t1& a, const t2& b, const t3& c) { | |
9329 | typedef typename cimg::superset2<t1,t2,t3>::type restype; | |
9330 | return (restype)cimg::min(cimg::min(a,b),c); | |
9331 | } | |
9332 | template<typename t1, typename t2, typename t3, typename t4> | |
9333 | inline typename cimg::superset3<t1,t2,t3,t4>::type min(const t1& a, const t2& b, const t3& c, const t4& d) { | |
9334 | typedef typename cimg::superset3<t1,t2,t3,t4>::type restype; | |
9335 | return (restype)cimg::min(cimg::min(a,b,c),d); | |
9336 | } | |
9337 | template<typename t1, typename t2> inline typename cimg::superset<t1,t2>::type max(const t1& a, const t2& b) { | |
9338 | typedef typename cimg::superset<t1,t2>::type restype; | |
9339 | return (restype)(a>=b?a:b); | |
9340 | } | |
9341 | template<typename t1, typename t2, typename t3> inline typename cimg::superset2<t1,t2,t3>::type max(const t1& a, const t2& b, const t3& c) { | |
9342 | typedef typename cimg::superset2<t1,t2,t3>::type restype; | |
9343 | return (restype)cimg::max(cimg::max(a,b),c); | |
9344 | } | |
9345 | template<typename t1, typename t2, typename t3, typename t4> | |
9346 | inline typename cimg::superset3<t1,t2,t3,t4>::type max(const t1& a, const t2& b, const t3& c, const t4& d) { | |
9347 | typedef typename cimg::superset3<t1,t2,t3,t4>::type restype; | |
9348 | return (restype)cimg::max(cimg::max(a,b,c),d); | |
9349 | } | |
9350 | template<typename T> inline T sign(const T x) { | |
9351 | return (x<0)?(T)(-1):(x==0?(T)0:(T)1); | |
9352 | } | |
9353 | template<typename T> inline unsigned long nearest_pow2(const T x) { | |
9354 | unsigned long i=1; | |
9355 | while (x>i) i<<=1; | |
9356 | return i; | |
9357 | } | |
9358 | template<typename T> inline T mod(const T& x, const T& m) { | |
9359 | const double dx = (double)x, dm = (double)m; | |
9360 | if (x<0) { return (T)(dm+dx+dm*std::floor(-dx/dm)); } | |
9361 | return (T)(dx-dm*std::floor(dx/dm)); | |
9362 | } | |
9363 | inline int mod(const char x, const char m) { | |
9364 | return x>=0?x%m:(x%m?m+x%m:0); | |
9365 | } | |
9366 | inline int mod(const short x, const short m) { | |
9367 | return x>=0?x%m:(x%m?m+x%m:0); | |
9368 | } | |
9369 | inline int mod(const int x, const int m) { | |
9370 | return x>=0?x%m:(x%m?m+x%m:0); | |
9371 | } | |
9372 | inline int mod(const long x, const long m) { | |
9373 | return x>=0?x%m:(x%m?m+x%m:0); | |
9374 | } | |
9375 | inline int mod(const unsigned char x, const unsigned char m) { | |
9376 | return x%m; | |
9377 | } | |
9378 | inline int mod(const unsigned short x, const unsigned short m) { | |
9379 | return x%m; | |
9380 | } | |
9381 | inline int mod(const unsigned int x, const unsigned int m) { | |
9382 | return x%m; | |
9383 | } | |
9384 | inline int mod(const unsigned long x, const unsigned long m) { | |
9385 | return x%m; | |
9386 | } | |
9387 | template<typename T> inline T minmod(const T a, const T b) { | |
9388 | return a*b<=0?0:(a>0?(a<b?a:b):(a<b?b:a)); | |
9389 | } | |
9390 | inline double rand() { | |
9391 | return (double)std::rand()/2147483647; | |
9392 | } | |
9393 | inline double crand() { | |
9394 | return 1-2*cimg::rand(); | |
9395 | } | |
9396 | inline double grand() { | |
9397 | double x1, w; | |
9398 | do { | |
9399 | const double x2 = 2*cimg::rand()-1.0; | |
9400 | x1 = 2*cimg::rand()-1.0; | |
9401 | w = x1*x1 + x2*x2; | |
9402 | } while (w<=0 || w>=1.0); | |
9403 | return x1*std::sqrt((-2*std::log(w))/w); | |
9404 | } | |
9405 | inline double round(const double x, const double y, const unsigned int round_type=0) { | |
9406 | if (y<=0) return x; | |
9407 | const double delta = cimg::mod(x,y); | |
9408 | if (delta==0.0) return x; | |
9409 | const double | |
9410 | backward = x - delta, | |
9411 | forward = backward + y; | |
9412 | return round_type==1?backward:(round_type==2?forward:(2*delta<y?backward:forward)); | |
9413 | } | |
9414 | inline double pythagore(double a, double b) { | |
9415 | const double absa = cimg::abs(a), absb = cimg::abs(b); | |
9416 | if (absa>absb) { const double tmp = absb/absa; return absa*std::sqrt(1.0+tmp*tmp); } | |
9417 | else { const double tmp = absa/absb; return (absb==0?0:absb*std::sqrt(1.0+tmp*tmp)); } | |
9418 | } | |
9419 | inline void info() { | |
9420 | char tmp[1024] = { 0 }; | |
9421 | std::fprintf(stderr,"\n %sCImg Library %d.%d.%d%s, compiled %s ( %s ) with the following flags :\n\n", | |
9422 | cimg::t_red,128/100,(128%100)/10,128%10,cimg::t_normal,"Jun 4 2008","19:16:48"); | |
9423 | std::fprintf(stderr," > CPU endianness : %s%s Endian%s\n", | |
9424 | cimg::t_bold, | |
9425 | cimg::endian()?"Big":"Little", | |
9426 | cimg::t_normal); | |
9427 | std::fprintf(stderr," > Operating System : %s%-13s%s %s('cimg_OS'=%d)%s\n", | |
9428 | cimg::t_bold, | |
9429 | 1==1?"Unix":(1==2?"Windows":"Unknow"), | |
9430 | cimg::t_normal,cimg::t_purple, | |
9431 | 1, | |
9432 | cimg::t_normal); | |
9433 | std::fprintf(stderr," > Display type : %s%-13s%s %s('cimg_display_type'=%d)%s\n", | |
9434 | cimg::t_bold, | |
9435 | 1==0?"No display": | |
9436 | (1==1?"X11": | |
9437 | (1==2?"Windows GDI": | |
9438 | (1==3?"Carbon":"Unknow"))), | |
9439 | cimg::t_normal,cimg::t_purple, | |
9440 | 1, | |
9441 | cimg::t_normal); | |
9442 | std::fprintf(stderr," > Color terminal : %s%-13s%s %s('cimg_color_terminal' %s)%s\n", | |
9443 | cimg::t_bold, | |
9444 | "Yes",cimg::t_normal,cimg::t_purple,"defined", | |
9445 | cimg::t_normal); | |
9446 | std::fprintf(stderr," > Debug messages : %s%-13s%s %s('cimg_debug'=%d)%s\n", | |
9447 | cimg::t_bold, | |
9448 | 1==0?"No":(1==1 || 1==2?"Yes":(1==3?"Yes+":"Unknown")), | |
9449 | cimg::t_normal,cimg::t_purple, | |
9450 | 1, | |
9451 | cimg::t_normal); | |
9452 | std::fprintf(stderr," > Using XShm for X11 : %s%-13s%s %s('cimg_use_xshm' %s)%s\n", | |
9453 | cimg::t_bold, | |
9454 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9455 | cimg::t_normal); | |
9456 | std::fprintf(stderr," > Using XRand for X11 : %s%-13s%s %s('cimg_use_xrandr' %s)%s\n", | |
9457 | cimg::t_bold, | |
9458 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9459 | cimg::t_normal); | |
9460 | std::fprintf(stderr," > Using OpenMP : %s%-13s%s %s('cimg_use_openmp' %s)%s\n", | |
9461 | cimg::t_bold, | |
9462 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9463 | cimg::t_normal); | |
9464 | std::fprintf(stderr," > Using PNG library : %s%-13s%s %s('cimg_use_png' %s)%s\n", | |
9465 | cimg::t_bold, | |
9466 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9467 | cimg::t_normal); | |
9468 | std::fprintf(stderr," > Using JPEG library : %s%-13s%s %s('cimg_use_jpeg' %s)%s\n", | |
9469 | cimg::t_bold, | |
9470 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9471 | cimg::t_normal); | |
9472 | std::fprintf(stderr," > Using TIFF library : %s%-13s%s %s('cimg_use_tiff' %s)%s\n", | |
9473 | cimg::t_bold, | |
9474 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9475 | cimg::t_normal); | |
9476 | std::fprintf(stderr," > Using Magick++ library : %s%-13s%s %s('cimg_use_magick' %s)%s\n", | |
9477 | cimg::t_bold, | |
9478 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9479 | cimg::t_normal); | |
9480 | std::fprintf(stderr," > Using FFTW3 library : %s%-13s%s %s('cimg_use_fftw3' %s)%s\n", | |
9481 | cimg::t_bold, | |
9482 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9483 | cimg::t_normal); | |
9484 | std::fprintf(stderr," > Using LAPACK library : %s%-13s%s %s('cimg_use_lapack' %s)%s\n", | |
9485 | cimg::t_bold, | |
9486 | "No",cimg::t_normal,cimg::t_purple,"undefined", | |
9487 | cimg::t_normal); | |
9488 | std::sprintf(tmp,"\"%.1020s\"",cimg::imagemagick_path()); | |
9489 | std::fprintf(stderr," > Path of ImageMagick : %s%-13s%s %s('cimg_imagemagick_path'%s)%s\n", | |
9490 | cimg::t_bold, | |
9491 | tmp, | |
9492 | cimg::t_normal, | |
9493 | cimg::t_purple," undefined", | |
9494 | cimg::t_normal); | |
9495 | std::sprintf(tmp,"\"%.1020s\"",cimg::graphicsmagick_path()); | |
9496 | std::fprintf(stderr," > Path of GraphicsMagick : %s%-13s%s %s('cimg_graphicsmagick_path'%s)%s\n", | |
9497 | cimg::t_bold, | |
9498 | tmp, | |
9499 | cimg::t_normal, | |
9500 | cimg::t_purple," undefined", | |
9501 | cimg::t_normal); | |
9502 | std::sprintf(tmp,"\"%.1020s\"",cimg::medcon_path()); | |
9503 | std::fprintf(stderr," > Path of 'medcon' : %s%-13s%s %s('cimg_medcon_path'%s)%s\n", | |
9504 | cimg::t_bold, | |
9505 | tmp, | |
9506 | cimg::t_normal, | |
9507 | cimg::t_purple," undefined", | |
9508 | cimg::t_normal); | |
9509 | std::sprintf(tmp,"\"%.1020s\"",cimg::temporary_path()); | |
9510 | std::fprintf(stderr," > Temporary path : %s%-13s%s %s('cimg_temporary_path'%s)%s\n", | |
9511 | cimg::t_bold, | |
9512 | tmp, | |
9513 | cimg::t_normal, | |
9514 | cimg::t_purple," undefined", | |
9515 | cimg::t_normal); | |
9516 | std::fprintf(stderr,"\n"); | |
9517 | } | |
9518 | } | |
9519 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator+(const CImg<t1>& img, const t2 val) { | |
9520 | typedef typename cimg::superset<t1,t2>::type restype; | |
9521 | return CImg<restype>(img,false)+=val; | |
9522 | } | |
9523 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator+(const t1 val, const CImg<t2>& img) { | |
9524 | return img+val; | |
9525 | } | |
9526 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator+(const CImgList<t1>& list, const t2 val) { | |
9527 | typedef typename cimg::superset<t1,t2>::type restype; | |
9528 | return CImgList<restype>(list)+=val; | |
9529 | } | |
9530 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator+(const t1 val, const CImgList<t2>& list) { | |
9531 | return list+val; | |
9532 | } | |
9533 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator+(const CImg<t1>& img1, const CImg<t2>& img2) { | |
9534 | typedef typename cimg::superset<t1,t2>::type restype; | |
9535 | return CImg<restype>(img1,false)+=img2; | |
9536 | } | |
9537 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator+(const CImg<t1>& img, const CImgList<t2>& list) { | |
9538 | typedef typename cimg::superset<t1,t2>::type restype; | |
9539 | return CImgList<restype>(list)+=img; | |
9540 | } | |
9541 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator+(const CImgList<t1>& list, const CImg<t2>& img) { | |
9542 | return img+list; | |
9543 | } | |
9544 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator+(const CImgList<t1>& list1, const CImgList<t2>& list2) { | |
9545 | typedef typename cimg::superset<t1,t2>::type restype; | |
9546 | return CImgList<restype>(list1)+=list2; | |
9547 | } | |
9548 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator-(const CImg<t1>& img, const t2 val) { | |
9549 | typedef typename cimg::superset<t1,t2>::type restype; | |
9550 | return CImg<restype>(img,false)-=val; | |
9551 | } | |
9552 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator-(const t1 val, const CImg<t2>& img) { | |
9553 | typedef typename cimg::superset<t1,t2>::type restype; | |
9554 | return CImg<restype>(img.width,img.height,img.depth,img.dim,(restype)val)-=img; | |
9555 | } | |
9556 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator-(const CImgList<t1>& list, const t2 val) { | |
9557 | typedef typename cimg::superset<t1,t2>::type restype; | |
9558 | return CImgList<restype>(list)-=val; | |
9559 | } | |
9560 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator-(const t1 val, const CImgList<t2>& list) { | |
9561 | typedef typename cimg::superset<t1,t2>::type restype; | |
9562 | CImgList<restype> res(list.size); | |
9563 | for (unsigned int l=0; l<(res).size; ++l) res[l] = val-list[l]; | |
9564 | return res; | |
9565 | } | |
9566 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator-(const CImg<t1>& img1, const CImg<t2>& img2) { | |
9567 | typedef typename cimg::superset<t1,t2>::type restype; | |
9568 | return CImg<restype>(img1,false)-=img2; | |
9569 | } | |
9570 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator-(const CImg<t1>& img, const CImgList<t2>& list) { | |
9571 | typedef typename cimg::superset<t1,t2>::type restype; | |
9572 | CImgList<restype> res(list.size); | |
9573 | for (unsigned int l=0; l<(res).size; ++l) res[l] = img-list[l]; | |
9574 | return res; | |
9575 | } | |
9576 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator-(const CImgList<t1>& list, const CImg<t2>& img) { | |
9577 | typedef typename cimg::superset<t1,t2>::type restype; | |
9578 | return CImgList<restype>(list)-=img; | |
9579 | } | |
9580 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator-(const CImgList<t1>& list1, const CImgList<t2>& list2) { | |
9581 | typedef typename cimg::superset<t1,t2>::type restype; | |
9582 | return CImgList<restype>(list1)-=list2; | |
9583 | } | |
9584 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator*(const CImg<t1>& img, const t2 val) { | |
9585 | typedef typename cimg::superset<t1,t2>::type restype; | |
9586 | return CImg<restype>(img,false)*=val; | |
9587 | } | |
9588 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator*(const t1 val, const CImg<t2>& img) { | |
9589 | return img*val; | |
9590 | } | |
9591 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator*(const CImgList<t1>& list, const t2 val) { | |
9592 | typedef typename cimg::superset<t1,t2>::type restype; | |
9593 | return CImgList<restype>(list)*=val; | |
9594 | } | |
9595 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator*(const t1 val, const CImgList<t2>& list) { | |
9596 | return list*val; | |
9597 | } | |
9598 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator*(const CImg<t1>& img1, const CImg<t2>& img2) { | |
9599 | typedef typename cimg::superset<t1,t2>::type restype; | |
9600 | if (img1.width!=img2.height) | |
9601 | throw CImgArgumentException("operator*() : can't multiply a matrix (%ux%u) by a matrix (%ux%u)", | |
9602 | img1.width,img1.height,img2.width,img2.height); | |
9603 | CImg<restype> res(img2.width,img1.height); | |
9604 | restype val; | |
9605 | for (int j = 0; j<(int)((res).height); ++j) for (int i = 0; i<(int)((res).width); ++i) { val = 0; for (int k = 0; k<(int)((img1).width); ++k) val+=img1(k,j)*img2(i,k); res(i,j) = val; } | |
9606 | return res; | |
9607 | } | |
9608 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator*(const CImg<t1>& img, const CImgList<t2>& list) { | |
9609 | typedef typename cimg::superset<t1,t2>::type restype; | |
9610 | CImgList<restype> res(list.size); | |
9611 | for (unsigned int l=0; l<(res).size; ++l) res[l] = img*list[l]; | |
9612 | return res; | |
9613 | } | |
9614 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator*(const CImgList<t1>& list, const CImg<t2>& img) { | |
9615 | typedef typename cimg::superset<t1,t2>::type restype; | |
9616 | CImgList<restype> res(list.size); | |
9617 | for (unsigned int l=0; l<(res).size; ++l) res[l] = list[l]*img; | |
9618 | return res; | |
9619 | } | |
9620 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator*(const CImgList<t1>& list1, const CImgList<t2>& list2) { | |
9621 | typedef typename cimg::superset<t1,t2>::type restype; | |
9622 | CImgList<restype> res(cimg::min(list1.size,list2.size)); | |
9623 | for (unsigned int l=0; l<(res).size; ++l) res[l] = list1[l]*list2[l]; | |
9624 | return res; | |
9625 | } | |
9626 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator/(const CImg<t1>& img, const t2 val) { | |
9627 | typedef typename cimg::superset<t1,t2>::type restype; | |
9628 | return CImg<restype>(img,false)/=val; | |
9629 | } | |
9630 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator/(const t1 val, CImg<t2>& img) { | |
9631 | return val*img.get_invert(); | |
9632 | } | |
9633 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator/(const CImgList<t1>& list, const t2 val) { | |
9634 | typedef typename cimg::superset<t1,t2>::type restype; | |
9635 | return CImgList<restype>(list)/=val; | |
9636 | } | |
9637 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator/(const t1 val, const CImgList<t2>& list) { | |
9638 | typedef typename cimg::superset<t1,t2>::type restype; | |
9639 | CImgList<restype> res(list.size); | |
9640 | for (unsigned int l=0; l<(res).size; ++l) res[l] = val/list[l]; | |
9641 | return res; | |
9642 | } | |
9643 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator/(const CImg<t1>& img1, const CImg<t2>& img2) { | |
9644 | typedef typename cimg::superset<t1,t2>::type restype; | |
9645 | return CImg<restype>(img1,false)*=img2.get_invert(); | |
9646 | } | |
9647 | template<typename t1, typename t2> inline CImg<typename cimg::superset<t1,t2>::type> operator/(const CImg<t1>& img, const CImgList<t2>& list) { | |
9648 | typedef typename cimg::superset<t1,t2>::type restype; | |
9649 | CImgList<restype> res(list.size); | |
9650 | for (unsigned int l=0; l<(res).size; ++l) res[l] = img/list[l]; | |
9651 | return res; | |
9652 | } | |
9653 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator/(const CImgList<t1>& list, const CImg<t2>& img) { | |
9654 | typedef typename cimg::superset<t1,t2>::type restype; | |
9655 | return CImgList<restype>(list)/=img; | |
9656 | } | |
9657 | template<typename t1, typename t2> inline CImgList<typename cimg::superset<t1,t2>::type> operator/(const CImgList<t1>& list1, const CImgList<t2>& list2) { | |
9658 | typedef typename cimg::superset<t1,t2>::type restype; | |
9659 | return CImgList<restype>(list1)/=list2; | |
9660 | } | |
9661 | template<typename T, typename t> inline CImg<T> apply(const CImg<T>& instance, t& func) { | |
9662 | return instance.get_apply(func); | |
9663 | } | |
9664 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> mul(const CImg<T>& instance, const CImg<t>& img) { | |
9665 | return instance.get_mul(img); | |
9666 | } | |
9667 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> div(const CImg<T>& instance, const CImg<t>& img) { | |
9668 | return instance.get_div(img); | |
9669 | } | |
9670 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> max(const CImg<T>& instance, const CImg<t>& img) { | |
9671 | return instance.get_max(img); | |
9672 | } | |
9673 | template<typename T> inline CImg<T> max(const CImg<T>& instance, const T val) { | |
9674 | return instance.get_max(val); | |
9675 | } | |
9676 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> min(const CImg<T>& instance, const CImg<t>& img) { | |
9677 | return instance.get_min(img); | |
9678 | } | |
9679 | template<typename T> inline CImg<typename cimg::last<T,double>::type> stats(const CImg<T>& instance) { | |
9680 | return instance.get_stats(); | |
9681 | } | |
9682 | template<typename T> inline CImg<T> min(const CImg<T>& instance, const T val) { | |
9683 | return instance.get_min(val); | |
9684 | } | |
9685 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> sqr(const CImg<T>& instance) { | |
9686 | return instance.get_sqr(); | |
9687 | } | |
9688 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> sqrt(const CImg<T>& instance) { | |
9689 | return instance.get_sqrt(); | |
9690 | } | |
9691 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> exp(const CImg<T>& instance) { | |
9692 | return instance.get_exp(); | |
9693 | } | |
9694 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> log(const CImg<T>& instance) { | |
9695 | return instance.get_log(); | |
9696 | } | |
9697 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> log10(const CImg<T>& instance) { | |
9698 | return instance.get_log10(); | |
9699 | } | |
9700 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> pow(const CImg<T>& instance, const double p) { | |
9701 | return instance.get_pow(p); | |
9702 | } | |
9703 | template<typename T, typename t> inline CImg<typename cimg::superset<T,float>::type> pow(const CImg<T>& instance, const CImg<t>& img) { | |
9704 | return instance.get_pow(img); | |
9705 | } | |
9706 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> abs(const CImg<T>& instance) { | |
9707 | return instance.get_abs(); | |
9708 | } | |
9709 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> cos(const CImg<T>& instance) { | |
9710 | return instance.get_cos(); | |
9711 | } | |
9712 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> sin(const CImg<T>& instance) { | |
9713 | return instance.get_sin(); | |
9714 | } | |
9715 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> tan(const CImg<T>& instance) { | |
9716 | return instance.get_tan(); | |
9717 | } | |
9718 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> acos(const CImg<T>& instance) { | |
9719 | return instance.get_acos(); | |
9720 | } | |
9721 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> asin(const CImg<T>& instance) { | |
9722 | return instance.get_asin(); | |
9723 | } | |
9724 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> atan(const CImg<T>& instance) { | |
9725 | return instance.get_atan(); | |
9726 | } | |
9727 | template<typename T> inline CImg<T> round(const CImg<T>& instance, const float x, const unsigned int round_type=0) { | |
9728 | return instance.get_round(x,round_type); | |
9729 | } | |
9730 | template<typename T> inline CImg<T> rand(const CImg<T>& instance, const T val_min, const T val_max) { | |
9731 | return instance.get_rand(val_min,val_max); | |
9732 | } | |
9733 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val) { | |
9734 | return instance.get_fill(val); | |
9735 | } | |
9736 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1) { | |
9737 | return instance.get_fill(val0,val1); | |
9738 | } | |
9739 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2) { | |
9740 | return instance.get_fill(val0,val1,val2); | |
9741 | } | |
9742 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3) { | |
9743 | return instance.get_fill(val0,val1,val2,val3); | |
9744 | } | |
9745 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9746 | const T val4) { | |
9747 | return instance.get_fill(val0,val1,val2,val3,val4); | |
9748 | } | |
9749 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9750 | const T val4, const T val5) { | |
9751 | return instance.get_fill(val0,val1,val2,val3,val4,val5); | |
9752 | } | |
9753 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9754 | const T val4, const T val5, const T val6) { | |
9755 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6); | |
9756 | } | |
9757 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9758 | const T val4, const T val5, const T val6, const T val7) { | |
9759 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7); | |
9760 | } | |
9761 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9762 | const T val4, const T val5, const T val6, const T val7, const T val8) { | |
9763 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8); | |
9764 | } | |
9765 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9766 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9) { | |
9767 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9); | |
9768 | } | |
9769 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9770 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, | |
9771 | const T val10) { | |
9772 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10); | |
9773 | } | |
9774 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9775 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, | |
9776 | const T val10, const T val11) { | |
9777 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11); | |
9778 | } | |
9779 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9780 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, | |
9781 | const T val10, const T val11, const T val12) { | |
9782 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12); | |
9783 | } | |
9784 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9785 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, | |
9786 | const T val10, const T val11, const T val12, const T val13) { | |
9787 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13); | |
9788 | } | |
9789 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9790 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, | |
9791 | const T val10, const T val11, const T val12, const T val13, const T val14) { | |
9792 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14); | |
9793 | } | |
9794 | template<typename T> inline CImg<T> fill(const CImg<T>& instance, const T val0, const T val1, const T val2, const T val3, | |
9795 | const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, | |
9796 | const T val10, const T val11, const T val12, const T val13, const T val14, const T val15) { | |
9797 | return instance.get_fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14,val15); | |
9798 | } | |
9799 | template<typename T, int N> inline CImg<T> fill(const CImg<T>& instance, const int val0, ...) { | |
9800 | CImg<T> res(instance,false); | |
9801 | va_list ap; | |
9802 | __builtin_va_start(ap,val0); | |
9803 | res.template _fill<N,int>(val0,ap); | |
9804 | __builtin_va_end(ap); | |
9805 | return res; | |
9806 | } | |
9807 | template<typename T, int N> inline CImg<T> fill(const CImg<T>& instance, const double val0, ...) { | |
9808 | CImg<T> res(instance,false); | |
9809 | va_list ap; | |
9810 | __builtin_va_start(ap,val0); | |
9811 | res.template _fill<N,double>(val0,ap); | |
9812 | __builtin_va_end(ap); | |
9813 | return res; | |
9814 | } | |
9815 | template<typename T> inline CImg<T> normalize(const CImg<T>& instance, const T a, const T b) { | |
9816 | return instance.get_normalize(a,b); | |
9817 | } | |
9818 | template<typename T> inline CImg<T> cut(const CImg<T>& instance, const T a, const T b) { | |
9819 | return instance.get_cut(a,b); | |
9820 | } | |
9821 | template<typename T> inline CImg<T> quantize(const CImg<T>& instance, const unsigned int n=256, const bool keep_range=true) { | |
9822 | return instance.get_quantize(n,keep_range); | |
9823 | } | |
9824 | template<typename T> inline CImg<T> threshold(const CImg<T>& instance, const T thres) { | |
9825 | return instance.get_threshold(thres); | |
9826 | } | |
9827 | template<typename T> inline CImg<T> rotate(const CImg<T>& instance, const float angle, const unsigned int cond=3) { | |
9828 | return instance.get_rotate(angle,cond); | |
9829 | } | |
9830 | template<typename T> inline CImg<T> rotate(const CImg<T>& instance, const float angle, const float cx, const float cy, | |
9831 | const float zoom=1, const unsigned int cond=3) { | |
9832 | return instance.get_rotate(angle,cx,cy,zoom,cond); | |
9833 | } | |
9834 | template<typename T> inline CImg<T> resize(const CImg<T>& instance, | |
9835 | const int pdx=-100, const int pdy=-100, const int pdz=-100, const int pdv=-100, | |
9836 | const int interp=1, const int border_condition=-1, const bool center=false) { | |
9837 | return instance.get_resize(pdx,pdy,pdz,pdv,interp,border_condition,center); | |
9838 | } | |
9839 | template<typename T, typename t> inline CImg<T> resize(const CImg<T>& instance, const CImg<t>& src, | |
9840 | const int interp=1, const int border_condition=-1, | |
9841 | const bool center=false) { | |
9842 | return instance.get_resize(src,interp,border_condition,center); | |
9843 | } | |
9844 | template<typename T> inline CImg<T> resize(const CImg<T>& instance, const CImgDisplay& disp, | |
9845 | const int interp=1, const int border_condition=-1, const bool center=false) { | |
9846 | return instance.get_resize(disp,interp,border_condition,center); | |
9847 | } | |
9848 | template<typename T> inline CImg<T> permute_axes(const CImg<T>& instance, const char *permut="vxyz") { | |
9849 | return instance.get_permute_axes(instance,permut); | |
9850 | } | |
9851 | template<typename T> inline CImg<T> resize_halfXY(const CImg<T>& instance) { | |
9852 | return instance.get_resize_halfXY(); | |
9853 | } | |
9854 | template<typename T> inline CImg<T> crop(const CImg<T>& instance, const int x0, const int y0, const int z0, const int v0, | |
9855 | const int x1, const int y1, const int z1, const int v1, | |
9856 | const bool border_condition=false) { | |
9857 | return instance.get_crop(x0,y0,z0,v0,x1,y1,z1,v1,border_condition); | |
9858 | } | |
9859 | template<typename T> inline CImg<T> crop(const CImg<T>& instance, const int x0, const int y0, const int z0, | |
9860 | const int x1, const int y1, const int z1, | |
9861 | const bool border_condition=false) { | |
9862 | return instance.get_crop(x0,y0,z0,x1,y1,z1,border_condition); | |
9863 | } | |
9864 | template<typename T> inline CImg<T> crop(const CImg<T>& instance, const int x0, const int y0, | |
9865 | const int x1, const int y1, | |
9866 | const bool border_condition=false) { | |
9867 | return instance.get_crop(x0,y0,x1,y1,border_condition); | |
9868 | } | |
9869 | template<typename T> inline CImg<T> crop(const CImg<T>& instance, const int x0, const int x1, | |
9870 | const bool border_condition=false) { | |
9871 | return instance.get_crop(x0,x1,border_condition); | |
9872 | } | |
9873 | template<typename T> inline CImg<T> columns(const CImg<T>& instance, const unsigned int x0, const unsigned int x1) { | |
9874 | return instance.get_columns(x0,x1); | |
9875 | } | |
9876 | template<typename T> inline CImg<T> column(const CImg<T>& instance, const unsigned int x0) { | |
9877 | return instance.get_column(x0); | |
9878 | } | |
9879 | template<typename T> inline CImg<T> lines(const CImg<T>& instance, const unsigned int y0, const unsigned int y1) { | |
9880 | return instance.get_lines(y0,y1); | |
9881 | } | |
9882 | template<typename T> inline CImg<T> line(const CImg<T>& instance, const unsigned int y0) { | |
9883 | return instance.get_line(y0); | |
9884 | } | |
9885 | template<typename T> inline CImg<T> slices(const CImg<T>& instance, const unsigned int z0, const unsigned int z1) { | |
9886 | return instance.get_slices(z0,z1); | |
9887 | } | |
9888 | template<typename T> inline CImg<T> slice(const CImg<T>& instance, const unsigned int z0) { | |
9889 | return instance.get_slice(z0); | |
9890 | } | |
9891 | template<typename T> inline CImg<T> channels(const CImg<T>& instance, const unsigned int v0, const unsigned int v1) { | |
9892 | return instance.get_channels(v0,v1); | |
9893 | } | |
9894 | template<typename T> inline CImg<T> channel(const CImg<T>& instance, const unsigned int v0) { | |
9895 | return instance.get_channel(v0); | |
9896 | } | |
9897 | template<typename T> inline CImg<T> shared_points(CImg<T>& instance, const unsigned int x0, const unsigned int x1, | |
9898 | const unsigned int y0=0, const unsigned int z0=0, const unsigned int v0=0) { | |
9899 | return instance.get_shared_points(x0,x1,y0,z0,v0); | |
9900 | } | |
9901 | template<typename T> inline CImg<T> shared_points(const CImg<T>& instance, const unsigned int x0, const unsigned int x1, | |
9902 | const unsigned int y0=0, const unsigned int z0=0, const unsigned int v0=0) { | |
9903 | return instance.get_shared_points(x0,x1,y0,z0,v0); | |
9904 | } | |
9905 | template<typename T> inline CImg<T> shared_lines(CImg<T>& instance, const unsigned int y0, const unsigned int y1, | |
9906 | const unsigned int z0=0, const unsigned int v0=0) { | |
9907 | return instance.get_shared_lines(y0,y1,z0,v0); | |
9908 | } | |
9909 | template<typename T> inline CImg<T> shared_lines(const CImg<T>& instance, const unsigned int y0, const unsigned int y1, | |
9910 | const unsigned int z0=0, const unsigned int v0=0) { | |
9911 | return instance.get_shared_lines(y0,y1,z0,v0); | |
9912 | } | |
9913 | template<typename T> inline CImg<T> shared_line(CImg<T>& instance, | |
9914 | const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0) { | |
9915 | return instance.get_shared_line(y0,z0,v0); | |
9916 | } | |
9917 | template<typename T> inline CImg<T> shared_line(const CImg<T>& instance, | |
9918 | const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0) { | |
9919 | return instance.get_shared_line(y0,z0,v0); | |
9920 | } | |
9921 | template<typename T> inline CImg<T> shared_planes(CImg<T>& instance, | |
9922 | const unsigned int z0, const unsigned int z1, const unsigned int v0=0) { | |
9923 | return instance.get_shared_planes(z0,z1,v0); | |
9924 | } | |
9925 | template<typename T> inline CImg<T> shared_planes(const CImg<T>& instance, | |
9926 | const unsigned int z0, const unsigned int z1, const unsigned int v0=0) { | |
9927 | return instance.get_shared_planes(z0,z1,v0); | |
9928 | } | |
9929 | template<typename T> inline CImg<T> shared_plane(CImg<T>& instance, const unsigned int z0, const unsigned int v0=0) { | |
9930 | return instance.get_shared_plane(z0,v0); | |
9931 | } | |
9932 | template<typename T> inline CImg<T> shared_plane(const CImg<T>& instance, const unsigned int z0, const unsigned int v0=0) { | |
9933 | return instance.get_shared_plane(z0,v0); | |
9934 | } | |
9935 | template<typename T> inline CImg<T> shared_channels(CImg<T>& instance, const unsigned int v0, const unsigned int v1) { | |
9936 | return instance.get_shared_channels(v0,v1); | |
9937 | } | |
9938 | template<typename T> inline CImg<T> shared_channels(const CImg<T>& instance, const unsigned int v0, const unsigned int v1) { | |
9939 | return instance.get_shared_channels(v0,v1); | |
9940 | } | |
9941 | template<typename T> inline CImg<T> shared_channel(CImg<T>& instance, const unsigned int v0) { | |
9942 | return instance.get_shared_channel(v0); | |
9943 | } | |
9944 | template<typename T> inline CImg<T> shared_channel(const CImg<T>& instance, const unsigned int v0) { | |
9945 | return instance.get_shared_channel(v0); | |
9946 | } | |
9947 | template<typename T> inline CImg<T> shared(CImg<T>& instance) { | |
9948 | return instance.get_shared(); | |
9949 | } | |
9950 | template<typename T> inline CImg<T> shared(const CImg<T>& instance) { | |
9951 | return instance.get_shared(); | |
9952 | } | |
9953 | template<typename T> inline CImg<T> mirror(const CImg<T>& instance, const char axe='x') { | |
9954 | return instance.get_mirror(axe); | |
9955 | } | |
9956 | template<typename T> inline CImg<T> translate(const CImg<T>& instance, const int deltax, const int deltay=0, const int deltaz=0, | |
9957 | const int deltav=0, const int border_condition=0) { | |
9958 | return instance.get_translate(deltax,deltay,deltaz,deltav,border_condition); | |
9959 | } | |
9960 | template<typename T> inline CImg<T> projections2d(const CImg<T>& instance, | |
9961 | const unsigned int x0, const unsigned int y0, const unsigned int z0, | |
9962 | const int dx=-100, const int dy=-100, const int dz=-100) { | |
9963 | return instance.get_projections2d(x0,y0,z0,dx,dy,dz); | |
9964 | } | |
9965 | template<typename T> inline CImg<typename cimg::last<T,float>::type> | |
9966 | histogram(const CImg<T>& instance, const unsigned int nblevels=256, const T val_min=(T)0, const T val_max=(T)0) { | |
9967 | return instance.get_histogram(nblevels,val_min,val_max); | |
9968 | } | |
9969 | template<typename T> inline CImg<T> equalize_histogram(const CImg<T>& instance, | |
9970 | const unsigned int nblevels=256, const T val_min=(T)0, const T val_max=(T)0) { | |
9971 | return instance.get_equalize_histogram(nblevels,val_min,val_max); | |
9972 | } | |
9973 | template<typename T> inline CImg<typename cimg::last<T,unsigned int>::type> label_regions(const CImg<T>& instance) { | |
9974 | return instance.get_label_regions(); | |
9975 | } | |
9976 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> norm_pointwise(const CImg<T>& instance, int norm_type=2) { | |
9977 | return instance.get_norm_pointwise(norm_type); | |
9978 | } | |
9979 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> orientation_pointwise(const CImg<T>& instance) { | |
9980 | return instance.get_orientation_pointwise(); | |
9981 | } | |
9982 | template<typename T> inline CImgList<T> split(const CImg<T>& instance, const char axe='x', const unsigned int nb=0) { | |
9983 | return instance.get_split(axe,nb); | |
9984 | } | |
9985 | template<typename T> inline CImg<T> append(const CImg<T>& instance, const CImg<T>& img, const char axis='x', const char align='c') { | |
9986 | return instance.get_append(img,axis,align); | |
9987 | } | |
9988 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> gradientXY(const CImg<T>& instance, const int scheme=0) { | |
9989 | return instance.get_gradientXY(scheme); | |
9990 | } | |
9991 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> gradientXYZ(const CImg<T>& instance, const int scheme=0) { | |
9992 | return instance.get_gradientXYZ(scheme); | |
9993 | } | |
9994 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> structure_tensorXY(const CImg<T>& instance, const int scheme=1) { | |
9995 | return instance.get_structure_tensorXY(scheme); | |
9996 | } | |
9997 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> structure_tensorXYZ(const CImg<T>& instance, const int scheme=1) { | |
9998 | return instance.get_structure_tensorXYZ(scheme); | |
9999 | } | |
10000 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10001 | distance_function(const CImg<T>& instance, const unsigned int nb_iter=100, const float band_size=0.0f, const float precision=0.5f) { | |
10002 | return instance.get_distance_function(nb_iter,band_size,precision); | |
10003 | } | |
10004 | template<typename T, typename t> inline CImg<typename cimg::superset<T,float>::type> | |
10005 | dijkstra(const CImg<T>& instance, const unsigned int starting_node, const unsigned int ending_node, CImg<t>& previous) { | |
10006 | return instance.get_dijkstra(starting_node,ending_node,previous); | |
10007 | } | |
10008 | template<typename T, typename t> inline CImg<typename cimg::superset<T,float>::type> | |
10009 | dijkstra(const CImg<T>& instance, const unsigned int starting_node, const unsigned int ending_node=~0U) { | |
10010 | return instance.get_dijkstra(starting_node,ending_node); | |
10011 | } | |
10012 | template<typename T, typename t> inline CImg<t> RGBtoLUT(const CImg<T>& instance, const CImg<t>& palette, | |
10013 | const bool dithering=true, const bool indexing=false) { | |
10014 | return instance.get_RGBtoLUT(palette,dithering,indexing); | |
10015 | } | |
10016 | template<typename T> inline CImg<T> RGBtoLUT(const CImg<T>& instance, const bool dithering=true, const bool indexing=false) { | |
10017 | return instance.get_RGBtoLUT(dithering,indexing); | |
10018 | } | |
10019 | template<typename T, typename t> inline CImg<t> LUTtoRGB(const CImg<T>& instance, const CImg<t>& palette) { | |
10020 | return instance.get_LUTtoRGB(palette); | |
10021 | } | |
10022 | template<typename T> inline CImg<T> LUTtoRGB(const CImg<T>& instance) { | |
10023 | return instance.get_LUTtoRGB(); | |
10024 | } | |
10025 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> RGBtoHSV(const CImg<T>& instance) { | |
10026 | return instance.get_RGBtoHSV(); | |
10027 | } | |
10028 | template<typename T> inline CImg<T> HSVtoRGB(const CImg<T>& instance) { | |
10029 | return instance.get_HSVtoRGB(); | |
10030 | } | |
10031 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> RGBtoHSL(const CImg<T>& instance) { | |
10032 | return instance.get_RGBtoHSL(); | |
10033 | } | |
10034 | template<typename T> inline CImg<T> HSLtoRGB(const CImg<T>& instance) { | |
10035 | return instance.get_HSLtoRGB(); | |
10036 | } | |
10037 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> RGBtoHSI(const CImg<T>& instance) { | |
10038 | return instance.get_RGBtoHSI(); | |
10039 | } | |
10040 | template<typename T> inline CImg<T> HSItoRGB(const CImg<T>& instance) { | |
10041 | return instance.get_HSItoRGB(); | |
10042 | } | |
10043 | template<typename T> inline CImg<T> RGBtoYCbCr(const CImg<T>& instance) { | |
10044 | return instance.get_RGBtoYCbCr(); | |
10045 | } | |
10046 | template<typename T> inline CImg<T> YCbCrtoRGB(const CImg<T>& instance) { | |
10047 | return instance.get_YCbCrtoRGB(); | |
10048 | } | |
10049 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> RGBtoYUV(const CImg<T>& instance) { | |
10050 | return instance.get_RGBtoYUV(); | |
10051 | } | |
10052 | template<typename T> inline CImg<T> YUVtoRGB(const CImg<T>& instance) { | |
10053 | return instance.get_YUVtoRGB(); | |
10054 | } | |
10055 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> RGBtoXYZ(const CImg<T>& instance) { | |
10056 | return instance.get_RGBtoXYZ(); | |
10057 | } | |
10058 | template<typename T> inline CImg<T> XYZtoRGB(const CImg<T>& instance) { | |
10059 | return instance.get_XYZtoRGB(); | |
10060 | } | |
10061 | template<typename T> inline CImg<T> XYZtoLab(const CImg<T>& instance) { | |
10062 | return instance.get_XYZtoLab(); | |
10063 | } | |
10064 | template<typename T> inline CImg<T> LabtoXYZ(const CImg<T>& instance) { | |
10065 | return instance.get_LabtoXYZ(); | |
10066 | } | |
10067 | template<typename T> inline CImg<T> XYZtoxyY(const CImg<T>& instance) { | |
10068 | return instance.get_XYZtoxyY(); | |
10069 | } | |
10070 | template<typename T> inline CImg<T> xyYtoXYZ(const CImg<T>& instance) { | |
10071 | return instance.get_xyYtoXYZ(); | |
10072 | } | |
10073 | template<typename T> inline CImg<T> RGBtoLab(const CImg<T>& instance) { | |
10074 | return instance.get_RGBtoLab(); | |
10075 | } | |
10076 | template<typename T> inline CImg<T> LabtoRGB(const CImg<T>& instance) { | |
10077 | return instance.get_LabtoRGB(); | |
10078 | } | |
10079 | template<typename T> inline CImg<T> RGBtoxyY(const CImg<T>& instance) { | |
10080 | return instance.get_RGBtoxyY(); | |
10081 | } | |
10082 | template<typename T> inline CImg<T> xyYtoRGB(const CImg<T>& instance) { | |
10083 | return instance.get_xyYtoRGB(); | |
10084 | } | |
10085 | template<typename T> inline CImg<T> RGBtoBayer(const CImg<T>& instance, const bool even_mode=true) { | |
10086 | return instance.get_RGBtoBayer(even_mode); | |
10087 | } | |
10088 | template<typename T> inline CImg<T> BayertoRGB(const CImg<T>& instance, const unsigned int interpolation_type=3, const bool even_mode=true) { | |
10089 | return instance.get_BayertoRGB(interpolation_type,even_mode); | |
10090 | } | |
10091 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> | |
10092 | correlate(const CImg<T>& instance, const CImg<t>& mask, const unsigned int cond=1, const bool weighted_correl=false) { | |
10093 | return instance.get_correlate(mask,cond,weighted_correl); | |
10094 | } | |
10095 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> | |
10096 | convolve(const CImg<T>& instance, const CImg<t>& mask, const unsigned int cond=1, const bool weighted_convol=false) { | |
10097 | return instance.get_convolve(mask,cond,weighted_convol); | |
10098 | } | |
10099 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> | |
10100 | erode(const CImg<T>& instance, const CImg<t>& mask, const unsigned int cond=1, const bool weighted_erosion=false) { | |
10101 | return instance.get_erode(mask,cond,weighted_erosion); | |
10102 | } | |
10103 | template<typename T> inline CImg<T> erode(const CImg<T>& instance, const unsigned int n, const unsigned int cond=1) { | |
10104 | return instance.get_erode(n,cond); | |
10105 | } | |
10106 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> | |
10107 | dilate(const CImg<T>& instance, const CImg<t>& mask, const unsigned int cond=1, const bool weighted_dilatation=false) { | |
10108 | return instance.get_dilate(mask,cond,weighted_dilatation); | |
10109 | } | |
10110 | template<typename T> inline CImg<T> dilate(const CImg<T>& instance, const unsigned int n, const unsigned int cond=1) { | |
10111 | return instance.get_dilate(n,cond); | |
10112 | } | |
10113 | template<typename T> inline CImg<T> noise(const CImg<T>& instance, const double sigma=-20, const unsigned int ntype=0) { | |
10114 | return instance.get_noise(sigma,ntype); | |
10115 | } | |
10116 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10117 | deriche(const CImg<T>& instance, const float sigma, const int order=0, const char axe='x', const bool cond=true) { | |
10118 | return instance.get_deriche(sigma,order,axe,cond); | |
10119 | } | |
10120 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10121 | blur(const CImg<T>& instance, const float sigmax, const float sigmay, const float sigmaz, const bool cond=true) { | |
10122 | return instance.get_blur(sigmax,sigmay,sigmaz,cond); | |
10123 | } | |
10124 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10125 | blur(const CImg<T>& instance, const float sigma, const bool cond=true) { | |
10126 | return instance.get_blur(sigma,cond); | |
10127 | } | |
10128 | template<typename T, typename t> inline CImg<T> blur_anisotropic(const CImg<T>& instance, const CImg<t>& G, const float amplitude=60.0f, | |
10129 | const float dl=0.8f, const float da=30.0f, | |
10130 | const float gauss_prec=2.0f, const unsigned int interpolation=0, | |
10131 | const bool fast_approx=true) { | |
10132 | return instance.get_blur_anisotropic(G,amplitude,dl,da,gauss_prec,interpolation,fast_approx); | |
10133 | } | |
10134 | template<typename T, typename tm> inline CImg<T> blur_anisotropic(const CImg<T>& instance, const CImg<tm>& mask, | |
10135 | const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, | |
10136 | const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, | |
10137 | const float da=30.0f, const float gauss_prec=2.0f, | |
10138 | const unsigned int interpolation=0, const bool fast_approx=true, | |
10139 | const float geom_factor=1.0f) { | |
10140 | return instance.get_blur_anisotropic(mask,amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation,fast_approx,geom_factor); | |
10141 | } | |
10142 | template<typename T> inline CImg<T> blur_anisotropic(const CImg<T>& instance, const float amplitude, const float sharpness=0.7f, | |
10143 | const float anisotropy=0.3f, | |
10144 | const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, | |
10145 | const float da=30.0f, const float gauss_prec=2.0f, const unsigned int interpolation=0, | |
10146 | const bool fast_approx=true, const float geom_factor=1.0f) { | |
10147 | return instance.get_blur_anisotropic(amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation,fast_approx,geom_factor); | |
10148 | } | |
10149 | template<typename T> inline CImg<T> blur_bilateral(const CImg<T>& instance, | |
10150 | const float sigmax, const float sigmay, const float sigmaz, const float sigmar, | |
10151 | const int bgridx, const int bgridy, const int bgridz, const int bgridr, | |
10152 | const bool interpolation=true) { | |
10153 | return instance.get_blur_bilateral(sigmax,sigmay,sigmaz,sigmar,bgridx,bgridy,bgridz,bgridr,interpolation); | |
10154 | } | |
10155 | template<typename T> inline CImg<T> blur_bilateral(const CImg<T>& instance, | |
10156 | const float sigmas, const float sigmar, const int bgrids=-33, const int bgridr=32, | |
10157 | const bool interpolation=true) { | |
10158 | return instance.get_blur_bilateral(sigmas,sigmar,bgrids,bgridr,interpolation); | |
10159 | } | |
10160 | template<typename T> inline CImg<T> blur_patch(const CImg<T>& instance, const unsigned int patch_size=3, | |
10161 | const float sigma_p=10.0f, const float sigma_s=10.0f, | |
10162 | const unsigned int lookup_size=4, const bool fast_approx=true) { | |
10163 | return instance.get_blur_patch(patch_size,sigma_p,sigma_s,lookup_size,fast_approx); | |
10164 | } | |
10165 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> FFT(const CImg<T>& instance, const char axe, const bool invert=false) { | |
10166 | return instance.get_FFT(axe,invert); | |
10167 | } | |
10168 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> FFT(const CImg<T>& instance, const bool invert=false) { | |
10169 | return instance.get_FFT(invert); | |
10170 | } | |
10171 | template<typename T> inline CImg<T> blur_median(const CImg<T>& instance, const unsigned int n=3) { | |
10172 | return instance.get_blur_median(n); | |
10173 | } | |
10174 | template<typename T> inline CImg<T> sharpen(const CImg<T>& instance, const float amplitude=50.0f, const float edge=1.0f, | |
10175 | const float alpha=0.0f, const float sigma=0.0f) { | |
10176 | return instance.get_sharpen(amplitude,edge,alpha,sigma); | |
10177 | } | |
10178 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10179 | haar(const CImg<T>& instance, const char axis, const bool invert=false, const unsigned int nb_scales=1) { | |
10180 | return instance.get_haar(axis,invert,nb_scales); | |
10181 | } | |
10182 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10183 | haar(const CImg<T>& instance, const bool invert=false, const unsigned int nb_scales=1) { | |
10184 | return instance.get_haar(invert,nb_scales); | |
10185 | } | |
10186 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> | |
10187 | displacement_field(const CImg<T>& instance, const CImg<T>& target, | |
10188 | const float smooth=0.1f, const float precision=0.1f, | |
10189 | const unsigned int nb_scales=0, const unsigned int itermax=10000) { | |
10190 | return instance.get_displacement_field(target,smooth,precision,nb_scales,itermax); | |
10191 | } | |
10192 | template<typename T> inline CImg<T> matrix(const CImg<T>& instance) { | |
10193 | return instance.get_matrix(); | |
10194 | } | |
10195 | template<typename T> inline CImg<T> tensor(const CImg<T>& instance) { | |
10196 | return instance.get_tensor(); | |
10197 | } | |
10198 | template<typename T> inline CImg<T> unroll(const CImg<T>& instance, const char axe='x') { | |
10199 | return instance.get_unroll(axe); | |
10200 | } | |
10201 | template<typename T> inline CImg<T> diagonal(const CImg<T>& instance) { | |
10202 | return instance.get_diagonal(); | |
10203 | } | |
10204 | template<typename T> inline CImg<T> identity_matrix(const CImg<T>& instance) { | |
10205 | return instance.get_identity_matrix(); | |
10206 | } | |
10207 | template<typename T> inline CImg<T> sequence(const CImg<T>& instance, const T a0, const T a1) { | |
10208 | return instance.get_sequence(a0,a1); | |
10209 | } | |
10210 | template<typename T> inline CImg<T> vector_at(const CImg<T>& instance, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) { | |
10211 | return instance.get_vector_at(x,y,z); | |
10212 | } | |
10213 | template<typename T> inline CImg<T> matrix_at(const CImg<T>& instance, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) { | |
10214 | return instance.get_matrix_at(x,y,z); | |
10215 | } | |
10216 | template<typename T> inline CImg<T> tensor_at(const CImg<T>& instance, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) { | |
10217 | return instance.get_tensor_at(x,y,z); | |
10218 | } | |
10219 | template<typename T> inline CImg<T> transpose(const CImg<T>& instance) { | |
10220 | return instance.get_transpose(); | |
10221 | } | |
10222 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> invert(const CImg<T>& instance, const bool use_LU=true) { | |
10223 | return instance.get_invert(use_LU); | |
10224 | } | |
10225 | template<typename T> inline CImg<typename cimg::superset<T,float>::type> pseudoinvert(const CImg<T>& instance) { | |
10226 | return instance.get_pseudoinvert(); | |
10227 | } | |
10228 | template<typename T, typename t> inline CImg<typename cimg::superset<T,t>::type> cross(const CImg<T>& instance, const CImg<t>& img) { | |
10229 | return instance.get_cross(img); | |
10230 | } | |
10231 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> SVD(const CImg<T>& instance, const bool sorting=true) { | |
10232 | return instance.get_SVD(sorting); | |
10233 | } | |
10234 | template<typename T, typename t> inline CImg<typename cimg::superset2<T,t,float>::type> solve(const CImg<T>& instance, const CImg<t>& A) { | |
10235 | return instance.get_solve(A); | |
10236 | } | |
10237 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> eigen(const CImg<T>& instance) { | |
10238 | return instance.get_eigen(); | |
10239 | } | |
10240 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> symmetric_eigen(const CImg<T>& instance) { | |
10241 | return instance.get_symmetric_eigen(); | |
10242 | } | |
10243 | template<typename T, typename t> inline CImg<T> sort(const CImg<T>& instance, CImg<t>& permutations, const bool increasing=true) { | |
10244 | return instance.get_sort(permutations,increasing); | |
10245 | } | |
10246 | template<typename T> inline CImg<T> sort(const CImg<T>& instance, const bool increasing=true) { | |
10247 | return instance.get_sort(increasing); | |
10248 | } | |
10249 | template<typename T, typename t> inline CImg<T> permute(const CImg<T>& instance, const CImg<t>& permutation) { | |
10250 | return instance.get_permute(permutation); | |
10251 | } | |
10252 | template<typename T> inline CImg<typename cimg::last<T,int>::type> | |
10253 | coordinates(const CImg<T>& instance, const int coords_type, CImgDisplay &disp, | |
10254 | unsigned int *const XYZ=0, const unsigned char *const color=0) { | |
10255 | return instance.get_coordinates(coords_type,disp,XYZ,color); | |
10256 | } | |
10257 | template<typename T, typename t> inline CImgList<typename cimg::superset<T,t>::type> | |
10258 | insert(const CImgList<T>& instance, const CImg<t>& img, const unsigned int pos=~0U, const bool shared=false) { | |
10259 | return instance.get_insert(img,pos,shared); | |
10260 | } | |
10261 | template<typename T, typename t> inline CImgList<typename cimg::superset<T,t>::type> | |
10262 | insert(const CImgList<T>& instance, const unsigned int n, const CImg<t>& img, | |
10263 | const unsigned int pos=~0U, const bool shared=false) { | |
10264 | return instance.get_insert(n,img,pos,shared); | |
10265 | } | |
10266 | template<typename T, typename t> inline CImgList<typename cimg::superset<T,t>::type> | |
10267 | insert(const CImgList<T>& instance, const CImgList<t>& list, const unsigned int pos=~0U, int shared=0) { | |
10268 | return instance.get_insert(list,pos,shared); | |
10269 | } | |
10270 | template<typename T, typename t> inline CImgList<typename cimg::superset<T,t>::type> | |
10271 | insert(const CImgList<T>& instance, const unsigned int n, const CImgList<t>& list, const unsigned int pos=~0U, const int shared=0) { | |
10272 | return instance.insert(n,list,pos,shared); | |
10273 | } | |
10274 | template<typename T> inline CImgList<T> remove(const CImgList<T>& instance, const unsigned int pos) { | |
10275 | return instance.get_remove(pos); | |
10276 | } | |
10277 | template<typename T> inline CImgList<T> remove(const CImgList<T>& instance) { | |
10278 | return instance.get_remove(); | |
10279 | } | |
10280 | template<typename T> inline CImgList<T> reverse(const CImgList<T>& instance) { | |
10281 | return instance.get_reverse(); | |
10282 | } | |
10283 | template<typename T> inline CImgList<T> crop(const CImgList<T>& instance, const unsigned int i0, const unsigned int i1, | |
10284 | const bool shared=false) { | |
10285 | return instance.get_crop(i0,i1,shared); | |
10286 | } | |
10287 | template<typename T> inline CImgList<T> crop(const CImgList<T>& instance, const unsigned int i0, const unsigned int i1, | |
10288 | const int x0, const int y0, const int z0, const int v0, | |
10289 | const int x1, const int y1, const int z1, const int v1) { | |
10290 | return instance.get_crop(i0,i1,x0,y0,z0,v0,x1,y1,z1,v1); | |
10291 | } | |
10292 | template<typename T> inline CImgList<T> crop(const CImgList<T>& instance, const unsigned int i0, const unsigned int i1, | |
10293 | const int x0, const int y0, const int z0, | |
10294 | const int x1, const int y1, const int z1) { | |
10295 | return instance.get_crop(i0,i1,x0,y0,z0,x1,y1,z1); | |
10296 | } | |
10297 | template<typename T> inline CImgList<T> crop(const CImgList<T>& instance, const unsigned int i0, const unsigned int i1, | |
10298 | const int x0, const int y0, | |
10299 | const int x1, const int y1) { | |
10300 | return instance.get_crop(i0,i1,x0,y0,x1,y1); | |
10301 | } | |
10302 | template<typename T> inline CImgList<T> crop(const CImgList<T>& instance, const unsigned int i0, const unsigned int i1, | |
10303 | const int x0, const int x1) { | |
10304 | return instance.get_crop(i0,i1,x0,x1); | |
10305 | } | |
10306 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> | |
10307 | FFT(const CImgList<T>& instance, const char axe, const bool invert=false) { | |
10308 | return instance.get_FFT(axe,invert); | |
10309 | } | |
10310 | template<typename T> inline CImgList<typename cimg::superset<T,float>::type> | |
10311 | FFT(const CImgList<T>& instance, const bool invert=false) { | |
10312 | return instance.get_FFT(invert); | |
10313 | } | |
10314 | template<typename T> inline CImgList<T> split(const CImgList<T>& instance, const char axe='x') { | |
10315 | return instance.get_split(axe); | |
10316 | } | |
10317 | template<typename T> inline CImg<T> append(const CImgList<T>& instance, const char axe='x', const char align='c') { | |
10318 | return instance.get_append(axe,align); | |
10319 | } | |
10320 | template<typename T> inline CImgList<T> crop_font(const CImgList<T>& instance) { | |
10321 | return instance.get_crop_font(); | |
10322 | } | |
10323 | struct CImgDisplay { | |
10324 | unsigned int width; | |
10325 | unsigned int height; | |
10326 | unsigned int normalization; | |
10327 | unsigned int events; | |
10328 | char* title; | |
10329 | volatile int window_x; | |
10330 | volatile int window_y; | |
10331 | volatile unsigned int window_width; | |
10332 | volatile unsigned int window_height; | |
10333 | volatile int mouse_x; | |
10334 | volatile int mouse_y; | |
10335 | volatile unsigned int buttons[512]; | |
10336 | volatile unsigned int& button; | |
10337 | volatile int wheel; | |
10338 | volatile unsigned int& key; | |
10339 | volatile unsigned int keys[512]; | |
10340 | volatile unsigned int& released_key; | |
10341 | volatile unsigned int released_keys[512]; | |
10342 | volatile bool is_closed; | |
10343 | volatile bool is_resized; | |
10344 | volatile bool is_moved; | |
10345 | volatile bool is_event; | |
10346 | bool is_fullscreen; | |
10347 | float fps_fps, min, max; | |
10348 | unsigned long timer, fps_frames, fps_timer; | |
10349 | CImgDisplay(): | |
10350 | width(0),height(0),normalization(0),events(0),title(0), | |
10351 | window_x(0),window_y(0),window_width(0),window_height(0), | |
10352 | mouse_x(0),mouse_y(0),button(*buttons),wheel(0),key(*keys),released_key(*released_keys), | |
10353 | is_closed(true),is_resized(false),is_moved(false),is_event(false),is_fullscreen(false), | |
10354 | min(0),max(0) {} | |
10355 | CImgDisplay(const unsigned int dimw, const unsigned int dimh, const char *title=0, | |
10356 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
10357 | const bool fullscreen_flag=false, const bool closed_flag=false): | |
10358 | width(0),height(0),normalization(0),events(0),title(0), | |
10359 | window_x(0),window_y(0),window_width(0),window_height(0), | |
10360 | mouse_x(0),mouse_y(0),button(*buttons),wheel(0),key(*keys),released_key(*released_keys), | |
10361 | is_closed(true),is_resized(false),is_moved(false),is_event(false),is_fullscreen(false), | |
10362 | min(0),max(0) { | |
10363 | assign(dimw,dimh,title,normalization_type,events_type,fullscreen_flag,closed_flag); | |
10364 | } | |
10365 | template<typename T> | |
10366 | CImgDisplay(const CImg<T>& img, const char *title=0, | |
10367 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
10368 | const bool fullscreen_flag=false, const bool closed_flag=false): | |
10369 | width(0),height(0),normalization(0),events(0),title(0), | |
10370 | window_x(0),window_y(0),window_width(0),window_height(0), | |
10371 | mouse_x(0),mouse_y(0),button(*buttons),wheel(0),key(*keys),released_key(*released_keys), | |
10372 | is_closed(true),is_resized(false),is_moved(false),is_event(false),is_fullscreen(false),min(0),max(0) { | |
10373 | assign(img,title,normalization_type,events_type,fullscreen_flag,closed_flag); | |
10374 | } | |
10375 | template<typename T> | |
10376 | CImgDisplay(const CImgList<T>& list, const char *title=0, | |
10377 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
10378 | const bool fullscreen_flag=false, const bool closed_flag=false): | |
10379 | width(0),height(0),normalization(0),events(0),title(0), | |
10380 | window_x(0),window_y(0),window_width(0),window_height(0), | |
10381 | mouse_x(0),mouse_y(0),button(*buttons),wheel(0),key(*keys),released_key(*released_keys), | |
10382 | is_closed(true),is_resized(false),is_moved(false),is_event(false),is_fullscreen(false),min(0),max(0) { | |
10383 | assign(list,title,normalization_type,events_type,fullscreen_flag,closed_flag); | |
10384 | } | |
10385 | CImgDisplay(const CImgDisplay& disp): | |
10386 | width(0),height(0),normalization(0),events(0),title(0), | |
10387 | window_x(0),window_y(0),window_width(0),window_height(0), | |
10388 | mouse_x(0),mouse_y(0),button(*buttons),wheel(0),key(*keys),released_key(*released_keys), | |
10389 | is_closed(true),is_resized(false),is_moved(false),is_event(false),is_fullscreen(false),min(0),max(0) { | |
10390 | assign(disp); | |
10391 | } | |
10392 | ~CImgDisplay() { | |
10393 | assign(); | |
10394 | } | |
10395 | CImgDisplay& operator=(const CImgDisplay& disp) { | |
10396 | return assign(disp); | |
10397 | } | |
10398 | bool is_empty() const { | |
10399 | return (!width || !height); | |
10400 | } | |
10401 | operator bool() const { | |
10402 | return !is_empty(); | |
10403 | } | |
10404 | int dimx() const { | |
10405 | return (int)width; | |
10406 | } | |
10407 | int dimy() const { | |
10408 | return (int)height; | |
10409 | } | |
10410 | int window_dimx() const { | |
10411 | return (int)window_width; | |
10412 | } | |
10413 | int window_dimy() const { | |
10414 | return (int)window_height; | |
10415 | } | |
10416 | int window_posx() const { | |
10417 | return window_x; | |
10418 | } | |
10419 | int window_posy() const { | |
10420 | return window_y; | |
10421 | } | |
10422 | CImgDisplay& wait(const unsigned int milliseconds) { | |
10423 | cimg::wait(milliseconds, timer); | |
10424 | return *this; | |
10425 | } | |
10426 | CImgDisplay& wait() { | |
10427 | if (!is_empty()) wait(*this); | |
10428 | return *this; | |
10429 | } | |
10430 | static void wait(CImgDisplay& disp1) { | |
10431 | disp1.is_event = 0; | |
10432 | while (!disp1.is_event) wait_all(); | |
10433 | } | |
10434 | static void wait(CImgDisplay& disp1, CImgDisplay& disp2) { | |
10435 | disp1.is_event = disp2.is_event = 0; | |
10436 | while (!disp1.is_event && !disp2.is_event) wait_all(); | |
10437 | } | |
10438 | static void wait(CImgDisplay& disp1, CImgDisplay& disp2, CImgDisplay& disp3) { | |
10439 | disp1.is_event = disp2.is_event = disp3.is_event = 0; | |
10440 | while (!disp1.is_event && !disp2.is_event && !disp3.is_event) wait_all(); | |
10441 | } | |
10442 | static void wait(CImgDisplay& disp1, CImgDisplay& disp2, CImgDisplay& disp3, CImgDisplay& disp4) { | |
10443 | disp1.is_event = disp2.is_event = disp3.is_event = disp4.is_event = 0; | |
10444 | while (!disp1.is_event && !disp2.is_event && !disp3.is_event && !disp4.is_event) wait_all(); | |
10445 | } | |
10446 | float frames_per_second() { | |
10447 | if (!fps_timer) fps_timer = cimg::time(); | |
10448 | const float delta = (cimg::time()-fps_timer)/1000.0f; | |
10449 | ++fps_frames; | |
10450 | if (delta>=1.0f) { | |
10451 | fps_fps = fps_frames/delta; | |
10452 | fps_frames = 0; | |
10453 | fps_timer = cimg::time(); | |
10454 | } | |
10455 | return fps_fps; | |
10456 | } | |
10457 | template<typename T> CImgDisplay& display(const CImgList<T>& list, const char axe='x', const char align='c') { | |
10458 | return display(list.get_append(axe,align)); | |
10459 | } | |
10460 | template<typename T> CImgDisplay& operator<<(const CImg<T>& img) { | |
10461 | return display(img); | |
10462 | } | |
10463 | template<typename T> CImgDisplay& operator<<(const CImgList<T>& list) { | |
10464 | return display(list); | |
10465 | } | |
10466 | template<typename T> CImgDisplay& resize(const CImg<T>& img, const bool redraw=true) { | |
10467 | return resize(img.width,img.height,redraw); | |
10468 | } | |
10469 | CImgDisplay& resize(const CImgDisplay& disp, const bool redraw=true) { | |
10470 | return resize(disp.width,disp.height,redraw); | |
10471 | } | |
10472 | CImgDisplay& resize(const bool redraw=true) { | |
10473 | resize(window_width,window_height,redraw); | |
10474 | return *this; | |
10475 | } | |
10476 | template<typename tp, typename tf, typename tc, typename to> | |
10477 | CImgDisplay& display_object3d(const tp& points, const CImgList<tf>& primitives, | |
10478 | const CImgList<tc>& colors, const to& opacities, | |
10479 | const bool centering=true, | |
10480 | const int render_static=4, const int render_motion=1, | |
10481 | const bool double_sided=false, const float focale=500.0f, | |
10482 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
10483 | const bool display_axes=true, float *const pose_matrix=0) { | |
10484 | CImg<tc>(width,height,1,3,0).display_object3d(points,primitives,colors,opacities,*this, | |
10485 | centering,render_static,render_motion, | |
10486 | double_sided,focale,specular_light,specular_shine, | |
10487 | display_axes,pose_matrix); | |
10488 | return *this; | |
10489 | } | |
10490 | template<typename tp, typename tf, typename tc> | |
10491 | CImgDisplay& display_object3d(const tp& points, const CImgList<tf>& primitives, | |
10492 | const CImgList<tc>& colors, | |
10493 | const bool centering=true, | |
10494 | const int render_static=4, const int render_motion=1, | |
10495 | const bool double_sided=false, const float focale=500.0f, | |
10496 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
10497 | const bool display_axes=true, | |
10498 | float *const pose_matrix=0, | |
10499 | const float opacity=1.0f) { | |
10500 | typedef typename cimg::superset<tc,float>::type to; | |
10501 | CImg<tc>(width,height,1,3,0).display_object3d(points,primitives,colors, | |
10502 | CImg<to>::vector((to)opacity), | |
10503 | *this,centering,render_static,render_motion, | |
10504 | double_sided,focale,specular_light,specular_shine,display_axes,pose_matrix); | |
10505 | return *this; | |
10506 | } | |
10507 | CImgDisplay& toggle_fullscreen() { | |
10508 | return assign(width,height,title,normalization,events,!is_fullscreen,is_closed); | |
10509 | } | |
10510 | template<typename t, typename T> static void _render_resize(const T *ptrs, const unsigned int ws, const unsigned int hs, | |
10511 | t *ptrd, const unsigned int wd, const unsigned int hd) { | |
10512 | unsigned int *const offx = new unsigned int[wd], *const offy = new unsigned int[hd+1], *poffx, *poffy; | |
10513 | float s, curr, old; | |
10514 | s = (float)ws/wd; | |
10515 | poffx = offx; curr = 0; for (unsigned int x=0; x<wd; ++x) { old=curr; curr+=s; *(poffx++) = (unsigned int)curr-(unsigned int)old; } | |
10516 | s = (float)hs/hd; | |
10517 | poffy = offy; curr = 0; for (unsigned int y=0; y<hd; ++y) { old=curr; curr+=s; *(poffy++) = ws*((unsigned int)curr-(unsigned int)old); } | |
10518 | *poffy = 0; | |
10519 | poffy = offy; | |
10520 | {for (unsigned int y=0; y<hd; ) { | |
10521 | const T *ptr = ptrs; | |
10522 | poffx = offx; | |
10523 | for (unsigned int x=0; x<wd; ++x) { *(ptrd++) = *ptr; ptr+=*(poffx++); } | |
10524 | ++y; | |
10525 | unsigned int dy=*(poffy++); | |
10526 | for (;!dy && y<hd; std::memcpy(ptrd, ptrd-wd, sizeof(t)*wd), ++y, ptrd+=wd, dy=*(poffy++)); | |
10527 | ptrs+=dy; | |
10528 | }} | |
10529 | delete[] offx; delete[] offy; | |
10530 | } | |
10531 | CImgDisplay& flush() { | |
10532 | std::memset((void*)buttons,0,512*sizeof(unsigned int)); | |
10533 | std::memset((void*)keys,0,512*sizeof(unsigned int)); | |
10534 | std::memset((void*)released_keys,0,512*sizeof(unsigned int)); | |
10535 | mouse_x = mouse_y = -1; | |
10536 | return *this; | |
10537 | } | |
10538 | bool is_key(const bool remove=false) { | |
10539 | for (unsigned int *ptrs=(unsigned int*)keys+512-1; ptrs>=keys; --ptrs) if (*ptrs) { if (remove) *ptrs = 0; return true; } | |
10540 | return false; | |
10541 | } | |
10542 | bool is_key(const unsigned int key1, const bool remove) { | |
10543 | for (unsigned int *ptrs=(unsigned int*)keys+512-1; ptrs>=keys; --ptrs) if (*ptrs==key1) { if (remove) *ptrs = 0; return true; } | |
10544 | return false; | |
10545 | } | |
10546 | bool is_key(const unsigned int key1, const unsigned int key2, const bool remove) { | |
10547 | const unsigned int seq[] = { key1, key2 }; | |
10548 | return is_key(seq,2,remove); | |
10549 | } | |
10550 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, const bool remove) { | |
10551 | const unsigned int seq[] = { key1, key2, key3 }; | |
10552 | return is_key(seq,3,remove); | |
10553 | } | |
10554 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, | |
10555 | const unsigned int key4, const bool remove) { | |
10556 | const unsigned int seq[] = { key1, key2, key3, key4 }; | |
10557 | return is_key(seq,4,remove); | |
10558 | } | |
10559 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, | |
10560 | const unsigned int key4, const unsigned int key5, const bool remove) { | |
10561 | const unsigned int seq[] = { key1, key2, key3, key4, key5 }; | |
10562 | return is_key(seq,5,remove); | |
10563 | } | |
10564 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, | |
10565 | const unsigned int key4, const unsigned int key5, const unsigned int key6, const bool remove) { | |
10566 | const unsigned int seq[] = { key1, key2, key3, key4, key5, key6 }; | |
10567 | return is_key(seq,6,remove); | |
10568 | } | |
10569 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, | |
10570 | const unsigned int key4, const unsigned int key5, const unsigned int key6, | |
10571 | const unsigned int key7, const bool remove) { | |
10572 | const unsigned int seq[] = { key1, key2, key3, key4, key5, key6, key7 }; | |
10573 | return is_key(seq,7,remove); | |
10574 | } | |
10575 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, | |
10576 | const unsigned int key4, const unsigned int key5, const unsigned int key6, | |
10577 | const unsigned int key7, const unsigned int key8, const bool remove) { | |
10578 | const unsigned int seq[] = { key1, key2, key3, key4, key5, key6, key7, key8 }; | |
10579 | return is_key(seq,8,remove); | |
10580 | } | |
10581 | bool is_key(const unsigned int key1, const unsigned int key2, const unsigned int key3, | |
10582 | const unsigned int key4, const unsigned int key5, const unsigned int key6, | |
10583 | const unsigned int key7, const unsigned int key8, const unsigned int key9, const bool remove) { | |
10584 | const unsigned int seq[] = { key1, key2, key3, key4, key5, key6, key7, key8, key9 }; | |
10585 | return is_key(seq,9,remove); | |
10586 | } | |
10587 | bool is_key(const unsigned int *const keyseq, const unsigned int N, const bool remove=true) { | |
10588 | if (keyseq && N) { | |
10589 | const unsigned int *const ps_end = keyseq+N-1, k = *ps_end, *const pk_end = (unsigned int*)keys+1+512-N; | |
10590 | for (unsigned int *pk = (unsigned int*)keys; pk<pk_end; ) { | |
10591 | if (*(pk++)==k) { | |
10592 | bool res = true; | |
10593 | const unsigned int *ps = ps_end, *pk2 = pk; | |
10594 | for (unsigned int i=1; i<N; ++i) res = (*(--ps)==*(pk2++)); | |
10595 | if (res) { | |
10596 | if (remove) std::memset((void*)(pk-1),0,sizeof(unsigned int)*N); | |
10597 | return true; | |
10598 | } | |
10599 | } | |
10600 | } | |
10601 | } | |
10602 | return false; | |
10603 | } | |
10604 | void *data; | |
10605 | Window window; | |
10606 | Window background_window; | |
10607 | XImage *image; | |
10608 | Colormap colormap; | |
10609 | Atom wm_delete_window, wm_delete_protocol; | |
10610 | static int screen_dimx() { | |
10611 | int res = 0; | |
10612 | if (!cimg::X11attr().display) { | |
10613 | Display *disp = XOpenDisplay((std::getenv("DISPLAY")?std::getenv("DISPLAY"):":0.0")); | |
10614 | if (!disp) throw CImgDisplayException("CImgDisplay::screen_dimx() : Can't open X11 display"); | |
10615 | res = ((&((_XPrivDisplay)disp)->screens[(((_XPrivDisplay)disp)->default_screen)])->width); | |
10616 | XCloseDisplay(disp); | |
10617 | } else { | |
10618 | res = ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->width); | |
10619 | } | |
10620 | return res; | |
10621 | } | |
10622 | static int screen_dimy() { | |
10623 | int res = 0; | |
10624 | if (!cimg::X11attr().display) { | |
10625 | Display *disp = XOpenDisplay((std::getenv("DISPLAY") ? std::getenv("DISPLAY") : ":0.0")); | |
10626 | if (!disp) throw CImgDisplayException("CImgDisplay::screen_dimy() : Can't open X11 display"); | |
10627 | res = ((&((_XPrivDisplay)disp)->screens[(((_XPrivDisplay)disp)->default_screen)])->height); | |
10628 | XCloseDisplay(disp); | |
10629 | } else { | |
10630 | res = ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->height); | |
10631 | } | |
10632 | return res; | |
10633 | } | |
10634 | CImgDisplay& assign() { | |
10635 | if (!is_empty()) { | |
10636 | XLockDisplay(cimg::X11attr().display); | |
10637 | unsigned int i; | |
10638 | for (i=0; i<cimg::X11attr().nb_wins && cimg::X11attr().wins[i]!=this; ++i); | |
10639 | for (; i<cimg::X11attr().nb_wins-1; ++i) cimg::X11attr().wins[i]=cimg::X11attr().wins[i+1]; | |
10640 | --cimg::X11attr().nb_wins; | |
10641 | if (is_fullscreen) _desinit_fullscreen(); | |
10642 | XDestroyWindow(cimg::X11attr().display,window); | |
10643 | window = 0; | |
10644 | ((*((image)->f.destroy_image))((image))); | |
10645 | data = 0; | |
10646 | image = 0; | |
10647 | if (cimg::X11attr().nb_bits==8) XFreeColormap(cimg::X11attr().display,colormap); | |
10648 | colormap = 0; | |
10649 | XSync(cimg::X11attr().display, 0); | |
10650 | if (title) delete[] title; | |
10651 | width = height = normalization = events = 0; | |
10652 | is_fullscreen = is_resized = is_moved = is_event = false; | |
10653 | is_closed = true; | |
10654 | title = 0; | |
10655 | window_x = window_y = window_width = window_height = mouse_x = mouse_y = wheel = 0; | |
10656 | std::memset((void*)buttons,0,512*sizeof(unsigned int)); | |
10657 | std::memset((void*)keys,0,512*sizeof(unsigned int)); | |
10658 | std::memset((void*)released_keys,0,512*sizeof(unsigned int)); | |
10659 | min = max = 0; | |
10660 | XUnlockDisplay(cimg::X11attr().display); | |
10661 | } | |
10662 | return *this; | |
10663 | } | |
10664 | CImgDisplay& assign(const unsigned int dimw, const unsigned int dimh, const char *title=0, | |
10665 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
10666 | const bool fullscreen_flag=false, const bool closed_flag=false) { | |
10667 | if (!dimw || !dimh) return assign(); | |
10668 | _assign(dimw,dimh,title,normalization_type,events_type,fullscreen_flag,closed_flag); | |
10669 | min = max = 0; | |
10670 | std::memset(data,0,(cimg::X11attr().nb_bits==8?sizeof(unsigned char): | |
10671 | (cimg::X11attr().nb_bits==16?sizeof(unsigned short):sizeof(unsigned int)))*width*height); | |
10672 | return paint(); | |
10673 | } | |
10674 | template<typename T> CImgDisplay& assign(const CImg<T>& img, const char *title=0, | |
10675 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
10676 | const bool fullscreen_flag=false, const bool closed_flag=false) { | |
10677 | if (!img) return assign(); | |
10678 | CImg<T> tmp; | |
10679 | const CImg<T>& nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2)); | |
10680 | _assign(nimg.width,nimg.height,title,normalization_type,events_type,fullscreen_flag,closed_flag); | |
10681 | if (normalization==2) min = (float)nimg.minmax(max); | |
10682 | return render(nimg).paint(); | |
10683 | } | |
10684 | template<typename T> CImgDisplay& assign(const CImgList<T>& list, const char *title=0, | |
10685 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
10686 | const bool fullscreen_flag=false, const bool closed_flag=false) { | |
10687 | if (!list) return assign(); | |
10688 | CImg<T> tmp; | |
10689 | const CImg<T> img = list.get_append('x','p'), | |
10690 | &nimg = (img.depth==1)?img:(tmp=img.get_projections2d(img.width/2,img.height/2,img.depth/2)); | |
10691 | _assign(nimg.width,nimg.height,title,normalization_type,events_type,fullscreen_flag,closed_flag); | |
10692 | if (normalization==2) min = (float)nimg.minmax(max); | |
10693 | return render(nimg).paint(); | |
10694 | } | |
10695 | CImgDisplay& assign(const CImgDisplay& win) { | |
10696 | if (!win) return assign(); | |
10697 | _assign(win.width,win.height,win.title,win.normalization,win.events,win.is_fullscreen,win.is_closed); | |
10698 | std::memcpy(data,win.data,(cimg::X11attr().nb_bits==8?sizeof(unsigned char): | |
10699 | cimg::X11attr().nb_bits==16?sizeof(unsigned short): | |
10700 | sizeof(unsigned int))*width*height); | |
10701 | return paint(); | |
10702 | } | |
10703 | template<typename T> CImgDisplay& display(const CImg<T>& img) { | |
10704 | if (is_empty()) assign(img.width,img.height); | |
10705 | return render(img).paint(false); | |
10706 | } | |
10707 | CImgDisplay& resize(const int nwidth, const int nheight, const bool redraw=true) { | |
10708 | if (!nwidth || !nheight) return assign(); | |
10709 | if (is_empty()) return assign(cimg::max(nwidth,0),cimg::max(nheight,0)); | |
10710 | const unsigned int | |
10711 | tmpdimx = (nwidth>0)?nwidth:(-nwidth*width/100), | |
10712 | tmpdimy = (nheight>0)?nheight:(-nheight*height/100), | |
10713 | dimx = cimg::min(tmpdimx?tmpdimx:1,(unsigned int)screen_dimx()), | |
10714 | dimy = cimg::min(tmpdimy?tmpdimy:1,(unsigned int)screen_dimy()); | |
10715 | const bool | |
10716 | is_disp_different = (width!=dimx || height!=dimy), | |
10717 | is_win_different = (window_width!=dimx || window_height!=dimy); | |
10718 | if (is_disp_different || is_win_different) { | |
10719 | XLockDisplay(cimg::X11attr().display); | |
10720 | XResizeWindow(cimg::X11attr().display,window,dimx,dimy); | |
10721 | window_width = dimx; | |
10722 | window_height = dimy; | |
10723 | is_resized = false; | |
10724 | if (is_disp_different) { | |
10725 | switch (cimg::X11attr().nb_bits) { | |
10726 | case 8: { unsigned char foo = 0; _resize(foo,dimx,dimy,redraw); } break; | |
10727 | case 16: { unsigned short foo = 0; _resize(foo,dimx,dimy,redraw); } break; | |
10728 | default: { unsigned int foo = 0; _resize(foo,dimx,dimy,redraw); } break; | |
10729 | } | |
10730 | width = dimx; | |
10731 | height = dimy; | |
10732 | } | |
10733 | XUnlockDisplay(cimg::X11attr().display); | |
10734 | if (is_fullscreen) move((screen_dimx()-width)/2,(screen_dimy()-height)/2); | |
10735 | if (redraw) return paint(); | |
10736 | } | |
10737 | return *this; | |
10738 | } | |
10739 | CImgDisplay& move(const int posx, const int posy) { | |
10740 | if (is_empty()) return *this; | |
10741 | show(); | |
10742 | XLockDisplay(cimg::X11attr().display); | |
10743 | XMoveWindow(cimg::X11attr().display,window,posx,posy); | |
10744 | is_moved = false; | |
10745 | window_x = posx; | |
10746 | window_y = posy; | |
10747 | XUnlockDisplay(cimg::X11attr().display); | |
10748 | return paint(); | |
10749 | } | |
10750 | CImgDisplay& set_mouse(const int posx, const int posy) { | |
10751 | if (!is_closed && posx>=0 && posy>=0) { | |
10752 | XLockDisplay(cimg::X11attr().display); | |
10753 | XWarpPointer(cimg::X11attr().display,0L,window,0,0,0,0,posx,posy); | |
10754 | is_moved = false; | |
10755 | mouse_x = posx; | |
10756 | mouse_y = posy; | |
10757 | XSync(cimg::X11attr().display, 0); | |
10758 | XUnlockDisplay(cimg::X11attr().display); | |
10759 | } | |
10760 | return *this; | |
10761 | } | |
10762 | CImgDisplay& hide_mouse() { | |
10763 | if (cimg::X11attr().display) { | |
10764 | XLockDisplay(cimg::X11attr().display); | |
10765 | const char pix_data[8] = { 0 }; | |
10766 | XColor col; | |
10767 | col.red = col.green = col.blue = 0; | |
10768 | Pixmap pix = XCreateBitmapFromData(cimg::X11attr().display,window,pix_data,8,8); | |
10769 | Cursor cur = XCreatePixmapCursor(cimg::X11attr().display,pix,pix,&col,&col,0,0); | |
10770 | XFreePixmap(cimg::X11attr().display,pix); | |
10771 | XDefineCursor(cimg::X11attr().display,window,cur); | |
10772 | XUnlockDisplay(cimg::X11attr().display); | |
10773 | } | |
10774 | return *this; | |
10775 | } | |
10776 | CImgDisplay& show_mouse() { | |
10777 | if (cimg::X11attr().display) { | |
10778 | XLockDisplay(cimg::X11attr().display); | |
10779 | XDefineCursor(cimg::X11attr().display,window,0L); | |
10780 | XUnlockDisplay(cimg::X11attr().display); | |
10781 | } | |
10782 | return *this; | |
10783 | } | |
10784 | static void wait_all() { | |
10785 | if (cimg::X11attr().display) { | |
10786 | XLockDisplay(cimg::X11attr().display); | |
10787 | bool flag = true; | |
10788 | XEvent event; | |
10789 | while (flag) { | |
10790 | for (unsigned int i = 0; i<cimg::X11attr().nb_wins; ++i) { | |
10791 | cimg::X11attr().wins[i]->is_event = false; | |
10792 | const unsigned int | |
10793 | xevent_type = (cimg::X11attr().wins[i]->events)&3, | |
10794 | emask = ((xevent_type>=1)?(1L<<15)|(1L<<17):0) | | |
10795 | ((xevent_type>=2)?(1L<<2)|(1L<<0)|(1L<<6)|(1L<<5):0) | | |
10796 | ((xevent_type>=3)?(1L<<3)|(1L<<1):0); | |
10797 | XSelectInput(cimg::X11attr().display,cimg::X11attr().wins[i]->window,emask); | |
10798 | } | |
10799 | XNextEvent(cimg::X11attr().display, &event); | |
10800 | for (unsigned int i = 0; i<cimg::X11attr().nb_wins; ++i) | |
10801 | if (!cimg::X11attr().wins[i]->is_closed && event.xany.window==cimg::X11attr().wins[i]->window) { | |
10802 | cimg::X11attr().wins[i]->_handle_events(&event); | |
10803 | if (cimg::X11attr().wins[i]->is_event) flag = false; | |
10804 | } | |
10805 | } | |
10806 | XUnlockDisplay(cimg::X11attr().display); | |
10807 | } | |
10808 | } | |
10809 | CImgDisplay& show() { | |
10810 | if (is_empty()) return *this; | |
10811 | if (is_closed) { | |
10812 | XLockDisplay(cimg::X11attr().display); | |
10813 | if (is_fullscreen) _init_fullscreen(); | |
10814 | _map_window(); | |
10815 | is_closed = false; | |
10816 | XUnlockDisplay(cimg::X11attr().display); | |
10817 | } | |
10818 | return paint(); | |
10819 | } | |
10820 | CImgDisplay& close() { | |
10821 | if (is_empty()) return *this; | |
10822 | if (!is_closed) { | |
10823 | XLockDisplay(cimg::X11attr().display); | |
10824 | if (is_fullscreen) _desinit_fullscreen(); | |
10825 | XUnmapWindow(cimg::X11attr().display,window); | |
10826 | window_x = window_y = -1; | |
10827 | is_closed = true; | |
10828 | XUnlockDisplay(cimg::X11attr().display); | |
10829 | } | |
10830 | return *this; | |
10831 | } | |
10832 | CImgDisplay& set_title(const char *format, ...) { | |
10833 | if (is_empty()) return *this; | |
10834 | char tmp[1024] = {0}; | |
10835 | va_list ap; | |
10836 | __builtin_va_start(ap,format); | |
10837 | std::vsprintf(tmp,format,ap); | |
10838 | __builtin_va_end(ap); | |
10839 | if (title) delete[] title; | |
10840 | const int s = cimg::strlen(tmp)+1; | |
10841 | title = new char[s]; | |
10842 | std::memcpy(title,tmp,s*sizeof(char)); | |
10843 | XLockDisplay(cimg::X11attr().display); | |
10844 | XStoreName(cimg::X11attr().display,window,tmp); | |
10845 | XUnlockDisplay(cimg::X11attr().display); | |
10846 | return *this; | |
10847 | } | |
10848 | CImgDisplay& paint(const bool wait_expose=true) { | |
10849 | if (is_empty()) return *this; | |
10850 | XLockDisplay(cimg::X11attr().display); | |
10851 | _paint(wait_expose); | |
10852 | XUnlockDisplay(cimg::X11attr().display); | |
10853 | return *this; | |
10854 | } | |
10855 | template<typename T> CImgDisplay& render(const CImg<T>& img, const bool flag8=false) { | |
10856 | if (is_empty()) return *this; | |
10857 | if (!img) | |
10858 | throw CImgArgumentException("CImgDisplay::_render_image() : Specified input image (%u,%u,%u,%u,%p) is empty.", | |
10859 | img.width,img.height,img.depth,img.dim,img.data); | |
10860 | if (img.depth!=1) return render(img.get_projections2d(img.width/2,img.height/2,img.depth/2)); | |
10861 | if (cimg::X11attr().nb_bits==8 && (img.width!=width || img.height!=height)) return render(img.get_resize(width,height,1,-100,1)); | |
10862 | if (cimg::X11attr().nb_bits==8 && !flag8 && img.dim==3) return render(img.get_RGBtoLUT(true),true); | |
10863 | const T | |
10864 | *data1 = img.data, | |
10865 | *data2 = (img.dim>1)?img.ptr(0,0,0,1):data1, | |
10866 | *data3 = (img.dim>2)?img.ptr(0,0,0,2):data1; | |
10867 | if (cimg::X11attr().blue_first) cimg::swap(data1,data3); | |
10868 | XLockDisplay(cimg::X11attr().display); | |
10869 | if (!normalization || (normalization==3 && cimg::type<T>::string()==cimg::type<unsigned char>::string())) { | |
10870 | min = max = 0; | |
10871 | switch (cimg::X11attr().nb_bits) { | |
10872 | case 8: { | |
10873 | _set_colormap(colormap,img.dim); | |
10874 | unsigned char *const ndata = (img.width==width && img.height==height)?(unsigned char*)data:new unsigned char[img.width*img.height]; | |
10875 | unsigned char *ptrd = (unsigned char*)ndata; | |
10876 | switch (img.dim) { | |
10877 | case 1: for (unsigned int xy = img.width*img.height; xy>0; --xy) (*ptrd++) = (unsigned char)*(data1++); | |
10878 | break; | |
10879 | case 2: for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10880 | const unsigned char R = (unsigned char)*(data1++), G = (unsigned char)*(data2++); | |
10881 | (*ptrd++) = (R&0xf0) | (G>>4); | |
10882 | } break; | |
10883 | default: for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10884 | const unsigned char R = (unsigned char)*(data1++), G = (unsigned char)*(data2++), B = (unsigned char)*(data3++); | |
10885 | (*ptrd++) = (R&0xe0) | ((G>>5)<<2) | (B>>6); | |
10886 | } break; | |
10887 | } | |
10888 | if (ndata!=data) { _render_resize(ndata,img.width,img.height,(unsigned char*)data,width,height); delete[] ndata; } | |
10889 | } break; | |
10890 | case 16: { | |
10891 | unsigned short *const ndata = (img.width==width && img.height==height)?(unsigned short*)data:new unsigned short[img.width*img.height]; | |
10892 | unsigned char *ptrd = (unsigned char*)ndata; | |
10893 | const unsigned int M = 248; | |
10894 | switch (img.dim) { | |
10895 | case 1: | |
10896 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10897 | const unsigned char val = (unsigned char)*(data1++), G = val>>2; | |
10898 | *(ptrd++) = val&M | (G>>3); | |
10899 | *(ptrd++) = (G<<5) | (G>>1); | |
10900 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10901 | const unsigned char val = (unsigned char)*(data1++), G = val>>2; | |
10902 | *(ptrd++) = (G<<5) | (G>>1); | |
10903 | *(ptrd++) = val&M | (G>>3); | |
10904 | } | |
10905 | break; | |
10906 | case 2: | |
10907 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10908 | const unsigned char G = (unsigned char)*(data2++)>>2; | |
10909 | *(ptrd++) = (unsigned char)*(data1++)&M | (G>>3); | |
10910 | *(ptrd++) = (G<<5); | |
10911 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10912 | const unsigned char G = (unsigned char)*(data2++)>>2; | |
10913 | *(ptrd++) = (G<<5); | |
10914 | *(ptrd++) = (unsigned char)*(data1++)&M | (G>>3); | |
10915 | } | |
10916 | break; | |
10917 | default: | |
10918 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10919 | const unsigned char G = (unsigned char)*(data2++)>>2; | |
10920 | *(ptrd++) = (unsigned char)*(data1++)&M | (G>>3); | |
10921 | *(ptrd++) = (G<<5) | ((unsigned char)*(data3++)>>3); | |
10922 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10923 | const unsigned char G = (unsigned char)*(data2++)>>2; | |
10924 | *(ptrd++) = (G<<5) | ((unsigned char)*(data3++)>>3); | |
10925 | *(ptrd++) = (unsigned char)*(data1++)&M | (G>>3); | |
10926 | } | |
10927 | break; | |
10928 | } | |
10929 | if (ndata!=data) { _render_resize(ndata,img.width,img.height,(unsigned short*)data,width,height); delete[] ndata; } | |
10930 | } break; | |
10931 | default: { | |
10932 | unsigned int *const ndata = (img.width==width && img.height==height)?(unsigned int*)data:new unsigned int[img.width*img.height]; | |
10933 | if (sizeof(int)==4) { | |
10934 | unsigned int *ptrd = ndata; | |
10935 | switch (img.dim) { | |
10936 | case 1: | |
10937 | if (cimg::X11attr().byte_order==cimg::endian()) | |
10938 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10939 | const unsigned char val = (unsigned char)*(data1++); | |
10940 | *(ptrd++) = (val<<16) | (val<<8) | val; | |
10941 | } | |
10942 | else | |
10943 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10944 | const unsigned char val = (unsigned char)*(data1++)<<8; | |
10945 | *(ptrd++) = (val<<16) | (val<<8) | val; | |
10946 | } | |
10947 | break; | |
10948 | case 2: | |
10949 | if (cimg::X11attr().byte_order==cimg::endian()) | |
10950 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
10951 | *(ptrd++) = ((unsigned char)*(data1++)<<16) | ((unsigned char)*(data2++)<<8); | |
10952 | else | |
10953 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
10954 | *(ptrd++) = ((unsigned char)*(data2++)<<16) | ((unsigned char)*(data1++)<<8); | |
10955 | break; | |
10956 | default: | |
10957 | if (cimg::X11attr().byte_order==cimg::endian()) | |
10958 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
10959 | *(ptrd++) = ((unsigned char)*(data1++)<<16) | ((unsigned char)*(data2++)<<8) | (unsigned char)*(data3++); | |
10960 | else | |
10961 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
10962 | *(ptrd++) = ((unsigned char)*(data3++)<<24) | ((unsigned char)*(data2++)<<16) | ((unsigned char)*(data1++)<<8); | |
10963 | break; | |
10964 | } | |
10965 | } else { | |
10966 | unsigned char *ptrd = (unsigned char*)ndata; | |
10967 | switch (img.dim) { | |
10968 | case 1: | |
10969 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10970 | *(ptrd++) = 0; | |
10971 | *(ptrd++) = (unsigned char)*(data1++); | |
10972 | *(ptrd++) = 0; | |
10973 | *(ptrd++) = 0; | |
10974 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10975 | *(ptrd++) = 0; | |
10976 | *(ptrd++) = 0; | |
10977 | *(ptrd++) = (unsigned char)*(data1++); | |
10978 | *(ptrd++) = 0; | |
10979 | } | |
10980 | break; | |
10981 | case 2: | |
10982 | if (cimg::X11attr().byte_order) cimg::swap(data1,data2); | |
10983 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10984 | *(ptrd++) = 0; | |
10985 | *(ptrd++) = (unsigned char)*(data2++); | |
10986 | *(ptrd++) = (unsigned char)*(data1++); | |
10987 | *(ptrd++) = 0; | |
10988 | } | |
10989 | break; | |
10990 | default: | |
10991 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10992 | *(ptrd++) = 0; | |
10993 | *(ptrd++) = (unsigned char)*(data1++); | |
10994 | *(ptrd++) = (unsigned char)*(data2++); | |
10995 | *(ptrd++) = (unsigned char)*(data3++); | |
10996 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
10997 | *(ptrd++) = (unsigned char)*(data3++); | |
10998 | *(ptrd++) = (unsigned char)*(data2++); | |
10999 | *(ptrd++) = (unsigned char)*(data1++); | |
11000 | *(ptrd++) = 0; | |
11001 | } | |
11002 | break; | |
11003 | } | |
11004 | } | |
11005 | if (ndata!=data) { _render_resize(ndata,img.width,img.height,(unsigned int*)data,width,height); delete[] ndata; } | |
11006 | } break; | |
11007 | }; | |
11008 | } else { | |
11009 | if (normalization==3) { | |
11010 | if (cimg::type<T>::is_float()) min = (float)img.minmax(max); | |
11011 | else { min = (float)cimg::type<T>::min(); max = (float)cimg::type<T>::max(); } | |
11012 | } else if ((min>max) || normalization==1) min = (float)img.minmax(max); | |
11013 | const float delta = max-min, mm = delta?delta:1.0f; | |
11014 | switch (cimg::X11attr().nb_bits) { | |
11015 | case 8: { | |
11016 | _set_colormap(colormap,img.dim); | |
11017 | unsigned char *const ndata = (img.width==width && img.height==height)?(unsigned char*)data:new unsigned char[img.width*img.height]; | |
11018 | unsigned char *ptrd = (unsigned char*)ndata; | |
11019 | switch (img.dim) { | |
11020 | case 1: for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11021 | const unsigned char R = (unsigned char)(255*(*(data1++)-min)/mm); | |
11022 | *(ptrd++) = R; | |
11023 | } break; | |
11024 | case 2: for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11025 | const unsigned char | |
11026 | R = (unsigned char)(255*(*(data1++)-min)/mm), | |
11027 | G = (unsigned char)(255*(*(data2++)-min)/mm); | |
11028 | (*ptrd++) = (R&0xf0) | (G>>4); | |
11029 | } break; | |
11030 | default: | |
11031 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11032 | const unsigned char | |
11033 | R = (unsigned char)(255*(*(data1++)-min)/mm), | |
11034 | G = (unsigned char)(255*(*(data2++)-min)/mm), | |
11035 | B = (unsigned char)(255*(*(data3++)-min)/mm); | |
11036 | *(ptrd++) = (R&0xe0) | ((G>>5)<<2) | (B>>6); | |
11037 | } break; | |
11038 | } | |
11039 | if (ndata!=data) { _render_resize(ndata,img.width,img.height,(unsigned char*)data,width,height); delete[] ndata; } | |
11040 | } break; | |
11041 | case 16: { | |
11042 | unsigned short *const ndata = (img.width==width && img.height==height)?(unsigned short*)data:new unsigned short[img.width*img.height]; | |
11043 | unsigned char *ptrd = (unsigned char*)ndata; | |
11044 | const unsigned int M = 248; | |
11045 | switch (img.dim) { | |
11046 | case 1: | |
11047 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11048 | const unsigned char val = (unsigned char)(255*(*(data1++)-min)/mm), G = val>>2; | |
11049 | *(ptrd++) = val&M | (G>>3); | |
11050 | *(ptrd++) = (G<<5) | (val>>3); | |
11051 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11052 | const unsigned char val = (unsigned char)(255*(*(data1++)-min)/mm), G = val>>2; | |
11053 | *(ptrd++) = (G<<5) | (val>>3); | |
11054 | *(ptrd++) = val&M | (G>>3); | |
11055 | } | |
11056 | break; | |
11057 | case 2: | |
11058 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11059 | const unsigned char G = (unsigned char)(255*(*(data2++)-min)/mm)>>2; | |
11060 | *(ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm)&M | (G>>3); | |
11061 | *(ptrd++) = (G<<5); | |
11062 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11063 | const unsigned char G = (unsigned char)(255*(*(data2++)-min)/mm)>>2; | |
11064 | *(ptrd++) = (G<<5); | |
11065 | *(ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm)&M | (G>>3); | |
11066 | } | |
11067 | break; | |
11068 | default: | |
11069 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11070 | const unsigned char G = (unsigned char)(255*(*(data2++)-min)/mm)>>2; | |
11071 | *(ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm)&M | (G>>3); | |
11072 | *(ptrd++) = (G<<5) | ((unsigned char)(255*(*(data3++)-min)/mm)>>3); | |
11073 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11074 | const unsigned char G = (unsigned char)(255*(*(data2++)-min)/mm)>>2; | |
11075 | *(ptrd++) = (G<<5) | ((unsigned char)(255*(*(data3++)-min)/mm)>>3); | |
11076 | *(ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm)&M | (G>>3); | |
11077 | } | |
11078 | break; | |
11079 | } | |
11080 | if (ndata!=data) { _render_resize(ndata,img.width,img.height,(unsigned short*)data,width,height); delete[] ndata; } | |
11081 | } break; | |
11082 | default: { | |
11083 | unsigned int *const ndata = (img.width==width && img.height==height)?(unsigned int*)data:new unsigned int[img.width*img.height]; | |
11084 | if (sizeof(int)==4) { | |
11085 | unsigned int *ptrd = ndata; | |
11086 | switch (img.dim) { | |
11087 | case 1: | |
11088 | if (cimg::X11attr().byte_order==cimg::endian()) | |
11089 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11090 | const unsigned char val = (unsigned char)(255*(*(data1++)-min)/mm); | |
11091 | *(ptrd++) = (val<<16) | (val<<8) | val; | |
11092 | } | |
11093 | else | |
11094 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11095 | const unsigned char val = (unsigned char)(255*(*(data1++)-min)/mm); | |
11096 | *(ptrd++) = (val<<24) | (val<<16) | (val<<8); | |
11097 | } | |
11098 | break; | |
11099 | case 2: | |
11100 | if (cimg::X11attr().byte_order==cimg::endian()) | |
11101 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
11102 | *(ptrd++) = | |
11103 | ((unsigned char)(255*(*(data1++)-min)/mm)<<16) | | |
11104 | ((unsigned char)(255*(*(data2++)-min)/mm)<<8); | |
11105 | else | |
11106 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
11107 | *(ptrd++) = | |
11108 | ((unsigned char)(255*(*(data2++)-min)/mm)<<16) | | |
11109 | ((unsigned char)(255*(*(data1++)-min)/mm)<<8); | |
11110 | break; | |
11111 | default: | |
11112 | if (cimg::X11attr().byte_order==cimg::endian()) | |
11113 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
11114 | *(ptrd++) = | |
11115 | ((unsigned char)(255*(*(data1++)-min)/mm)<<16) | | |
11116 | ((unsigned char)(255*(*(data2++)-min)/mm)<<8) | | |
11117 | (unsigned char)(255*(*(data3++)-min)/mm); | |
11118 | else | |
11119 | for (unsigned int xy = img.width*img.height; xy>0; --xy) | |
11120 | *(ptrd++) = | |
11121 | ((unsigned char)(255*(*(data3++)-min)/mm)<<24) | | |
11122 | ((unsigned char)(255*(*(data2++)-min)/mm)<<16) | | |
11123 | ((unsigned char)(255*(*(data1++)-min)/mm)<<8); | |
11124 | break; | |
11125 | } | |
11126 | } else { | |
11127 | unsigned char *ptrd = (unsigned char*)ndata; | |
11128 | switch (img.dim) { | |
11129 | case 1: | |
11130 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11131 | const unsigned char val = (unsigned char)(255*(*(data1++)-min)/mm); | |
11132 | (*ptrd++) = 0; | |
11133 | (*ptrd++) = val; | |
11134 | (*ptrd++) = val; | |
11135 | (*ptrd++) = val; | |
11136 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11137 | const unsigned char val = (unsigned char)(255*(*(data1++)-min)/mm); | |
11138 | (*ptrd++) = val; | |
11139 | (*ptrd++) = val; | |
11140 | (*ptrd++) = val; | |
11141 | (*ptrd++) = 0; | |
11142 | } | |
11143 | break; | |
11144 | case 2: | |
11145 | if (cimg::X11attr().byte_order) cimg::swap(data1,data2); | |
11146 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11147 | (*ptrd++) = 0; | |
11148 | (*ptrd++) = (unsigned char)(255*(*(data2++)-min)/mm); | |
11149 | (*ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm); | |
11150 | (*ptrd++) = 0; | |
11151 | } | |
11152 | break; | |
11153 | default: | |
11154 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11155 | (*ptrd++) = 0; | |
11156 | (*ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm); | |
11157 | (*ptrd++) = (unsigned char)(255*(*(data2++)-min)/mm); | |
11158 | (*ptrd++) = (unsigned char)(255*(*(data3++)-min)/mm); | |
11159 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11160 | (*ptrd++) = (unsigned char)(255*(*(data3++)-min)/mm); | |
11161 | (*ptrd++) = (unsigned char)(255*(*(data2++)-min)/mm); | |
11162 | (*ptrd++) = (unsigned char)(255*(*(data1++)-min)/mm); | |
11163 | (*ptrd++) = 0; | |
11164 | } | |
11165 | break; | |
11166 | } | |
11167 | } | |
11168 | if (ndata!=data) { _render_resize(ndata,img.width,img.height,(unsigned int*)data,width,height); delete[] ndata; } | |
11169 | } break; | |
11170 | } | |
11171 | } | |
11172 | XUnlockDisplay(cimg::X11attr().display); | |
11173 | return *this; | |
11174 | } | |
11175 | template<typename T> const CImgDisplay& snapshot(CImg<T>& img) const { | |
11176 | if (is_empty()) img.assign(); | |
11177 | else { | |
11178 | img.assign(width,height,1,3); | |
11179 | T | |
11180 | *data1 = img.ptr(0,0,0,0), | |
11181 | *data2 = img.ptr(0,0,0,1), | |
11182 | *data3 = img.ptr(0,0,0,2); | |
11183 | if (cimg::X11attr().blue_first) cimg::swap(data1,data3); | |
11184 | switch (cimg::X11attr().nb_bits) { | |
11185 | case 8: { | |
11186 | unsigned char *ptrs = (unsigned char*)data; | |
11187 | for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11188 | const unsigned char val = *(ptrs++); | |
11189 | *(data1++) = val&0xe0; | |
11190 | *(data2++) = (val&0x1c)<<3; | |
11191 | *(data3++) = val<<6; | |
11192 | } | |
11193 | } break; | |
11194 | case 16: { | |
11195 | unsigned char *ptrs = (unsigned char*)data; | |
11196 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11197 | const unsigned char val0 = *(ptrs++), val1 = *(ptrs++); | |
11198 | *(data1++) = val0&0xf8; | |
11199 | *(data2++) = (val0<<5) | ((val1&0xe0)>>5); | |
11200 | *(data3++) = val1<<3; | |
11201 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11202 | const unsigned short val0 = *(ptrs++), val1 = *(ptrs++); | |
11203 | *(data1++) = val1&0xf8; | |
11204 | *(data2++) = (val1<<5) | ((val0&0xe0)>>5); | |
11205 | *(data3++) = val0<<3; | |
11206 | } | |
11207 | } break; | |
11208 | default: { | |
11209 | unsigned char *ptrs = (unsigned char*)data; | |
11210 | if (cimg::X11attr().byte_order) for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11211 | ++ptrs; | |
11212 | *(data1++) = *(ptrs++); | |
11213 | *(data2++) = *(ptrs++); | |
11214 | *(data3++) = *(ptrs++); | |
11215 | } else for (unsigned int xy = img.width*img.height; xy>0; --xy) { | |
11216 | *(data3++) = *(ptrs++); | |
11217 | *(data2++) = *(ptrs++); | |
11218 | *(data1++) = *(ptrs++); | |
11219 | ++ptrs; | |
11220 | } | |
11221 | } break; | |
11222 | } | |
11223 | } | |
11224 | return *this; | |
11225 | } | |
11226 | static int _assign_xshm(Display *dpy, XErrorEvent *error) { | |
11227 | dpy = 0; error = 0; | |
11228 | cimg::X11attr().shm_enabled = false; | |
11229 | return 0; | |
11230 | } | |
11231 | void _assign(const unsigned int dimw, const unsigned int dimh, const char *ptitle=0, | |
11232 | const unsigned int normalization_type=3, const unsigned int events_type=3, | |
11233 | const bool fullscreen_flag=false, const bool closed_flag=false) { | |
11234 | const int s = cimg::strlen(ptitle)+1; | |
11235 | char *tmp_title = s?new char[s]:0; | |
11236 | if (s) std::memcpy(tmp_title,ptitle,s*sizeof(char)); | |
11237 | if (!is_empty()) assign(); | |
11238 | if (!cimg::X11attr().display) { | |
11239 | static bool xinit_threads = false; | |
11240 | if (!xinit_threads) { XInitThreads(); xinit_threads = true; } | |
11241 | cimg::X11attr().nb_wins = 0; | |
11242 | cimg::X11attr().display = XOpenDisplay((std::getenv("DISPLAY") ? std::getenv("DISPLAY") : ":0.0")); | |
11243 | if (!cimg::X11attr().display) | |
11244 | throw CImgDisplayException("CImgDisplay::_create_window() : Can't open X11 display"); | |
11245 | cimg::X11attr().nb_bits = ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root_depth); | |
11246 | if (cimg::X11attr().nb_bits!=8 && cimg::X11attr().nb_bits!=16 && cimg::X11attr().nb_bits!=24 && cimg::X11attr().nb_bits!=32) | |
11247 | throw CImgDisplayException("CImgDisplay::_create_window() : %u bits mode is not supported " | |
11248 | "(only 8, 16, 24 and 32 bits modes are supported)",cimg::X11attr().nb_bits); | |
11249 | cimg::X11attr().gc = new GC; | |
11250 | *cimg::X11attr().gc = ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->default_gc); | |
11251 | Visual *visual = ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root_visual); | |
11252 | XVisualInfo vtemplate; | |
11253 | vtemplate.visualid = XVisualIDFromVisual(visual); | |
11254 | int nb_visuals; | |
11255 | XVisualInfo *vinfo = XGetVisualInfo(cimg::X11attr().display,0x1,&vtemplate,&nb_visuals); | |
11256 | if (vinfo && vinfo->red_mask<vinfo->blue_mask) cimg::X11attr().blue_first = true; | |
11257 | cimg::X11attr().byte_order = (((_XPrivDisplay)cimg::X11attr().display)->byte_order); | |
11258 | XFree(vinfo); | |
11259 | XLockDisplay(cimg::X11attr().display); | |
11260 | cimg::X11attr().event_thread = new pthread_t; | |
11261 | pthread_create(cimg::X11attr().event_thread,0,_events_thread,0); | |
11262 | } else XLockDisplay(cimg::X11attr().display); | |
11263 | width = cimg::min(dimw,(unsigned int)screen_dimx()); | |
11264 | height = cimg::min(dimh,(unsigned int)screen_dimy()); | |
11265 | normalization = normalization_type%4; | |
11266 | events = events_type%4; | |
11267 | is_fullscreen = fullscreen_flag; | |
11268 | title = tmp_title; | |
11269 | window_x = window_y = wheel = 0; | |
11270 | mouse_x = mouse_y = -1; | |
11271 | std::memset((void*)buttons,0,512*sizeof(unsigned int)); | |
11272 | std::memset((void*)keys,0,512*sizeof(unsigned int)); | |
11273 | std::memset((void*)released_keys,0,512*sizeof(unsigned int)); | |
11274 | is_resized = is_moved = is_event = false; | |
11275 | is_closed = closed_flag; | |
11276 | fps_timer = fps_frames = timer = 0; | |
11277 | fps_fps = 0; | |
11278 | if (is_fullscreen) { | |
11279 | _init_fullscreen(); | |
11280 | const unsigned int sx = screen_dimx(), sy = screen_dimy(); | |
11281 | XSetWindowAttributes winattr; | |
11282 | winattr.override_redirect = 1; | |
11283 | window = XCreateWindow(cimg::X11attr().display, | |
11284 | ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root), | |
11285 | (sx-width)/2,(sy-height)/2, | |
11286 | width,height,0,0,1,0L,(1L<<9),&winattr); | |
11287 | } else | |
11288 | window = XCreateSimpleWindow(cimg::X11attr().display, | |
11289 | ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root), | |
11290 | 0,0,width,height,2,0,0x0L); | |
11291 | XStoreName(cimg::X11attr().display,window,title?title:" "); | |
11292 | if (cimg::X11attr().nb_bits==8) { | |
11293 | colormap = XCreateColormap(cimg::X11attr().display,window,((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root_visual),1); | |
11294 | _set_colormap(colormap,3); | |
11295 | XSetWindowColormap(cimg::X11attr().display,window,colormap); | |
11296 | } | |
11297 | window_width = width; | |
11298 | window_height = height; | |
11299 | const unsigned int bufsize = width*height*(cimg::X11attr().nb_bits==8?1:(cimg::X11attr().nb_bits==16?2:4)); | |
11300 | { | |
11301 | data = std::malloc(bufsize); | |
11302 | image = XCreateImage(cimg::X11attr().display,((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root_visual), | |
11303 | cimg::X11attr().nb_bits,2,0,(char*)data,width,height,8,0); | |
11304 | } | |
11305 | if (!is_closed) _map_window(); else { window_x = window_y = cimg::type<int>::min(); } | |
11306 | if (events) { | |
11307 | wm_delete_window = XInternAtom(cimg::X11attr().display, "WM_DELETE_WINDOW", 0); | |
11308 | wm_delete_protocol = XInternAtom(cimg::X11attr().display, "WM_PROTOCOLS", 0); | |
11309 | XSetWMProtocols(cimg::X11attr().display, window, &wm_delete_window, 1); | |
11310 | if (is_fullscreen) XGrabKeyboard(cimg::X11attr().display, window, 1, 1, 1, 0L); | |
11311 | } | |
11312 | cimg::X11attr().wins[cimg::X11attr().nb_wins++]=this; | |
11313 | XUnlockDisplay(cimg::X11attr().display); | |
11314 | } | |
11315 | void _map_window() { | |
11316 | XWindowAttributes attr; | |
11317 | XEvent event; | |
11318 | XSelectInput(cimg::X11attr().display,window,(1L<<15) | (1L<<17)); | |
11319 | bool exposed = false, mapped = false; | |
11320 | XMapRaised(cimg::X11attr().display,window); | |
11321 | XSync(cimg::X11attr().display,0); | |
11322 | do { | |
11323 | XWindowEvent(cimg::X11attr().display,window,(1L<<17) | (1L<<15),&event); | |
11324 | switch (event.type) { | |
11325 | case 19: mapped = true; break; | |
11326 | case 12: exposed = true; break; | |
11327 | default: XSync(cimg::X11attr().display, 0); cimg::sleep(10); | |
11328 | } | |
11329 | } while (!(exposed && mapped)); | |
11330 | do { | |
11331 | XGetWindowAttributes(cimg::X11attr().display, window, &attr); | |
11332 | if (attr.map_state!=2) { XSync(cimg::X11attr().display,0); cimg::sleep(10); } | |
11333 | } while (attr.map_state != 2); | |
11334 | window_x = attr.x; | |
11335 | window_y = attr.y; | |
11336 | } | |
11337 | void _set_colormap(Colormap& colormap, const unsigned int dim) { | |
11338 | XColor palette[256]; | |
11339 | switch (dim) { | |
11340 | case 1: | |
11341 | for (unsigned int index=0; index<256; ++index) { | |
11342 | palette[index].pixel = index; | |
11343 | palette[index].red = palette[index].green = palette[index].blue = (unsigned short)(index<<8); | |
11344 | palette[index].flags = (1<<0) | (1<<1) | (1<<2); | |
11345 | } | |
11346 | break; | |
11347 | case 2: | |
11348 | for (unsigned int index=0, r=8; r<256; r+=16) | |
11349 | for (unsigned int g=8; g<256; g+=16) { | |
11350 | palette[index].pixel = index; | |
11351 | palette[index].red = palette[index].blue = (unsigned short)(r<<8); | |
11352 | palette[index].green = (unsigned short)(g<<8); | |
11353 | palette[index++].flags = (1<<0) | (1<<1) | (1<<2); | |
11354 | } | |
11355 | break; | |
11356 | default: | |
11357 | for (unsigned int index=0, r=16; r<256; r+=32) | |
11358 | for (unsigned int g=16; g<256; g+=32) | |
11359 | for (unsigned int b=32; b<256; b+=64) { | |
11360 | palette[index].pixel = index; | |
11361 | palette[index].red = (unsigned short)(r<<8); | |
11362 | palette[index].green = (unsigned short)(g<<8); | |
11363 | palette[index].blue = (unsigned short)(b<<8); | |
11364 | palette[index++].flags = (1<<0) | (1<<1) | (1<<2); | |
11365 | } | |
11366 | break; | |
11367 | } | |
11368 | XStoreColors(cimg::X11attr().display,colormap,palette,256); | |
11369 | } | |
11370 | void _paint(const bool wait_expose=true) { | |
11371 | if (!is_closed) { | |
11372 | if (wait_expose) { | |
11373 | static XEvent event; | |
11374 | event.xexpose.type = 12; | |
11375 | event.xexpose.serial = 0; | |
11376 | event.xexpose.send_event = 1; | |
11377 | event.xexpose.display = cimg::X11attr().display; | |
11378 | event.xexpose.window = window; | |
11379 | event.xexpose.x = 0; | |
11380 | event.xexpose.y = 0; | |
11381 | event.xexpose.width = dimx(); | |
11382 | event.xexpose.height = dimy(); | |
11383 | event.xexpose.count = 0; | |
11384 | XSendEvent(cimg::X11attr().display, window, 0, 0, &event); | |
11385 | } else { | |
11386 | XPutImage(cimg::X11attr().display,window,*cimg::X11attr().gc,image,0,0,0,0,width,height); | |
11387 | XSync(cimg::X11attr().display, 0); | |
11388 | } | |
11389 | } | |
11390 | } | |
11391 | template<typename T> void _resize(T foo, const unsigned int ndimx, const unsigned int ndimy, const bool redraw) { | |
11392 | foo = 0; | |
11393 | { | |
11394 | T *ndata = (T*)std::malloc(ndimx*ndimy*sizeof(T)); | |
11395 | if (redraw) _render_resize((T*)data,width,height,ndata,ndimx,ndimy); | |
11396 | else std::memset(ndata,0,sizeof(T)*ndimx*ndimy); | |
11397 | data = (void*)ndata; | |
11398 | ((*((image)->f.destroy_image))((image))); | |
11399 | image = XCreateImage(cimg::X11attr().display,((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root_visual), | |
11400 | cimg::X11attr().nb_bits,2,0,(char*)data,ndimx,ndimy,8,0); | |
11401 | } | |
11402 | } | |
11403 | void _init_fullscreen() { | |
11404 | background_window = 0; | |
11405 | if (is_fullscreen && !is_closed) { | |
11406 | const unsigned int sx = screen_dimx(), sy = screen_dimy(); | |
11407 | XSetWindowAttributes winattr; | |
11408 | winattr.override_redirect = 1; | |
11409 | if (sx!=width || sy!=height) { | |
11410 | background_window = XCreateWindow(cimg::X11attr().display, | |
11411 | ((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root),0,0, | |
11412 | sx,sy,0,0,1,0L,(1L<<9),&winattr); | |
11413 | const unsigned int bufsize = sx*sy*(cimg::X11attr().nb_bits==8?1:(cimg::X11attr().nb_bits==16?2:4)); | |
11414 | void *background_data = std::malloc(bufsize); | |
11415 | std::memset(background_data,0,bufsize); | |
11416 | XImage *background_image = XCreateImage(cimg::X11attr().display,((&((_XPrivDisplay)cimg::X11attr().display)->screens[(((_XPrivDisplay)cimg::X11attr().display)->default_screen)])->root_visual), | |
11417 | cimg::X11attr().nb_bits,2,0,(char*)background_data,sx,sy,8,0); | |
11418 | XEvent event; | |
11419 | XSelectInput(cimg::X11attr().display,background_window,(1L<<17)); | |
11420 | XMapRaised(cimg::X11attr().display,background_window); | |
11421 | do XWindowEvent(cimg::X11attr().display,background_window,(1L<<17),&event); | |
11422 | while (event.type!=19); | |
11423 | XPutImage(cimg::X11attr().display,background_window,*cimg::X11attr().gc,background_image,0,0,0,0,sx,sy); | |
11424 | XWindowAttributes attr; | |
11425 | XGetWindowAttributes(cimg::X11attr().display, background_window, &attr); | |
11426 | while (attr.map_state != 2) XSync(cimg::X11attr().display, 0); | |
11427 | ((*((background_image)->f.destroy_image))((background_image))); | |
11428 | } | |
11429 | } | |
11430 | } | |
11431 | void _desinit_fullscreen() { | |
11432 | if (is_fullscreen) { | |
11433 | XUngrabKeyboard(cimg::X11attr().display,0L); | |
11434 | if (background_window) XDestroyWindow(cimg::X11attr().display,background_window); | |
11435 | background_window = 0; | |
11436 | is_fullscreen = false; | |
11437 | } | |
11438 | } | |
11439 | void _handle_events(const XEvent *const pevent) { | |
11440 | XEvent event=*pevent; | |
11441 | switch (event.type) { | |
11442 | case 33: | |
11443 | if ((int)event.xclient.message_type==(int)wm_delete_protocol && | |
11444 | (int)event.xclient.data.l[0]==(int)wm_delete_window) { | |
11445 | XUnmapWindow(cimg::X11attr().display,window); | |
11446 | mouse_x = mouse_y = -1; | |
11447 | if (button) { | |
11448 | std::memmove((void*)(buttons+1),(void*)buttons,512-1); | |
11449 | button = 0; | |
11450 | } | |
11451 | if (key) { | |
11452 | std::memmove((void*)(keys+1),(void*)keys,512-1); | |
11453 | key = 0; | |
11454 | } | |
11455 | if (released_key) { | |
11456 | std::memmove((void*)(released_keys+1),(void*)released_keys,512-1); | |
11457 | released_key = 0; | |
11458 | } | |
11459 | is_closed = is_event = true; | |
11460 | } | |
11461 | break; | |
11462 | case 22: { | |
11463 | while (XCheckWindowEvent(cimg::X11attr().display,window,(1L<<17),&event)); | |
11464 | const unsigned int | |
11465 | nw = event.xconfigure.width, | |
11466 | nh = event.xconfigure.height; | |
11467 | const int | |
11468 | nx = event.xconfigure.x, | |
11469 | ny = event.xconfigure.y; | |
11470 | if (nw && nh && (nw!=window_width || nh!=window_height)) { | |
11471 | window_width = nw; | |
11472 | window_height = nh; | |
11473 | mouse_x = mouse_y = -1; | |
11474 | XResizeWindow(cimg::X11attr().display,window,window_width,window_height); | |
11475 | is_resized = is_event = true; | |
11476 | } | |
11477 | if (nx!=window_x || ny!=window_y) { | |
11478 | window_x = nx; | |
11479 | window_y = ny; | |
11480 | is_moved = is_event = true; | |
11481 | } | |
11482 | } break; | |
11483 | case 12: { | |
11484 | while (XCheckWindowEvent(cimg::X11attr().display,window,(1L<<15),&event)); | |
11485 | _paint(false); | |
11486 | if (is_fullscreen) { | |
11487 | XWindowAttributes attr; | |
11488 | XGetWindowAttributes(cimg::X11attr().display, window, &attr); | |
11489 | while (attr.map_state != 2) XSync(cimg::X11attr().display, 0); | |
11490 | XSetInputFocus(cimg::X11attr().display, window, 2, 0L); | |
11491 | } | |
11492 | } break; | |
11493 | case 4: { | |
11494 | do { | |
11495 | switch (event.xbutton.button) { | |
11496 | case 1: std::memmove((void*)(buttons+1),(void*)buttons,512-1); button|=1; is_event = true; break; | |
11497 | case 2: std::memmove((void*)(buttons+1),(void*)buttons,512-1); button|=4; is_event = true; break; | |
11498 | case 3: std::memmove((void*)(buttons+1),(void*)buttons,512-1); button|=2; is_event = true; break; | |
11499 | default: break; | |
11500 | } | |
11501 | } while (XCheckWindowEvent(cimg::X11attr().display,window,(1L<<2),&event)); | |
11502 | } break; | |
11503 | case 5: { | |
11504 | do { | |
11505 | switch (event.xbutton.button) { | |
11506 | case 1: std::memmove((void*)(buttons+1),(void*)buttons,512-1); button&=~1U; is_event = true; break; | |
11507 | case 2: std::memmove((void*)(buttons+1),(void*)buttons,512-1); button&=~4U; is_event = true; break; | |
11508 | case 3: std::memmove((void*)(buttons+1),(void*)buttons,512-1); button&=~2U; is_event = true; break; | |
11509 | case 4: ++wheel; is_event = true; break; | |
11510 | case 5: --wheel; is_event = true; break; | |
11511 | default: break; | |
11512 | } | |
11513 | } while (XCheckWindowEvent(cimg::X11attr().display,window,(1L<<3),&event)); | |
11514 | } break; | |
11515 | case 2: { | |
11516 | char tmp; | |
11517 | KeySym ksym; | |
11518 | XLookupString(&event.xkey,&tmp,1,&ksym,0); | |
11519 | if (key) std::memmove((void*)(keys+1),(void*)keys,512-1); | |
11520 | key = (unsigned int)ksym; | |
11521 | if (released_key) { | |
11522 | std::memmove((void*)(released_keys+1),(void*)released_keys,512-1); | |
11523 | released_key = 0; | |
11524 | } | |
11525 | is_event = true; | |
11526 | } break; | |
11527 | case 3: { | |
11528 | char tmp; | |
11529 | KeySym ksym; | |
11530 | XLookupString(&event.xkey,&tmp,1,&ksym,0); | |
11531 | if (key) { | |
11532 | std::memmove((void*)(keys+1),(void*)keys,512-1); | |
11533 | key = 0; | |
11534 | } | |
11535 | if (released_key) std::memmove((void*)(released_keys+1),(void*)released_keys,512-1); | |
11536 | released_key = (unsigned int)ksym; | |
11537 | is_event = true; | |
11538 | } break; | |
11539 | case 8: | |
11540 | while (XCheckWindowEvent(cimg::X11attr().display,window,(1L<<5),&event)); | |
11541 | mouse_x = mouse_y =-1; | |
11542 | is_event = true; | |
11543 | break; | |
11544 | case 6: | |
11545 | while (XCheckWindowEvent(cimg::X11attr().display,window,(1L<<6),&event)); | |
11546 | mouse_x = event.xmotion.x; | |
11547 | mouse_y = event.xmotion.y; | |
11548 | if (mouse_x<0 || mouse_y<0 || mouse_x>=dimx() || mouse_y>=dimy()) mouse_x = mouse_y = -1; | |
11549 | is_event = true; | |
11550 | break; | |
11551 | } | |
11552 | } | |
11553 | static void* _events_thread(void *arg) { | |
11554 | arg = 0; | |
11555 | XEvent event; | |
11556 | pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,0); | |
11557 | pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); | |
11558 | for (;;) { | |
11559 | XLockDisplay(cimg::X11attr().display); | |
11560 | for (unsigned int i=0; i<cimg::X11attr().nb_wins; ++i) { | |
11561 | const unsigned int xevent_type = (cimg::X11attr().wins[i]->events)&3; | |
11562 | const unsigned int emask = | |
11563 | ((xevent_type>=1)?(1L<<15)|(1L<<17):0)| | |
11564 | ((xevent_type>=2)?(1L<<2)|(1L<<0)|(1L<<6)|(1L<<5):0)| | |
11565 | ((xevent_type>=3)?(1L<<3)|(1L<<1):0); | |
11566 | XSelectInput(cimg::X11attr().display,cimg::X11attr().wins[i]->window,emask); | |
11567 | } | |
11568 | bool event_flag = XCheckTypedEvent(cimg::X11attr().display, 33, &event); | |
11569 | if (!event_flag) event_flag = XCheckMaskEvent(cimg::X11attr().display, | |
11570 | (1L<<15)|(1L<<17)|(1L<<2)| | |
11571 | (1L<<0)|(1L<<6)|(1L<<5)|(1L<<3)| | |
11572 | (1L<<1),&event); | |
11573 | if (event_flag) { | |
11574 | for (unsigned int i=0; i<cimg::X11attr().nb_wins; ++i) | |
11575 | if (!cimg::X11attr().wins[i]->is_closed && event.xany.window==cimg::X11attr().wins[i]->window) | |
11576 | cimg::X11attr().wins[i]->_handle_events(&event); | |
11577 | } | |
11578 | XUnlockDisplay(cimg::X11attr().display); | |
11579 | pthread_testcancel(); | |
11580 | cimg::sleep(7); | |
11581 | } | |
11582 | return 0; | |
11583 | } | |
11584 | }; | |
11585 | template<typename T> struct CImg { | |
11586 | unsigned int width; | |
11587 | unsigned int height; | |
11588 | unsigned int depth; | |
11589 | unsigned int dim; | |
11590 | bool is_shared; | |
11591 | T *data; | |
11592 | typedef T* iterator; | |
11593 | typedef const T* const_iterator; | |
11594 | typedef T value_type; | |
11595 | struct _greycstoration_params { | |
11596 | bool patch_based; | |
11597 | float amplitude; | |
11598 | float sharpness; | |
11599 | float anisotropy; | |
11600 | float alpha; | |
11601 | float sigma; | |
11602 | float gfact; | |
11603 | float dl; | |
11604 | float da; | |
11605 | float gauss_prec; | |
11606 | unsigned int interpolation; | |
11607 | unsigned int patch_size; | |
11608 | float sigma_s; | |
11609 | float sigma_p; | |
11610 | unsigned int lookup_size; | |
11611 | CImg<T> *source; | |
11612 | const CImg<unsigned char> *mask; | |
11613 | CImg<T> *temporary; | |
11614 | unsigned long *counter; | |
11615 | unsigned int tile; | |
11616 | unsigned int tile_border; | |
11617 | unsigned int thread; | |
11618 | unsigned int nb_threads; | |
11619 | bool fast_approx; | |
11620 | bool is_running; | |
11621 | bool *stop_request; | |
11622 | pthread_mutex_t | |
11623 | *mutex; | |
11624 | _greycstoration_params():patch_based(false),amplitude(0),sharpness(0),anisotropy(0),alpha(0),sigma(0),gfact(1), | |
11625 | dl(0),da(0),gauss_prec(0),interpolation(0),patch_size(0), | |
11626 | sigma_s(0),sigma_p(0),lookup_size(0),source(0),mask(0),temporary(0),counter(0),tile(0), | |
11627 | tile_border(0),thread(0),nb_threads(0),fast_approx(false),is_running(false), stop_request(0), mutex(0) {} | |
11628 | }; | |
11629 | _greycstoration_params greycstoration_params[16]; | |
11630 | bool greycstoration_is_running() const { | |
11631 | return greycstoration_params->is_running; | |
11632 | } | |
11633 | CImg& greycstoration_stop() { | |
11634 | if (greycstoration_is_running()) { | |
11635 | *(greycstoration_params->stop_request) = true; | |
11636 | while (greycstoration_params->is_running) cimg::wait(50); | |
11637 | } | |
11638 | return *this; | |
11639 | } | |
11640 | float greycstoration_progress() const { | |
11641 | if (!greycstoration_is_running()) return 0.0f; | |
11642 | const unsigned long counter = greycstoration_params->counter?*(greycstoration_params->counter):0; | |
11643 | const float | |
11644 | da = greycstoration_params->da, | |
11645 | factor = greycstoration_params->patch_based?1:(1+360/da); | |
11646 | float maxcounter = 0; | |
11647 | if (greycstoration_params->tile==0) maxcounter = width*height*depth*factor; | |
11648 | else { | |
11649 | const unsigned int | |
11650 | t = greycstoration_params->tile, | |
11651 | b = greycstoration_params->tile_border, | |
11652 | n = (1+(width-1)/t)*(1+(height-1)/t)*(1+(depth-1)/t); | |
11653 | maxcounter = (width*height*depth + n*4*b*(b + t))*factor; | |
11654 | } | |
11655 | return cimg::min(counter*99.9f/maxcounter,99.9f); | |
11656 | } | |
11657 | CImg& greycstoration_run(const CImg<unsigned char>& mask, | |
11658 | const float amplitude=60, const float sharpness=0.7f, const float anisotropy=0.3f, | |
11659 | const float alpha=0.6f, const float sigma=1.1f, const float gfact=1.0f, | |
11660 | const float dl=0.8f, const float da=30.0f, | |
11661 | const float gauss_prec=2.0f, const unsigned int interpolation=0, const bool fast_approx=true, | |
11662 | const unsigned int tile=0, const unsigned int tile_border=0, const unsigned int nb_threads=1) { | |
11663 | if (greycstoration_is_running()) | |
11664 | throw CImgInstanceException("CImg<T>::greycstoration_run() : A GREYCstoration thread is already running on" | |
11665 | " the instance image (%u,%u,%u,%u,%p).",width,height,depth,dim,data); | |
11666 | else { | |
11667 | if (!mask.is_empty() && !mask.is_sameXY(*this)) | |
11668 | throw CImgArgumentException("CImg<%s>::greycstoration_run() : Given mask (%u,%u,%u,%u,%p) and instance image " | |
11669 | "(%u,%u,%u,%u,%p) have different dimensions.", | |
11670 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data,width,height,depth,dim,data); | |
11671 | if (nb_threads>16) cimg::warn("CImg<%s>::greycstoration_run() : Multi-threading mode limited to 16 threads max."); | |
11672 | const unsigned int | |
11673 | ntile = (tile && (tile<width || tile<height || (depth>1 && tile<depth)))?tile:0, | |
11674 | nthreads = ntile?cimg::min(nb_threads,16U):cimg::min(nb_threads,1U); | |
11675 | CImg<T> *const temporary = ntile?new CImg<T>(*this):0; | |
11676 | unsigned long *const counter = new unsigned long; | |
11677 | *counter = 0; | |
11678 | bool *const stop_request = new bool; | |
11679 | *stop_request = false; | |
11680 | for (unsigned int k=0; k<(nthreads?nthreads:1); k++) { | |
11681 | greycstoration_params[k].patch_based = false; | |
11682 | greycstoration_params[k].amplitude = amplitude; | |
11683 | greycstoration_params[k].sharpness = sharpness; | |
11684 | greycstoration_params[k].anisotropy = anisotropy; | |
11685 | greycstoration_params[k].alpha = alpha; | |
11686 | greycstoration_params[k].sigma = sigma; | |
11687 | greycstoration_params[k].gfact = gfact; | |
11688 | greycstoration_params[k].dl = dl; | |
11689 | greycstoration_params[k].da = da; | |
11690 | greycstoration_params[k].gauss_prec = gauss_prec; | |
11691 | greycstoration_params[k].interpolation = interpolation; | |
11692 | greycstoration_params[k].fast_approx = fast_approx; | |
11693 | greycstoration_params[k].source = this; | |
11694 | greycstoration_params[k].mask = &mask; | |
11695 | greycstoration_params[k].temporary = temporary; | |
11696 | greycstoration_params[k].counter = counter; | |
11697 | greycstoration_params[k].tile = ntile; | |
11698 | greycstoration_params[k].tile_border = tile_border; | |
11699 | greycstoration_params[k].thread = k; | |
11700 | greycstoration_params[k].nb_threads = nthreads; | |
11701 | greycstoration_params[k].is_running = true; | |
11702 | greycstoration_params[k].stop_request = stop_request; | |
11703 | if (k) greycstoration_params[k].mutex = greycstoration_params[0].mutex; | |
11704 | else greycstoration_mutex_create(greycstoration_params[0]); | |
11705 | } | |
11706 | if (nthreads) { | |
11707 | pthread_attr_t attr; | |
11708 | pthread_attr_init(&attr); | |
11709 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | |
11710 | for (unsigned int k=0; k<greycstoration_params->nb_threads; k++) { | |
11711 | pthread_t thread; | |
11712 | const int err = pthread_create(&thread, &attr, greycstoration_thread, (void*)(greycstoration_params+k)); | |
11713 | if (err) throw CImgException("CImg<%s>::greycstoration_run() : pthread_create returned error %d", | |
11714 | pixel_type(), err); | |
11715 | } | |
11716 | } else greycstoration_thread((void*)greycstoration_params); | |
11717 | } | |
11718 | return *this; | |
11719 | } | |
11720 | CImg& greycstoration_run(const float amplitude=50, const float sharpness=0.7f, const float anisotropy=0.3f, | |
11721 | const float alpha=0.6f, const float sigma=1.1f, const float gfact=1.0f, | |
11722 | const float dl=0.8f, const float da=30.0f, | |
11723 | const float gauss_prec=2.0f, const unsigned int interpolation=0, const bool fast_approx=true, | |
11724 | const unsigned int tile=0, const unsigned int tile_border=0, const unsigned int nb_threads=1) { | |
11725 | static const CImg<unsigned char> empty_mask; | |
11726 | return greycstoration_run(empty_mask,amplitude,sharpness,anisotropy,alpha,sigma,gfact,dl,da,gauss_prec, | |
11727 | interpolation,fast_approx,tile,tile_border,nb_threads); | |
11728 | } | |
11729 | CImg& greycstoration_patch_run(const unsigned int patch_size=5, const float sigma_p=10, const float sigma_s=100, | |
11730 | const unsigned int lookup_size=20, const bool fast_approx=true, | |
11731 | const unsigned int tile=0, const unsigned int tile_border=0, const unsigned int nb_threads=1) { | |
11732 | static const CImg<unsigned char> empty_mask; | |
11733 | if (greycstoration_is_running()) | |
11734 | throw CImgInstanceException("CImg<T>::greycstoration_run() : A GREYCstoration thread is already running on" | |
11735 | " the instance image (%u,%u,%u,%u,%p).",width,height,depth,dim,data); | |
11736 | else { | |
11737 | if (nb_threads>16) cimg::warn("CImg<%s>::greycstoration_run() : Multi-threading mode limited to 16 threads max."); | |
11738 | const unsigned int | |
11739 | ntile = (tile && (tile<width || tile<height || (depth>1 && tile<depth)))?tile:0, | |
11740 | nthreads = ntile?cimg::min(nb_threads,16U):cimg::min(nb_threads,1U); | |
11741 | CImg<T> *const temporary = ntile?new CImg<T>(*this):0; | |
11742 | unsigned long *const counter = new unsigned long; | |
11743 | *counter = 0; | |
11744 | bool *const stop_request = new bool; | |
11745 | *stop_request = false; | |
11746 | for (unsigned int k=0; k<(nthreads?nthreads:1); k++) { | |
11747 | greycstoration_params[k].patch_based = true; | |
11748 | greycstoration_params[k].patch_size = patch_size; | |
11749 | greycstoration_params[k].sigma_s = sigma_s; | |
11750 | greycstoration_params[k].sigma_p = sigma_p; | |
11751 | greycstoration_params[k].lookup_size = lookup_size; | |
11752 | greycstoration_params[k].source = this; | |
11753 | greycstoration_params[k].mask = &empty_mask; | |
11754 | greycstoration_params[k].temporary = temporary; | |
11755 | greycstoration_params[k].counter = counter; | |
11756 | greycstoration_params[k].tile = ntile; | |
11757 | greycstoration_params[k].tile_border = tile_border; | |
11758 | greycstoration_params[k].thread = k; | |
11759 | greycstoration_params[k].nb_threads = nthreads; | |
11760 | greycstoration_params[k].fast_approx = fast_approx; | |
11761 | greycstoration_params[k].is_running = true; | |
11762 | greycstoration_params[k].stop_request = stop_request; | |
11763 | if (k) greycstoration_params[k].mutex = greycstoration_params[0].mutex; | |
11764 | else greycstoration_mutex_create(greycstoration_params[0]); | |
11765 | } | |
11766 | if (nthreads) { | |
11767 | pthread_attr_t attr; | |
11768 | pthread_attr_init(&attr); | |
11769 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | |
11770 | for (unsigned int k=0; k<greycstoration_params->nb_threads; k++) { | |
11771 | pthread_t thread; | |
11772 | const int err = pthread_create(&thread, &attr, greycstoration_thread, (void*)(greycstoration_params+k)); | |
11773 | if (err) throw CImgException("CImg<%s>::greycstoration_run() : pthread_create returned error %d", | |
11774 | pixel_type(), err); | |
11775 | } | |
11776 | } else greycstoration_thread((void*)greycstoration_params); | |
11777 | } | |
11778 | return *this; | |
11779 | } | |
11780 | static void greycstoration_mutex_create(_greycstoration_params &p) { | |
11781 | if (p.nb_threads>1) { | |
11782 | p.mutex = new pthread_mutex_t; | |
11783 | pthread_mutex_init(p.mutex,0); | |
11784 | } | |
11785 | } | |
11786 | static void greycstoration_mutex_lock(_greycstoration_params &p) { | |
11787 | if (p.nb_threads>1) { | |
11788 | if (p.mutex) pthread_mutex_lock(p.mutex); | |
11789 | } | |
11790 | } | |
11791 | static void greycstoration_mutex_unlock(_greycstoration_params &p) { | |
11792 | if (p.nb_threads>1) { | |
11793 | if (p.mutex) pthread_mutex_unlock(p.mutex); | |
11794 | } | |
11795 | } | |
11796 | static void greycstoration_mutex_destroy(_greycstoration_params &p) { | |
11797 | if (p.nb_threads>1) { | |
11798 | if (p.mutex) pthread_mutex_destroy(p.mutex); | |
11799 | p.mutex = 0; | |
11800 | } | |
11801 | } | |
11802 | static void* greycstoration_thread(void *arg) { | |
11803 | _greycstoration_params &p = *(_greycstoration_params*)arg; | |
11804 | greycstoration_mutex_lock(p); | |
11805 | const CImg<unsigned char> &mask = *(p.mask); | |
11806 | CImg<T> &source = *(p.source); | |
11807 | if (!p.tile) { | |
11808 | if (p.patch_based) source.blur_patch(p.patch_size,p.sigma_p,p.sigma_s,p.lookup_size,p.fast_approx); | |
11809 | else source.blur_anisotropic(mask,p.amplitude,p.sharpness,p.anisotropy,p.alpha,p.sigma,p.dl,p.da,p.gauss_prec, | |
11810 | p.interpolation,p.fast_approx,p.gfact); | |
11811 | } else { | |
11812 | CImg<T> &temporary = *(p.temporary); | |
11813 | const bool threed = (source.depth>1); | |
11814 | const unsigned int b = p.tile_border; | |
11815 | unsigned int ctile = 0; | |
11816 | if (threed) { | |
11817 | for (unsigned int z=0; z<source.depth && !*(p.stop_request); z+=p.tile) | |
11818 | for (unsigned int y=0; y<source.height && !*(p.stop_request); y+=p.tile) | |
11819 | for (unsigned int x=0; x<source.width && !*(p.stop_request); x+=p.tile) | |
11820 | if (!p.nb_threads || ((ctile++)%p.nb_threads)==p.thread) { | |
11821 | const unsigned int | |
11822 | x1 = x+p.tile-1, | |
11823 | y1 = y+p.tile-1, | |
11824 | z1 = z+p.tile-1, | |
11825 | xe = x1<source.width?x1:source.width-1, | |
11826 | ye = y1<source.height?y1:source.height-1, | |
11827 | ze = z1<source.depth?z1:source.depth-1; | |
11828 | CImg<T> img = source.get_crop(x-b,y-b,z-b,xe+b,ye+b,ze+b,true); | |
11829 | CImg<unsigned char> mask_tile = mask.is_empty()?mask:mask.get_crop(x-b,y-b,z-b,xe+b,ye+b,ze+b,true); | |
11830 | img.greycstoration_params[0] = p; | |
11831 | greycstoration_mutex_unlock(p); | |
11832 | if (p.patch_based) img.blur_patch(p.patch_size,p.sigma_p,p.sigma_s,p.lookup_size,p.fast_approx); | |
11833 | else img.blur_anisotropic(mask_tile,p.amplitude,p.sharpness,p.anisotropy, | |
11834 | p.alpha,p.sigma,p.dl,p.da,p.gauss_prec,p.interpolation,p.fast_approx,p.gfact); | |
11835 | greycstoration_mutex_lock(p); | |
11836 | temporary.draw_image(img.crop(b,b,b,img.width-b,img.height-b,img.depth-b),x,y,z); | |
11837 | } | |
11838 | } else { | |
11839 | for (unsigned int y=0; y<source.height && !*(p.stop_request); y+=p.tile) | |
11840 | for (unsigned int x=0; x<source.width && !*(p.stop_request); x+=p.tile) | |
11841 | if (!p.nb_threads || ((ctile++)%p.nb_threads)==p.thread) { | |
11842 | const unsigned int | |
11843 | x1 = x+p.tile-1, | |
11844 | y1 = y+p.tile-1, | |
11845 | xe = x1<source.width?x1:source.width-1, | |
11846 | ye = y1<source.height?y1:source.height-1; | |
11847 | CImg<T> img = source.get_crop(x-b,y-b,xe+b,ye+b,true); | |
11848 | CImg<unsigned char> mask_tile = mask.is_empty()?mask:mask.get_crop(x-b,y-b,xe+b,ye+b,true); | |
11849 | img.greycstoration_params[0] = p; | |
11850 | greycstoration_mutex_unlock(p); | |
11851 | if (p.patch_based) img.blur_patch(p.patch_size,p.sigma_p,p.sigma_s,p.lookup_size,p.fast_approx); | |
11852 | else img.blur_anisotropic(mask_tile,p.amplitude,p.sharpness,p.anisotropy, | |
11853 | p.alpha,p.sigma,p.dl,p.da,p.gauss_prec,p.interpolation,p.fast_approx,p.gfact); | |
11854 | temporary.draw_image(img.crop(b,b,img.width-b,img.height-b),x,y); | |
11855 | greycstoration_mutex_lock(p); | |
11856 | } | |
11857 | } | |
11858 | } | |
11859 | greycstoration_mutex_unlock(p); | |
11860 | if (!p.thread) { | |
11861 | if (p.nb_threads>1) { | |
11862 | bool stopflag = true; | |
11863 | do { | |
11864 | stopflag = true; | |
11865 | for (unsigned int k=1; k<p.nb_threads; k++) if (source.greycstoration_params[k].is_running) stopflag = false; | |
11866 | if (!stopflag) cimg::wait(50); | |
11867 | } while (!stopflag); | |
11868 | } | |
11869 | if (p.counter) delete p.counter; | |
11870 | if (p.temporary) { source = *(p.temporary); delete p.temporary; } | |
11871 | if (p.stop_request) delete p.stop_request; | |
11872 | p.mask = 0; | |
11873 | p.amplitude = p.sharpness = p.anisotropy = p.alpha = p.sigma = p.gfact = p.dl = p.da = p.gauss_prec = p.sigma_s = p.sigma_p = 0; | |
11874 | p.patch_size = p.interpolation = p.lookup_size = 0; | |
11875 | p.fast_approx = false; | |
11876 | p.source = 0; | |
11877 | p.temporary = 0; | |
11878 | p.counter = 0; | |
11879 | p.tile = p.tile_border = p.thread = p.nb_threads = 0; | |
11880 | p.stop_request = false; | |
11881 | greycstoration_mutex_destroy(p); | |
11882 | } | |
11883 | p.is_running = false; | |
11884 | if (p.nb_threads) { | |
11885 | pthread_exit(arg); | |
11886 | return arg; | |
11887 | } | |
11888 | return 0; | |
11889 | } | |
11890 | CImg(): | |
11891 | width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {} | |
11892 | ~CImg() { | |
11893 | if (data && !is_shared) delete[] data; | |
11894 | } | |
11895 | CImg<T>& assign() { | |
11896 | if (data && !is_shared) delete[] data; | |
11897 | width = height = depth = dim = 0; is_shared = false; data = 0; | |
11898 | return *this; | |
11899 | } | |
11900 | CImg<T>& clear() { | |
11901 | return assign(); | |
11902 | } | |
11903 | explicit CImg(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1): | |
11904 | is_shared(false) { | |
11905 | const unsigned long siz = dx*dy*dz*dv; | |
11906 | if (siz) { width = dx; height = dy; depth = dz; dim = dv; data = new T[siz]; } | |
11907 | else { width = height = depth = dim = 0; data = 0; } | |
11908 | } | |
11909 | CImg<T>& assign(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1) { | |
11910 | const unsigned long siz = dx*dy*dz*dv; | |
11911 | if (!siz) return assign(); | |
11912 | const unsigned long curr_siz = size(); | |
11913 | if (is_shared) { | |
11914 | if (siz>curr_siz) | |
11915 | throw CImgArgumentException("CImg<%s>::assign() : Cannot assign image (%u,%u,%u,%u) to shared instance image (%u,%u,%u,%u,%p).", | |
11916 | pixel_type(),dx,dy,dz,dv,width,height,depth,dim,data); | |
11917 | } else { | |
11918 | if (siz!=curr_siz) { if (data) delete[] data; data = new T[siz]; } | |
11919 | width = dx; height = dy; depth = dz; dim = dv; | |
11920 | } | |
11921 | return *this; | |
11922 | } | |
11923 | CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const T val): | |
11924 | is_shared(false) { | |
11925 | const unsigned long siz = dx*dy*dz*dv; | |
11926 | if (siz) { width = dx; height = dy; depth = dz; dim = dv; data = new T[siz]; fill(val); } | |
11927 | else { width = height = depth = dim = 0; data = 0; } | |
11928 | } | |
11929 | CImg<T>& assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const T val) { | |
11930 | return assign(dx,dy,dz,dv).fill(val); | |
11931 | } | |
11932 | template<typename t> CImg(const t *const data_buffer, const unsigned int dx, const unsigned int dy=1, | |
11933 | const unsigned int dz=1, const unsigned int dv=1, const bool shared=false):is_shared(false) { | |
11934 | if (shared) throw CImgArgumentException("CImg<%s>::CImg() : Cannot construct a shared copy from a (%s*) buffer " | |
11935 | "(different pixel types).",pixel_type(),CImg<t>::pixel_type()); | |
11936 | const unsigned long siz = dx*dy*dz*dv; | |
11937 | if (data_buffer && siz) { | |
11938 | width = dx; height = dy; depth = dz; dim = dv; data = new T[siz]; | |
11939 | const t *ptrs = data_buffer + siz; for (T *ptrd = (*this).data + (*this).size(); (ptrd--)>(*this).data; ) *ptrd = (T)*(--ptrs); | |
11940 | } else { width = height = depth = dim = 0; data = 0; } | |
11941 | } | |
11942 | CImg(const T *const data_buffer, const unsigned int dx, const unsigned int dy=1, | |
11943 | const unsigned int dz=1, const unsigned int dv=1, const bool shared=false) { | |
11944 | const unsigned long siz = dx*dy*dz*dv; | |
11945 | if (data_buffer && siz) { | |
11946 | width = dx; height = dy; depth = dz; dim = dv; is_shared = shared; | |
11947 | if (is_shared) data = const_cast<T*>(data_buffer); | |
11948 | else { data = new T[siz]; std::memcpy(data,data_buffer,siz*sizeof(T)); } | |
11949 | } else { width = height = depth = dim = 0; is_shared = false; data = 0; } | |
11950 | } | |
11951 | template<typename t> CImg<T>& assign(const t *const data_buffer, const unsigned int dx, const unsigned int dy=1, | |
11952 | const unsigned int dz=1, const unsigned int dv=1) { | |
11953 | const unsigned long siz = dx*dy*dz*dv; | |
11954 | if (!data_buffer || !siz) return assign(); | |
11955 | assign(dx,dy,dz,dv); | |
11956 | const t *ptrs = data_buffer + siz; | |
11957 | for (T *ptrd = (*this).data + (*this).size(); (ptrd--)>(*this).data; ) *ptrd = (T)*(--ptrs); | |
11958 | return *this; | |
11959 | } | |
11960 | CImg<T>& assign(const T *const data_buffer, const unsigned int dx, const unsigned int dy=1, | |
11961 | const unsigned int dz=1, const unsigned int dv=1) { | |
11962 | const unsigned long siz = dx*dy*dz*dv; | |
11963 | if (!data_buffer || !siz) return assign(); | |
11964 | const unsigned long curr_siz = size(); | |
11965 | if (data_buffer==data && siz==curr_siz) return assign(dx,dy,dz,dv); | |
11966 | if (is_shared || data_buffer+siz<data || data_buffer>=data+size()) { | |
11967 | assign(dx,dy,dz,dv); | |
11968 | if (is_shared) std::memmove(data,data_buffer,siz*sizeof(T)); | |
11969 | else std::memcpy(data,data_buffer,siz*sizeof(T)); | |
11970 | } else { | |
11971 | T *new_data = new T[siz]; | |
11972 | std::memcpy(new_data,data_buffer,siz*sizeof(T)); | |
11973 | delete[] data; data = new_data; width = dx; height = dy; depth = dz; dim = dv; | |
11974 | } | |
11975 | return *this; | |
11976 | } | |
11977 | template<typename t> CImg<T>& assign(const t *const data_buffer, const unsigned int dx, const unsigned int dy, | |
11978 | const unsigned int dz, const unsigned int dv, const bool shared) { | |
11979 | if (shared) throw CImgArgumentException("CImg<%s>::assign() : Cannot construct a shared copy from a (%s*) buffer " | |
11980 | "(different pixel types).",pixel_type(),CImg<t>::pixel_type()); | |
11981 | return assign().assign(data_buffer,dx,dy,dz,dv); | |
11982 | } | |
11983 | CImg<T>& assign(const T *const data_buffer, const unsigned int dx, const unsigned int dy, | |
11984 | const unsigned int dz, const unsigned int dv, const bool shared) { | |
11985 | if (!shared) return assign(data_buffer,dx,dy,dz,dv); | |
11986 | const unsigned long siz = dx*dy*dz*dv; | |
11987 | if (!data_buffer || !siz) | |
11988 | throw CImgArgumentException("CImg<%s>::assign() : Cannot construct a shared copy of an empty image.",pixel_type()); | |
11989 | if (!is_shared) { | |
11990 | if (data_buffer+siz<data || data_buffer>=data+size()) assign(); | |
11991 | else cimg::warn("CImg<%s>::assign() : Create shared version of previous parts of the instance image, possible memory leaks !", | |
11992 | pixel_type()); | |
11993 | } | |
11994 | width = dx; height = dy; depth = dz; dim = dv; is_shared = true; | |
11995 | data = const_cast<T*>(data_buffer); | |
11996 | return *this; | |
11997 | } | |
11998 | template<typename t> CImg(const CImg<t>& img):is_shared(false) { | |
11999 | const unsigned int siz = img.size(); | |
12000 | if (img.data && siz) { | |
12001 | width = img.width; height = img.height; depth = img.depth; dim = img.dim; data = new T[siz]; | |
12002 | const t *ptrs = img.data + siz; for (T *ptrd = (*this).data + (*this).size(); (ptrd--)>(*this).data; ) *ptrd = (T)*(--ptrs); | |
12003 | } else { width = height = depth = dim = 0; data = 0; } | |
12004 | } | |
12005 | CImg(const CImg<T>& img) { | |
12006 | const unsigned int siz = img.size(); | |
12007 | if (img.data && siz) { | |
12008 | width = img.width; height = img.height; depth = img.depth; dim = img.dim; is_shared = img.is_shared; | |
12009 | if (is_shared) data = const_cast<T*>(img.data); | |
12010 | else { data = new T[siz]; std::memcpy(data,img.data,siz*sizeof(T)); } | |
12011 | } else { width = height = depth = dim = 0; is_shared = false; data = 0; } | |
12012 | } | |
12013 | template<typename t> CImg<T>& assign(const CImg<t>& img) { | |
12014 | return assign(img.data,img.width,img.height,img.depth,img.dim); | |
12015 | } | |
12016 | template<typename t> CImg(const CImg<t>& img, const bool shared):is_shared(false) { | |
12017 | if (shared) throw CImgArgumentException("CImg<%s>::CImg() : Cannot construct a shared copy from a CImg<%s> image " | |
12018 | "(different pixel types).",pixel_type(),CImg<t>::pixel_type()); | |
12019 | const unsigned int siz = img.size(); | |
12020 | if (img.data && siz) { | |
12021 | width = img.width; height = img.height; depth = img.depth; dim = img.dim; data = new T[siz]; | |
12022 | const t *ptrs = img.data+siz; for (T *ptrd = (*this).data + (*this).size(); (ptrd--)>(*this).data; ) *ptrd = (T)*(--ptrs); | |
12023 | } else { width = height = depth = dim = 0; data = 0; } | |
12024 | } | |
12025 | CImg(const CImg<T>& img, const bool shared) { | |
12026 | const unsigned int siz = img.size(); | |
12027 | if (img.data && siz) { | |
12028 | width = img.width; height = img.height; depth = img.depth; dim = img.dim; is_shared = shared; | |
12029 | if (is_shared) data = const_cast<T*>(img.data); | |
12030 | else { data = new T[siz]; std::memcpy(data,img.data,siz*sizeof(T)); } | |
12031 | } else { width = height = depth = dim = 0; is_shared = false; data = 0; } | |
12032 | } | |
12033 | template<typename t> CImg<T>& assign(const CImg<t>& img, const bool shared) { | |
12034 | return assign(img.data,img.width,img.height,img.depth,img.dim,shared); | |
12035 | } | |
12036 | CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, | |
12037 | const int val0, const int val1, ...):width(0),height(0),depth(0),dim(0),is_shared(false),data(0) { | |
12038 | assign(dx,dy,dz,dv); | |
12039 | { unsigned int _siz = (unsigned int)dx*dy*dz*dv; if (_siz--) { va_list ap; __builtin_va_start(ap,val1); T *ptrd = (*this).data; *(ptrd++) = (T)val0; if (_siz--) { *(ptrd++) = (T)val1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }}; | |
12040 | } | |
12041 | CImg<T>& assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, | |
12042 | const int val0, const int val1, ...) { | |
12043 | assign(dx,dy,dz,dv); | |
12044 | { unsigned int _siz = (unsigned int)dx*dy*dz*dv; if (_siz--) { va_list ap; __builtin_va_start(ap,val1); T *ptrd = (*this).data; *(ptrd++) = (T)val0; if (_siz--) { *(ptrd++) = (T)val1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }}; | |
12045 | return *this; | |
12046 | } | |
12047 | CImg(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, | |
12048 | const double val0, const double val1, ...):width(0),height(0),depth(0),dim(0),is_shared(false),data(0) { | |
12049 | assign(dx,dy,dz,dv); | |
12050 | { unsigned int _siz = (unsigned int)dx*dy*dz*dv; if (_siz--) { va_list ap; __builtin_va_start(ap,val1); T *ptrd = (*this).data; *(ptrd++) = (T)val0; if (_siz--) { *(ptrd++) = (T)val1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }}; | |
12051 | } | |
12052 | CImg<T>& assign(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, | |
12053 | const double val0, const double val1, ...) { | |
12054 | assign(dx,dy,dz,dv); | |
12055 | { unsigned int _siz = (unsigned int)dx*dy*dz*dv; if (_siz--) { va_list ap; __builtin_va_start(ap,val1); T *ptrd = (*this).data; *(ptrd++) = (T)val0; if (_siz--) { *(ptrd++) = (T)val1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }}; | |
12056 | return *this; | |
12057 | } | |
12058 | template<typename t> CImg(const CImg<t>& img, const char *const dimensions):width(0),height(0),depth(0),dim(0),is_shared(false),data(0) { | |
12059 | assign(img,dimensions); | |
12060 | } | |
12061 | template<typename t> CImg<T>& assign(const CImg<t>& img, const char *const dimensions) { | |
12062 | if (dimensions) { | |
12063 | unsigned int siz[4] = { 0,1,1,1 }; | |
12064 | const char *s = dimensions; | |
12065 | char tmp[256] = { 0 }, c = 0; | |
12066 | int val = 0; | |
12067 | for (unsigned int k=0; k<4; ++k) { | |
12068 | const int err = std::sscanf(s,"%[-0-9]%c",tmp,&c); | |
12069 | if (err>=1) { | |
12070 | const int err = std::sscanf(s,"%d",&val); | |
12071 | if (err==1) { | |
12072 | int val2 = val<0?-val:(c=='%'?val:-1); | |
12073 | if (val2>=0) { | |
12074 | val = (int)((k==0?img.width:(k==1?img.height:(k==2?img.depth:img.dim)))*val2/100); | |
12075 | if (c!='%' && !val) val = 1; | |
12076 | } | |
12077 | siz[k] = val; | |
12078 | } | |
12079 | s+=cimg::strlen(tmp); | |
12080 | if (c=='%') ++s; | |
12081 | } | |
12082 | if (!err) { | |
12083 | if (!cimg::strncasecmp(s,"x",1)) { ++s; siz[k] = img.width; } | |
12084 | else if (!cimg::strncasecmp(s,"y",1)) { ++s; siz[k] = img.height; } | |
12085 | else if (!cimg::strncasecmp(s,"z",1)) { ++s; siz[k] = img.depth; } | |
12086 | else if (!cimg::strncasecmp(s,"v",1)) { ++s; siz[k] = img.dim; } | |
12087 | else if (!cimg::strncasecmp(s,"dx",2)) { s+=2; siz[k] = img.width; } | |
12088 | else if (!cimg::strncasecmp(s,"dy",2)) { s+=2; siz[k] = img.height; } | |
12089 | else if (!cimg::strncasecmp(s,"dz",2)) { s+=2; siz[k] = img.depth; } | |
12090 | else if (!cimg::strncasecmp(s,"dv",2)) { s+=2; siz[k] = img.dim; } | |
12091 | else if (!cimg::strncasecmp(s,"dimx",4)) { s+=4; siz[k] = img.width; } | |
12092 | else if (!cimg::strncasecmp(s,"dimy",4)) { s+=4; siz[k] = img.height; } | |
12093 | else if (!cimg::strncasecmp(s,"dimz",4)) { s+=4; siz[k] = img.depth; } | |
12094 | else if (!cimg::strncasecmp(s,"dimv",4)) { s+=4; siz[k] = img.dim; } | |
12095 | else if (!cimg::strncasecmp(s,"width",5)) { s+=5; siz[k] = img.width; } | |
12096 | else if (!cimg::strncasecmp(s,"height",6)) { s+=6; siz[k] = img.height; } | |
12097 | else if (!cimg::strncasecmp(s,"depth",5)) { s+=5; siz[k] = img.depth; } | |
12098 | else if (!cimg::strncasecmp(s,"dim",3)) { s+=3; siz[k] = img.dim; } | |
12099 | else { ++s; --k; } | |
12100 | } | |
12101 | } | |
12102 | return assign(siz[0],siz[1],siz[2],siz[3]); | |
12103 | } | |
12104 | return assign(); | |
12105 | } | |
12106 | template<typename t> CImg(const CImg<t>& img, const char *const dimensions, const T val): | |
12107 | width(0),height(0),depth(0),dim(0),is_shared(false),data(0) { | |
12108 | assign(img,dimensions).fill(val); | |
12109 | } | |
12110 | template<typename t> CImg<T>& assign(const CImg<t>& img, const char *const dimensions, const T val) { | |
12111 | return assign(img,dimensions).fill(val); | |
12112 | } | |
12113 | CImg(const char *const filename):width(0),height(0),depth(0),dim(0),is_shared(false),data(0) { | |
12114 | assign(filename); | |
12115 | } | |
12116 | CImg<T>& assign(const char *const filename) { | |
12117 | return load(filename); | |
12118 | } | |
12119 | CImg(const CImgDisplay &disp):width(0),height(0),depth(0),dim(0),is_shared(false),data(0) { | |
12120 | disp.snapshot(*this); | |
12121 | } | |
12122 | CImg<T>& assign(const CImgDisplay &disp) { | |
12123 | disp.snapshot(*this); | |
12124 | return *this; | |
12125 | } | |
12126 | CImg<T>& swap(CImg<T>& img) { | |
12127 | cimg::swap(width,img.width); | |
12128 | cimg::swap(height,img.height); | |
12129 | cimg::swap(depth,img.depth); | |
12130 | cimg::swap(dim,img.dim); | |
12131 | cimg::swap(data,img.data); | |
12132 | cimg::swap(is_shared,img.is_shared); | |
12133 | return img; | |
12134 | } | |
12135 | CImg<T>& transfer_to(CImg<T>& img) { | |
12136 | if (is_shared || img.is_shared) { img.assign(*this); assign(); } | |
12137 | else { | |
12138 | img.assign(); | |
12139 | cimg::swap(width,img.width); | |
12140 | cimg::swap(height,img.height); | |
12141 | cimg::swap(depth,img.depth); | |
12142 | cimg::swap(dim,img.dim); | |
12143 | cimg::swap(data,img.data); | |
12144 | } | |
12145 | return img; | |
12146 | } | |
12147 | template<typename t> CImg<t>& transfer_to(CImg<t>& img) { | |
12148 | img.assign(*this); | |
12149 | assign(); | |
12150 | return img; | |
12151 | } | |
12152 | static const char* pixel_type() { | |
12153 | return cimg::type<T>::string(); | |
12154 | } | |
12155 | unsigned long size() const { | |
12156 | return width*height*depth*dim; | |
12157 | } | |
12158 | int dimx() const { | |
12159 | return (int)width; | |
12160 | } | |
12161 | int dimy() const { | |
12162 | return (int)height; | |
12163 | } | |
12164 | int dimz() const { | |
12165 | return (int)depth; | |
12166 | } | |
12167 | int dimv() const { | |
12168 | return (int)dim; | |
12169 | } | |
12170 | template<typename t> bool is_sameX(const CImg<t>& img) const { | |
12171 | return (width==img.width); | |
12172 | } | |
12173 | bool is_sameX(const CImgDisplay& disp) const { | |
12174 | return (width==disp.width); | |
12175 | } | |
12176 | template<typename t> bool is_sameY(const CImg<t>& img) const { | |
12177 | return (height==img.height); | |
12178 | } | |
12179 | bool is_sameY(const CImgDisplay& disp) const { | |
12180 | return (height==disp.height); | |
12181 | } | |
12182 | template<typename t> bool is_sameZ(const CImg<t>& img) const { | |
12183 | return (depth==img.depth); | |
12184 | } | |
12185 | template<typename t> bool is_sameV(const CImg<t>& img) const { | |
12186 | return (dim==img.dim); | |
12187 | } | |
12188 | template<typename t> bool is_sameXY(const CImg<t>& img) const { | |
12189 | return (is_sameX(img) && is_sameY(img)); | |
12190 | } | |
12191 | bool is_sameXY(const CImgDisplay& disp) const { | |
12192 | return (is_sameX(disp) && is_sameY(disp)); | |
12193 | } | |
12194 | template<typename t> bool is_sameXZ(const CImg<t>& img) const { | |
12195 | return (is_sameX(img) && is_sameZ(img)); | |
12196 | } | |
12197 | template<typename t> bool is_sameXV(const CImg<t>& img) const { | |
12198 | return (is_sameX(img) && is_sameV(img)); | |
12199 | } | |
12200 | template<typename t> bool is_sameYZ(const CImg<t>& img) const { | |
12201 | return (is_sameY(img) && is_sameZ(img)); | |
12202 | } | |
12203 | template<typename t> bool is_sameYV(const CImg<t>& img) const { | |
12204 | return (is_sameY(img) && is_sameV(img)); | |
12205 | } | |
12206 | template<typename t> bool is_sameZV(const CImg<t>& img) const { | |
12207 | return (is_sameZ(img) && is_sameV(img)); | |
12208 | } | |
12209 | template<typename t> bool is_sameXYZ(const CImg<t>& img) const { | |
12210 | return (is_sameXY(img) && is_sameZ(img)); | |
12211 | } | |
12212 | template<typename t> bool is_sameXYV(const CImg<t>& img) const { | |
12213 | return (is_sameXY(img) && is_sameZ(img)); | |
12214 | } | |
12215 | template<typename t> bool is_sameXZV(const CImg<t>& img) const { | |
12216 | return (is_sameXY(img) && is_sameZ(img)); | |
12217 | } | |
12218 | template<typename t> bool is_sameYZV(const CImg<t>& img) const { | |
12219 | return (is_sameXY(img) && is_sameZ(img)); | |
12220 | } | |
12221 | template<typename t> bool is_sameXYZV(const CImg<t>& img) const { | |
12222 | return (is_sameXYZ(img) && is_sameV(img)); | |
12223 | } | |
12224 | bool contains(const int x, const int y=0, const int z=0, const int v=0) const { | |
12225 | return data && x>=0 && x<dimx() && y>=0 && y<dimy() && z>=0 && z<dimz() && v>=0 && v<dimv(); | |
12226 | } | |
12227 | template<typename t> bool contains(const T& pixel, t& x, t& y, t& z, t& v) const { | |
12228 | const T *ptr = &pixel; | |
12229 | unsigned long off = (unsigned long)(ptr-data); | |
12230 | const unsigned long whz = width*height*depth, wh = width*height; | |
12231 | v = (t)(off/whz); off%=whz; z =(t)(off/wh); off%=wh; y = (t)(off/width); x = (t)(off%width); | |
12232 | return contains(x,y,z,v); | |
12233 | } | |
12234 | template<typename t> bool contains(const T& pixel, t& x, t& y, t& z) const { | |
12235 | t v; | |
12236 | return contains(pixel,x,y,z,v); | |
12237 | } | |
12238 | template<typename t> bool contains(const T& pixel, t& x, t& y) const { | |
12239 | t z,v; | |
12240 | return contains(pixel,x,y,z,v); | |
12241 | } | |
12242 | template<typename t> bool contains(const T& pixel, t& x) const { | |
12243 | t y,z,v; | |
12244 | return contains(pixel,x,y,z,v); | |
12245 | } | |
12246 | template<typename t> bool contains(const T& pixel) const { | |
12247 | t x,y,z,v; | |
12248 | return contains(pixel,x,y,z,v); | |
12249 | } | |
12250 | template<typename t> bool is_overlapping(const CImg<t>& img) const { | |
12251 | const unsigned long csiz = size(), isiz = img.size(); | |
12252 | return !((void*)(data+csiz)<=(void*)img.data || (void*)data>=(void*)(img.data+isiz)); | |
12253 | } | |
12254 | bool is_empty() const { | |
12255 | return !(data && width && height && depth && dim); | |
12256 | } | |
12257 | operator bool() const { | |
12258 | return !is_empty(); | |
12259 | } | |
12260 | long offset(const int x, const int y, const int z, const int v) const { | |
12261 | return (long)x + (long)y*width + (long)z*width*height + (long)v*width*height*depth; | |
12262 | } | |
12263 | long offset(const int x, const int y, const int z) const { | |
12264 | return (long)x + (long)y*width + (long)z*width*height; | |
12265 | } | |
12266 | long offset(const int x, const int y) const { | |
12267 | return (long)x + (long)y*width; | |
12268 | } | |
12269 | long offset(const int x) const { | |
12270 | return (long)x; | |
12271 | } | |
12272 | T* ptr(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int v) { | |
12273 | return data + (long)x + (long)y*width + (long)z*width*height + (long)v*width*height*depth; | |
12274 | } | |
12275 | const T* ptr(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int v) const { | |
12276 | return data + (long)x + (long)y*width + (long)z*width*height + (long)v*width*height*depth; | |
12277 | } | |
12278 | T* ptr(const unsigned int x, const unsigned int y, const unsigned int z) { | |
12279 | return data + (long)x + (long)y*width + (long)z*width*height; | |
12280 | } | |
12281 | const T* ptr(const unsigned int x, const unsigned int y, const unsigned int z) const { | |
12282 | return data + (long)x + (long)y*width + (long)z*width*height; | |
12283 | } | |
12284 | T* ptr(const unsigned int x, const unsigned int y) { | |
12285 | return data + (long)x + (long)y*width; | |
12286 | } | |
12287 | const T* ptr(const unsigned int x, const unsigned int y) const { | |
12288 | return data + (long)x + (long)y*width; | |
12289 | } | |
12290 | T* ptr(const unsigned int x) { | |
12291 | return data + (long)x; | |
12292 | } | |
12293 | const T* ptr(const unsigned int x) const { | |
12294 | return data + (long)x; | |
12295 | } | |
12296 | T* ptr() { | |
12297 | return data; | |
12298 | } | |
12299 | const T* ptr() const { | |
12300 | return data; | |
12301 | } | |
12302 | iterator begin() { | |
12303 | return data; | |
12304 | } | |
12305 | const_iterator begin() const { | |
12306 | return data; | |
12307 | } | |
12308 | iterator end() { | |
12309 | return data + size(); | |
12310 | } | |
12311 | const_iterator end() const { | |
12312 | return data + size(); | |
12313 | } | |
12314 | T& operator()(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int v) { | |
12315 | return data[(long)x + (long)y*width + (long)z*width*height + (long)v*width*height*depth]; | |
12316 | } | |
12317 | const T& operator()(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int v) const { | |
12318 | return data[(long)x + (long)y*width + (long)z*width*height + (long)v*width*height*depth]; | |
12319 | } | |
12320 | T& operator()(const unsigned int x, const unsigned int y, const unsigned int z) { | |
12321 | return data[(long)x + (long)y*width + (long)z*width*height]; | |
12322 | } | |
12323 | const T& operator()(const unsigned int x, const unsigned int y, const unsigned int z) const { | |
12324 | return data[(long)x + (long)y*width + (long)z*width*height]; | |
12325 | } | |
12326 | T& operator()(const unsigned int x, const unsigned int y) { | |
12327 | return data[(long)x + (long)y*width]; | |
12328 | } | |
12329 | const T& operator()(const unsigned int x, const unsigned int y) const { | |
12330 | return data[(long)x + (long)y*width]; | |
12331 | } | |
12332 | T& operator()(const unsigned int x) { | |
12333 | return data[(long)x]; | |
12334 | } | |
12335 | const T& operator()(const unsigned int x) const { | |
12336 | return data[(long)x]; | |
12337 | } | |
12338 | T& at(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) { | |
12339 | return (*this)(x,y,z,v); | |
12340 | } | |
12341 | const T& at(const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) const { | |
12342 | return (*this)(x,y,z,v); | |
12343 | } | |
12344 | T& operator[](const unsigned long off) { | |
12345 | return data[off]; | |
12346 | } | |
12347 | const T& operator[](const unsigned long off) const { | |
12348 | return data[off]; | |
12349 | } | |
12350 | T& back() { | |
12351 | return operator()(size()-1); | |
12352 | } | |
12353 | const T& back() const { | |
12354 | return operator()(size()-1); | |
12355 | } | |
12356 | T& front() { | |
12357 | return *data; | |
12358 | } | |
12359 | const T& front() const { | |
12360 | return *data; | |
12361 | } | |
12362 | T pix1d(const int x, const int y, const int z, const int v, const T out_val) const { | |
12363 | return (x<0 || x>=dimx())?out_val:(*this)(x,y,z,v); | |
12364 | } | |
12365 | const T& pix1d(const int x, const int y=0, const int z=0, const int v=0) const { | |
12366 | return (*this)(x<0?0:(x>=dimx()?dimx()-1:x),y,z,v); | |
12367 | } | |
12368 | T pix2d(const int x, const int y, const int z, const int v, const T out_val) const { | |
12369 | return (x<0 || y<0 || x>=dimx() || y>=dimy())?out_val:(*this)(x,y,z,v); | |
12370 | } | |
12371 | const T& pix2d(const int x, const int y, const int z=0, const int v=0) const { | |
12372 | return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y),z,v); | |
12373 | } | |
12374 | T pix3d(const int x, const int y, const int z, const int v, const T out_val) const { | |
12375 | return (x<0 || y<0 || z<0 || x>=dimx() || y>=dimy() || z>=dimz())?out_val:(*this)(x,y,z,v); | |
12376 | } | |
12377 | const T& pix3d(const int x, const int y, const int z, const int v=0) const { | |
12378 | return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y), | |
12379 | z<0?0:(z>=dimz()?dimz()-1:z),v); | |
12380 | } | |
12381 | T pix4d(const int x, const int y, const int z, const int v, const T out_val) const { | |
12382 | return (x<0 || y<0 || z<0 || v<0 || x>=dimx() || y>=dimy() || z>=dimz() || v>=dimv())?out_val:(*this)(x,y,z,v); | |
12383 | } | |
12384 | T pix4d(const int x, const int y, const int z, const int v) const { | |
12385 | return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y), | |
12386 | z<0?0:(z>=dimz()?dimz()-1:z), v<0?0:(v>=dimv()?dimv()-1:v)); | |
12387 | } | |
12388 | typename cimg::superset<T,float>::type linear_pix1d(const float fx, const int y, const int z, const int v, | |
12389 | const T out_val) const { | |
12390 | typedef typename cimg::superset<T,float>::type ftype; | |
12391 | const int | |
12392 | x = (int)fx-(fx>=0?0:1), nx = x+1; | |
12393 | const float | |
12394 | dx = fx-x; | |
12395 | const ftype | |
12396 | Ic = (ftype)pix1d(x,y,z,v,out_val), In = (ftype)pix2d(nx,y,z,v,out_val); | |
12397 | return Ic + dx*(In-Ic); | |
12398 | } | |
12399 | typename cimg::superset<T,float>::type linear_pix1d(const float fx, const int y=0, const int z=0, const int v=0) const { | |
12400 | typedef typename cimg::superset<T,float>::type ftype; | |
12401 | const float | |
12402 | nfx = fx<0?0:(fx>width-1?width-1:fx); | |
12403 | const unsigned int | |
12404 | x = (unsigned int)nfx; | |
12405 | const float | |
12406 | dx = nfx-x; | |
12407 | const unsigned int | |
12408 | nx = dx>0?x+1:x; | |
12409 | const ftype | |
12410 | Ic = (ftype)(*this)(x,y,z,v), In = (ftype)(*this)(nx,y,z,v); | |
12411 | return Ic + dx*(In-Ic); | |
12412 | } | |
12413 | typename cimg::superset<T,float>::type linear_pix2d(const float fx, const float fy, const int z, const int v, | |
12414 | const T out_val) const { | |
12415 | typedef typename cimg::superset<T,float>::type ftype; | |
12416 | const int | |
12417 | x = (int)fx-(fx>=0?0:1), nx = x+1, | |
12418 | y = (int)fy-(fy>=0?0:1), ny = y+1; | |
12419 | const float | |
12420 | dx = fx-x, | |
12421 | dy = fy-y; | |
12422 | const ftype | |
12423 | Icc = (ftype)pix2d(x,y,z,v,out_val), Inc = (ftype)pix2d(nx,y,z,v,out_val), | |
12424 | Icn = (ftype)pix2d(x,ny,z,v,out_val), Inn = (ftype)pix2d(nx,ny,z,v,out_val); | |
12425 | return Icc + dx*(Inc-Icc + dy*(Icc+Inn-Icn-Inc)) + dy*(Icn-Icc); | |
12426 | } | |
12427 | typename cimg::superset<T,float>::type linear_pix2d(const float fx, const float fy, const int z=0, const int v=0) const { | |
12428 | typedef typename cimg::superset<T,float>::type ftype; | |
12429 | const float | |
12430 | nfx = fx<0?0:(fx>width-1?width-1:fx), | |
12431 | nfy = fy<0?0:(fy>height-1?height-1:fy); | |
12432 | const unsigned int | |
12433 | x = (unsigned int)nfx, | |
12434 | y = (unsigned int)nfy; | |
12435 | const float | |
12436 | dx = nfx-x, | |
12437 | dy = nfy-y; | |
12438 | const unsigned int | |
12439 | nx = dx>0?x+1:x, | |
12440 | ny = dy>0?y+1:y; | |
12441 | const ftype | |
12442 | Icc = (ftype)(*this)(x,y,z,v), Inc = (ftype)(*this)(nx,y,z,v), | |
12443 | Icn = (ftype)(*this)(x,ny,z,v), Inn = (ftype)(*this)(nx,ny,z,v); | |
12444 | return Icc + dx*(Inc-Icc + dy*(Icc+Inn-Icn-Inc)) + dy*(Icn-Icc); | |
12445 | } | |
12446 | typename cimg::superset<T,float>::type linear_pix3d(const float fx, const float fy, const float fz, const int v, | |
12447 | const T out_val) const { | |
12448 | typedef typename cimg::superset<T,float>::type ftype; | |
12449 | const int | |
12450 | x = (int)fx-(fx>=0?0:1), nx = x+1, | |
12451 | y = (int)fy-(fy>=0?0:1), ny = y+1, | |
12452 | z = (int)fz-(fz>=0?0:1), nz = z+1; | |
12453 | const float | |
12454 | dx = fx-x, | |
12455 | dy = fy-y, | |
12456 | dz = fz-z; | |
12457 | const ftype | |
12458 | Iccc = (ftype)pix3d(x,y,z,v,out_val), Incc = (ftype)pix3d(nx,y,z,v,out_val), | |
12459 | Icnc = (ftype)pix3d(x,ny,z,v,out_val), Innc = (ftype)pix3d(nx,ny,z,v,out_val), | |
12460 | Iccn = (ftype)pix3d(x,y,nz,v,out_val), Incn = (ftype)pix3d(nx,y,nz,v,out_val), | |
12461 | Icnn = (ftype)pix3d(x,ny,nz,v,out_val), Innn = (ftype)pix3d(nx,ny,nz,v,out_val); | |
12462 | return Iccc + | |
12463 | dx*(Incc-Iccc + | |
12464 | dy*(Iccc+Innc-Icnc-Incc + | |
12465 | dz*(Iccn+Innn+Icnc+Incc-Icnn-Incn-Iccc-Innc)) + | |
12466 | dz*(Iccc+Incn-Iccn-Incc)) + | |
12467 | dy*(Icnc-Iccc + | |
12468 | dz*(Iccc+Icnn-Iccn-Icnc)) + | |
12469 | dz*(Iccn-Iccc); | |
12470 | } | |
12471 | typename cimg::superset<T,float>::type linear_pix3d(const float fx, const float fy=0, const float fz=0, const int v=0) const { | |
12472 | typedef typename cimg::superset<T,float>::type ftype; | |
12473 | const float | |
12474 | nfx = fx<0?0:(fx>width-1?width-1:fx), | |
12475 | nfy = fy<0?0:(fy>height-1?height-1:fy), | |
12476 | nfz = fz<0?0:(fz>depth-1?depth-1:fz); | |
12477 | const unsigned int | |
12478 | x = (unsigned int)nfx, | |
12479 | y = (unsigned int)nfy, | |
12480 | z = (unsigned int)nfz; | |
12481 | const float | |
12482 | dx = nfx-x, | |
12483 | dy = nfy-y, | |
12484 | dz = nfz-z; | |
12485 | const unsigned int | |
12486 | nx = dx>0?x+1:x, | |
12487 | ny = dy>0?y+1:y, | |
12488 | nz = dz>0?z+1:z; | |
12489 | const ftype | |
12490 | Iccc = (ftype)(*this)(x,y,z,v), Incc = (ftype)(*this)(nx,y,z,v), | |
12491 | Icnc = (ftype)(*this)(x,ny,z,v), Innc = (ftype)(*this)(nx,ny,z,v), | |
12492 | Iccn = (ftype)(*this)(x,y,nz,v), Incn = (ftype)(*this)(nx,y,nz,v), | |
12493 | Icnn = (ftype)(*this)(x,ny,nz,v), Innn = (ftype)(*this)(nx,ny,nz,v); | |
12494 | return Iccc + | |
12495 | dx*(Incc-Iccc + | |
12496 | dy*(Iccc+Innc-Icnc-Incc + | |
12497 | dz*(Iccn+Innn+Icnc+Incc-Icnn-Incn-Iccc-Innc)) + | |
12498 | dz*(Iccc+Incn-Iccn-Incc)) + | |
12499 | dy*(Icnc-Iccc + | |
12500 | dz*(Iccc+Icnn-Iccn-Icnc)) + | |
12501 | dz*(Iccn-Iccc); | |
12502 | } | |
12503 | typename cimg::superset<T,float>::type linear_pix4d(const float fx, const float fy, const float fz, const float fv, | |
12504 | const T out_val) const { | |
12505 | typedef typename cimg::superset<T,float>::type ftype; | |
12506 | const int | |
12507 | x = (int)fx-(fx>=0?0:1), nx = x+1, | |
12508 | y = (int)fy-(fy>=0?0:1), ny = y+1, | |
12509 | z = (int)fz-(fz>=0?0:1), nz = z+1, | |
12510 | v = (int)fv-(fv>=0?0:1), nv = v+1; | |
12511 | const float | |
12512 | dx = fx-x, | |
12513 | dy = fy-y, | |
12514 | dz = fz-z, | |
12515 | dv = fv-v; | |
12516 | const ftype | |
12517 | Icccc = (ftype)pix4d(x,y,z,v,out_val), Inccc = (ftype)pix4d(nx,y,z,v,out_val), | |
12518 | Icncc = (ftype)pix4d(x,ny,z,v,out_val), Inncc = (ftype)pix4d(nx,ny,z,v,out_val), | |
12519 | Iccnc = (ftype)pix4d(x,y,nz,v,out_val), Incnc = (ftype)pix4d(nx,y,nz,v,out_val), | |
12520 | Icnnc = (ftype)pix4d(x,ny,nz,v,out_val), Innnc = (ftype)pix4d(nx,ny,nz,v,out_val), | |
12521 | Icccn = (ftype)pix4d(x,y,z,nv,out_val), Inccn = (ftype)pix4d(nx,y,z,nv,out_val), | |
12522 | Icncn = (ftype)pix4d(x,ny,z,nv,out_val), Inncn = (ftype)pix4d(nx,ny,z,nv,out_val), | |
12523 | Iccnn = (ftype)pix4d(x,y,nz,nv,out_val), Incnn = (ftype)pix4d(nx,y,nz,nv,out_val), | |
12524 | Icnnn = (ftype)pix4d(x,ny,nz,nv,out_val), Innnn = (ftype)pix4d(nx,ny,nz,nv,out_val); | |
12525 | return Icccc + | |
12526 | dx*(Inccc-Icccc + | |
12527 | dy*(Icccc+Inncc-Icncc-Inccc + | |
12528 | dz*(Iccnc+Innnc+Icncc+Inccc-Icnnc-Incnc-Icccc-Inncc + | |
12529 | dv*(Iccnn+Innnn+Icncn+Inccn+Icnnc+Incnc+Icccc+Inncc-Icnnn-Incnn-Icccn-Inncn-Iccnc-Innnc-Icncc-Inccc)) + | |
12530 | dv*(Icccn+Inncn+Icncc+Inccc-Icncn-Inccn-Icccc-Inncc)) + | |
12531 | dz*(Icccc+Incnc-Iccnc-Inccc + | |
12532 | dv*(Icccn+Incnn+Iccnc+Inccc-Iccnn-Inccn-Icccc-Incnc)) + | |
12533 | dv*(Icccc+Inccn-Inccc-Icccn)) + | |
12534 | dy*(Icncc-Icccc + | |
12535 | dz*(Icccc+Icnnc-Iccnc-Icncc + | |
12536 | dv*(Icccn+Icnnn+Iccnc+Icncc-Iccnn-Icncn-Icccc-Icnnc)) + | |
12537 | dv*(Icccc+Icncn-Icncc-Icccn)) + | |
12538 | dz*(Iccnc-Icccc + | |
12539 | dv*(Icccc+Iccnn-Iccnc-Icccn)) + | |
12540 | dv*(Icccn-Icccc); | |
12541 | } | |
12542 | typename cimg::superset<T,float>::type linear_pix4d(const float fx, const float fy=0, const float fz=0, const float fv=0) const { | |
12543 | typedef typename cimg::superset<T,float>::type ftype; | |
12544 | const float | |
12545 | nfx = fx<0?0:(fx>width-1?width-1:fx), | |
12546 | nfy = fy<0?0:(fy>height-1?height-1:fy), | |
12547 | nfz = fz<0?0:(fz>depth-1?depth-1:fz), | |
12548 | nfv = fv<0?0:(fv>dim-1?dim-1:fv); | |
12549 | const unsigned int | |
12550 | x = (unsigned int)nfx, | |
12551 | y = (unsigned int)nfy, | |
12552 | z = (unsigned int)nfz, | |
12553 | v = (unsigned int)nfv; | |
12554 | const float | |
12555 | dx = nfx-x, | |
12556 | dy = nfy-y, | |
12557 | dz = nfz-z, | |
12558 | dv = nfv-v; | |
12559 | const unsigned int | |
12560 | nx = dx>0?x+1:x, | |
12561 | ny = dy>0?y+1:y, | |
12562 | nz = dz>0?z+1:z, | |
12563 | nv = dv>0?v+1:v; | |
12564 | const ftype | |
12565 | Icccc = (ftype)(*this)(x,y,z,v), Inccc = (ftype)(*this)(nx,y,z,v), | |
12566 | Icncc = (ftype)(*this)(x,ny,z,v), Inncc = (ftype)(*this)(nx,ny,z,v), | |
12567 | Iccnc = (ftype)(*this)(x,y,nz,v), Incnc = (ftype)(*this)(nx,y,nz,v), | |
12568 | Icnnc = (ftype)(*this)(x,ny,nz,v), Innnc = (ftype)(*this)(nx,ny,nz,v), | |
12569 | Icccn = (ftype)(*this)(x,y,z,nv), Inccn = (ftype)(*this)(nx,y,z,nv), | |
12570 | Icncn = (ftype)(*this)(x,ny,z,nv), Inncn = (ftype)(*this)(nx,ny,z,nv), | |
12571 | Iccnn = (ftype)(*this)(x,y,nz,nv), Incnn = (ftype)(*this)(nx,y,nz,nv), | |
12572 | Icnnn = (ftype)(*this)(x,ny,nz,nv), Innnn = (ftype)(*this)(nx,ny,nz,nv); | |
12573 | return Icccc + | |
12574 | dx*(Inccc-Icccc + | |
12575 | dy*(Icccc+Inncc-Icncc-Inccc + | |
12576 | dz*(Iccnc+Innnc+Icncc+Inccc-Icnnc-Incnc-Icccc-Inncc + | |
12577 | dv*(Iccnn+Innnn+Icncn+Inccn+Icnnc+Incnc+Icccc+Inncc-Icnnn-Incnn-Icccn-Inncn-Iccnc-Innnc-Icncc-Inccc)) + | |
12578 | dv*(Icccn+Inncn+Icncc+Inccc-Icncn-Inccn-Icccc-Inncc)) + | |
12579 | dz*(Icccc+Incnc-Iccnc-Inccc + | |
12580 | dv*(Icccn+Incnn+Iccnc+Inccc-Iccnn-Inccn-Icccc-Incnc)) + | |
12581 | dv*(Icccc+Inccn-Inccc-Icccn)) + | |
12582 | dy*(Icncc-Icccc + | |
12583 | dz*(Icccc+Icnnc-Iccnc-Icncc + | |
12584 | dv*(Icccn+Icnnn+Iccnc+Icncc-Iccnn-Icncn-Icccc-Icnnc)) + | |
12585 | dv*(Icccc+Icncn-Icncc-Icccn)) + | |
12586 | dz*(Iccnc-Icccc + | |
12587 | dv*(Icccc+Iccnn-Iccnc-Icccn)) + | |
12588 | dv*(Icccn-Icccc); | |
12589 | } | |
12590 | typename cimg::superset<T,float>::type cubic_pix1d(const float fx, const int y, const int z, const int v, | |
12591 | const T out_val) const { | |
12592 | typedef typename cimg::superset<T,float>::type ftype; | |
12593 | const int | |
12594 | x = (int)fx-(fx>=0?0:1), px = x-1, nx = x+1, ax = x+2; | |
12595 | const float | |
12596 | dx = fx-x; | |
12597 | const ftype | |
12598 | Ip = (ftype)pix1d(px,y,z,v,out_val), Ic = (ftype)pix1d(x,y,z,v,out_val), | |
12599 | In = (ftype)pix1d(nx,y,z,v,out_val), Ia = (ftype)pix1d(ax,y,z,v,out_val), | |
12600 | valm = cimg::min(Ip,In,Ic,Ia), valM = cimg::max(Ip,In,Ic,Ia), | |
12601 | u0 = Ic - Ip, | |
12602 | u1 = Ia - In, | |
12603 | a = 2*(Ic-In) + u0 + u1, | |
12604 | b = 3*(In-Ic) - 2*u0 - u1, | |
12605 | val = a*dx*dx*dx + b*dx*dx + u0*dx + Ic; | |
12606 | return val<valm?valm:(val>valM?valM:val); | |
12607 | } | |
12608 | typename cimg::superset<T,float>::type cubic_pix1d(const float fx, const int y=0, const int z=0, const int v=0) const { | |
12609 | typedef typename cimg::superset<T,float>::type ftype; | |
12610 | const float | |
12611 | nfx = fx<0?0:(fx>width-1?width-1:fx); | |
12612 | const int | |
12613 | x = (int)nfx; | |
12614 | const float | |
12615 | dx = nfx-x; | |
12616 | const int | |
12617 | px = x-1<0?0:x-1, nx = dx>0?x+1:x, ax = x+2>=dimx()?dimx()-1:x+2; | |
12618 | const ftype | |
12619 | Ip = (ftype)(*this)(px,y,z,v), Ic = (ftype)(*this)(x,y,z,v), | |
12620 | In = (ftype)(*this)(nx,y,z,v), Ia = (ftype)(*this)(ax,y,z,v), | |
12621 | valm = cimg::min(Ip,In,Ic,Ia), valM = cimg::max(Ip,In,Ic,Ia), | |
12622 | u0 = Ic - Ip, | |
12623 | u1 = Ia - In, | |
12624 | a = 2*(Ic-In) + u0 + u1, | |
12625 | b = 3*(In-Ic) - 2*u0 - u1, | |
12626 | val = a*dx*dx*dx + b*dx*dx + u0*dx + Ic; | |
12627 | return val<valm?valm:(val>valM?valM:val); | |
12628 | } | |
12629 | typename cimg::superset<T,float>::type cubic_pix2d(const float fx, const float fy, const int z, const int v, | |
12630 | const T out_val) const { | |
12631 | typedef typename cimg::superset<T,float>::type ftype; | |
12632 | const int | |
12633 | x = (int)fx-(fx>=0?0:1), px = x-1, nx = x+1, ax = x+2, | |
12634 | y = (int)fy-(fy>=0?0:1), py = y-1, ny = y+1, ay = y+2; | |
12635 | const float | |
12636 | dx = fx-x, dx2 = dx*dx, dx3 = dx2*dx, | |
12637 | dy = fy-y; | |
12638 | const ftype | |
12639 | Ipp = (ftype)pix2d(px,py,z,v,out_val), Icp = (ftype)pix2d(x,py,z,v,out_val), | |
12640 | Inp = (ftype)pix2d(nx,py,z,v,out_val), Iap = (ftype)pix2d(ax,py,z,v,out_val), | |
12641 | Ipc = (ftype)pix2d(px,y,z,v,out_val), Icc = (ftype)pix2d(x,y,z,v,out_val), | |
12642 | Inc = (ftype)pix2d(nx,y,z,v,out_val), Iac = (ftype)pix2d(ax,y,z,v,out_val), | |
12643 | Ipn = (ftype)pix2d(px,ny,z,v,out_val), Icn = (ftype)pix2d(x,ny,z,v,out_val), | |
12644 | Inn = (ftype)pix2d(nx,ny,z,v,out_val), Ian = (ftype)pix2d(ax,ny,z,v,out_val), | |
12645 | Ipa = (ftype)pix2d(px,ay,z,v,out_val), Ica = (ftype)pix2d(x,ay,z,v,out_val), | |
12646 | Ina = (ftype)pix2d(nx,ay,z,v,out_val), Iaa = (ftype)pix2d(ax,ay,z,v,out_val), | |
12647 | valm = cimg::min(cimg::min(Ipp,Icp,Inp,Iap),cimg::min(Ipc,Icc,Inc,Iac),cimg::min(Ipn,Icn,Inn,Ian),cimg::min(Ipa,Ica,Ina,Iaa)), | |
12648 | valM = cimg::max(cimg::max(Ipp,Icp,Inp,Iap),cimg::max(Ipc,Icc,Inc,Iac),cimg::max(Ipn,Icn,Inn,Ian),cimg::max(Ipa,Ica,Ina,Iaa)), | |
12649 | u0p = Icp - Ipp, | |
12650 | u1p = Iap - Inp, | |
12651 | ap = 2*(Icp-Inp) + u0p + u1p, | |
12652 | bp = 3*(Inp-Icp) - 2*u0p - u1p, | |
12653 | u0c = Icc - Ipc, | |
12654 | u1c = Iac - Inc, | |
12655 | ac = 2*(Icc-Inc) + u0c + u1c, | |
12656 | bc = 3*(Inc-Icc) - 2*u0c - u1c, | |
12657 | u0n = Icn - Ipn, | |
12658 | u1n = Ian - Inn, | |
12659 | an = 2*(Icn-Inn) + u0n + u1n, | |
12660 | bn = 3*(Inn-Icn) - 2*u0n - u1n, | |
12661 | u0a = Ica - Ipa, | |
12662 | u1a = Iaa - Ina, | |
12663 | aa = 2*(Ica-Ina) + u0a + u1a, | |
12664 | ba = 3*(Ina-Ica) - 2*u0a - u1a, | |
12665 | valp = ap*dx3 + bp*dx2 + u0p*dx + Icp, | |
12666 | valc = ac*dx3 + bc*dx2 + u0c*dx + Icc, | |
12667 | valn = an*dx3 + bn*dx2 + u0n*dx + Icn, | |
12668 | vala = aa*dx3 + ba*dx2 + u0a*dx + Ica, | |
12669 | u0 = valc - valp, | |
12670 | u1 = vala - valn, | |
12671 | a = 2*(valc-valn) + u0 + u1, | |
12672 | b = 3*(valn-valc) - 2*u0 - u1, | |
12673 | val = a*dy*dy*dy + b*dy*dy + u0*dy + valc; | |
12674 | return val<valm?valm:(val>valM?valM:val); | |
12675 | } | |
12676 | typename cimg::superset<T,float>::type cubic_pix2d(const float fx, const float fy, const int z=0, const int v=0) const { | |
12677 | typedef typename cimg::superset<T,float>::type ftype; | |
12678 | const float | |
12679 | nfx = fx<0?0:(fx>width-1?width-1:fx), | |
12680 | nfy = fy<0?0:(fy>height-1?height-1:fy); | |
12681 | const int | |
12682 | x = (int)nfx, | |
12683 | y = (int)nfy; | |
12684 | const float | |
12685 | dx = nfx-x, dx2 = dx*dx, dx3 = dx2*dx, | |
12686 | dy = nfy-y; | |
12687 | const int | |
12688 | px = x-1<0?0:x-1, nx = dx>0?x+1:x, ax = x+2>=dimx()?dimx()-1:x+2, | |
12689 | py = y-1<0?0:y-1, ny = dy>0?y+1:y, ay = y+2>=dimy()?dimy()-1:y+2; | |
12690 | const ftype | |
12691 | Ipp = (ftype)(*this)(px,py,z,v), Icp = (ftype)(*this)(x,py,z,v), | |
12692 | Inp = (ftype)(*this)(nx,py,z,v), Iap = (ftype)(*this)(ax,py,z,v), | |
12693 | Ipc = (ftype)(*this)(px,y,z,v), Icc = (ftype)(*this)(x,y,z,v), | |
12694 | Inc = (ftype)(*this)(nx,y,z,v), Iac = (ftype)(*this)(ax,y,z,v), | |
12695 | Ipn = (ftype)(*this)(px,ny,z,v), Icn = (ftype)(*this)(x,ny,z,v), | |
12696 | Inn = (ftype)(*this)(nx,ny,z,v), Ian = (ftype)(*this)(ax,ny,z,v), | |
12697 | Ipa = (ftype)(*this)(px,ay,z,v), Ica = (ftype)(*this)(x,ay,z,v), | |
12698 | Ina = (ftype)(*this)(nx,ay,z,v), Iaa = (ftype)(*this)(ax,ay,z,v), | |
12699 | valm = cimg::min(cimg::min(Ipp,Icp,Inp,Iap),cimg::min(Ipc,Icc,Inc,Iac),cimg::min(Ipn,Icn,Inn,Ian),cimg::min(Ipa,Ica,Ina,Iaa)), | |
12700 | valM = cimg::max(cimg::max(Ipp,Icp,Inp,Iap),cimg::max(Ipc,Icc,Inc,Iac),cimg::max(Ipn,Icn,Inn,Ian),cimg::max(Ipa,Ica,Ina,Iaa)), | |
12701 | u0p = Icp - Ipp, | |
12702 | u1p = Iap - Inp, | |
12703 | ap = 2*(Icp-Inp) + u0p + u1p, | |
12704 | bp = 3*(Inp-Icp) - 2*u0p - u1p, | |
12705 | u0c = Icc - Ipc, | |
12706 | u1c = Iac - Inc, | |
12707 | ac = 2*(Icc-Inc) + u0c + u1c, | |
12708 | bc = 3*(Inc-Icc) - 2*u0c - u1c, | |
12709 | u0n = Icn - Ipn, | |
12710 | u1n = Ian - Inn, | |
12711 | an = 2*(Icn-Inn) + u0n + u1n, | |
12712 | bn = 3*(Inn-Icn) - 2*u0n - u1n, | |
12713 | u0a = Ica - Ipa, | |
12714 | u1a = Iaa - Ina, | |
12715 | aa = 2*(Ica-Ina) + u0a + u1a, | |
12716 | ba = 3*(Ina-Ica) - 2*u0a - u1a, | |
12717 | valp = ap*dx3 + bp*dx2 + u0p*dx + Icp, | |
12718 | valc = ac*dx3 + bc*dx2 + u0c*dx + Icc, | |
12719 | valn = an*dx3 + bn*dx2 + u0n*dx + Icn, | |
12720 | vala = aa*dx3 + ba*dx2 + u0a*dx + Ica, | |
12721 | u0 = valc - valp, | |
12722 | u1 = vala - valn, | |
12723 | a = 2*(valc-valn) + u0 + u1, | |
12724 | b = 3*(valn-valc) - 2*u0 - u1, | |
12725 | val = a*dy*dy*dy + b*dy*dy + u0*dy + valc; | |
12726 | return val<valm?valm:(val>valM?valM:val); | |
12727 | } | |
12728 | const T& max() const { | |
12729 | if (is_empty()) throw CImgInstanceException("CImg<%s>::max() : Instance image is empty.",pixel_type()); | |
12730 | const T *ptrmax = data; | |
12731 | T max_value = *ptrmax; | |
12732 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) if ((*ptr)>max_value) max_value = *(ptrmax=ptr); | |
12733 | return *ptrmax; | |
12734 | } | |
12735 | T& max() { | |
12736 | if (is_empty()) throw CImgInstanceException("CImg<%s>::max() : Instance image is empty.",pixel_type()); | |
12737 | T *ptrmax = data; | |
12738 | T max_value = *ptrmax; | |
12739 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) if ((*ptr)>max_value) max_value = *(ptrmax=ptr); | |
12740 | return *ptrmax; | |
12741 | } | |
12742 | const T& min() const { | |
12743 | if (is_empty()) throw CImgInstanceException("CImg<%s>::min() : Instance image is empty.",pixel_type()); | |
12744 | const T *ptrmin = data; | |
12745 | T min_value = *ptrmin; | |
12746 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) if ((*ptr)<min_value) min_value = *(ptrmin=ptr); | |
12747 | return *ptrmin; | |
12748 | } | |
12749 | T& min() { | |
12750 | if (is_empty()) throw CImgInstanceException("CImg<%s>::min() : Instance image is empty.",pixel_type()); | |
12751 | T *ptrmin = data; | |
12752 | T min_value = *ptrmin; | |
12753 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) if ((*ptr)<min_value) min_value = *(ptrmin=ptr); | |
12754 | return *ptrmin; | |
12755 | } | |
12756 | template<typename t> const T& minmax(t& max_val) const { | |
12757 | if (is_empty()) throw CImgInstanceException("CImg<%s>::minmax() : Instance image is empty.",pixel_type()); | |
12758 | const T *ptrmin = data; | |
12759 | T min_value = *ptrmin, max_value = min_value; | |
12760 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
12761 | const T val = *ptr; | |
12762 | if (val<min_value) { min_value = val; ptrmin = ptr; } | |
12763 | if (val>max_value) max_value = val; | |
12764 | } | |
12765 | max_val = (t)max_value; | |
12766 | return *ptrmin; | |
12767 | } | |
12768 | template<typename t> T& minmax(t& max_val) { | |
12769 | if (is_empty()) throw CImgInstanceException("CImg<%s>::minmax() : Instance image is empty.",pixel_type()); | |
12770 | T *ptrmin = data; | |
12771 | T min_value = *ptrmin, max_value = min_value; | |
12772 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
12773 | const T val = *ptr; | |
12774 | if (val<min_value) { min_value = val; ptrmin = ptr; } | |
12775 | if (val>max_value) max_value = val; | |
12776 | } | |
12777 | max_val = (t)max_value; | |
12778 | return *ptrmin; | |
12779 | } | |
12780 | template<typename t> const T& maxmin(t& min_val) const { | |
12781 | if (is_empty()) throw CImgInstanceException("CImg<%s>::maxmin() : Instance image is empty.",pixel_type()); | |
12782 | const T *ptrmax = data; | |
12783 | T max_value = *ptrmax, min_value = max_value; | |
12784 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
12785 | const T val = *ptr; | |
12786 | if (val>max_value) { max_value = val; ptrmax = ptr; } | |
12787 | if (val<min_value) min_value = val; | |
12788 | } | |
12789 | min_val = (t)min_value; | |
12790 | return *ptrmax; | |
12791 | } | |
12792 | template<typename t> T& maxmin(t& min_val) { | |
12793 | if (is_empty()) throw CImgInstanceException("CImg<%s>::maxmin() : Instance image is empty.",pixel_type()); | |
12794 | T *ptrmax = data; | |
12795 | T max_value = *ptrmax, min_value = max_value; | |
12796 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
12797 | const T val = *ptr; | |
12798 | if (val>max_value) { max_value = val; ptrmax = ptr; } | |
12799 | if (val<min_value) min_value = val; | |
12800 | } | |
12801 | min_val = (t)min_value; | |
12802 | return *ptrmax; | |
12803 | } | |
12804 | double mean() const { | |
12805 | if (is_empty()) throw CImgInstanceException("CImg<%s>::mean() : Instance image is empty.",pixel_type()); | |
12806 | double val = 0; | |
12807 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) val+=(double)*ptr; | |
12808 | return val/size(); | |
12809 | } | |
12810 | template<typename t> double variancemean(const unsigned int variance_method, t& mean) const { | |
12811 | if (is_empty()) | |
12812 | throw CImgInstanceException("CImg<%s>::variance() : Instance image is empty.",pixel_type()); | |
12813 | double variance = 0, average = 0; | |
12814 | const unsigned int siz = size(); | |
12815 | switch (variance_method) { | |
12816 | case 3: { | |
12817 | CImg<double> buf(*this); | |
12818 | const unsigned int siz2 = siz>>1; | |
12819 | { for (double *ptrs = (buf).data + (buf).size(); (ptrs--)>(buf).data; ) { const double val = *ptrs; (*ptrs)*=val; average+=val; }} | |
12820 | buf.sort(); | |
12821 | double a = 0; | |
12822 | const double *ptrs = buf.ptr(); | |
12823 | for (unsigned int j=0; j<siz2; ++j) a+=(*ptrs++); | |
12824 | const double sig = 2.6477*std::sqrt(a/siz2); | |
12825 | variance = sig*sig; | |
12826 | } break; | |
12827 | case 2: { | |
12828 | CImg<double> buf(*this); | |
12829 | buf.sort(); | |
12830 | const unsigned int siz2 = siz>>1; | |
12831 | const double med_i = buf[siz2]; | |
12832 | for (double *ptrs = (buf).data + (buf).size(); (ptrs--)>(buf).data; ) { const double val = *ptrs; *ptrs = cimg::abs(val-med_i); average+=val; } | |
12833 | buf.sort(); | |
12834 | const double sig = 1.4828*buf[siz2]; | |
12835 | variance = sig*sig; | |
12836 | } break; | |
12837 | case 1: { | |
12838 | double S = 0, S2 = 0; | |
12839 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const double val = (double)*ptr; S+=val; S2+=val*val; } | |
12840 | variance = siz>1?(S2 - S*S/siz)/(siz-1):0; | |
12841 | average = S; | |
12842 | } break; | |
12843 | default:{ | |
12844 | double S = 0, S2 = 0; | |
12845 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const double val = (double)*ptr; S+=val; S2+=val*val; } | |
12846 | variance = (S2 - S*S/siz)/siz; | |
12847 | average = S; | |
12848 | } break; | |
12849 | } | |
12850 | mean = (t)(average/siz); | |
12851 | return variance; | |
12852 | } | |
12853 | double variance(const unsigned int variance_method=0) const { | |
12854 | double foo; | |
12855 | return variancemean(variance_method,foo); | |
12856 | } | |
12857 | template<typename t> double MSE(const CImg<t>& img) const { | |
12858 | if (img.size()!=size()) | |
12859 | throw CImgArgumentException("CImg<%s>::MSE() : Instance image (%u,%u,%u,%u) and given image (%u,%u,%u,%u) have different dimensions.", | |
12860 | pixel_type(),width,height,depth,dim,img.width,img.height,img.depth,img.dim); | |
12861 | double vMSE = 0; | |
12862 | const t* ptr2 = img.end(); | |
12863 | for (T *ptr1 = (*this).data + (*this).size(); (ptr1--)>(*this).data; ) { | |
12864 | const double diff = (double)*ptr1 - (double)*(--ptr2); | |
12865 | vMSE += diff*diff; | |
12866 | } | |
12867 | vMSE/=img.size(); | |
12868 | return vMSE; | |
12869 | } | |
12870 | template<typename t> double PSNR(const CImg<t>& img, const double valmax=255.0) const { | |
12871 | const double vMSE = std::sqrt(MSE(img)); | |
12872 | return (vMSE!=0)?(20*std::log10(valmax/vMSE)):(cimg::type<double>::max()); | |
12873 | } | |
12874 | double trace() const { | |
12875 | if (is_empty()) | |
12876 | throw CImgInstanceException("CImg<%s>::trace() : Instance matrix (%u,%u,%u,%u,%p) is empty.", | |
12877 | pixel_type(),width,height,depth,dim,data); | |
12878 | double res = 0; | |
12879 | for (int k = 0; k<(int)((*this).width); ++k) res+=(*this)(k,k); | |
12880 | return res; | |
12881 | } | |
12882 | T median() const { | |
12883 | const unsigned int s = size(); | |
12884 | const T res = kth_smallest(s>>1); | |
12885 | return (s%2)?res:((res+kth_smallest((s>>1)-1))/2); | |
12886 | } | |
12887 | template<typename t> double dot(const CImg<t>& img) const { | |
12888 | if (is_empty()) | |
12889 | throw CImgInstanceException("CImg<%s>::dot() : Instance object (%u,%u,%u,%u,%p) is empty.", | |
12890 | pixel_type(),width,height,depth,dim,data); | |
12891 | if (!img) | |
12892 | throw CImgArgumentException("CImg<%s>::trace() : Specified argument (%u,%u,%u,%u,%p) is empty.", | |
12893 | pixel_type(),img.width,img.height,img.depth,img.dim,img.data); | |
12894 | const unsigned long nb = cimg::min(size(),img.size()); | |
12895 | double res = 0; | |
12896 | for (unsigned long off=0; off<nb; ++off) res+=(double)data[off]*(double)img[off]; | |
12897 | return res; | |
12898 | } | |
12899 | double det() const { | |
12900 | if (is_empty() || width!=height || depth!=1 || dim!=1) | |
12901 | throw CImgInstanceException("CImg<%s>::det() : Instance matrix (%u,%u,%u,%u,%p) is not square or is empty.", | |
12902 | pixel_type(),width,height,depth,dim,data); | |
12903 | switch (width) { | |
12904 | case 1: return (*this)(0,0); | |
12905 | case 2: return (*this)(0,0)*(*this)(1,1)-(*this)(0,1)*(*this)(1,0); | |
12906 | case 3: { | |
12907 | const double | |
12908 | a = data[0], d = data[1], g = data[2], | |
12909 | b = data[3], e = data[4], h = data[5], | |
12910 | c = data[6], f = data[7], i = data[8]; | |
12911 | return i*a*e-a*h*f-i*b*d+b*g*f+c*d*h-c*g*e; | |
12912 | } | |
12913 | default: { | |
12914 | typedef typename cimg::superset<T,float>::type ftype; | |
12915 | CImg<ftype> lu(*this); | |
12916 | CImg<unsigned int> indx; | |
12917 | bool d; | |
12918 | lu._LU(indx,d); | |
12919 | double res = d?1.0:-1.0; | |
12920 | for (int i = 0; i<(int)((lu).width); ++i) res*=lu(i,i); | |
12921 | return res; | |
12922 | } | |
12923 | } | |
12924 | return 0; | |
12925 | } | |
12926 | double norm(const int norm_type=2) const { | |
12927 | if (is_empty()) | |
12928 | throw CImgInstanceException("CImg<%s>::norm() : Instance object (%u,%u,%u,%u,%p) is empty.", | |
12929 | pixel_type(),width,height,depth,dim,data); | |
12930 | double res = 0; | |
12931 | switch (norm_type) { | |
12932 | case -1: { | |
12933 | for (unsigned int off = 0; off<(*this).size(); ++off) { | |
12934 | const double tmp = cimg::abs((double)data[off]); | |
12935 | if (tmp>res) res = tmp; | |
12936 | } | |
12937 | return res; | |
12938 | } break; | |
12939 | case 1 : { | |
12940 | for (unsigned int off = 0; off<(*this).size(); ++off) res+=cimg::abs((double)data[off]); | |
12941 | return res; | |
12942 | } break; | |
12943 | default: { return std::sqrt(dot(*this)); } | |
12944 | } | |
12945 | return 0; | |
12946 | } | |
12947 | double sum() const { | |
12948 | if (is_empty()) | |
12949 | throw CImgInstanceException("CImg<%s>::sum() : Instance object (%u,%u,%u,%u,%p) is empty.", | |
12950 | pixel_type(),width,height,depth,dim,data); | |
12951 | double res = 0; | |
12952 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) res+=*ptr; | |
12953 | return res; | |
12954 | } | |
12955 | const T kth_smallest(const unsigned int k) const { | |
12956 | if (is_empty()) | |
12957 | throw CImgInstanceException("CImg<%s>::kth_smallest() : Instance image (%u,%u,%u,%u,%p) is empty.", | |
12958 | pixel_type(),width,height,depth,dim,data); | |
12959 | CImg<T> arr(*this); | |
12960 | unsigned long l = 0, ir = size()-1; | |
12961 | for (;;) { | |
12962 | if (ir<=l+1) { | |
12963 | if (ir==l+1 && arr[ir]<arr[l]) cimg::swap(arr[l],arr[ir]); | |
12964 | return arr[k]; | |
12965 | } else { | |
12966 | const unsigned long mid = (l+ir)>>1; | |
12967 | cimg::swap(arr[mid],arr[l+1]); | |
12968 | if (arr[l]>arr[ir]) cimg::swap(arr[l],arr[ir]); | |
12969 | if (arr[l+1]>arr[ir]) cimg::swap(arr[l+1],arr[ir]); | |
12970 | if (arr[l]>arr[l+1]) cimg::swap(arr[l],arr[l+1]); | |
12971 | unsigned long i = l+1, j = ir; | |
12972 | const T pivot = arr[l+1]; | |
12973 | for (;;) { | |
12974 | do ++i; while (arr[i]<pivot); | |
12975 | do --j; while (arr[j]>pivot); | |
12976 | if (j<i) break; | |
12977 | cimg::swap(arr[i],arr[j]); | |
12978 | } | |
12979 | arr[l+1] = arr[j]; | |
12980 | arr[j] = pivot; | |
12981 | if (j>=k) ir=j-1; | |
12982 | if (j<=k) l=i; | |
12983 | } | |
12984 | } | |
12985 | return 0; | |
12986 | } | |
12987 | const CImg<T>& print(const char *title=0, const int print_flag=1) const { | |
12988 | typedef typename cimg::last<T,double>::type cdouble; | |
12989 | static CImg<cdouble> st; | |
12990 | if (print_flag>=0) { | |
12991 | const unsigned long msiz = size()*sizeof(T); | |
12992 | const unsigned int mdisp = msiz<8*1024?0:(msiz<8*1024*1024?1:2); | |
12993 | std::fprintf(stderr,"%-8s(this=%p): { size=(%u,%u,%u,%u) [%lu %s], data=(%s*)%p (%s)", | |
12994 | title?title:"CImg",(void*)this, | |
12995 | width,height,depth,dim, | |
12996 | mdisp==0?msiz:(mdisp==1?(msiz>>10):(msiz>>20)), | |
12997 | mdisp==0?"b":(mdisp==1?"Kb":"Mb"), | |
12998 | pixel_type(),(void*)data,is_shared?"shared":"not shared"); | |
12999 | if (is_empty()) { std::fprintf(stderr,", [Undefined pixel data] }\n"); return *this; } | |
13000 | if (print_flag>=1) { | |
13001 | st = get_stats(); | |
13002 | int xm, ym, zm, vm, xM, yM, zM, vM; | |
13003 | contains(data[(int)st(4)],xm,ym,zm,vm); | |
13004 | contains(data[(int)st(5)],xM,yM,zM,vM); | |
13005 | std::fprintf(stderr,", min=%g, mean=%g [std=%g], max=%g, pmin=(%d,%d,%d,%d), pmax=(%d,%d,%d,%d)", | |
13006 | st[0],st[2],std::sqrt(st[3]),st[1],xm,ym,zm,vm,xM,yM,zM,vM); | |
13007 | } | |
13008 | if (print_flag>=2 || size()<=16) { | |
13009 | std::fprintf(stderr," }\n%s = [ ",title?title:"data"); | |
13010 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
13011 | std::fprintf(stderr,cimg::type<T>::format(),cimg::type<T>::format((*this)(x,y,z,k))); | |
13012 | std::fprintf(stderr,"%s",((x+1)*(y+1)*(z+1)*(k+1)==(int)size()?" ]\n":(((x+1)%width==0)?" ; ":" "))); | |
13013 | } | |
13014 | } else std::fprintf(stderr," }\n"); | |
13015 | } | |
13016 | return *this; | |
13017 | } | |
13018 | const CImg<T>& print(const int print_flag) const { | |
13019 | return print(0,print_flag); | |
13020 | } | |
13021 | template<typename t> CImg<T>& operator=(const CImg<t>& img) { | |
13022 | return assign(img); | |
13023 | } | |
13024 | CImg<T>& operator=(const CImg<T>& img) { | |
13025 | return assign(img); | |
13026 | } | |
13027 | CImg<T>& operator=(const T *buf) { | |
13028 | return assign(buf,width,height,depth,dim); | |
13029 | } | |
13030 | CImg<T>& operator=(const T val) { | |
13031 | return fill(val); | |
13032 | } | |
13033 | CImg<T> operator+() const { | |
13034 | return CImg<T>(*this,false); | |
13035 | } | |
13036 | template<typename t> CImg<T>& operator+=(const t val) { | |
13037 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)((*ptr)+val); | |
13038 | return *this; | |
13039 | } | |
13040 | template<typename t> CImg<T>& operator+=(const CImg<t>& img) { | |
13041 | if (is_overlapping(img)) return *this+=+img; | |
13042 | const unsigned int smin = cimg::min(size(),img.size()); | |
13043 | t *ptrs = img.data + smin; | |
13044 | for (T *ptrd = data + smin; ptrd>data; --ptrd, (*ptrd)=(T)((*ptrd)+(*(--ptrs)))); | |
13045 | return *this; | |
13046 | } | |
13047 | CImg<T>& operator++() { | |
13048 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) ++(*ptr); | |
13049 | return *this; | |
13050 | } | |
13051 | CImg<T> operator++(int) { | |
13052 | CImg<T> copy(*this,false); | |
13053 | ++*this; | |
13054 | return copy; | |
13055 | } | |
13056 | CImg<T> operator-() const { | |
13057 | return CImg<T>(width,height,depth,dim,0)-=*this; | |
13058 | } | |
13059 | template<typename t> CImg<T>& operator-=(const t val) { | |
13060 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)((*ptr)-val); | |
13061 | return *this; | |
13062 | } | |
13063 | template<typename t> CImg<T>& operator-=(const CImg<t>& img) { | |
13064 | if (is_overlapping(img)) return *this-=+img; | |
13065 | const unsigned int smin = cimg::min(size(),img.size()); | |
13066 | t *ptrs = img.data+smin; | |
13067 | for (T *ptrd = data+smin; ptrd>data; --ptrd, (*ptrd) = (T)((*ptrd)-(*(--ptrs)))); | |
13068 | return *this; | |
13069 | } | |
13070 | CImg<T>& operator--() { | |
13071 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = *ptr-(T)1; | |
13072 | return *this; | |
13073 | } | |
13074 | CImg<T> operator--(int) { | |
13075 | CImg<T> copy(*this,false); | |
13076 | --*this; | |
13077 | return copy; | |
13078 | } | |
13079 | template<typename t> CImg<T>& operator*=(const t val) { | |
13080 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)((*ptr)*val); | |
13081 | return *this; | |
13082 | } | |
13083 | template<typename t> CImg<T>& operator*=(const CImg<t>& img) { | |
13084 | return ((*this)*img).transfer_to(*this); | |
13085 | } | |
13086 | template<typename t> CImg<T>& operator/=(const t val) { | |
13087 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)((*ptr)/val); | |
13088 | return *this; | |
13089 | } | |
13090 | template<typename t> CImg<T>& operator/=(const CImg<t>& img) { | |
13091 | return assign(*this*img.get_invert()); | |
13092 | } | |
13093 | template<typename t> CImg<typename cimg::superset<T,t>::type> operator%(const CImg<t>& img) const { | |
13094 | typedef typename cimg::superset<T,t>::type restype; | |
13095 | return CImg<restype>(*this,false)%=img; | |
13096 | } | |
13097 | CImg<T> operator%(const T val) const { | |
13098 | return (+*this)%=val; | |
13099 | } | |
13100 | CImg<T>& operator%=(const T val) { | |
13101 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)cimg::mod(*ptr,val); | |
13102 | return *this; | |
13103 | } | |
13104 | template<typename t> CImg<T>& operator%=(const CImg<t>& img) { | |
13105 | if (is_overlapping(img)) return *this%=+img; | |
13106 | typedef typename cimg::superset<T,t>::type btype; | |
13107 | const unsigned int smin = cimg::min(size(),img.size()); | |
13108 | const t *ptrs = img.data + smin; | |
13109 | for (T *ptrd = data + smin; ptrd>data; ) { | |
13110 | T& val = *(--ptrd); | |
13111 | val = (T)cimg::mod((btype)val,(btype)*(--ptrs)); | |
13112 | } | |
13113 | return *this; | |
13114 | } | |
13115 | template<typename t> CImg<typename cimg::superset<T,t>::type> operator&(const CImg<t>& img) const { | |
13116 | typedef typename cimg::superset<T,t>::type restype; | |
13117 | return CImg<restype>(*this,false)&=img; | |
13118 | } | |
13119 | CImg<T> operator&(const T val) const { | |
13120 | return (+*this)&=val; | |
13121 | } | |
13122 | template<typename t> CImg<T>& operator&=(const CImg<t>& img) { | |
13123 | if (is_overlapping(img)) return *this&=+img; | |
13124 | const unsigned int smin = cimg::min(size(),img.size()); | |
13125 | const t *ptrs = img.data + smin; | |
13126 | for (T *ptrd = data + smin; ptrd>data; ) { | |
13127 | T& val = *(--ptrd); | |
13128 | val = (T)((unsigned long)val & (unsigned long)*(--ptrs)); | |
13129 | } | |
13130 | return *this; | |
13131 | } | |
13132 | CImg<T>& operator&=(const T val) { | |
13133 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)((unsigned long)*ptr & (unsigned long)val); | |
13134 | return *this; | |
13135 | } | |
13136 | template<typename t> CImg<typename cimg::superset<T,t>::type> operator|(const CImg<t>& img) const { | |
13137 | typedef typename cimg::superset<T,t>::type restype; | |
13138 | return CImg<restype>(*this,false)|=img; | |
13139 | } | |
13140 | CImg<T> operator|(const T val) const { | |
13141 | return (+*this)|=val; | |
13142 | } | |
13143 | template<typename t> CImg<T>& operator|=(const CImg<t>& img) { | |
13144 | if (is_overlapping(img)) return *this|=+img; | |
13145 | const unsigned int smin = cimg::min(size(),img.size()); | |
13146 | const t *ptrs = img.data + smin; | |
13147 | for (T *ptrd = data + smin; ptrd>data; ) { | |
13148 | T& val = *(--ptrd); | |
13149 | val = (T)((unsigned long)val | (unsigned long)*(--ptrs)); | |
13150 | } | |
13151 | return *this; | |
13152 | } | |
13153 | CImg<T>& operator|=(const T val) { | |
13154 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)((unsigned long)*ptr | (unsigned long)val); | |
13155 | return *this; | |
13156 | } | |
13157 | template<typename t> CImg<typename cimg::superset<T,t>::type> operator^(const CImg<t>& img) const { | |
13158 | typedef typename cimg::superset<T,t>::type restype; | |
13159 | return CImg<restype>(*this,false)^=img; | |
13160 | } | |
13161 | CImg<T> operator^(const T val) const { | |
13162 | return (+*this)^=val; | |
13163 | } | |
13164 | template<typename t> CImg<T>& operator^=(const CImg<t>& img) { | |
13165 | if (is_overlapping(img)) return *this^=+img; | |
13166 | const unsigned int smin = cimg::min(size(),img.size()); | |
13167 | const t *ptrs = img.data + smin; | |
13168 | for (T *ptrd = data+smin; ptrd>data; ) { | |
13169 | T& val = *(--ptrd); | |
13170 | val =(T)((unsigned long)val ^ (unsigned long)*(--ptrs)); | |
13171 | } | |
13172 | return *this; | |
13173 | } | |
13174 | CImg<T>& operator^=(const T val) { | |
13175 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)((unsigned long)*ptr ^ (unsigned long)val); | |
13176 | return *this; | |
13177 | } | |
13178 | CImg<T> operator~() const { | |
13179 | CImg<T> res(width,height,depth,dim); | |
13180 | const T *ptrs = end(); | |
13181 | for (T *ptrd = (res).data + (res).size(); (ptrd--)>(res).data; ) *ptrd = (T)~(unsigned long)*(--ptrs); | |
13182 | return res; | |
13183 | } | |
13184 | CImg<T>& operator<<=(const int n) { | |
13185 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)(((long)*ptr)<<n); | |
13186 | return *this; | |
13187 | } | |
13188 | CImg<T> operator<<(const int n) const { | |
13189 | return (+*this)<<=n; | |
13190 | } | |
13191 | CImg<T>& operator>>=(const int n) { | |
13192 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)(((long)*ptr)>>n); | |
13193 | return *this; | |
13194 | } | |
13195 | CImg<T> operator>>(const int n) const { | |
13196 | return (+*this)>>=n; | |
13197 | } | |
13198 | template<typename t> bool operator==(const CImg<t>& img) const { | |
13199 | const unsigned int siz = size(); | |
13200 | bool vequal = true; | |
13201 | if (siz!=img.size()) return false; | |
13202 | t *ptrs = img.data + siz; | |
13203 | for (T *ptrd = data + siz; vequal && ptrd>data; vequal = vequal && ((*(--ptrd))==(*(--ptrs)))); | |
13204 | return vequal; | |
13205 | } | |
13206 | template<typename t> bool operator!=(const CImg<t>& img) const { | |
13207 | return !((*this)==img); | |
13208 | } | |
13209 | template<typename t> CImgList<typename cimg::superset<T,t>::type> operator<<(const CImg<t>& img) const { | |
13210 | typedef typename cimg::superset<T,t>::type restype; | |
13211 | return CImgList<restype>(*this,img); | |
13212 | } | |
13213 | template<typename t> CImgList<typename cimg::superset<T,t>::type> operator<<(const CImgList<t>& list) const { | |
13214 | typedef typename cimg::superset<T,t>::type restype; | |
13215 | return CImgList<restype>(list).insert(*this,0); | |
13216 | } | |
13217 | template<typename t> CImgList<typename cimg::superset<T,t>::type> operator>>(const CImg<t>& img) const { | |
13218 | return (*this)<<img; | |
13219 | } | |
13220 | template<typename t> CImgList<t>& operator>>(const CImgList<t>& list) const { | |
13221 | return list.insert(*this,0); | |
13222 | } | |
13223 | const CImg<T>& operator>>(CImgDisplay& disp) const { | |
13224 | return display(disp); | |
13225 | } | |
13226 | template<typename t> CImg<T> get_apply(t& func) const { | |
13227 | return (+*this).apply(func); | |
13228 | } | |
13229 | template<typename t> CImg<T>& apply(t& func) { | |
13230 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = func(*ptr); | |
13231 | return *this; | |
13232 | } | |
13233 | template<typename t> CImg<typename cimg::superset<T,t>::type> get_mul(const CImg<t>& img) const { | |
13234 | typedef typename cimg::superset<T,t>::type restype; | |
13235 | return CImg<restype>(*this,false).mul(img); | |
13236 | } | |
13237 | template<typename t> CImg<T>& mul(const CImg<t>& img) { | |
13238 | if (is_overlapping(img)) return mul(+img); | |
13239 | t *ptrs = img.data; | |
13240 | T *ptrf = data + cimg::min(size(),img.size()); | |
13241 | for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = (T)(*ptrd*(*(ptrs++))); | |
13242 | return *this; | |
13243 | } | |
13244 | template<typename t> CImg<typename cimg::superset<T,t>::type> get_div(const CImg<t>& img) const { | |
13245 | typedef typename cimg::superset<T,t>::type restype; | |
13246 | return CImg<restype>(*this,false).div(img); | |
13247 | } | |
13248 | template<typename t> CImg<T>& div(const CImg<t>& img) { | |
13249 | if (is_overlapping(img)) return div(+img); | |
13250 | t *ptrs = img.data; | |
13251 | T *ptrf = data + cimg::min(size(),img.size()); | |
13252 | for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = (T)(*ptrd/(*(ptrs++))); | |
13253 | return *this; | |
13254 | } | |
13255 | template<typename t> CImg<typename cimg::superset<T,t>::type> get_max(const CImg<t>& img) const { | |
13256 | typedef typename cimg::superset<T,t>::type restype; | |
13257 | return CImg<restype>(*this,false).max(img); | |
13258 | } | |
13259 | template<typename t> CImg<T>& max(const CImg<t>& img) { | |
13260 | if (is_overlapping(img)) return max(+img); | |
13261 | t *ptrs = img.data; | |
13262 | T *ptrf = data + cimg::min(size(),img.size()); | |
13263 | for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = cimg::max((T)*(ptrs++),*ptrd); | |
13264 | return *this; | |
13265 | } | |
13266 | CImg<T> get_max(const T val) const { | |
13267 | return (+*this).max(val); | |
13268 | } | |
13269 | CImg<T>& max(const T val) { | |
13270 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = cimg::max(*ptr,val); | |
13271 | return *this; | |
13272 | } | |
13273 | template<typename t> CImg<typename cimg::superset<T,t>::type> get_min(const CImg<t>& img) const { | |
13274 | typedef typename cimg::superset<T,t>::type restype; | |
13275 | return CImg<restype>(*this,false).min(img); | |
13276 | } | |
13277 | template<typename t> CImg<T>& min(const CImg<t>& img) { | |
13278 | if (is_overlapping(img)) return min(+img); | |
13279 | t *ptrs = img.data; | |
13280 | T *ptrf = data + cimg::min(size(),img.size()); | |
13281 | for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = cimg::min((T)*(ptrs++),*ptrd); | |
13282 | return *this; | |
13283 | } | |
13284 | CImg<T> get_min(const T val) const { | |
13285 | return (+*this).min(val); | |
13286 | } | |
13287 | CImg<T>& min(const T val) { | |
13288 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = cimg::min(*ptr,val); | |
13289 | return *this; | |
13290 | } | |
13291 | CImg<typename cimg::last<T,double>::type> get_stats() const { | |
13292 | typedef typename cimg::last<T,double>::type restype; | |
13293 | return CImg<restype>(*this).stats(); | |
13294 | } | |
13295 | CImg<T>& stats() { | |
13296 | if (is_empty()) | |
13297 | throw CImgInstanceException("CImg<%s>::stats() : Instance image is empty.",pixel_type()); | |
13298 | const unsigned long siz = size(); | |
13299 | const T *pm = data, *pM = pm; | |
13300 | double S = 0, S2 = 0; | |
13301 | T m = *pm, M = m; | |
13302 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
13303 | const T val = *ptr; | |
13304 | const double fval = (double)val; | |
13305 | if (val<m) { m = val; pm = ptr; } | |
13306 | if (val>M) { M = val; pM = ptr; } | |
13307 | S+=fval; | |
13308 | S2+=fval*fval; | |
13309 | } | |
13310 | return assign(1,6).fill((T)m,(T)M,(T)(S/siz),(T)((S2-S*S/siz)/siz),(T)(pm-data),(T)(pM-data)); | |
13311 | } | |
13312 | CImg<typename cimg::superset<T,float>::type> get_sqr() const { | |
13313 | typedef typename cimg::superset<T,float>::type restype; | |
13314 | return CImg<restype>(*this,false).sqr(); | |
13315 | } | |
13316 | CImg<T>& sqr() { | |
13317 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const T val = *ptr; *ptr = (T)(val*val); }; | |
13318 | return *this; | |
13319 | } | |
13320 | CImg<typename cimg::superset<T,float>::type> get_sqrt() const { | |
13321 | typedef typename cimg::superset<T,float>::type restype; | |
13322 | return CImg<restype>(*this,false).sqrt(); | |
13323 | } | |
13324 | CImg<T>& sqrt() { | |
13325 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::sqrt((double)(*ptr)); | |
13326 | return *this; | |
13327 | } | |
13328 | CImg<typename cimg::superset<T,float>::type> get_exp() const { | |
13329 | typedef typename cimg::superset<T,float>::type restype; | |
13330 | return CImg<restype>(*this,false).exp(); | |
13331 | } | |
13332 | CImg<T>& exp() { | |
13333 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::exp((double)(*ptr)); | |
13334 | return *this; | |
13335 | } | |
13336 | CImg<typename cimg::superset<T,float>::type> get_log() const { | |
13337 | typedef typename cimg::superset<T,float>::type restype; | |
13338 | return CImg<restype>(*this,false).log(); | |
13339 | } | |
13340 | CImg<T>& log() { | |
13341 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::log((double)(*ptr)); | |
13342 | return *this; | |
13343 | } | |
13344 | CImg<typename cimg::superset<T,float>::type> get_log10() const { | |
13345 | typedef typename cimg::superset<T,float>::type restype; | |
13346 | return CImg<restype>(*this,false).log10(); | |
13347 | } | |
13348 | CImg<T>& log10() { | |
13349 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::log10((double)(*ptr)); | |
13350 | return *this; | |
13351 | } | |
13352 | CImg<typename cimg::superset<T,float>::type> get_pow(const double p) const { | |
13353 | typedef typename cimg::superset<T,float>::type restype; | |
13354 | return CImg<restype>(*this,false).pow(p); | |
13355 | } | |
13356 | CImg<T>& pow(const double p) { | |
13357 | if (p==0) return fill(1); | |
13358 | if (p==0.5) { for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const T val = *ptr; *ptr = (T)std::sqrt((double)val); } return *this; } | |
13359 | if (p==1) return *this; | |
13360 | if (p==2) { for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const T val = *ptr; *ptr = val*val; } return *this; } | |
13361 | if (p==3) { for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const T val = *ptr; *ptr = val*val*val; } return *this; } | |
13362 | if (p==4) { for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { const T val = *ptr; *ptr = val*val*val*val; } return *this; } | |
13363 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::pow((double)(*ptr),p); | |
13364 | return *this; | |
13365 | } | |
13366 | template<typename t> CImg<typename cimg::superset<T,float>::type> get_pow(const CImg<t>& img) const { | |
13367 | typedef typename cimg::superset<T,float>::type restype; | |
13368 | return CImg<restype>(*this,false).pow(img); | |
13369 | } | |
13370 | template<typename t> CImg<T>& pow(const CImg<t>& img) { | |
13371 | if (is_overlapping(img)) return pow(+img); | |
13372 | t *ptrs = img.data; | |
13373 | T *ptrf = data + cimg::min(size(),img.size()); | |
13374 | for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = (T)std::pow((double)*ptrd,(double)(*(ptrs++))); | |
13375 | return *this; | |
13376 | } | |
13377 | CImg<typename cimg::superset<T,float>::type> get_abs() const { | |
13378 | typedef typename cimg::superset<T,float>::type restype; | |
13379 | return CImg<restype>(*this,false).abs(); | |
13380 | } | |
13381 | CImg<T>& abs() { | |
13382 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = cimg::abs(*ptr); | |
13383 | return *this; | |
13384 | } | |
13385 | CImg<typename cimg::superset<T,float>::type> get_cos() const { | |
13386 | typedef typename cimg::superset<T,float>::type restype; | |
13387 | return CImg<restype>(*this,false).cos(); | |
13388 | } | |
13389 | CImg<T>& cos() { | |
13390 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::cos((double)(*ptr)); | |
13391 | return *this; | |
13392 | } | |
13393 | CImg<typename cimg::superset<T,float>::type> get_sin() const { | |
13394 | typedef typename cimg::superset<T,float>::type restype; | |
13395 | return CImg<restype>(*this,false).sin(); | |
13396 | } | |
13397 | CImg<T>& sin() { | |
13398 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::sin((double)(*ptr)); | |
13399 | return *this; | |
13400 | } | |
13401 | CImg<typename cimg::superset<T,float>::type> get_tan() const { | |
13402 | typedef typename cimg::superset<T,float>::type restype; | |
13403 | return CImg<restype>(*this,false).tan(); | |
13404 | } | |
13405 | CImg<T>& tan() { | |
13406 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::tan((double)(*ptr)); | |
13407 | return *this; | |
13408 | } | |
13409 | CImg<typename cimg::superset<T,float>::type> get_acos() const { | |
13410 | typedef typename cimg::superset<T,float>::type restype; | |
13411 | return CImg<restype>(*this,false).acos(); | |
13412 | } | |
13413 | CImg<T>& acos() { | |
13414 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::acos((double)(*ptr)); | |
13415 | return *this; | |
13416 | } | |
13417 | CImg<typename cimg::superset<T,float>::type> get_asin() const { | |
13418 | typedef typename cimg::superset<T,float>::type restype; | |
13419 | return CImg<restype>(*this,false).asin(); | |
13420 | } | |
13421 | CImg<T>& asin() { | |
13422 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::asin((double)(*ptr)); | |
13423 | return *this; | |
13424 | } | |
13425 | CImg<typename cimg::superset<T,float>::type> get_atan() const { | |
13426 | typedef typename cimg::superset<T,float>::type restype; | |
13427 | return CImg<restype>(*this,false).atan(); | |
13428 | } | |
13429 | CImg<T>& atan() { | |
13430 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)std::atan((double)(*ptr)); | |
13431 | return *this; | |
13432 | } | |
13433 | CImg<T> get_round(const float x, const unsigned int round_type=0) const { | |
13434 | return (+*this).round(x,round_type); | |
13435 | } | |
13436 | CImg<T>& round(const float x, const unsigned int round_type=0) { | |
13437 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) (*ptr) = (T)cimg::round(*ptr,x,round_type); | |
13438 | return *this; | |
13439 | } | |
13440 | CImg<T> get_rand(const T val_min, const T val_max) const { | |
13441 | return (+*this).rand(val_min,val_max); | |
13442 | } | |
13443 | CImg<T>& rand(const T val_min, const T val_max) { | |
13444 | const float delta = (float)val_max - (float)val_min; | |
13445 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)(val_min + cimg::rand()*delta); | |
13446 | return *this; | |
13447 | } | |
13448 | CImg<T> get_fill(const T val) const { | |
13449 | return CImg<T>(width,height,depth,dim).fill(val); | |
13450 | } | |
13451 | CImg<T>& fill(const T val) { | |
13452 | if (!is_empty()) { | |
13453 | if (val && sizeof(T)!=1) for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = val; | |
13454 | else std::memset(data,(int)val,size()*sizeof(T)); | |
13455 | } | |
13456 | return *this; | |
13457 | } | |
13458 | CImg<T> get_fill(const T val0, const T val1) const { | |
13459 | return CImg<T>(width,height,depth,dim).fill(val0,val1); | |
13460 | } | |
13461 | CImg<T>& fill(const T val0, const T val1) { | |
13462 | if (!is_empty()) { | |
13463 | T *ptr, *ptr_end = end()-1; | |
13464 | for (ptr=data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; } | |
13465 | if (ptr!=ptr_end+1) *(ptr++) = val0; | |
13466 | } | |
13467 | return *this; | |
13468 | } | |
13469 | CImg<T> get_fill(const T val0, const T val1, const T val2) const { | |
13470 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2); | |
13471 | } | |
13472 | CImg<T>& fill(const T val0, const T val1, const T val2) { | |
13473 | if (!is_empty()) { | |
13474 | T *ptr, *ptr_end = end()-2; | |
13475 | for (ptr=data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; } | |
13476 | ptr_end+=2; | |
13477 | switch (ptr_end-ptr) { | |
13478 | case 2: *(--ptr_end) = val1; | |
13479 | case 1: *(--ptr_end) = val0; | |
13480 | } | |
13481 | } | |
13482 | return *this; | |
13483 | } | |
13484 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3) const { | |
13485 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3); | |
13486 | } | |
13487 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3) { | |
13488 | if (!is_empty()) { | |
13489 | T *ptr, *ptr_end = end()-3; | |
13490 | for (ptr=data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; } | |
13491 | ptr_end+=3; | |
13492 | switch (ptr_end-ptr) { | |
13493 | case 3: *(--ptr_end) = val2; | |
13494 | case 2: *(--ptr_end) = val1; | |
13495 | case 1: *(--ptr_end) = val0; | |
13496 | } | |
13497 | } | |
13498 | return *this; | |
13499 | } | |
13500 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4) const { | |
13501 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4); | |
13502 | } | |
13503 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4) { | |
13504 | if (!is_empty()) { | |
13505 | T *ptr, *ptr_end = end()-4; | |
13506 | for (ptr=data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; } | |
13507 | ptr_end+=4; | |
13508 | switch (ptr_end-ptr) { | |
13509 | case 4: *(--ptr_end) = val3; | |
13510 | case 3: *(--ptr_end) = val2; | |
13511 | case 2: *(--ptr_end) = val1; | |
13512 | case 1: *(--ptr_end) = val0; | |
13513 | } | |
13514 | } | |
13515 | return *this; | |
13516 | } | |
13517 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5) const { | |
13518 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5); | |
13519 | } | |
13520 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5) { | |
13521 | if (!is_empty()) { | |
13522 | T *ptr, *ptr_end = end()-5; | |
13523 | for (ptr=data; ptr<ptr_end; ) { | |
13524 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13525 | } | |
13526 | ptr_end+=5; | |
13527 | switch (ptr_end-ptr) { | |
13528 | case 5: *(--ptr_end) = val4; | |
13529 | case 4: *(--ptr_end) = val3; | |
13530 | case 3: *(--ptr_end) = val2; | |
13531 | case 2: *(--ptr_end) = val1; | |
13532 | case 1: *(--ptr_end) = val0; | |
13533 | } | |
13534 | } | |
13535 | return *this; | |
13536 | } | |
13537 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6) const { | |
13538 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6); | |
13539 | } | |
13540 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6) { | |
13541 | if (!is_empty()) { | |
13542 | T *ptr, *ptr_end = end()-6; | |
13543 | for (ptr=data; ptr<ptr_end; ) { | |
13544 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; *(ptr++) = val6; | |
13545 | } | |
13546 | ptr_end+=6; | |
13547 | switch (ptr_end-ptr) { | |
13548 | case 6: *(--ptr_end) = val5; | |
13549 | case 5: *(--ptr_end) = val4; | |
13550 | case 4: *(--ptr_end) = val3; | |
13551 | case 3: *(--ptr_end) = val2; | |
13552 | case 2: *(--ptr_end) = val1; | |
13553 | case 1: *(--ptr_end) = val0; | |
13554 | } | |
13555 | } | |
13556 | return *this; | |
13557 | } | |
13558 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13559 | const T val7) const { | |
13560 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7); | |
13561 | } | |
13562 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13563 | const T val7) { | |
13564 | if (!is_empty()) { | |
13565 | T *ptr, *ptr_end = end()-7; | |
13566 | for (ptr=data; ptr<ptr_end; ) { | |
13567 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; | |
13568 | *(ptr++) = val4; *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; | |
13569 | } | |
13570 | ptr_end+=7; | |
13571 | switch (ptr_end-ptr) { | |
13572 | case 7: *(--ptr_end) = val6; | |
13573 | case 6: *(--ptr_end) = val5; | |
13574 | case 5: *(--ptr_end) = val4; | |
13575 | case 4: *(--ptr_end) = val3; | |
13576 | case 3: *(--ptr_end) = val2; | |
13577 | case 2: *(--ptr_end) = val1; | |
13578 | case 1: *(--ptr_end) = val0; | |
13579 | } | |
13580 | } | |
13581 | return *this; | |
13582 | } | |
13583 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13584 | const T val7, const T val8) const { | |
13585 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8); | |
13586 | } | |
13587 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13588 | const T val7, const T val8) { | |
13589 | if (!is_empty()) { | |
13590 | T *ptr, *ptr_end = end()-8; | |
13591 | for (ptr=data; ptr<ptr_end; ) { | |
13592 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; | |
13593 | *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13594 | *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; | |
13595 | } | |
13596 | ptr_end+=8; | |
13597 | switch (ptr_end-ptr) { | |
13598 | case 8: *(--ptr_end) = val7; | |
13599 | case 7: *(--ptr_end) = val6; | |
13600 | case 6: *(--ptr_end) = val5; | |
13601 | case 5: *(--ptr_end) = val4; | |
13602 | case 4: *(--ptr_end) = val3; | |
13603 | case 3: *(--ptr_end) = val2; | |
13604 | case 2: *(--ptr_end) = val1; | |
13605 | case 1: *(--ptr_end) = val0; | |
13606 | } | |
13607 | } | |
13608 | return *this; | |
13609 | } | |
13610 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13611 | const T val7, const T val8, const T val9) const { | |
13612 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9); | |
13613 | } | |
13614 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13615 | const T val7, const T val8, const T val9) { | |
13616 | if (!is_empty()) { | |
13617 | T *ptr, *ptr_end = end()-9; | |
13618 | for (ptr=data; ptr<ptr_end; ) { | |
13619 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; | |
13620 | *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; | |
13621 | } | |
13622 | ptr_end+=9; | |
13623 | switch (ptr_end-ptr) { | |
13624 | case 9: *(--ptr_end) = val8; | |
13625 | case 8: *(--ptr_end) = val7; | |
13626 | case 7: *(--ptr_end) = val6; | |
13627 | case 6: *(--ptr_end) = val5; | |
13628 | case 5: *(--ptr_end) = val4; | |
13629 | case 4: *(--ptr_end) = val3; | |
13630 | case 3: *(--ptr_end) = val2; | |
13631 | case 2: *(--ptr_end) = val1; | |
13632 | case 1: *(--ptr_end) = val0; | |
13633 | } | |
13634 | } | |
13635 | return *this; | |
13636 | } | |
13637 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13638 | const T val7, const T val8, const T val9, const T val10) const { | |
13639 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10); | |
13640 | } | |
13641 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13642 | const T val7, const T val8, const T val9, const T val10) { | |
13643 | if (!is_empty()) { | |
13644 | T *ptr, *ptr_end = end()-10; | |
13645 | for (ptr=data; ptr<ptr_end; ) { | |
13646 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; | |
13647 | *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; | |
13648 | *(ptr++) = val10; | |
13649 | } | |
13650 | ptr_end+=10; | |
13651 | switch (ptr_end-ptr) { | |
13652 | case 10: *(--ptr_end) = val9; | |
13653 | case 9: *(--ptr_end) = val8; | |
13654 | case 8: *(--ptr_end) = val7; | |
13655 | case 7: *(--ptr_end) = val6; | |
13656 | case 6: *(--ptr_end) = val5; | |
13657 | case 5: *(--ptr_end) = val4; | |
13658 | case 4: *(--ptr_end) = val3; | |
13659 | case 3: *(--ptr_end) = val2; | |
13660 | case 2: *(--ptr_end) = val1; | |
13661 | case 1: *(--ptr_end) = val0; | |
13662 | } | |
13663 | } | |
13664 | return *this; | |
13665 | } | |
13666 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13667 | const T val7, const T val8, const T val9, const T val10, const T val11) const { | |
13668 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11); | |
13669 | } | |
13670 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13671 | const T val7, const T val8, const T val9, const T val10, const T val11) { | |
13672 | if (!is_empty()) { | |
13673 | T *ptr, *ptr_end = end()-11; | |
13674 | for (ptr=data; ptr<ptr_end; ) { | |
13675 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13676 | *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11; | |
13677 | } | |
13678 | ptr_end+=11; | |
13679 | switch (ptr_end-ptr) { | |
13680 | case 11: *(--ptr_end) = val10; | |
13681 | case 10: *(--ptr_end) = val9; | |
13682 | case 9: *(--ptr_end) = val8; | |
13683 | case 8: *(--ptr_end) = val7; | |
13684 | case 7: *(--ptr_end) = val6; | |
13685 | case 6: *(--ptr_end) = val5; | |
13686 | case 5: *(--ptr_end) = val4; | |
13687 | case 4: *(--ptr_end) = val3; | |
13688 | case 3: *(--ptr_end) = val2; | |
13689 | case 2: *(--ptr_end) = val1; | |
13690 | case 1: *(--ptr_end) = val0; | |
13691 | } | |
13692 | } | |
13693 | return *this; | |
13694 | } | |
13695 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13696 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12) const { | |
13697 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12); | |
13698 | } | |
13699 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13700 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12) { | |
13701 | if (!is_empty()) { | |
13702 | T *ptr, *ptr_end = end()-12; | |
13703 | for (ptr=data; ptr<ptr_end; ) { | |
13704 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13705 | *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11; | |
13706 | *(ptr++) = val12; | |
13707 | } | |
13708 | ptr_end+=12; | |
13709 | switch (ptr_end-ptr) { | |
13710 | case 12: *(--ptr_end) = val11; | |
13711 | case 11: *(--ptr_end) = val10; | |
13712 | case 10: *(--ptr_end) = val9; | |
13713 | case 9: *(--ptr_end) = val8; | |
13714 | case 8: *(--ptr_end) = val7; | |
13715 | case 7: *(--ptr_end) = val6; | |
13716 | case 6: *(--ptr_end) = val5; | |
13717 | case 5: *(--ptr_end) = val4; | |
13718 | case 4: *(--ptr_end) = val3; | |
13719 | case 3: *(--ptr_end) = val2; | |
13720 | case 2: *(--ptr_end) = val1; | |
13721 | case 1: *(--ptr_end) = val0; | |
13722 | } | |
13723 | } | |
13724 | return *this; | |
13725 | } | |
13726 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13727 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, | |
13728 | const T val13) const { | |
13729 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13); | |
13730 | } | |
13731 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13732 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, | |
13733 | const T val13) { | |
13734 | if (!is_empty()) { | |
13735 | T *ptr, *ptr_end = end()-13; | |
13736 | for (ptr=data; ptr<ptr_end; ) { | |
13737 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13738 | *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11; | |
13739 | *(ptr++) = val12; *(ptr++) = val13; | |
13740 | } | |
13741 | ptr_end+=13; | |
13742 | switch (ptr_end-ptr) { | |
13743 | case 13: *(--ptr_end) = val12; | |
13744 | case 12: *(--ptr_end) = val11; | |
13745 | case 11: *(--ptr_end) = val10; | |
13746 | case 10: *(--ptr_end) = val9; | |
13747 | case 9: *(--ptr_end) = val8; | |
13748 | case 8: *(--ptr_end) = val7; | |
13749 | case 7: *(--ptr_end) = val6; | |
13750 | case 6: *(--ptr_end) = val5; | |
13751 | case 5: *(--ptr_end) = val4; | |
13752 | case 4: *(--ptr_end) = val3; | |
13753 | case 3: *(--ptr_end) = val2; | |
13754 | case 2: *(--ptr_end) = val1; | |
13755 | case 1: *(--ptr_end) = val0; | |
13756 | } | |
13757 | } | |
13758 | return *this; | |
13759 | } | |
13760 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13761 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, | |
13762 | const T val13, const T val14) const { | |
13763 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14); | |
13764 | } | |
13765 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13766 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, | |
13767 | const T val13, const T val14) { | |
13768 | if (!is_empty()) { | |
13769 | T *ptr, *ptr_end = end()-14; | |
13770 | for (ptr=data; ptr<ptr_end; ) { | |
13771 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13772 | *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11; | |
13773 | *(ptr++) = val12; *(ptr++) = val13; *(ptr++) = val14; | |
13774 | } | |
13775 | ptr_end+=14; | |
13776 | switch (ptr_end-ptr) { | |
13777 | case 14: *(--ptr_end) = val13; | |
13778 | case 13: *(--ptr_end) = val12; | |
13779 | case 12: *(--ptr_end) = val11; | |
13780 | case 11: *(--ptr_end) = val10; | |
13781 | case 10: *(--ptr_end) = val9; | |
13782 | case 9: *(--ptr_end) = val8; | |
13783 | case 8: *(--ptr_end) = val7; | |
13784 | case 7: *(--ptr_end) = val6; | |
13785 | case 6: *(--ptr_end) = val5; | |
13786 | case 5: *(--ptr_end) = val4; | |
13787 | case 4: *(--ptr_end) = val3; | |
13788 | case 3: *(--ptr_end) = val2; | |
13789 | case 2: *(--ptr_end) = val1; | |
13790 | case 1: *(--ptr_end) = val0; | |
13791 | } | |
13792 | } | |
13793 | return *this; | |
13794 | } | |
13795 | CImg<T> get_fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13796 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, | |
13797 | const T val13, const T val14, const T val15) const { | |
13798 | return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14,val15); | |
13799 | } | |
13800 | CImg<T>& fill(const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, | |
13801 | const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, | |
13802 | const T val13, const T val14, const T val15) { | |
13803 | if (!is_empty()) { | |
13804 | T *ptr, *ptr_end = end()-15; | |
13805 | for (ptr=data; ptr<ptr_end; ) { | |
13806 | *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; | |
13807 | *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11; | |
13808 | *(ptr++) = val12; *(ptr++) = val13; *(ptr++) = val14; *(ptr++) = val15; | |
13809 | } | |
13810 | ptr_end+=15; | |
13811 | switch (ptr_end-ptr) { | |
13812 | case 15: *(--ptr_end) = val14; | |
13813 | case 14: *(--ptr_end) = val13; | |
13814 | case 13: *(--ptr_end) = val12; | |
13815 | case 12: *(--ptr_end) = val11; | |
13816 | case 11: *(--ptr_end) = val10; | |
13817 | case 10: *(--ptr_end) = val9; | |
13818 | case 9: *(--ptr_end) = val8; | |
13819 | case 8: *(--ptr_end) = val7; | |
13820 | case 7: *(--ptr_end) = val6; | |
13821 | case 6: *(--ptr_end) = val5; | |
13822 | case 5: *(--ptr_end) = val4; | |
13823 | case 4: *(--ptr_end) = val3; | |
13824 | case 3: *(--ptr_end) = val2; | |
13825 | case 2: *(--ptr_end) = val1; | |
13826 | case 1: *(--ptr_end) = val0; | |
13827 | } | |
13828 | } | |
13829 | return *this; | |
13830 | } | |
13831 | template<int N> CImg<T> get_fill(const int val0, ...) const { | |
13832 | CImg<T> res(*this,false); | |
13833 | va_list ap; | |
13834 | __builtin_va_start(ap,val0); | |
13835 | res._fill<N,int>(val0,ap); | |
13836 | __builtin_va_end(ap); | |
13837 | return res; | |
13838 | } | |
13839 | template<int N> CImg<T>& fill(const int val0, ...) { | |
13840 | va_list ap; | |
13841 | __builtin_va_start(ap,val0); | |
13842 | _fill<N,int>(val0,ap); | |
13843 | __builtin_va_end(ap); | |
13844 | return *this; | |
13845 | } | |
13846 | template<int N> CImg<T> get_fill(const double val0, ...) const { | |
13847 | CImg<T> res(*this,false); | |
13848 | va_list ap; | |
13849 | __builtin_va_start(ap,val0); | |
13850 | res._fill<N,double>(val0,ap); | |
13851 | __builtin_va_end(ap); | |
13852 | return res; | |
13853 | } | |
13854 | template<int N> CImg<T>& fill(const double val0, ...) { | |
13855 | va_list ap; | |
13856 | __builtin_va_start(ap,val0); | |
13857 | _fill<N,double>(val0,ap); | |
13858 | __builtin_va_end(ap); | |
13859 | return *this; | |
13860 | } | |
13861 | template<int N, typename t> CImg<T>& _fill(const t val0, va_list &ap) { | |
13862 | if (N>0 && !is_empty()) { | |
13863 | CImg<T> vals(N); | |
13864 | T *ptrs = vals.data; | |
13865 | *(ptrs++) = (T)val0; | |
13866 | for (int i=1; i<N; ++i) *(ptrs++) = (T)__builtin_va_arg(ap,t); | |
13867 | ptrs-=N; | |
13868 | T *ptr, *ptr_end = end()+1-N; | |
13869 | for (ptr=data; ptr<ptr_end; ) { ptrs = vals.data; for (int i=0; i<N; ++i) *(ptr++) = *(ptrs++); } | |
13870 | ptr_end+=N-1; | |
13871 | ptrs = vals.data; | |
13872 | for (int i = ptr_end-ptr; i>0; --i) *(ptr++) = *(ptrs++); | |
13873 | } | |
13874 | return *this; | |
13875 | } | |
13876 | CImg<T>& fillV(const unsigned int x, const unsigned int y, const unsigned int z, const int a0, ...) { | |
13877 | if (x<width && y<height && z<depth) { va_list ap; __builtin_va_start(ap,a0); const unsigned int whz = width*height*depth; T *ptrd = ptr(x,y,z,0); *ptrd = (T)a0; for (unsigned int k=1; k<dim; ++k) { ptrd+=whz; *ptrd = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }; | |
13878 | return *this; | |
13879 | } | |
13880 | CImg<T>& fillV(const unsigned int x, const unsigned int y, const unsigned int z, const double a0, ...) { | |
13881 | if (x<width && y<height && z<depth) { va_list ap; __builtin_va_start(ap,a0); const unsigned int whz = width*height*depth; T *ptrd = ptr(x,y,z,0); *ptrd = (T)a0; for (unsigned int k=1; k<dim; ++k) { ptrd+=whz; *ptrd = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }; | |
13882 | return *this; | |
13883 | } | |
13884 | CImg<T>& fillZV(const unsigned int x, const unsigned int y, const int a0, ...) { | |
13885 | if (x<width && y<height) { va_list ap; __builtin_va_start(ap,a0); const unsigned int wh = width*height, zd = depth*dim; T *ptrd = ptr(x,y,0,0); *ptrd = (T)a0; for (unsigned int k=1; k<zd; ++k) { ptrd+=wh; *ptrd = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }; | |
13886 | return *this; | |
13887 | } | |
13888 | CImg<T>& fillZV(const unsigned int x, const unsigned int y, const double a0, ...) { | |
13889 | if (x<width && y<height) { va_list ap; __builtin_va_start(ap,a0); const unsigned int wh = width*height, zd = depth*dim; T *ptrd = ptr(x,y,0,0); *ptrd = (T)a0; for (unsigned int k=1; k<zd; ++k) { ptrd+=wh; *ptrd = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }; | |
13890 | return *this; | |
13891 | } | |
13892 | CImg<T>& fillYZV(const unsigned int x, const int a0, ...) { | |
13893 | if (x<width) { va_list ap; __builtin_va_start(ap,a0); const unsigned int hzd = height*depth*dim; T *ptrd = ptr(x,0,0,0); *ptrd = (T)a0; for (unsigned int k=1; k<hzd; ++k) { ptrd+=width; *ptrd = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }; | |
13894 | return *this; | |
13895 | } | |
13896 | CImg<T>& fillYZV(const unsigned int x, const double a0, ...) { | |
13897 | if (x<width) { va_list ap; __builtin_va_start(ap,a0); const unsigned int hzd = height*depth*dim; T *ptrd = ptr(x,0,0,0); *ptrd = (T)a0; for (unsigned int k=1; k<hzd; ++k) { ptrd+=width; *ptrd = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }; | |
13898 | return *this; | |
13899 | } | |
13900 | CImg<T> get_normalize(const T a, const T b) const { | |
13901 | return (+*this).normalize(a,b); | |
13902 | } | |
13903 | CImg<T>& normalize(const T a, const T b) { | |
13904 | if (!is_empty()) { | |
13905 | typedef typename cimg::superset<T,float>::type ftype; | |
13906 | T m, M = maxmin(m); | |
13907 | const ftype fm = (ftype)m, fM = (ftype)M; | |
13908 | if (m==M) return fill(0); | |
13909 | if (m!=a || M!=b) for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (T)((*ptr-fm)/(fM-fm)*(b-a)+a); | |
13910 | } | |
13911 | return *this; | |
13912 | } | |
13913 | CImg<T> get_cut(const T a, const T b) const { | |
13914 | return (+*this).cut(a,b); | |
13915 | } | |
13916 | CImg<T>& cut(const T a, const T b) { | |
13917 | if (!is_empty()) | |
13918 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = (*ptr<a)?a:((*ptr>b)?b:*ptr); | |
13919 | return *this; | |
13920 | } | |
13921 | CImg<T> get_quantize(const unsigned int n=256, const bool keep_range=true) const { | |
13922 | return (+*this).quantize(n,keep_range); | |
13923 | } | |
13924 | CImg<T>& quantize(const unsigned int n=256, const bool keep_range=true) { | |
13925 | if (!is_empty()) { | |
13926 | if (!n) throw CImgArgumentException("CImg<%s>::quantize() : Cannot quantize image to 0 values.", | |
13927 | pixel_type()); | |
13928 | typedef typename cimg::superset<T,float>::type ftype; | |
13929 | ftype m, M = (ftype)maxmin(m), range = M - m; | |
13930 | if (range>0) { | |
13931 | if (keep_range) for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
13932 | const unsigned int val = (unsigned int)((*ptr-m)*n/range); | |
13933 | *ptr = (T)(m + cimg::min(val,n-1)*range/n); | |
13934 | } else for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
13935 | const unsigned int val = (unsigned int)((*ptr-m)*n/range); | |
13936 | *ptr = (T)cimg::min(val,n-1); | |
13937 | } | |
13938 | } | |
13939 | } | |
13940 | return *this; | |
13941 | } | |
13942 | CImg<T> get_threshold(const T thres) const { | |
13943 | return (+*this).threshold(thres); | |
13944 | } | |
13945 | CImg<T>& threshold(const T thres) { | |
13946 | if (!is_empty()) for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) *ptr = *ptr<=thres?(T)0:(T)1; | |
13947 | return *this; | |
13948 | } | |
13949 | CImg<T> get_rotate(const float angle, const unsigned int cond=3) const { | |
13950 | if (is_empty()) return CImg<T>(); | |
13951 | CImg<T> dest; | |
13952 | const float nangle = cimg::mod(angle,360.0f), rad = (float)((nangle*cimg::valuePI)/180.0), | |
13953 | ca=(float)std::cos(rad), sa=(float)std::sin(rad); | |
13954 | if (cond!=1 && cimg::mod(nangle,90.0f)==0) { | |
13955 | const int wm1 = dimx()-1, hm1 = dimy()-1; | |
13956 | const int iangle = (int)nangle/90; | |
13957 | switch (iangle) { | |
13958 | case 1: { | |
13959 | dest.assign(height,width,depth,dim); | |
13960 | for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) dest(x,y,z,v) = (*this)(y,hm1-x,z,v); | |
13961 | } break; | |
13962 | case 2: { | |
13963 | dest.assign(width,height,depth,dim); | |
13964 | for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) dest(x,y,z,v) = (*this)(wm1-x,hm1-y,z,v); | |
13965 | } break; | |
13966 | case 3: { | |
13967 | dest.assign(height,width,depth,dim); | |
13968 | for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) dest(x,y,z,v) = (*this)(wm1-y,x,z,v); | |
13969 | } break; | |
13970 | default: | |
13971 | return *this; | |
13972 | } | |
13973 | } else { | |
13974 | const float | |
13975 | ux = (float)(cimg::abs(width*ca)), uy = (float)(cimg::abs(width*sa)), | |
13976 | vx = (float)(cimg::abs(height*sa)), vy = (float)(cimg::abs(height*ca)), | |
13977 | w2 = 0.5f*width, h2 = 0.5f*height, | |
13978 | dw2 = 0.5f*(ux+vx), dh2 = 0.5f*(uy+vy); | |
13979 | dest.assign((int)(ux+vx), (int)(uy+vy),depth,dim); | |
13980 | switch (cond) { | |
13981 | case 0: { | |
13982 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) | |
13983 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) | |
13984 | dest(x,y,z,v) = pix2d((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),(int)(h2 - (x-dw2)*sa + (y-dh2)*ca),z,v,0); | |
13985 | } break; | |
13986 | case 1: { | |
13987 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) | |
13988 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) | |
13989 | dest(x,y,z,v) = (*this)(cimg::mod((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),dimx()), | |
13990 | cimg::mod((int)(h2 - (x-dw2)*sa + (y-dh2)*ca),dimy()),z,v); | |
13991 | } break; | |
13992 | case 2: { | |
13993 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) { | |
13994 | const float X = w2 + (x-dw2)*ca + (y-dh2)*sa, Y = h2 - (x-dw2)*sa + (y-dh2)*ca; | |
13995 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) dest(x,y,z,v) = (T)linear_pix2d(X,Y,z,v,0); | |
13996 | } | |
13997 | } break; | |
13998 | default: { | |
13999 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) { | |
14000 | const float X = w2 + (x-dw2)*ca + (y-dh2)*sa, Y = h2 - (x-dw2)*sa + (y-dh2)*ca; | |
14001 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) dest(x,y,z,v) = (T)cubic_pix2d(X,Y,z,v,0); | |
14002 | } | |
14003 | } break; | |
14004 | } | |
14005 | } | |
14006 | return dest; | |
14007 | } | |
14008 | CImg<T>& rotate(const float angle, const unsigned int cond=3) { | |
14009 | return get_rotate(angle,cond).transfer_to(*this); | |
14010 | } | |
14011 | CImg<T> get_rotate(const float angle, const float cx, const float cy, const float zoom=1, const unsigned int cond=3) const { | |
14012 | if (is_empty()) return CImg<T>(); | |
14013 | CImg<T> dest(width,height,depth,dim); | |
14014 | const float nangle = cimg::mod(angle,360.0f), rad = (float)((nangle*cimg::valuePI)/180.0), | |
14015 | ca=(float)std::cos(rad)/zoom, sa=(float)std::sin(rad)/zoom; | |
14016 | if (cond!=1 && zoom==1 && cimg::mod(nangle,90.0f)==0) { | |
14017 | const int iangle = (int)nangle/90; | |
14018 | switch (iangle) { | |
14019 | case 1: { | |
14020 | dest.fill(0); | |
14021 | const unsigned int | |
14022 | xmin = cimg::max(0,(dimx()-dimy())/2), xmax = cimg::min(width,xmin+height), | |
14023 | ymin = cimg::max(0,(dimy()-dimx())/2), ymax = cimg::min(height,ymin+width), | |
14024 | xoff = xmin + cimg::min(0,(dimx()-dimy())/2), | |
14025 | yoff = ymin + cimg::min(0,(dimy()-dimx())/2); | |
14026 | for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (unsigned int y=ymin; y<ymax; ++y) for (unsigned int x=xmin; x<xmax; ++x) | |
14027 | dest(x,y,z,v) = (*this)(y-yoff,height-1-x+xoff,z,v); | |
14028 | } break; | |
14029 | case 2: { | |
14030 | for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) dest(x,y,z,v) = (*this)(width-1-x,height-1-y,z,v); | |
14031 | } break; | |
14032 | case 3: { | |
14033 | dest.fill(0); | |
14034 | const unsigned int | |
14035 | xmin = cimg::max(0,(dimx()-dimy())/2), xmax = cimg::min(width,xmin+height), | |
14036 | ymin = cimg::max(0,(dimy()-dimx())/2), ymax = cimg::min(height,ymin+width), | |
14037 | xoff = xmin + cimg::min(0,(dimx()-dimy())/2), | |
14038 | yoff = ymin + cimg::min(0,(dimy()-dimx())/2); | |
14039 | for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (unsigned int y=ymin; y<ymax; ++y) for (unsigned int x=xmin; x<xmax; ++x) | |
14040 | dest(x,y,z,v) = (*this)(width-1-y+yoff,x-xoff,z,v); | |
14041 | } break; | |
14042 | default: | |
14043 | return *this; | |
14044 | } | |
14045 | } else | |
14046 | switch (cond) { | |
14047 | case 0: { | |
14048 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) | |
14049 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) | |
14050 | dest(x,y,z,v) = pix2d((int)(cx + (x-cx)*ca + (y-cy)*sa),(int)(cy - (x-cx)*sa + (y-cy)*ca),z,v,0); | |
14051 | } break; | |
14052 | case 1: { | |
14053 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) | |
14054 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) | |
14055 | dest(x,y,z,v) = (*this)(cimg::mod((int)(cx + (x-cx)*ca + (y-cy)*sa),dimx()), | |
14056 | cimg::mod((int)(cy - (x-cx)*sa + (y-cy)*ca),dimy()),z,v); | |
14057 | } break; | |
14058 | case 2: { | |
14059 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) { | |
14060 | const float X = cx + (x-cx)*ca + (y-cy)*sa, Y = cy - (x-cx)*sa + (y-cy)*ca; | |
14061 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) dest(x,y,z,v) = (T)linear_pix2d(X,Y,z,v,0); | |
14062 | } | |
14063 | } break; | |
14064 | default: { | |
14065 | for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) { | |
14066 | const float X = cx + (x-cx)*ca + (y-cy)*sa, Y = cy - (x-cx)*sa + (y-cy)*ca; | |
14067 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) dest(x,y,z,v) = (T)cubic_pix2d(X,Y,z,v,0); | |
14068 | } | |
14069 | } break; | |
14070 | } | |
14071 | return dest; | |
14072 | } | |
14073 | CImg<T>& rotate(const float angle, const float cx, const float cy, const float zoom=1, const unsigned int cond=3) { | |
14074 | return get_rotate(angle,cx,cy,zoom,cond).transfer_to(*this); | |
14075 | } | |
14076 | CImg<T> get_resize(const int pdx=-100, const int pdy=-100, const int pdz=-100, const int pdv=-100, | |
14077 | const int interp=1, const int border_condition=-1, const bool center=false) const { | |
14078 | if (!pdx || !pdy || !pdz || !pdv) return CImg<T>(); | |
14079 | const unsigned int | |
14080 | tdx = pdx<0?-pdx*width/100:pdx, | |
14081 | tdy = pdy<0?-pdy*height/100:pdy, | |
14082 | tdz = pdz<0?-pdz*depth/100:pdz, | |
14083 | tdv = pdv<0?-pdv*dim/100:pdv, | |
14084 | dx = tdx?tdx:1, | |
14085 | dy = tdy?tdy:1, | |
14086 | dz = tdz?tdz:1, | |
14087 | dv = tdv?tdv:1; | |
14088 | if (width==dx && height==dy && depth==dz && dim==dv) return +*this; | |
14089 | if (is_empty()) return CImg<T>(dx,dy,dz,dv,0); | |
14090 | CImg<T> res; | |
14091 | switch (interp) { | |
14092 | case -1: | |
14093 | std::memcpy(res.assign(dx,dy,dz,dv,0).data,data,sizeof(T)*cimg::min(size(),(long unsigned int)dx*dy*dz*dv)); | |
14094 | break; | |
14095 | case 0: { | |
14096 | const unsigned int bx = width-1, by = height-1, bz = depth-1, bv = dim-1; | |
14097 | res.assign(dx,dy,dz,dv); | |
14098 | switch (border_condition) { | |
14099 | case 1: { | |
14100 | if (center) { | |
14101 | const int | |
14102 | x0 = (res.dimx()-dimx())/2, | |
14103 | y0 = (res.dimy()-dimy())/2, | |
14104 | z0 = (res.dimz()-dimz())/2, | |
14105 | v0 = (res.dimv()-dimv())/2, | |
14106 | x1 = x0 + (int)bx, | |
14107 | y1 = y0 + (int)by, | |
14108 | z1 = z0 + (int)bz, | |
14109 | v1 = v0 + (int)bv; | |
14110 | res.draw_image(*this,x0,y0,z0,v0); | |
14111 | for (int v = 0; v<(int)((res).dim); ++v) for (int _n1l = (int)(v<(int)(v0) || v>(int)(v1)), z = 0; z<(int)((res).depth); ++z) for (int _n1k = (int)(z<(int)(z0) || z>(int)(z1)), y = 0; y<(int)((res).height); ++y) for (int _n1j = (int)(y<(int)(y0) || y>(int)(y1)), x = _n1j || _n1k || _n1l?0:(int)(x0)>0?0:(int)(x1)+1; x<(int)((res).width); ++x, x = _n1j || _n1k || _n1l?x:(x==(int)(x0)?(int)(x1)+1:x)) res(x,y,z,v) = pix4d(x-x0,y-y0,z-z0,v-v0); | |
14112 | } else { | |
14113 | res.draw_image(*this,0,0,0,0); | |
14114 | for (int v = 0; v<(int)((res).dim); ++v) for (int _n1l = (int)(v<(int)(0) || v>(int)(bv)), z = 0; z<(int)((res).depth); ++z) for (int _n1k = (int)(z<(int)(0) || z>(int)(bz)), y = 0; y<(int)((res).height); ++y) for (int _n1j = (int)(y<(int)(0) || y>(int)(by)), x = _n1j || _n1k || _n1l?0:(int)(0)>0?0:(int)(bx)+1; x<(int)((res).width); ++x, x = _n1j || _n1k || _n1l?x:(x==(int)(0)?(int)(bx)+1:x)) res(x,y,z,v) = pix4d(x,y,z,v); | |
14115 | } | |
14116 | } break; | |
14117 | case 2 : { | |
14118 | const int | |
14119 | x0 = (res.dimx()-dimx())/2, | |
14120 | y0 = (res.dimy()-dimy())/2, | |
14121 | z0 = (res.dimz()-dimz())/2, | |
14122 | v0 = (res.dimv()-dimv())/2, | |
14123 | nx0 = x0>0?x0-(1+x0/width)*width:x0, | |
14124 | ny0 = y0>0?y0-(1+y0/height)*height:y0, | |
14125 | nz0 = z0>0?z0-(1+z0/depth)*depth:z0, | |
14126 | nv0 = v0>0?v0-(1+v0/dim)*dim:v0; | |
14127 | for (int k=nv0; k<(int)dv; k+=dimv()) | |
14128 | for (int z=nz0; z<(int)dz; z+=dimz()) | |
14129 | for (int y=ny0; y<(int)dy; y+=dimy()) | |
14130 | for (int x=nx0; x<(int)dx; x+=dimx()) res.draw_image(*this,x,y,z,k); | |
14131 | } break; | |
14132 | default: { | |
14133 | res.fill(0); | |
14134 | if (center) res.draw_image(*this,(res.dimx()-dimx())/2,(res.dimy()-dimy())/2,(res.dimz()-dimz())/2,(res.dimv()-dimv())/2); | |
14135 | else res.draw_image(*this,0,0,0,0); | |
14136 | } break; | |
14137 | } | |
14138 | } break; | |
14139 | case 1: { | |
14140 | res.assign(dx,dy,dz,dv); | |
14141 | unsigned int | |
14142 | *const offx = new unsigned int[dx], | |
14143 | *const offy = new unsigned int[dy+1], | |
14144 | *const offz = new unsigned int[dz+1], | |
14145 | *const offv = new unsigned int[dv+1], | |
14146 | *poffx, *poffy, *poffz, *poffv, | |
14147 | curr, old; | |
14148 | const unsigned int wh = width*height, whd = width*height*depth, rwh = dx*dy, rwhd = dx*dy*dz; | |
14149 | poffx = offx; curr = 0; { for (int x = 0; x<(int)((res).width); ++x) { old=curr; curr=(x+1)*width/dx; *(poffx++) = (unsigned int)curr-(unsigned int)old; }} | |
14150 | poffy = offy; curr = 0; { for (int y = 0; y<(int)((res).height); ++y) { old=curr; curr=(y+1)*height/dy; *(poffy++) = width*((unsigned int)curr-(unsigned int)old); }} *poffy=0; | |
14151 | poffz = offz; curr = 0; { for (int z = 0; z<(int)((res).depth); ++z) { old=curr; curr=(z+1)*depth/dz; *(poffz++) = wh*((unsigned int)curr-(unsigned int)old); }} *poffz=0; | |
14152 | poffv = offv; curr = 0; { for (int k = 0; k<(int)((res).dim); ++k) { old=curr; curr=(k+1)*dim/dv; *(poffv++) = whd*((unsigned int)curr-(unsigned int)old); }} *poffv=0; | |
14153 | T *ptrd = res.data; | |
14154 | const T* ptrv = data; | |
14155 | poffv = offv; | |
14156 | for (unsigned int k=0; k<dv; ) { | |
14157 | const T *ptrz = ptrv; | |
14158 | poffz = offz; | |
14159 | for (unsigned int z=0; z<dz; ) { | |
14160 | const T *ptry = ptrz; | |
14161 | poffy = offy; | |
14162 | for (unsigned int y=0; y<dy; ) { | |
14163 | const T *ptrx = ptry; | |
14164 | poffx = offx; | |
14165 | for (int x = 0; x<(int)((res).width); ++x) { *(ptrd++) = *ptrx; ptrx+=*(poffx++); } | |
14166 | ++y; | |
14167 | unsigned int dy = *(poffy++); | |
14168 | for (;!dy && y<dy; std::memcpy(ptrd, ptrd-dx, sizeof(T)*dx), ++y, ptrd+=dx, dy=*(poffy++)); | |
14169 | ptry+=dy; | |
14170 | } | |
14171 | ++z; | |
14172 | unsigned int dz = *(poffz++); | |
14173 | for (;!dz && z<dz; std::memcpy(ptrd, ptrd-rwh, sizeof(T)*rwh), ++z, ptrd+=rwh, dz=*(poffz++)); | |
14174 | ptrz+=dz; | |
14175 | } | |
14176 | ++k; | |
14177 | unsigned int dv = *(poffv++); | |
14178 | for (;!dv && k<dv; std::memcpy(ptrd, ptrd-rwhd, sizeof(T)*rwhd), ++k, ptrd+=rwhd, dv=*(poffv++)); | |
14179 | ptrv+=dv; | |
14180 | } | |
14181 | delete[] offx; delete[] offy; delete[] offz; delete[] offv; | |
14182 | } break; | |
14183 | case 2: { | |
14184 | typedef typename cimg::superset<T,float>::type ftype; | |
14185 | bool instance_first = true; | |
14186 | if (dx!=width) { | |
14187 | CImg<ftype> tmp(dx,height,depth,dim,0); | |
14188 | for (unsigned int a=width*dx, b=width, c=dx, s=0, t=0; a; ) { | |
14189 | const unsigned int d = cimg::min(b,c); | |
14190 | a-=d; b-=d; c-=d; | |
14191 | for (int v = 0; v<(int)((tmp).dim); ++v) for (int z = 0; z<(int)((tmp).depth); ++z) for (int y = 0; y<(int)((tmp).height); ++y) tmp(t,y,z,v)+=(ftype)(*this)(s,y,z,v)*d; | |
14192 | if (!b) { for (int v = 0; v<(int)((tmp).dim); ++v) for (int z = 0; z<(int)((tmp).depth); ++z) for (int y = 0; y<(int)((tmp).height); ++y) tmp(t,y,z,v)/=width; ++t; b = width; } | |
14193 | if (!c) { ++s; c = dx; } | |
14194 | } | |
14195 | tmp.transfer_to(res); | |
14196 | instance_first = false; | |
14197 | } | |
14198 | if (dy!=height) { | |
14199 | CImg<ftype> tmp(dx,dy,depth,dim,0); | |
14200 | for (unsigned int a=height*dy, b=height, c=dy, s=0, t=0; a; ) { | |
14201 | const unsigned int d = cimg::min(b,c); | |
14202 | a-=d; b-=d; c-=d; | |
14203 | if (instance_first) for (int v = 0; v<(int)((tmp).dim); ++v) for (int z = 0; z<(int)((tmp).depth); ++z) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,t,z,v)+=(ftype)(*this)(x,s,z,v)*d; | |
14204 | else for (int v = 0; v<(int)((tmp).dim); ++v) for (int z = 0; z<(int)((tmp).depth); ++z) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,t,z,v)+=(ftype)res(x,s,z,v)*d; | |
14205 | if (!b) { for (int v = 0; v<(int)((tmp).dim); ++v) for (int z = 0; z<(int)((tmp).depth); ++z) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,t,z,v)/=height; ++t; b = height; } | |
14206 | if (!c) { ++s; c = dy; } | |
14207 | } | |
14208 | tmp.transfer_to(res); | |
14209 | instance_first = false; | |
14210 | } | |
14211 | if (dz!=depth) { | |
14212 | CImg<ftype> tmp(dx,dy,dz,dim,0); | |
14213 | for (unsigned int a=depth*dz, b=depth, c=dz, s=0, t=0; a; ) { | |
14214 | const unsigned int d = cimg::min(b,c); | |
14215 | a-=d; b-=d; c-=d; | |
14216 | if (instance_first) for (int v = 0; v<(int)((tmp).dim); ++v) for (int y = 0; y<(int)((tmp).height); ++y) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,y,t,v)+=(ftype)(*this)(x,y,s,v)*d; | |
14217 | else for (int v = 0; v<(int)((tmp).dim); ++v) for (int y = 0; y<(int)((tmp).height); ++y) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,y,t,v)+=(ftype)res(x,y,s,v)*d; | |
14218 | if (!b) { for (int v = 0; v<(int)((tmp).dim); ++v) for (int y = 0; y<(int)((tmp).height); ++y) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,y,t,v)/=depth; ++t; b = depth; } | |
14219 | if (!c) { ++s; c = dz; } | |
14220 | } | |
14221 | tmp.transfer_to(res); | |
14222 | instance_first = false; | |
14223 | } | |
14224 | if (dv!=dim) { | |
14225 | CImg<ftype> tmp(dx,dy,dz,dv,0); | |
14226 | for (unsigned int a=dim*dv, b=dim, c=dv, s=0, t=0; a; ) { | |
14227 | const unsigned int d = cimg::min(b,c); | |
14228 | a-=d; b-=d; c-=d; | |
14229 | if (instance_first) for (int z = 0; z<(int)((tmp).depth); ++z) for (int y = 0; y<(int)((tmp).height); ++y) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,y,z,t)+=(ftype)(*this)(x,y,z,s)*d; | |
14230 | else for (int z = 0; z<(int)((tmp).depth); ++z) for (int y = 0; y<(int)((tmp).height); ++y) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,y,z,t)+=(ftype)res(x,y,z,s)*d; | |
14231 | if (!b) { for (int z = 0; z<(int)((tmp).depth); ++z) for (int y = 0; y<(int)((tmp).height); ++y) for (int x = 0; x<(int)((tmp).width); ++x) tmp(x,y,z,t)/=dim; ++t; b = dim; } | |
14232 | if (!c) { ++s; c = dv; } | |
14233 | } | |
14234 | tmp.transfer_to(res); | |
14235 | instance_first = false; | |
14236 | } | |
14237 | } break; | |
14238 | case 3: { | |
14239 | const unsigned int dimmax = cimg::max(dx,dy,dz,dv); | |
14240 | const float | |
14241 | sx = (border_condition<0 && dx>width )?(dx>1?(width-1.0f)/(dx-1) :0):(float)width/dx, | |
14242 | sy = (border_condition<0 && dy>height)?(dy>1?(height-1.0f)/(dy-1):0):(float)height/dy, | |
14243 | sz = (border_condition<0 && dz>depth )?(dz>1?(depth-1.0f)/(dz-1) :0):(float)depth/dz, | |
14244 | sv = (border_condition<0 && dv>dim )?(dv>1?(dim-1.0f)/(dv-1) :0):(float)dim/dv; | |
14245 | unsigned int *const off = new unsigned int[dimmax], *poff; | |
14246 | float *const foff = new float[dimmax], *pfoff, old, curr; | |
14247 | CImg<T> resx, resy, resz, resv; | |
14248 | T *ptrd; | |
14249 | if (dx!=width) { | |
14250 | if (width==1) resx = get_resize(dx,height,depth,dim,1,0); | |
14251 | else { | |
14252 | resx.assign(dx,height,depth,dim); | |
14253 | curr = old = 0; poff = off; pfoff = foff; | |
14254 | for (int x = 0; x<(int)((resx).width); ++x) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sx; *(poff++) = (unsigned int)curr-(unsigned int)old; } | |
14255 | ptrd = resx.data; | |
14256 | const T *ptrs0 = data; | |
14257 | for (int k = 0; k<(int)((resx).dim); ++k) for (int z = 0; z<(int)((resx).depth); ++z) for (int y = 0; y<(int)((resx).height); ++y) { | |
14258 | poff = off; pfoff = foff; | |
14259 | const T *ptrs = ptrs0, *const ptrsmax = ptrs0 + (width-1); | |
14260 | for (int x = 0; x<(int)((resx).width); ++x) { | |
14261 | const float alpha = *(pfoff++); | |
14262 | const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+1):(border_condition?val1:0); | |
14263 | *(ptrd++) = (T)((1-alpha)*val1 + alpha*val2); | |
14264 | ptrs+=*(poff++); | |
14265 | } | |
14266 | ptrs0+=width; | |
14267 | } | |
14268 | } | |
14269 | } else resx.assign(*this,true); | |
14270 | if (dy!=height) { | |
14271 | if (height==1) resy = resx.get_resize(dx,dy,depth,dim,1,0); | |
14272 | else { | |
14273 | resy.assign(dx,dy,depth,dim); | |
14274 | curr = old = 0; poff = off; pfoff = foff; | |
14275 | for (int y = 0; y<(int)((resy).height); ++y) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sy; *(poff++) = dx*((unsigned int)curr-(unsigned int)old); } | |
14276 | for (int k = 0; k<(int)((resy).dim); ++k) for (int z = 0; z<(int)((resy).depth); ++z) for (int x = 0; x<(int)((resy).width); ++x) { | |
14277 | ptrd = resy.ptr(x,0,z,k); | |
14278 | const T *ptrs = resx.ptr(x,0,z,k), *const ptrsmax = ptrs + (height-1)*dx; | |
14279 | poff = off; pfoff = foff; | |
14280 | for (int y = 0; y<(int)((resy).height); ++y) { | |
14281 | const float alpha = *(pfoff++); | |
14282 | const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+dx):(border_condition?val1:0); | |
14283 | *ptrd = (T)((1-alpha)*val1 + alpha*val2); | |
14284 | ptrd+=dx; | |
14285 | ptrs+=*(poff++); | |
14286 | } | |
14287 | } | |
14288 | } | |
14289 | resx.assign(); | |
14290 | } else resy.assign(resx,true); | |
14291 | if (dz!=depth) { | |
14292 | if (depth==1) resz = resy.get_resize(dx,dy,dz,dim,1,0); | |
14293 | else { | |
14294 | const unsigned int wh = dx*dy; | |
14295 | resz.assign(dx,dy,dz,dim); | |
14296 | curr = old = 0; poff = off; pfoff = foff; | |
14297 | for (int z = 0; z<(int)((resz).depth); ++z) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sz; *(poff++) = wh*((unsigned int)curr-(unsigned int)old); } | |
14298 | for (int k = 0; k<(int)((resz).dim); ++k) for (int y = 0; y<(int)((resz).height); ++y) for (int x = 0; x<(int)((resz).width); ++x) { | |
14299 | ptrd = resz.ptr(x,y,0,k); | |
14300 | const T *ptrs = resy.ptr(x,y,0,k), *const ptrsmax = ptrs + (depth-1)*wh; | |
14301 | poff = off; pfoff = foff; | |
14302 | for (int z = 0; z<(int)((resz).depth); ++z) { | |
14303 | const float alpha = *(pfoff++); | |
14304 | const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+wh):(border_condition?val1:0); | |
14305 | *ptrd = (T)((1-alpha)*val1 + alpha*val2); | |
14306 | ptrd+=wh; | |
14307 | ptrs+=*(poff++); | |
14308 | } | |
14309 | } | |
14310 | } | |
14311 | resy.assign(); | |
14312 | } else resz.assign(resy,true); | |
14313 | if (dv!=dim) { | |
14314 | if (dim==1) resv = resz.get_resize(dx,dy,dz,dv,1,0); | |
14315 | else { | |
14316 | const unsigned int whd = dx*dy*dz; | |
14317 | resv.assign(dx,dy,dz,dv); | |
14318 | curr = old = 0; poff = off; pfoff = foff; | |
14319 | for (int k = 0; k<(int)((resv).dim); ++k) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sv; *(poff++) = whd*((unsigned int)curr-(unsigned int)old); } | |
14320 | for (int z = 0; z<(int)((resv).depth); ++z) for (int y = 0; y<(int)((resv).height); ++y) for (int x = 0; x<(int)((resv).width); ++x) { | |
14321 | ptrd = resv.ptr(x,y,z,0); | |
14322 | const T *ptrs = resz.ptr(x,y,z,0), *const ptrsmax = ptrs + (dim-1)*whd; | |
14323 | poff = off; pfoff = foff; | |
14324 | for (int k = 0; k<(int)((resv).dim); ++k) { | |
14325 | const float alpha = *(pfoff++); | |
14326 | const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+whd):(border_condition?val1:0); | |
14327 | *ptrd = (T)((1-alpha)*val1 + alpha*val2); | |
14328 | ptrd+=whd; | |
14329 | ptrs+=*(poff++); | |
14330 | } | |
14331 | } | |
14332 | } | |
14333 | resz.assign(); | |
14334 | } else resv.assign(resz,true); | |
14335 | delete[] off; delete[] foff; | |
14336 | return resv.is_shared?(resz.is_shared?(resy.is_shared?(resx.is_shared?(+(*this)):resx):resy):resz):resv; | |
14337 | } break; | |
14338 | case 4: { | |
14339 | res.assign(dx,dy,dz,dv,0); | |
14340 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(x*dx/width,y*dy/height,z*dz/depth,k*dv/dim) = (*this)(x,y,z,k); | |
14341 | } break; | |
14342 | case 5: { | |
14343 | typedef typename cimg::superset<T,float>::type ftype; | |
14344 | const float | |
14345 | sx = (border_condition<0 && dx>width )?(dx>1?(width-1.0f)/(dx-1) :0):(float)width/dx, | |
14346 | sy = (border_condition<0 && dy>height)?(dy>1?(height-1.0f)/(dy-1):0):(float)height/dy, | |
14347 | sz = (border_condition<0 && dz>depth )?(dz>1?(depth-1.0f)/(dz-1) :0):(float)depth/dz, | |
14348 | sv = (border_condition<0 && dv>dim )?(dv>1?(dim-1.0f)/(dv-1) :0):(float)dim/dv; | |
14349 | res.assign(dx,dy,dz,dv); | |
14350 | T *ptrd = res.ptr(); | |
14351 | float cx, cy, cz, ck = 0; | |
14352 | for (int k = 0; k<(int)((res).dim); ++k) { cz = 0; | |
14353 | for (int z = 0; z<(int)((res).depth); ++z) { cy = 0; | |
14354 | for (int y = 0; y<(int)((res).height); ++y) { cx = 0; | |
14355 | for (int x = 0; x<(int)((res).width); ++x) { | |
14356 | *(ptrd++) = (T)(border_condition?cubic_pix2d(cx,cy,(int)cz,(int)ck):cubic_pix2d(cx,cy,(int)cz,(int)ck,0)); | |
14357 | cx+=sx; | |
14358 | } cy+=sy; | |
14359 | } cz+=sz; | |
14360 | } ck+=sv; | |
14361 | } | |
14362 | } break; | |
14363 | default: | |
14364 | throw CImgArgumentException("CImg<%s>::resize() : Invalid interpolation method : %d specified.", | |
14365 | pixel_type(),interp); | |
14366 | } | |
14367 | return res; | |
14368 | } | |
14369 | CImg<T>& resize(const int pdx=-100, const int pdy=-100, const int pdz=-100, const int pdv=-100, | |
14370 | const int interp=1, const int border_condition=-1, const bool center=false) { | |
14371 | if (!pdx || !pdy || !pdz || !pdv) return assign(); | |
14372 | const unsigned int | |
14373 | dx = pdx<0?-pdx*width/100:pdx, | |
14374 | dy = pdy<0?-pdy*height/100:pdy, | |
14375 | dz = pdz<0?-pdz*depth/100:pdz, | |
14376 | dv = pdv<0?-pdv*dim/100:pdv; | |
14377 | if (width==dx && height==dy && depth==dz && dim==dv) return *this; | |
14378 | if (interp==-1 && dx*dy*dz*dv==size()) { | |
14379 | width = dx; height = dy; depth = dz; dim = dv; | |
14380 | return *this; | |
14381 | } | |
14382 | return get_resize(dx,dy,dz,dv,interp,border_condition,center).transfer_to(*this); | |
14383 | } | |
14384 | template<typename t> CImg<T> get_resize(const CImg<t>& src, const int interp=1, | |
14385 | const int border_condition=-1, const bool center=false) const { | |
14386 | return get_resize(src.width,src.height,src.depth,src.dim,interp,border_condition,center); | |
14387 | } | |
14388 | template<typename t> CImg<T>& resize(const CImg<t>& src, const int interp=1, | |
14389 | const int border_condition=-1, const bool center=false) { | |
14390 | return resize(src.width,src.height,src.depth,src.dim,interp,border_condition,center); | |
14391 | } | |
14392 | CImg<T> get_resize(const CImgDisplay& disp, const int interp=1, | |
14393 | const int border_condition=-1, const bool center=false) const { | |
14394 | return get_resize(disp.width,disp.height,depth,dim,interp,border_condition,center); | |
14395 | } | |
14396 | CImg<T>& resize(const CImgDisplay& disp, const int interp=1, | |
14397 | const int border_condition=-1, const bool center=false) { | |
14398 | return resize(disp.width,disp.height,depth,dim,interp,border_condition,center); | |
14399 | } | |
14400 | CImg<T> get_permute_axes(const char *permut="vxyz") const { | |
14401 | if (is_empty() || !permut) return (+*this); | |
14402 | CImg<T> res; | |
14403 | const T* ptr = data; | |
14404 | if (!cimg::strncasecmp(permut,"xyzv",4)) return (+*this); | |
14405 | if (!cimg::strncasecmp(permut,"xyvz",4)) { res.assign(width,height,dim,depth); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(x,y,v,z) = *(ptr++); return res; } | |
14406 | if (!cimg::strncasecmp(permut,"xzyv",4)) { res.assign(width,depth,height,dim); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(x,z,y,v) = *(ptr++); return res; } | |
14407 | if (!cimg::strncasecmp(permut,"xzvy",4)) { res.assign(width,depth,dim,height); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(x,z,v,y) = *(ptr++); return res; } | |
14408 | if (!cimg::strncasecmp(permut,"xvyz",4)) { res.assign(width,dim,height,depth); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(x,v,y,z) = *(ptr++); return res; } | |
14409 | if (!cimg::strncasecmp(permut,"xvzy",4)) { res.assign(width,dim,depth,height); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(x,v,z,y) = *(ptr++); return res; } | |
14410 | if (!cimg::strncasecmp(permut,"yxzv",4)) { res.assign(height,width,depth,dim); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(y,x,z,v) = *(ptr++); return res; } | |
14411 | if (!cimg::strncasecmp(permut,"yxvz",4)) { res.assign(height,width,dim,depth); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(y,x,v,z) = *(ptr++); return res; } | |
14412 | if (!cimg::strncasecmp(permut,"yzxv",4)) { res.assign(height,depth,width,dim); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(y,z,x,v) = *(ptr++); return res; } | |
14413 | if (!cimg::strncasecmp(permut,"yzvx",4)) { res.assign(height,depth,dim,width); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(y,z,v,x) = *(ptr++); return res; } | |
14414 | if (!cimg::strncasecmp(permut,"yvxz",4)) { res.assign(height,dim,width,depth); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(y,v,x,z) = *(ptr++); return res; } | |
14415 | if (!cimg::strncasecmp(permut,"yvzx",4)) { res.assign(height,dim,depth,width); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(y,v,z,x) = *(ptr++); return res; } | |
14416 | if (!cimg::strncasecmp(permut,"zxyv",4)) { res.assign(depth,width,height,dim); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(z,x,y,v) = *(ptr++); return res; } | |
14417 | if (!cimg::strncasecmp(permut,"zxvy",4)) { res.assign(depth,width,dim,height); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(z,x,v,y) = *(ptr++); return res; } | |
14418 | if (!cimg::strncasecmp(permut,"zyxv",4)) { res.assign(depth,height,width,dim); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(z,y,x,v) = *(ptr++); return res; } | |
14419 | if (!cimg::strncasecmp(permut,"zyvx",4)) { res.assign(depth,height,dim,width); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(z,y,v,x) = *(ptr++); return res; } | |
14420 | if (!cimg::strncasecmp(permut,"zvxy",4)) { res.assign(depth,dim,width,height); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(z,v,x,y) = *(ptr++); return res; } | |
14421 | if (!cimg::strncasecmp(permut,"zvyx",4)) { res.assign(depth,dim,height,width); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(z,v,y,x) = *(ptr++); return res; } | |
14422 | if (!cimg::strncasecmp(permut,"vxyz",4)) { res.assign(dim,width,height,depth); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(v,x,y,z) = *(ptr++); return res; } | |
14423 | if (!cimg::strncasecmp(permut,"vxzy",4)) { res.assign(dim,width,depth,height); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(v,x,z,y) = *(ptr++); return res; } | |
14424 | if (!cimg::strncasecmp(permut,"vyxz",4)) { res.assign(dim,height,width,depth); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(v,y,x,z) = *(ptr++); return res; } | |
14425 | if (!cimg::strncasecmp(permut,"vyzx",4)) { res.assign(dim,height,depth,width); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(v,y,z,x) = *(ptr++); return res; } | |
14426 | if (!cimg::strncasecmp(permut,"vzxy",4)) { res.assign(dim,depth,width,height); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(v,z,x,y) = *(ptr++); return res; } | |
14427 | if (!cimg::strncasecmp(permut,"vzyx",4)) { res.assign(dim,depth,height,width); for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) res(v,z,y,x) = *(ptr++); return res; } | |
14428 | throw CImgArgumentException("CImg<%s>::permute_axes() : Invalid input permutation '%s'.",pixel_type(),permut); | |
14429 | return res; | |
14430 | } | |
14431 | CImg<T>& permute_axes(const char *order="vxyz") { | |
14432 | return get_permute_axes(order).transfer_to(*this); | |
14433 | } | |
14434 | CImg<T> get_resize_halfXY() const { | |
14435 | typedef typename cimg::superset<T,float>::type ftype; | |
14436 | if (is_empty()) return CImg<T>(); | |
14437 | const ftype mask[9] = { 0.07842776544f, 0.1231940459f, 0.07842776544f, | |
14438 | 0.1231940459f, 0.1935127547f, 0.1231940459f, | |
14439 | 0.07842776544f, 0.1231940459f, 0.07842776544f }; | |
14440 | ftype I[9] = { 0 }; | |
14441 | CImg<T> dest(width/2,height/2,depth,dim); | |
14442 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,k)), (I[3] = I[4] = (*this)(0,y,z,k)), (I[6] = I[7] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,k)), (I[5] = (*this)(_n1x,y,z,k)), (I[8] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) | |
14443 | if (x%2 && y%2) dest(x/2,y/2,z,k) = (T) | |
14444 | (I[0]*mask[0] + I[1]*mask[1] + I[2]*mask[2] + | |
14445 | I[3]*mask[3] + I[4]*mask[4] + I[5]*mask[5] + | |
14446 | I[6]*mask[6] + I[7]*mask[7] + I[8]*mask[8]); | |
14447 | return dest; | |
14448 | } | |
14449 | CImg<T>& resize_halfXY() { | |
14450 | return get_resize_halfXY().transfer_to(*this); | |
14451 | } | |
14452 | CImg<T> get_mirror(const char axe='x') const { | |
14453 | return (+*this).mirror(axe); | |
14454 | } | |
14455 | CImg<T>& mirror(const char axe='x') { | |
14456 | if (!is_empty()) { | |
14457 | T *pf, *pb, *buf = 0; | |
14458 | switch (cimg::uncase(axe)) { | |
14459 | case 'x': { | |
14460 | pf = data; pb = ptr(width-1); | |
14461 | for (unsigned int yzv=0; yzv<height*depth*dim; ++yzv) { | |
14462 | for (unsigned int x=0; x<width/2; ++x) { const T val = *pf; *(pf++) = *pb; *(pb--) = val; } | |
14463 | pf+=width-width/2; | |
14464 | pb+=width+width/2; | |
14465 | } | |
14466 | } break; | |
14467 | case 'y': { | |
14468 | buf = new T[width]; | |
14469 | pf = data; pb = ptr(0,height-1); | |
14470 | for (unsigned int zv=0; zv<depth*dim; ++zv) { | |
14471 | for (unsigned int y=0; y<height/2; ++y) { | |
14472 | std::memcpy(buf,pf,width*sizeof(T)); | |
14473 | std::memcpy(pf,pb,width*sizeof(T)); | |
14474 | std::memcpy(pb,buf,width*sizeof(T)); | |
14475 | pf+=width; | |
14476 | pb-=width; | |
14477 | } | |
14478 | pf+=width*(height-height/2); | |
14479 | pb+=width*(height+height/2); | |
14480 | } | |
14481 | } break; | |
14482 | case 'z': { | |
14483 | buf = new T[width*height]; | |
14484 | pf = data; pb = ptr(0,0,depth-1); | |
14485 | for (int v = 0; v<(int)((*this).dim); ++v) { | |
14486 | for (unsigned int z=0; z<depth/2; ++z) { | |
14487 | std::memcpy(buf,pf,width*height*sizeof(T)); | |
14488 | std::memcpy(pf,pb,width*height*sizeof(T)); | |
14489 | std::memcpy(pb,buf,width*height*sizeof(T)); | |
14490 | pf+=width*height; | |
14491 | pb-=width*height; | |
14492 | } | |
14493 | pf+=width*height*(depth-depth/2); | |
14494 | pb+=width*height*(depth+depth/2); | |
14495 | } | |
14496 | } break; | |
14497 | case 'v': { | |
14498 | buf = new T[width*height*depth]; | |
14499 | pf = data; pb = ptr(0,0,0,dim-1); | |
14500 | for (unsigned int v=0; v<dim/2; ++v) { | |
14501 | std::memcpy(buf,pf,width*height*depth*sizeof(T)); | |
14502 | std::memcpy(pf,pb,width*height*depth*sizeof(T)); | |
14503 | std::memcpy(pb,buf,width*height*depth*sizeof(T)); | |
14504 | pf+=width*height*depth; | |
14505 | pb-=width*height*depth; | |
14506 | } | |
14507 | } break; | |
14508 | default: | |
14509 | throw CImgArgumentException("CImg<%s>::mirror() : unknow axe '%c', must be 'x','y','z' or 'v'",pixel_type(),axe); | |
14510 | } | |
14511 | if (buf) delete[] buf; | |
14512 | } | |
14513 | return *this; | |
14514 | } | |
14515 | CImg<T> get_translate(const int deltax, const int deltay=0, const int deltaz=0, const int deltav=0, | |
14516 | const int border_condition=0) const { | |
14517 | return (+*this).translate(deltax,deltay,deltaz,deltav,border_condition); | |
14518 | } | |
14519 | CImg<T>& translate(const int deltax, const int deltay=0, const int deltaz=0, const int deltav=0, | |
14520 | const int border_condition=0) { | |
14521 | if (!is_empty()) { | |
14522 | if (deltax) | |
14523 | switch (border_condition) { | |
14524 | case 0: | |
14525 | if (cimg::abs(deltax)>=dimx()) return fill(0); | |
14526 | if (deltax>0) for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
14527 | std::memmove(ptr(0,y,z,k),ptr(deltax,y,z,k),(width-deltax)*sizeof(T)); | |
14528 | std::memset(ptr(width-deltax,y,z,k),0,deltax*sizeof(T)); | |
14529 | } else for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
14530 | std::memmove(ptr(-deltax,y,z,k),ptr(0,y,z,k),(width+deltax)*sizeof(T)); | |
14531 | std::memset(ptr(0,y,z,k),0,-deltax*sizeof(T)); | |
14532 | } | |
14533 | break; | |
14534 | case 1: | |
14535 | if (deltax>0) { | |
14536 | const int ndeltax = (deltax>=dimx())?width-1:deltax; | |
14537 | if (!ndeltax) return *this; | |
14538 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
14539 | std::memmove(ptr(0,y,z,k),ptr(ndeltax,y,z,k),(width-ndeltax)*sizeof(T)); | |
14540 | T *ptrd = ptr(width-1,y,z,k); | |
14541 | const T val = *ptrd; | |
14542 | for (int l=0; l<ndeltax-1; ++l) *(--ptrd) = val; | |
14543 | } | |
14544 | } else { | |
14545 | const int ndeltax = (-deltax>=dimx())?width-1:-deltax; | |
14546 | if (!ndeltax) return *this; | |
14547 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
14548 | std::memmove(ptr(ndeltax,y,z,k),ptr(0,y,z,k),(width-ndeltax)*sizeof(T)); | |
14549 | T *ptrd = ptr(0,y,z,k); | |
14550 | const T val = *ptrd; | |
14551 | for (int l=0; l<ndeltax-1; ++l) *(++ptrd) = val; | |
14552 | } | |
14553 | } | |
14554 | break; | |
14555 | case 2: { | |
14556 | const int ml = cimg::mod(deltax,dimx()), ndeltax = (ml<=dimx()/2)?ml:(ml-dimx()); | |
14557 | if (!ndeltax) return *this; | |
14558 | T* buf = new T[cimg::abs(ndeltax)]; | |
14559 | if (ndeltax>0) for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
14560 | std::memcpy(buf,ptr(0,y,z,k),ndeltax*sizeof(T)); | |
14561 | std::memmove(ptr(0,y,z,k),ptr(ndeltax,y,z,k),(width-ndeltax)*sizeof(T)); | |
14562 | std::memcpy(ptr(width-ndeltax,y,z,k),buf,ndeltax*sizeof(T)); | |
14563 | } else for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
14564 | std::memcpy(buf,ptr(width+ndeltax,y,z,k),-ndeltax*sizeof(T)); | |
14565 | std::memmove(ptr(-ndeltax,y,z,k),ptr(0,y,z,k),(width+ndeltax)*sizeof(T)); | |
14566 | std::memcpy(ptr(0,y,z,k),buf,-ndeltax*sizeof(T)); | |
14567 | } | |
14568 | delete[] buf; | |
14569 | } break; | |
14570 | } | |
14571 | if (deltay) | |
14572 | switch (border_condition) { | |
14573 | case 0: | |
14574 | if (cimg::abs(deltay)>=dimy()) return fill(0); | |
14575 | if (deltay>0) for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) { | |
14576 | std::memmove(ptr(0,0,z,k),ptr(0,deltay,z,k),width*(height-deltay)*sizeof(T)); | |
14577 | std::memset(ptr(0,height-deltay,z,k),0,width*deltay*sizeof(T)); | |
14578 | } else for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) { | |
14579 | std::memmove(ptr(0,-deltay,z,k),ptr(0,0,z,k),width*(height+deltay)*sizeof(T)); | |
14580 | std::memset(ptr(0,0,z,k),0,-deltay*width*sizeof(T)); | |
14581 | } | |
14582 | break; | |
14583 | case 1: | |
14584 | if (deltay>0) { | |
14585 | const int ndeltay = (deltay>=dimy())?height-1:deltay; | |
14586 | if (!ndeltay) return *this; | |
14587 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) { | |
14588 | std::memmove(ptr(0,0,z,k),ptr(0,ndeltay,z,k),width*(height-ndeltay)*sizeof(T)); | |
14589 | T *ptrd = ptr(0,height-ndeltay,z,k), *ptrs = ptr(0,height-1,z,k); | |
14590 | for (int l=0; l<ndeltay-1; ++l) { std::memcpy(ptrd,ptrs,width*sizeof(T)); ptrd+=width; } | |
14591 | } | |
14592 | } else { | |
14593 | const int ndeltay = (-deltay>=dimy())?height-1:-deltay; | |
14594 | if (!ndeltay) return *this; | |
14595 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) { | |
14596 | std::memmove(ptr(0,ndeltay,z,k),ptr(0,0,z,k),width*(height-ndeltay)*sizeof(T)); | |
14597 | T *ptrd = ptr(0,1,z,k), *ptrs = ptr(0,0,z,k); | |
14598 | for (int l=0; l<ndeltay-1; ++l) { std::memcpy(ptrd,ptrs,width*sizeof(T)); ptrd+=width; } | |
14599 | } | |
14600 | } | |
14601 | break; | |
14602 | case 2: { | |
14603 | const int ml = cimg::mod(deltay,dimy()), ndeltay = (ml<=dimy()/2)?ml:(ml-dimy()); | |
14604 | if (!ndeltay) return *this; | |
14605 | T* buf = new T[width*cimg::abs(ndeltay)]; | |
14606 | if (ndeltay>0) for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) { | |
14607 | std::memcpy(buf,ptr(0,0,z,k),width*ndeltay*sizeof(T)); | |
14608 | std::memmove(ptr(0,0,z,k),ptr(0,ndeltay,z,k),width*(height-ndeltay)*sizeof(T)); | |
14609 | std::memcpy(ptr(0,height-ndeltay,z,k),buf,width*ndeltay*sizeof(T)); | |
14610 | } else for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) { | |
14611 | std::memcpy(buf,ptr(0,height+ndeltay,z,k),-ndeltay*width*sizeof(T)); | |
14612 | std::memmove(ptr(0,-ndeltay,z,k),ptr(0,0,z,k),width*(height+ndeltay)*sizeof(T)); | |
14613 | std::memcpy(ptr(0,0,z,k),buf,-ndeltay*width*sizeof(T)); | |
14614 | } | |
14615 | delete[] buf; | |
14616 | } break; | |
14617 | } | |
14618 | if (deltaz) | |
14619 | switch (border_condition) { | |
14620 | case 0: | |
14621 | if (cimg::abs(deltaz)>=dimz()) return fill(0); | |
14622 | if (deltaz>0) for (int k = 0; k<(int)((*this).dim); ++k) { | |
14623 | std::memmove(ptr(0,0,0,k),ptr(0,0,deltaz,k),width*height*(depth-deltaz)*sizeof(T)); | |
14624 | std::memset(ptr(0,0,depth-deltaz,k),0,width*height*deltaz*sizeof(T)); | |
14625 | } else for (int k = 0; k<(int)((*this).dim); ++k) { | |
14626 | std::memmove(ptr(0,0,-deltaz,k),ptr(0,0,0,k),width*height*(depth+deltaz)*sizeof(T)); | |
14627 | std::memset(ptr(0,0,0,k),0,-deltaz*width*height*sizeof(T)); | |
14628 | } | |
14629 | break; | |
14630 | case 1: | |
14631 | if (deltaz>0) { | |
14632 | const int ndeltaz = (deltaz>=dimz())?depth-1:deltaz; | |
14633 | if (!ndeltaz) return *this; | |
14634 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
14635 | std::memmove(ptr(0,0,0,k),ptr(0,0,ndeltaz,k),width*height*(depth-ndeltaz)*sizeof(T)); | |
14636 | T *ptrd = ptr(0,0,depth-ndeltaz,k), *ptrs = ptr(0,0,depth-1,k); | |
14637 | for (int l=0; l<ndeltaz-1; ++l) { std::memcpy(ptrd,ptrs,width*height*sizeof(T)); ptrd+=width*height; } | |
14638 | } | |
14639 | } else { | |
14640 | const int ndeltaz = (-deltaz>=dimz())?depth-1:-deltaz; | |
14641 | if (!ndeltaz) return *this; | |
14642 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
14643 | std::memmove(ptr(0,0,ndeltaz,k),ptr(0,0,0,k),width*height*(depth-ndeltaz)*sizeof(T)); | |
14644 | T *ptrd = ptr(0,0,1,k), *ptrs = ptr(0,0,0,k); | |
14645 | for (int l=0; l<ndeltaz-1; ++l) { std::memcpy(ptrd,ptrs,width*height*sizeof(T)); ptrd+=width*height; } | |
14646 | } | |
14647 | } | |
14648 | break; | |
14649 | case 2: { | |
14650 | const int ml = cimg::mod(deltaz,dimz()), ndeltaz = (ml<=dimz()/2)?ml:(ml-dimz()); | |
14651 | if (!ndeltaz) return *this; | |
14652 | T* buf = new T[width*height*cimg::abs(ndeltaz)]; | |
14653 | if (ndeltaz>0) for (int k = 0; k<(int)((*this).dim); ++k) { | |
14654 | std::memcpy(buf,ptr(0,0,0,k),width*height*ndeltaz*sizeof(T)); | |
14655 | std::memmove(ptr(0,0,0,k),ptr(0,0,ndeltaz,k),width*height*(depth-ndeltaz)*sizeof(T)); | |
14656 | std::memcpy(ptr(0,0,depth-ndeltaz,k),buf,width*height*ndeltaz*sizeof(T)); | |
14657 | } else for (int k = 0; k<(int)((*this).dim); ++k) { | |
14658 | std::memcpy(buf,ptr(0,0,depth+ndeltaz,k),-ndeltaz*width*height*sizeof(T)); | |
14659 | std::memmove(ptr(0,0,-ndeltaz,k),ptr(0,0,0,k),width*height*(depth+ndeltaz)*sizeof(T)); | |
14660 | std::memcpy(ptr(0,0,0,k),buf,-ndeltaz*width*height*sizeof(T)); | |
14661 | } | |
14662 | delete[] buf; | |
14663 | } break; | |
14664 | } | |
14665 | if (deltav) | |
14666 | switch (border_condition) { | |
14667 | case 0: | |
14668 | if (cimg::abs(deltav)>=dimv()) return fill(0); | |
14669 | if (deltav>0) { | |
14670 | std::memmove(data,ptr(0,0,0,deltav),width*height*depth*(dim-deltav)*sizeof(T)); | |
14671 | std::memset(ptr(0,0,0,dim-deltav),0,width*height*depth*deltav*sizeof(T)); | |
14672 | } else for (int k = 0; k<(int)((*this).dim); ++k) { | |
14673 | std::memmove(ptr(0,0,0,-deltav),data,width*height*depth*(dim+deltav)*sizeof(T)); | |
14674 | std::memset(data,0,-deltav*width*height*depth*sizeof(T)); | |
14675 | } | |
14676 | break; | |
14677 | case 1: | |
14678 | if (deltav>0) { | |
14679 | const int ndeltav = (deltav>=dimv())?dim-1:deltav; | |
14680 | if (!ndeltav) return *this; | |
14681 | std::memmove(data,ptr(0,0,0,ndeltav),width*height*depth*(dim-ndeltav)*sizeof(T)); | |
14682 | T *ptrd = ptr(0,0,0,dim-ndeltav), *ptrs = ptr(0,0,0,dim-1); | |
14683 | for (int l=0; l<ndeltav-1; ++l) { std::memcpy(ptrd,ptrs,width*height*depth*sizeof(T)); ptrd+=width*height*depth; } | |
14684 | } else { | |
14685 | const int ndeltav = (-deltav>=dimv())?dim-1:-deltav; | |
14686 | if (!ndeltav) return *this; | |
14687 | std::memmove(ptr(0,0,0,ndeltav),data,width*height*depth*(dim-ndeltav)*sizeof(T)); | |
14688 | T *ptrd = ptr(0,0,0,1); | |
14689 | for (int l=0; l<ndeltav-1; ++l) { std::memcpy(ptrd,data,width*height*depth*sizeof(T)); ptrd+=width*height*depth; } | |
14690 | } | |
14691 | break; | |
14692 | case 2: { | |
14693 | const int ml = cimg::mod(deltav,dimv()), ndeltav = (ml<=dimv()/2)?ml:(ml-dimv()); | |
14694 | if (!ndeltav) return *this; | |
14695 | T* buf = new T[width*height*depth*cimg::abs(ndeltav)]; | |
14696 | if (ndeltav>0) { | |
14697 | std::memcpy(buf,data,width*height*depth*ndeltav*sizeof(T)); | |
14698 | std::memmove(data,ptr(0,0,0,ndeltav),width*height*depth*(dim-ndeltav)*sizeof(T)); | |
14699 | std::memcpy(ptr(0,0,0,dim-ndeltav),buf,width*height*depth*ndeltav*sizeof(T)); | |
14700 | } else { | |
14701 | std::memcpy(buf,ptr(0,0,0,dim+ndeltav),-ndeltav*width*height*depth*sizeof(T)); | |
14702 | std::memmove(ptr(0,0,0,-ndeltav),data,width*height*depth*(dim+ndeltav)*sizeof(T)); | |
14703 | std::memcpy(data,buf,-ndeltav*width*height*depth*sizeof(T)); | |
14704 | } | |
14705 | delete[] buf; | |
14706 | } break; | |
14707 | } | |
14708 | } | |
14709 | return *this; | |
14710 | } | |
14711 | CImg<T> get_crop(const int x0, const int y0, const int z0, const int v0, | |
14712 | const int x1, const int y1, const int z1, const int v1, | |
14713 | const bool border_condition=false) const { | |
14714 | if (is_empty()) return *this; | |
14715 | const int | |
14716 | nx0 = x0<x1?x0:x1, nx1 = x0^x1^nx0, | |
14717 | ny0 = y0<y1?y0:y1, ny1 = y0^y1^ny0, | |
14718 | nz0 = z0<z1?z0:z1, nz1 = z0^z1^nz0, | |
14719 | nv0 = v0<v1?v0:v1, nv1 = v0^v1^nv0; | |
14720 | CImg<T> dest(1U+nx1-nx0,1U+ny1-ny0,1U+nz1-nz0,1U+nv1-nv0); | |
14721 | if (nx0<0 || nx1>=dimx() || ny0<0 || ny1>=dimy() || nz0<0 || nz1>=dimz() || nv0<0 || nv1>=dimv()) { | |
14722 | if (border_condition) for (int v = 0; v<(int)((dest).dim); ++v) for (int z = 0; z<(int)((dest).depth); ++z) for (int y = 0; y<(int)((dest).height); ++y) for (int x = 0; x<(int)((dest).width); ++x) dest(x,y,z,v) = pix4d(nx0+x,ny0+y,nz0+z,nv0+v); | |
14723 | else dest.fill(0).draw_image(*this,-nx0,-ny0,-nz0,-nv0); | |
14724 | } else dest.draw_image(*this,-nx0,-ny0,-nz0,-nv0); | |
14725 | return dest; | |
14726 | } | |
14727 | CImg<T>& crop(const int x0, const int y0, const int z0, const int v0, | |
14728 | const int x1, const int y1, const int z1, const int v1, | |
14729 | const bool border_condition=false) { | |
14730 | return get_crop(x0,y0,z0,v0,x1,y1,z1,v1,border_condition).transfer_to(*this); | |
14731 | } | |
14732 | CImg<T> get_crop(const int x0, const int y0, const int z0, | |
14733 | const int x1, const int y1, const int z1, | |
14734 | const bool border_condition=false) const { | |
14735 | return get_crop(x0,y0,z0,0,x1,y1,z1,dim-1,border_condition); | |
14736 | } | |
14737 | CImg<T>& crop(const int x0, const int y0, const int z0, | |
14738 | const int x1, const int y1, const int z1, | |
14739 | const bool border_condition=false) { | |
14740 | return crop(x0,y0,z0,0,x1,y1,z1,dim-1,border_condition); | |
14741 | } | |
14742 | CImg<T> get_crop(const int x0, const int y0, | |
14743 | const int x1, const int y1, | |
14744 | const bool border_condition=false) const { | |
14745 | return get_crop(x0,y0,0,0,x1,y1,depth-1,dim-1,border_condition); | |
14746 | } | |
14747 | CImg<T>& crop(const int x0, const int y0, | |
14748 | const int x1, const int y1, | |
14749 | const bool border_condition=false) { | |
14750 | return crop(x0,y0,0,0,x1,y1,depth-1,dim-1,border_condition); | |
14751 | } | |
14752 | CImg<T> get_crop(const int x0, const int x1, const bool border_condition=false) const { | |
14753 | return get_crop(x0,0,0,0,x1,height-1,depth-1,dim-1,border_condition); | |
14754 | } | |
14755 | CImg<T>& crop(const int x0, const int x1, const bool border_condition=false) { | |
14756 | return crop(x0,0,0,0,x1,height-1,depth-1,dim-1,border_condition); | |
14757 | } | |
14758 | CImg<T> get_columns(const unsigned int x0, const unsigned int x1) const { | |
14759 | return get_crop((int)x0,0,0,0,(int)x1,dimy()-1,dimz()-1,dimv()-1); | |
14760 | } | |
14761 | CImg<T>& columns(const unsigned int x0, const unsigned int x1) { | |
14762 | return get_columns(x0,x1).transfer_to(*this); | |
14763 | } | |
14764 | CImg<T> get_column(const unsigned int x0) const { | |
14765 | return get_columns(x0,x0); | |
14766 | } | |
14767 | CImg<T>& column(const unsigned int x0) { | |
14768 | return columns(x0,x0); | |
14769 | } | |
14770 | CImg<T> get_lines(const unsigned int y0, const unsigned int y1) const { | |
14771 | return get_crop(0,(int)y0,0,0,dimx()-1,(int)y1,dimz()-1,dimv()-1); | |
14772 | } | |
14773 | CImg<T>& lines(const unsigned int y0, const unsigned int y1) { | |
14774 | return get_lines(y0,y1).transfer_to(*this); | |
14775 | } | |
14776 | CImg<T> get_line(const unsigned int y0) const { | |
14777 | return get_lines(y0,y0); | |
14778 | } | |
14779 | CImg<T>& line(const unsigned int y0) { | |
14780 | return lines(y0,y0); | |
14781 | } | |
14782 | CImg<T> get_slices(const unsigned int z0, const unsigned int z1) const { | |
14783 | return get_crop(0,0,(int)z0,0,dimx()-1,dimy()-1,(int)z1,dimv()-1); | |
14784 | } | |
14785 | CImg<T>& slices(const unsigned int z0, const unsigned int z1) { | |
14786 | return get_slices(z0,z1).transfer_to(*this); | |
14787 | } | |
14788 | CImg<T> get_slice(const unsigned int z0) const { | |
14789 | return get_slices(z0,z0); | |
14790 | } | |
14791 | CImg<T>& slice(const unsigned int z0) { | |
14792 | return slices(z0,z0); | |
14793 | } | |
14794 | CImg<T> get_channels(const unsigned int v0, const unsigned int v1) const { | |
14795 | return get_crop(0,0,0,(int)v0,dimx()-1,dimy()-1,dimz()-1,(int)v1); | |
14796 | } | |
14797 | CImg<T>& channels(const unsigned int v0, const unsigned int v1) { | |
14798 | return get_channels(v0,v1).transfer_to(*this); | |
14799 | } | |
14800 | CImg<T> get_channel(const unsigned int v0) const { | |
14801 | return get_channels(v0,v0); | |
14802 | } | |
14803 | CImg<T>& channel(const unsigned int v0) { | |
14804 | return channels(v0,v0); | |
14805 | } | |
14806 | CImg<T> get_shared_points(const unsigned int x0, const unsigned int x1, | |
14807 | const unsigned int y0=0, const unsigned int z0=0, const unsigned int v0=0) { | |
14808 | const unsigned long beg = offset(x0,y0,z0,v0), end = offset(x1,y0,z0,v0); | |
14809 | if (beg>end || beg>=size() || end>=size()) | |
14810 | throw CImgArgumentException("CImg<%s>::get_shared_points() : Cannot return a shared-memory subset (%u->%u,%u,%u,%u) from " | |
14811 | "a (%u,%u,%u,%u) image.",pixel_type(),x0,x1,y0,z0,v0,width,height,depth,dim); | |
14812 | return CImg<T>(data+beg,x1-x0+1,1,1,1,true); | |
14813 | } | |
14814 | const CImg<T> get_shared_points(const unsigned int x0, const unsigned int x1, | |
14815 | const unsigned int y0=0, const unsigned int z0=0, const unsigned int v0=0) const { | |
14816 | const unsigned long beg = offset(x0,y0,z0,v0), end = offset(x1,y0,z0,v0); | |
14817 | if (beg>end || beg>=size() || end>=size()) | |
14818 | throw CImgArgumentException("CImg<%s>::get_shared_points() : Cannot return a shared-memory subset (%u->%u,%u,%u,%u) from " | |
14819 | "a (%u,%u,%u,%u) image.",pixel_type(),x0,x1,y0,z0,v0,width,height,depth,dim); | |
14820 | return CImg<T>(data+beg,x1-x0+1,1,1,1,true); | |
14821 | } | |
14822 | CImg<T> get_shared_lines(const unsigned int y0, const unsigned int y1, | |
14823 | const unsigned int z0=0, const unsigned int v0=0) { | |
14824 | const unsigned long beg = offset(0,y0,z0,v0), end = offset(0,y1,z0,v0); | |
14825 | if (beg>end || beg>=size() || end>=size()) | |
14826 | throw CImgArgumentException("CImg<%s>::get_shared_lines() : Cannot return a shared-memory subset (0->%u,%u->%u,%u,%u) from " | |
14827 | "a (%u,%u,%u,%u) image.",pixel_type(),width-1,y0,y1,z0,v0,width,height,depth,dim); | |
14828 | return CImg<T>(data+beg,width,y1-y0+1,1,1,true); | |
14829 | } | |
14830 | const CImg<T> get_shared_lines(const unsigned int y0, const unsigned int y1, | |
14831 | const unsigned int z0=0, const unsigned int v0=0) const { | |
14832 | const unsigned long beg = offset(0,y0,z0,v0), end = offset(0,y1,z0,v0); | |
14833 | if (beg>end || beg>=size() || end>=size()) | |
14834 | throw CImgArgumentException("CImg<%s>::get_shared_lines() : Cannot return a shared-memory subset (0->%u,%u->%u,%u,%u) from " | |
14835 | "a (%u,%u,%u,%u) image.",pixel_type(),width-1,y0,y1,z0,v0,width,height,depth,dim); | |
14836 | return CImg<T>(data+beg,width,y1-y0+1,1,1,true); | |
14837 | } | |
14838 | CImg<T> get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0) { | |
14839 | return get_shared_lines(y0,y0,z0,v0); | |
14840 | } | |
14841 | const CImg<T> get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0) const { | |
14842 | return get_shared_lines(y0,y0,z0,v0); | |
14843 | } | |
14844 | CImg<T> get_shared_planes(const unsigned int z0, const unsigned int z1, const unsigned int v0=0) { | |
14845 | const unsigned long beg = offset(0,0,z0,v0), end = offset(0,0,z1,v0); | |
14846 | if (beg>end || beg>=size() || end>=size()) | |
14847 | throw CImgArgumentException("CImg<%s>::get_shared_planes() : Cannot return a shared-memory subset (0->%u,0->%u,%u->%u,%u) from " | |
14848 | "a (%u,%u,%u,%u) image.",pixel_type(),width-1,height-1,z0,z1,v0,width,height,depth,dim); | |
14849 | return CImg<T>(data+beg,width,height,z1-z0+1,1,true); | |
14850 | } | |
14851 | const CImg<T> get_shared_planes(const unsigned int z0, const unsigned int z1, const unsigned int v0=0) const { | |
14852 | const unsigned long beg = offset(0,0,z0,v0), end = offset(0,0,z1,v0); | |
14853 | if (beg>end || beg>=size() || end>=size()) | |
14854 | throw CImgArgumentException("CImg<%s>::get_shared_planes() : Cannot return a shared-memory subset (0->%u,0->%u,%u->%u,%u) from " | |
14855 | "a (%u,%u,%u,%u) image.",pixel_type(),width-1,height-1,z0,z1,v0,width,height,depth,dim); | |
14856 | return CImg<T>(data+beg,width,height,z1-z0+1,1,true); | |
14857 | } | |
14858 | CImg<T> get_shared_plane(const unsigned int z0, const unsigned int v0=0) { | |
14859 | return get_shared_planes(z0,z0,v0); | |
14860 | } | |
14861 | const CImg<T> get_shared_plane(const unsigned int z0, const unsigned int v0=0) const { | |
14862 | return get_shared_planes(z0,z0,v0); | |
14863 | } | |
14864 | CImg<T> get_shared_channels(const unsigned int v0, const unsigned int v1) { | |
14865 | const unsigned long beg = offset(0,0,0,v0), end = offset(0,0,0,v1); | |
14866 | if (beg>end || beg>=size() || end>=size()) | |
14867 | throw CImgArgumentException("CImg<%s>::get_shared_channels() : Cannot return a shared-memory subset (0->%u,0->%u,0->%u,%u->%u) from " | |
14868 | "a (%u,%u,%u,%u) image.",pixel_type(),width-1,height-1,depth-1,v0,v1,width,height,depth,dim); | |
14869 | return CImg<T>(data+beg,width,height,depth,v1-v0+1,true); | |
14870 | } | |
14871 | const CImg<T> get_shared_channels(const unsigned int v0, const unsigned int v1) const { | |
14872 | const unsigned long beg = offset(0,0,0,v0), end = offset(0,0,0,v1); | |
14873 | if (beg>end || beg>=size() || end>=size()) | |
14874 | throw CImgArgumentException("CImg<%s>::get_shared_channels() : Cannot return a shared-memory subset (0->%u,0->%u,0->%u,%u->%u) from " | |
14875 | "a (%u,%u,%u,%u) image.",pixel_type(),width-1,height-1,depth-1,v0,v1,width,height,depth,dim); | |
14876 | return CImg<T>(data+beg,width,height,depth,v1-v0+1,true); | |
14877 | } | |
14878 | CImg<T> get_shared_channel(const unsigned int v0) { | |
14879 | return get_shared_channels(v0,v0); | |
14880 | } | |
14881 | const CImg<T> get_shared_channel(const unsigned int v0) const { | |
14882 | return get_shared_channels(v0,v0); | |
14883 | } | |
14884 | CImg<T> get_shared() { | |
14885 | return CImg<T>(data,width,height,depth,dim,true); | |
14886 | } | |
14887 | const CImg<T> get_shared() const { | |
14888 | return CImg<T>(data,width,height,depth,dim,true); | |
14889 | } | |
14890 | CImg<T> get_projections2d(const unsigned int x0, const unsigned int y0, const unsigned int z0, | |
14891 | const int dx=-100, const int dy=-100, const int dz=-100) const { | |
14892 | if (is_empty()) return CImg<T>(); | |
14893 | const unsigned int | |
14894 | nx0 = (x0>=width)?width-1:x0, | |
14895 | ny0 = (y0>=height)?height-1:y0, | |
14896 | nz0 = (z0>=depth)?depth-1:z0; | |
14897 | CImg<T> | |
14898 | imgxy(width,height,1,dim), | |
14899 | imgzy(depth,height,1,dim), | |
14900 | imgxz(width,depth,1,dim); | |
14901 | { for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) imgxy(x,y,k) = (*this)(x,y,nz0,k); } | |
14902 | { for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) imgzy(z,y,k) = (*this)(nx0,y,z,k); } | |
14903 | { for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int x = 0; x<(int)((*this).width); ++x) imgxz(x,z,k) = (*this)(x,ny0,z,k); } | |
14904 | imgxy.resize(dx,dy,1,dim,1); | |
14905 | imgzy.resize(dz,dy,1,dim,1); | |
14906 | imgxz.resize(dx,dz,1,dim,1); | |
14907 | return CImg<T>(imgxy.width+imgzy.width,imgxy.height+imgxz.height,1,dim,0). | |
14908 | draw_image(imgxy,0,0). | |
14909 | draw_image(imgzy,imgxy.width,0). | |
14910 | draw_image(imgxz,0,imgxy.height); | |
14911 | } | |
14912 | CImg<T>& projections2d(const unsigned int x0, const unsigned int y0, const unsigned int z0, | |
14913 | const int dx=-100, const int dy=-100, const int dz=-100) { | |
14914 | return get_projections2d(x0,y0,z0,dx,dy,dz).transfer_to(*this); | |
14915 | } | |
14916 | CImg<typename cimg::last<T,float>::type> get_histogram(const unsigned int nblevels=256, const T val_min=(T)0, const T val_max=(T)0) const { | |
14917 | typedef typename cimg::last<T,float>::type ftype; | |
14918 | if (is_empty()) return CImg<ftype>(); | |
14919 | if (!nblevels) | |
14920 | throw CImgArgumentException("CImg<%s>::get_histogram() : Can't compute an histogram with 0 levels", | |
14921 | pixel_type()); | |
14922 | T vmin = val_min, vmax = val_max; | |
14923 | CImg<ftype> res(nblevels,1,1,1,0); | |
14924 | if (vmin>=vmax && vmin==0) vmin = minmax(vmax); | |
14925 | if (vmin<vmax) for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
14926 | const int pos = (int)((*ptr-vmin)*(nblevels-1)/(vmax-vmin)); | |
14927 | if (pos>=0 && pos<(int)nblevels) ++res[pos]; | |
14928 | } else res[0]+=size(); | |
14929 | return res; | |
14930 | } | |
14931 | CImg<T>& histogram(const unsigned int nblevels=256, const T val_min=(T)0, const T val_max=(T)0) { | |
14932 | return get_histogram(nblevels,val_min,val_max).transfer_to(*this); | |
14933 | } | |
14934 | CImg<T> get_equalize_histogram(const unsigned int nblevels=256, const T val_min=(T)0, const T val_max=(T)0) const { | |
14935 | return (+*this).equalize_histogram(nblevels,val_min,val_max); | |
14936 | } | |
14937 | CImg<T>& equalize_histogram(const unsigned int nblevels=256, const T val_min=(T)0, const T val_max=(T)0) { | |
14938 | if (!is_empty()) { | |
14939 | T vmin = val_min, vmax = val_max; | |
14940 | if (vmin==vmax && vmin==0) vmin = minmax(vmax); | |
14941 | if (vmin<vmax) { | |
14942 | CImg<float> hist = get_histogram(nblevels,vmin,vmax); | |
14943 | float cumul = 0; | |
14944 | for (int pos = 0; pos<(int)((hist).width); ++pos) { cumul+=hist[pos]; hist[pos]=cumul; } | |
14945 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
14946 | const int pos = (unsigned int)((*ptr-vmin)*(nblevels-1)/(vmax-vmin)); | |
14947 | if (pos>=0 && pos<(int)nblevels) *ptr = (T)(vmin + (vmax-vmin)*hist[pos]/size()); | |
14948 | } | |
14949 | } | |
14950 | } | |
14951 | return *this; | |
14952 | } | |
14953 | CImg<typename cimg::last<T,unsigned int>::type> get_label_regions() const { | |
14954 | if (depth>1) | |
14955 | throw CImgInstanceException("CImg<%s>::label_regions() : Instance image must be a 2D image"); | |
14956 | typedef typename cimg::last<T,unsigned int>::type uitype; | |
14957 | CImg<uitype> res(width,height,depth,1,0); | |
14958 | unsigned int label = 1; | |
14959 | const unsigned int wh = width*height, siz = width*height*dim; | |
14960 | const int W1 = dimx()-1, H1 = dimy()-1; | |
14961 | bool flag; | |
14962 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
14963 | bool done = false; | |
14964 | if (y) { | |
14965 | { flag = true; const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(x,y-1) + siz; for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } }; | |
14966 | if (flag) { | |
14967 | const unsigned int lab = (res(x,y) = res(x,y-1)); | |
14968 | done = true; | |
14969 | if (x && res(x-1,y)!=lab) { | |
14970 | { flag = true; const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(x-1,y) + siz; for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } }; | |
14971 | if (flag) { | |
14972 | const unsigned int lold = res(x-1,y), *const cptr = res.ptr(x,y); | |
14973 | for (unsigned int *ptr = res.ptr(); ptr<cptr; ++ptr) if (*ptr==lold) *ptr = lab; | |
14974 | } | |
14975 | } | |
14976 | } | |
14977 | } | |
14978 | if (x && !done) { { flag = true; const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(x-1,y) + siz; for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } }; if (flag) { res(x,y) = res(x-1,y); done = true; }} | |
14979 | if (!done) res(x,y) = label++; | |
14980 | } | |
14981 | for (int y=H1; y>=0; --y) for (int x=W1; x>=0; --x) { | |
14982 | bool done = false; | |
14983 | if (y<H1) { | |
14984 | { flag = true; const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(x,y+1) + siz; for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } }; | |
14985 | if (flag) { | |
14986 | const unsigned int lab = (res(x,y) = res(x,y+1)); | |
14987 | done = true; | |
14988 | if (x<W1 && res(x+1,y)!=lab) { | |
14989 | { flag = true; const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(x+1,y) + siz; for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } }; | |
14990 | if (flag) { | |
14991 | const unsigned int lold = res(x+1,y), *const cptr = res.ptr(x,y); | |
14992 | for (unsigned int *ptr = res.ptr()+res.size()-1; ptr>cptr; --ptr) if (*ptr==lold) *ptr = lab; | |
14993 | } | |
14994 | } | |
14995 | } | |
14996 | } | |
14997 | if (x<W1 && !done) { { flag = true; const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(x+1,y) + siz; for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } }; if (flag) res(x,y) = res(x+1,y); done = true; } | |
14998 | } | |
14999 | const unsigned int lab0 = res.max()+1; | |
15000 | label = lab0; | |
15001 | for (unsigned int off = 0; off<(res).size(); ++off) { | |
15002 | const unsigned int lab = res[off]; | |
15003 | if (lab<lab0) { for (unsigned int *ptr = (res).data + (res).size(); (ptr--)>(res).data; ) if (*ptr==lab) *ptr = label; ++label; } | |
15004 | } | |
15005 | return (res-=lab0); | |
15006 | } | |
15007 | CImg<T>& label_regions() { | |
15008 | return get_label_regions().transfer_to(*this); | |
15009 | } | |
15010 | CImg<typename cimg::superset<T,float>::type> get_norm_pointwise(int norm_type=2) const { | |
15011 | typedef typename cimg::superset<T,float>::type restype; | |
15012 | if (is_empty()) return CImg<restype>(); | |
15013 | CImg<restype> res(width,height,depth); | |
15014 | switch(norm_type) { | |
15015 | case -1: { | |
15016 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15017 | restype n = 0; for (int v = 0; v<(int)((*this).dim); ++v) { | |
15018 | const restype tmp = (restype)cimg::abs((*this)(x,y,z,v)); | |
15019 | if (tmp>n) n=tmp; res(x,y,z) = n; | |
15020 | } | |
15021 | } | |
15022 | } break; | |
15023 | case 1: { | |
15024 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15025 | restype n = 0; for (int v = 0; v<(int)((*this).dim); ++v) n+=cimg::abs((*this)(x,y,z,v)); res(x,y,z) = n; | |
15026 | } | |
15027 | } break; | |
15028 | default: { | |
15029 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15030 | restype n = 0; for (int v = 0; v<(int)((*this).dim); ++v) n+=(*this)(x,y,z,v)*(*this)(x,y,z,v); res(x,y,z) = (restype)std::sqrt((double)n); | |
15031 | } | |
15032 | } break; | |
15033 | } | |
15034 | return res; | |
15035 | } | |
15036 | CImg<T>& norm_pointwise(int norm_type=2) { | |
15037 | return get_norm_pointwise(norm_type).transfer_to(*this); | |
15038 | } | |
15039 | CImg<typename cimg::superset<T,float>::type> get_orientation_pointwise() const { | |
15040 | typedef typename cimg::superset<T,float>::type restype; | |
15041 | if (is_empty()) return CImg<restype>(); | |
15042 | return CImg<restype>(*this,false).orientation_pointwise(); | |
15043 | } | |
15044 | CImg<T>& orientation_pointwise() { | |
15045 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15046 | float n = 0.0f; | |
15047 | for (int v = 0; v<(int)((*this).dim); ++v) n+=(float)((*this)(x,y,z,v)*(*this)(x,y,z,v)); | |
15048 | n = (float)std::sqrt(n); | |
15049 | if (n>0) for (int v = 0; v<(int)((*this).dim); ++v) (*this)(x,y,z,v) = (T)((*this)(x,y,z,v)/n); | |
15050 | else for (int v = 0; v<(int)((*this).dim); ++v) (*this)(x,y,z,v) = 0; | |
15051 | } | |
15052 | return *this; | |
15053 | } | |
15054 | CImgList<T> get_split(const char axe='x', const unsigned int nb=0) const { | |
15055 | if (is_empty()) return CImgList<T>(); | |
15056 | CImgList<T> res; | |
15057 | switch (cimg::uncase(axe)) { | |
15058 | case 'x': { | |
15059 | if (nb>width) | |
15060 | throw CImgArgumentException("CImg<%s>::get_split() : Cannot split instance image (%u,%u,%u,%u,%p) along 'x' into %u images.", | |
15061 | pixel_type(),width,height,depth,dim,data,nb); | |
15062 | res.assign(nb?nb:width); | |
15063 | const unsigned int delta = width/res.size + ((width%res.size)?1:0); | |
15064 | unsigned int l,x; | |
15065 | for (l=0, x=0; l<res.size-1; ++l, x+=delta) res[l] = get_crop(x,0,0,0,x+delta-1,height-1,depth-1,dim-1); | |
15066 | res[res.size-1] = get_crop(x,0,0,0,width-1,height-1,depth-1,dim-1); | |
15067 | } break; | |
15068 | case 'y': { | |
15069 | if (nb>height) | |
15070 | throw CImgArgumentException("CImg<%s>::get_split() : Cannot split instance image (%u,%u,%u,%u,%p) along 'y' into %u images.", | |
15071 | pixel_type(),width,height,depth,dim,data,nb); | |
15072 | res.assign(nb?nb:height); | |
15073 | const unsigned int delta = height/res.size + ((height%res.size)?1:0); | |
15074 | unsigned int l,x; | |
15075 | for (l=0, x=0; l<res.size-1; ++l, x+=delta) res[l] = get_crop(0,x,0,0,width-1,x+delta-1,depth-1,dim-1); | |
15076 | res[res.size-1] = get_crop(0,x,0,0,width-1,height-1,depth-1,dim-1); | |
15077 | } break; | |
15078 | case 'z': { | |
15079 | if (nb>depth) | |
15080 | throw CImgArgumentException("CImg<%s>::get_split() : Cannot split instance image (%u,%u,%u,%u,%p) along 'z' into %u images.", | |
15081 | pixel_type(),width,height,depth,dim,data,nb); | |
15082 | res.assign(nb?nb:depth); | |
15083 | const unsigned int delta = depth/res.size + ((depth%res.size)?1:0); | |
15084 | unsigned int l,x; | |
15085 | for (l=0, x=0; l<res.size-1; ++l, x+=delta) res[l] = get_crop(0,0,x,0,width-1,height-1,x+delta-1,dim-1); | |
15086 | res[res.size-1] = get_crop(0,0,x,0,width-1,height-1,depth-1,dim-1); | |
15087 | } break; | |
15088 | case 'v': { | |
15089 | if (nb>dim) | |
15090 | throw CImgArgumentException("CImg<%s>::get_split() : Cannot split instance image (%u,%u,%u,%u,%p) along 'v' into %u images.", | |
15091 | pixel_type(),width,height,depth,dim,data,nb); | |
15092 | res.assign(nb?nb:dim); | |
15093 | const unsigned int delta = dim/res.size + ((dim%res.size)?1:0); | |
15094 | unsigned int l,x; | |
15095 | for (l=0, x=0; l<res.size-1; ++l, x+=delta) res[l] = get_crop(0,0,0,x,width-1,height-1,depth-1,x+delta-1); | |
15096 | res[res.size-1] = get_crop(0,0,0,x,width-1,height-1,depth-1,dim-1); | |
15097 | } break; | |
15098 | default: | |
15099 | throw CImgArgumentException("CImg<%s>::get_split() : Unknow axe '%c', must be 'x','y','z' or 'v'",pixel_type(),axe); | |
15100 | break; | |
15101 | } | |
15102 | return res; | |
15103 | } | |
15104 | CImg<T> get_append(const CImg<T>& img, const char axis='x', const char align='c') const { | |
15105 | if (!img) return *this; | |
15106 | if (is_empty()) return img; | |
15107 | CImgList<T> temp(2); | |
15108 | temp[0].width = width; temp[0].height = height; temp[0].depth = depth; | |
15109 | temp[0].dim = dim; temp[0].data = data; | |
15110 | temp[1].width = img.width; temp[1].height = img.height; temp[1].depth = img.depth; | |
15111 | temp[1].dim = img.dim; temp[1].data = img.data; | |
15112 | const CImg<T> res = temp.get_append(axis,align); | |
15113 | temp[0].width = temp[0].height = temp[0].depth = temp[0].dim = 0; temp[0].data = 0; | |
15114 | temp[1].width = temp[1].height = temp[1].depth = temp[1].dim = 0; temp[1].data = 0; | |
15115 | return res; | |
15116 | } | |
15117 | CImg<T>& append(const CImg<T>& img, const char axis='x', const char align='c') { | |
15118 | if (!img) return *this; | |
15119 | if (is_empty()) return (*this=img); | |
15120 | return get_append(img,axis,align).transfer_to(*this); | |
15121 | } | |
15122 | CImgList<typename cimg::superset<T,float>::type> get_gradientXY(const int scheme=0) const { | |
15123 | typedef typename cimg::superset<T,float>::type restype; | |
15124 | if (is_empty()) return CImgList<restype>(2); | |
15125 | CImgList<restype> res(2,width,height,depth,dim); | |
15126 | switch(scheme) { | |
15127 | case -1: { | |
15128 | restype I[9]; restype& Ipp = I[0]; restype& Icp = I[1]; restype& Inp = I[2]; restype& Ipc = I[3]; restype& Icc = I[4]; restype& Inc = I[5]; restype& Ipn = I[6]; restype& Icn = I[7]; restype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15129 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,k)), (I[3] = I[4] = (*this)(0,y,z,k)), (I[6] = I[7] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,k)), (I[5] = (*this)(_n1x,y,z,k)), (I[8] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { res[0](x,y,z,k) = Icc-Ipc; res[1](x,y,z,k) = Icc-Icp; } | |
15130 | } break; | |
15131 | case 1: { | |
15132 | restype I[4]; restype& Icc = I[0]; restype& Inc = I[1]; restype& Icn = I[2]; restype& Inn = I[3]; Icc = Inc = Icn = Inn = 0; | |
15133 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = (int)( (I[0] = (*this)(0,y,z,k)), (I[2] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[1] = (*this)(_n1x,y,z,k)), (I[3] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[2] = I[3], ++x, ++_n1x) { res[0](x,y,0,k) = Inc-Icc; res[1](x,y,z,k) = Icn-Icc; } | |
15134 | } break; | |
15135 | case 2: { | |
15136 | restype I[9]; restype& Ipp = I[0]; restype& Icp = I[1]; restype& Inp = I[2]; restype& Ipc = I[3]; restype& Icc = I[4]; restype& Inc = I[5]; restype& Ipn = I[6]; restype& Icn = I[7]; restype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15137 | const float a = 1, b = 2; | |
15138 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,k)), (I[3] = I[4] = (*this)(0,y,z,k)), (I[6] = I[7] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,k)), (I[5] = (*this)(_n1x,y,z,k)), (I[8] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
15139 | res[0](x,y,z,k) = -a*Ipp-b*Ipc-a*Ipn+a*Inp+b*Inc+a*Inn; | |
15140 | res[1](x,y,z,k) = -a*Ipp-b*Icp-a*Inp+a*Ipn+b*Icn+a*Inn; | |
15141 | } | |
15142 | } break; | |
15143 | case 3: { | |
15144 | restype I[9]; restype& Ipp = I[0]; restype& Icp = I[1]; restype& Inp = I[2]; restype& Ipc = I[3]; restype& Icc = I[4]; restype& Inc = I[5]; restype& Ipn = I[6]; restype& Icn = I[7]; restype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15145 | const float a = (float)(0.25*(2-std::sqrt(2.0))), b = (float)(0.5f*(std::sqrt(2.0)-1)); | |
15146 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,k)), (I[3] = I[4] = (*this)(0,y,z,k)), (I[6] = I[7] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,k)), (I[5] = (*this)(_n1x,y,z,k)), (I[8] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
15147 | res[0](x,y,z,k) = -a*Ipp-b*Ipc-a*Ipn+a*Inp+b*Inc+a*Inn; | |
15148 | res[1](x,y,z,k) = -a*Ipp-b*Icp-a*Inp+a*Ipn+b*Icn+a*Inn; | |
15149 | } | |
15150 | } break; | |
15151 | case 4: { | |
15152 | res[0] = get_deriche(0,1,'x'); | |
15153 | res[1] = get_deriche(0,1,'y'); | |
15154 | } break; | |
15155 | default: { | |
15156 | restype I[9]; restype& Ipp = I[0]; restype& Icp = I[1]; restype& Inp = I[2]; restype& Ipc = I[3]; restype& Icc = I[4]; restype& Inc = I[5]; restype& Ipn = I[6]; restype& Icn = I[7]; restype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15157 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,k)), (I[3] = I[4] = (*this)(0,y,z,k)), (I[6] = I[7] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,k)), (I[5] = (*this)(_n1x,y,z,k)), (I[8] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
15158 | res[0](x,y,z,k) = 0.5f*(Inc-Ipc); | |
15159 | res[1](x,y,z,k) = 0.5f*(Icn-Icp); | |
15160 | } | |
15161 | } break; | |
15162 | } | |
15163 | return res; | |
15164 | } | |
15165 | CImgList<typename cimg::superset<T,float>::type> get_gradientXYZ(const int scheme=0) const { | |
15166 | typedef typename cimg::superset<T,float>::type restype; | |
15167 | if (is_empty()) return CImgList<restype>(3); | |
15168 | CImgList<restype> res(3,width,height,depth,dim); | |
15169 | restype I[27]; restype& Ippp = I[0]; restype& Icpp = I[1]; restype& Inpp = I[2]; restype& Ipcp = I[3]; restype& Iccp = I[4]; restype& Incp = I[5]; restype& Ipnp = I[6]; restype& Icnp = I[7]; restype& Innp = I[8]; restype& Ippc = I[9]; restype& Icpc = I[10]; restype& Inpc = I[11]; restype& Ipcc = I[12]; restype& Iccc = I[13]; restype& Incc = I[14]; restype& Ipnc = I[15]; restype& Icnc = I[16]; restype& Innc = I[17]; restype& Ippn = I[18]; restype& Icpn = I[19]; restype& Inpn = I[20]; restype& Ipcn = I[21]; restype& Iccn = I[22]; restype& Incn = I[23]; restype& Ipnn = I[24]; restype& Icnn = I[25]; restype& Innn = I[26]; Ippp = Icpp = Inpp = Ipcp = Iccp = Incp = Ipnp = Icnp = Innp = Ippc = Icpc = Inpc = Ipcc = Iccc = Incc = Ipnc = Icnc = Innc = Ippn = Icpn = Inpn = Ipcn = Iccn = Incn = Ipnn = Icnn = Innn = 0; | |
15170 | switch(scheme) { | |
15171 | case -1: { | |
15172 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
15173 | res[0](x,y,z,k) = Iccc-Ipcc; | |
15174 | res[1](x,y,z,k) = Iccc-Icpc; | |
15175 | res[2](x,y,z,k) = Iccc-Iccp; | |
15176 | } | |
15177 | } break; | |
15178 | case 1: { | |
15179 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
15180 | res[0](x,y,z,k) = Incc-Iccc; | |
15181 | res[1](x,y,z,k) = Icnc-Iccc; | |
15182 | res[2](x,y,z,k) = Iccn-Iccc; | |
15183 | } | |
15184 | } break; | |
15185 | case 4: { | |
15186 | res[0] = get_deriche(0,1,'x'); | |
15187 | res[1] = get_deriche(0,1,'y'); | |
15188 | res[2] = get_deriche(0,1,'z'); | |
15189 | } break; | |
15190 | default: { | |
15191 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
15192 | res[0](x,y,z,k) = 0.5f*(Incc-Ipcc); | |
15193 | res[1](x,y,z,k) = 0.5f*(Icnc-Icpc); | |
15194 | res[2](x,y,z,k) = 0.5f*(Iccn-Iccp); | |
15195 | } | |
15196 | } break; | |
15197 | } | |
15198 | return res; | |
15199 | } | |
15200 | CImg<typename cimg::superset<T,float>::type> get_structure_tensorXY(const int scheme=1) const { | |
15201 | typedef typename cimg::superset<T,float>::type restype; | |
15202 | if (is_empty()) return CImg<restype>(); | |
15203 | CImg<restype> res(width,height,depth,3,0); | |
15204 | restype I[9]; restype& Ipp = I[0]; restype& Icp = I[1]; restype& Inp = I[2]; restype& Ipc = I[3]; restype& Icc = I[4]; restype& Inc = I[5]; restype& Ipn = I[6]; restype& Icn = I[7]; restype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15205 | switch (scheme) { | |
15206 | case 0: { | |
15207 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,0,k)), (I[3] = I[4] = (*this)(0,y,0,k)), (I[6] = I[7] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,0,k)), (I[5] = (*this)(_n1x,y,0,k)), (I[8] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
15208 | const restype | |
15209 | ix = 0.5f*(Inc-Ipc), | |
15210 | iy = 0.5f*(Icn-Icp); | |
15211 | res(x,y,z,0)+=ix*ix; | |
15212 | res(x,y,z,1)+=ix*iy; | |
15213 | res(x,y,z,2)+=iy*iy; | |
15214 | } | |
15215 | } break; | |
15216 | default: { | |
15217 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,0,k)), (I[3] = I[4] = (*this)(0,y,0,k)), (I[6] = I[7] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,0,k)), (I[5] = (*this)(_n1x,y,0,k)), (I[8] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
15218 | const restype | |
15219 | ixf = Inc-Icc, ixb = Icc-Ipc, | |
15220 | iyf = Icn-Icc, iyb = Icc-Icp; | |
15221 | res(x,y,z,0) += 0.5f*(ixf*ixf+ixb*ixb); | |
15222 | res(x,y,z,1) += 0.25f*(ixf*iyf+ixf*iyb+ixb*iyf+ixb*iyb); | |
15223 | res(x,y,z,2) += 0.5f*(iyf*iyf+iyb*iyb); | |
15224 | } | |
15225 | } break; | |
15226 | } | |
15227 | return res; | |
15228 | } | |
15229 | CImg<T>& structure_tensorXY(const int scheme=1) { | |
15230 | return get_structure_tensorXY(scheme).transfer_to(*this); | |
15231 | } | |
15232 | CImg<typename cimg::superset<T,float>::type> get_structure_tensorXYZ(const int scheme=1) const { | |
15233 | typedef typename cimg::superset<T,float>::type restype; | |
15234 | if (is_empty()) return CImg<restype>(); | |
15235 | CImg<restype> res(width,height,depth,6,0); | |
15236 | restype I[27]; restype& Ippp = I[0]; restype& Icpp = I[1]; restype& Inpp = I[2]; restype& Ipcp = I[3]; restype& Iccp = I[4]; restype& Incp = I[5]; restype& Ipnp = I[6]; restype& Icnp = I[7]; restype& Innp = I[8]; restype& Ippc = I[9]; restype& Icpc = I[10]; restype& Inpc = I[11]; restype& Ipcc = I[12]; restype& Iccc = I[13]; restype& Incc = I[14]; restype& Ipnc = I[15]; restype& Icnc = I[16]; restype& Innc = I[17]; restype& Ippn = I[18]; restype& Icpn = I[19]; restype& Inpn = I[20]; restype& Ipcn = I[21]; restype& Iccn = I[22]; restype& Incn = I[23]; restype& Ipnn = I[24]; restype& Icnn = I[25]; restype& Innn = I[26]; Ippp = Icpp = Inpp = Ipcp = Iccp = Incp = Ipnp = Icnp = Innp = Ippc = Icpc = Inpc = Ipcc = Iccc = Incc = Ipnc = Icnc = Innc = Ippn = Icpn = Inpn = Ipcn = Iccn = Incn = Ipnn = Icnn = Innn = 0; | |
15237 | switch (scheme) { | |
15238 | case 0: { | |
15239 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
15240 | const restype | |
15241 | ix = 0.5f*(Incc-Ipcc), | |
15242 | iy = 0.5f*(Icnc-Icpc), | |
15243 | iz = 0.5f*(Iccn-Iccp); | |
15244 | res(x,y,z,0)+=ix*ix; | |
15245 | res(x,y,z,1)+=ix*iy; | |
15246 | res(x,y,z,2)+=ix*iz; | |
15247 | res(x,y,z,3)+=iy*iy; | |
15248 | res(x,y,z,4)+=iy*iz; | |
15249 | res(x,y,z,5)+=iz*iz; | |
15250 | } | |
15251 | } break; | |
15252 | default: { | |
15253 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
15254 | const restype | |
15255 | ixf = Incc-Iccc, ixb = Iccc-Ipcc, | |
15256 | iyf = Icnc-Iccc, iyb = Iccc-Icpc, | |
15257 | izf = Iccn-Iccc, izb = Iccc-Iccp; | |
15258 | res(x,y,z,0) += 0.5f*(ixf*ixf + ixb*ixb); | |
15259 | res(x,y,z,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb); | |
15260 | res(x,y,z,2) += 0.25f*(ixf*izf + ixf*izb + ixb*izf + ixb*izb); | |
15261 | res(x,y,z,3) += 0.5f*(iyf*iyf + iyb*iyb); | |
15262 | res(x,y,z,4) += 0.25f*(iyf*izf + iyf*izb + iyb*izf + iyb*izb); | |
15263 | res(x,y,z,5) += 0.5f*(izf*izf + izb*izb); | |
15264 | } | |
15265 | } break; | |
15266 | } | |
15267 | return res; | |
15268 | } | |
15269 | CImg<T>& structure_tensorXYZ(const int scheme=1) { | |
15270 | return get_structure_tensorXYZ(scheme).transfer_to(*this); | |
15271 | } | |
15272 | CImgList<typename cimg::superset<T,float>::type> get_hessianXY() { | |
15273 | typedef typename cimg::superset<T,float>::type ftype; | |
15274 | if (is_empty()) return CImgList<ftype>(3); | |
15275 | CImgList<ftype> res(3,width,height,depth,dim); | |
15276 | ftype I[9]; ftype& Ipp = I[0]; ftype& Icp = I[1]; ftype& Inp = I[2]; ftype& Ipc = I[3]; ftype& Icc = I[4]; ftype& Inc = I[5]; ftype& Ipn = I[6]; ftype& Icn = I[7]; ftype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15277 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,k)), (I[3] = I[4] = (*this)(0,y,z,k)), (I[6] = I[7] = (*this)(0,_n1y,z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,k)), (I[5] = (*this)(_n1x,y,z,k)), (I[8] = (*this)(_n1x,_n1y,z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
15278 | res[0](x,y,z,k) = Ipc + Inc - 2*Icc; | |
15279 | res[1](x,y,z,k) = 0.25f*(Ipp + Inn - Ipn - Inp); | |
15280 | res[2](x,y,z,k) = Icp + Icn - 2*Icc; | |
15281 | } | |
15282 | return res; | |
15283 | } | |
15284 | CImgList<typename cimg::superset<T,float>::type> get_hessianXYZ() { | |
15285 | typedef typename cimg::superset<T,float>::type ftype; | |
15286 | if (is_empty()) return CImgList<ftype>(6); | |
15287 | CImgList<ftype> res(6,width,height,depth,dim); | |
15288 | ftype I[27]; ftype& Ippp = I[0]; ftype& Icpp = I[1]; ftype& Inpp = I[2]; ftype& Ipcp = I[3]; ftype& Iccp = I[4]; ftype& Incp = I[5]; ftype& Ipnp = I[6]; ftype& Icnp = I[7]; ftype& Innp = I[8]; ftype& Ippc = I[9]; ftype& Icpc = I[10]; ftype& Inpc = I[11]; ftype& Ipcc = I[12]; ftype& Iccc = I[13]; ftype& Incc = I[14]; ftype& Ipnc = I[15]; ftype& Icnc = I[16]; ftype& Innc = I[17]; ftype& Ippn = I[18]; ftype& Icpn = I[19]; ftype& Inpn = I[20]; ftype& Ipcn = I[21]; ftype& Iccn = I[22]; ftype& Incn = I[23]; ftype& Ipnn = I[24]; ftype& Icnn = I[25]; ftype& Innn = I[26]; Ippp = Icpp = Inpp = Ipcp = Iccp = Incp = Ipnp = Icnp = Innp = Ippc = Icpc = Inpc = Ipcc = Iccc = Incc = Ipnc = Icnc = Innc = Ippn = Icpn = Inpn = Ipcn = Iccn = Incn = Ipnn = Icnn = Innn = 0; | |
15289 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
15290 | res[0](x,y,z,k) = Ipcc + Incc - 2*Iccc; | |
15291 | res[1](x,y,z,k) = 0.25f*(Ippc + Innc - Ipnc - Inpc); | |
15292 | res[2](x,y,z,k) = 0.25f*(Ipcp + Incn - Ipcn - Incp); | |
15293 | res[3](x,y,z,k) = Icpc + Icnc - 2*Iccc; | |
15294 | res[4](x,y,z,k) = 0.25f*(Icpp + Icnn - Icpn - Icnp); | |
15295 | res[5](x,y,z,k) = Iccn + Iccp - 2*Iccc; | |
15296 | } | |
15297 | return res; | |
15298 | } | |
15299 | CImg<typename cimg::superset<T,float>::type> get_distance_function(const unsigned int nb_iter=100, const float band_size=0.0f, const float precision=0.5f) const { | |
15300 | typedef typename cimg::superset<T,float>::type ftype; | |
15301 | return CImg<ftype>(*this,false).distance_function(nb_iter,band_size,precision); | |
15302 | } | |
15303 | CImg<T>& distance_function(const unsigned int nb_iter=100, const float band_size=0.0f, const float precision=0.5f) { | |
15304 | typedef typename cimg::superset<T,float>::type ftype; | |
15305 | if (is_empty()) return *this; | |
15306 | CImg<ftype> veloc(*this); | |
15307 | for (unsigned int iter=0; iter<nb_iter; ++iter) { | |
15308 | if (depth>1) { | |
15309 | ftype I[27]; ftype& Ippp = I[0]; ftype& Icpp = I[1]; ftype& Inpp = I[2]; ftype& Ipcp = I[3]; ftype& Iccp = I[4]; ftype& Incp = I[5]; ftype& Ipnp = I[6]; ftype& Icnp = I[7]; ftype& Innp = I[8]; ftype& Ippc = I[9]; ftype& Icpc = I[10]; ftype& Inpc = I[11]; ftype& Ipcc = I[12]; ftype& Iccc = I[13]; ftype& Incc = I[14]; ftype& Ipnc = I[15]; ftype& Icnc = I[16]; ftype& Innc = I[17]; ftype& Ippn = I[18]; ftype& Icpn = I[19]; ftype& Inpn = I[20]; ftype& Ipcn = I[21]; ftype& Iccn = I[22]; ftype& Incn = I[23]; ftype& Ipnn = I[24]; ftype& Icnn = I[25]; ftype& Innn = I[26]; Ippp = Icpp = Inpp = Ipcp = Iccp = Incp = Ipnp = Icnp = Innp = Ippc = Icpc = Inpc = Ipcc = Iccc = Incc = Ipnc = Icnc = Innc = Ippn = Icpn = Inpn = Ipcn = Iccn = Incn = Ipnn = Icnn = Innn = 0; | |
15310 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) if (band_size<=0 || cimg::abs(Iccc)<band_size) { | |
15311 | const ftype | |
15312 | gx = 0.5f*(Incc-Ipcc), | |
15313 | gy = 0.5f*(Icnc-Icpc), | |
15314 | gz = 0.5f*(Iccn-Iccp), | |
15315 | sgn = -cimg::sign(Iccc), | |
15316 | ix = gx*sgn>0?Incc-Iccc:Iccc-Ipcc, | |
15317 | iy = gy*sgn>0?Icnc-Iccc:Iccc-Icpc, | |
15318 | iz = gz*sgn>0?Iccn-Iccc:Iccc-Iccp, | |
15319 | ng = 1e-5f+(ftype)std::sqrt(gx*gx+gy*gy+gz*gz), | |
15320 | ngx = gx/ng, | |
15321 | ngy = gy/ng, | |
15322 | ngz = gz/ng; | |
15323 | veloc(x,y,z,k) = sgn*(ngx*ix+ngy*iy+ngz*iz-1); | |
15324 | } | |
15325 | } else { | |
15326 | ftype I[9]; ftype& Ipp = I[0]; ftype& Icp = I[1]; ftype& Inp = I[2]; ftype& Ipc = I[3]; ftype& Icc = I[4]; ftype& Inc = I[5]; ftype& Ipn = I[6]; ftype& Icn = I[7]; ftype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
15327 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,0,k)), (I[3] = I[4] = (*this)(0,y,0,k)), (I[6] = I[7] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,0,k)), (I[5] = (*this)(_n1x,y,0,k)), (I[8] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) if (band_size<=0 || cimg::abs(Icc)<band_size) { | |
15328 | const ftype | |
15329 | gx = 0.5f*(Inc-Ipc), | |
15330 | gy = 0.5f*(Icn-Icp), | |
15331 | sgn = -cimg::sign(Icc), | |
15332 | ix = gx*sgn>0?Inc-Icc:Icc-Ipc, | |
15333 | iy = gy*sgn>0?Icn-Icc:Icc-Icp, | |
15334 | ng = 1e-5f+(ftype)std::sqrt(gx*gx+gy*gy), | |
15335 | ngx = gx/ng, | |
15336 | ngy = gy/ng; | |
15337 | veloc(x,y,k) = sgn*(ngx*ix+ngy*iy-1); | |
15338 | } | |
15339 | } | |
15340 | float m, M = (float)veloc.maxmin(m), xdt = precision/(float)cimg::max(cimg::abs(m),cimg::abs(M)); | |
15341 | *this+=(veloc*=xdt); | |
15342 | } | |
15343 | return *this; | |
15344 | } | |
15345 | template<typename tf, typename t> | |
15346 | static CImg<T> get_dijkstra(const tf& distance, const unsigned int nb_nodes, | |
15347 | const unsigned int starting_node, const unsigned int ending_node, | |
15348 | CImg<t>& previous) { | |
15349 | CImg<T> dist(1,nb_nodes,1,1,cimg::type<T>::max()); | |
15350 | dist(starting_node) = 0; | |
15351 | previous.assign(1,nb_nodes,1,1,(t)-1); | |
15352 | previous(starting_node) = (t)starting_node; | |
15353 | typedef typename cimg::last<T,unsigned int>::type uitype; | |
15354 | CImg<uitype> Q(nb_nodes); | |
15355 | for (int u = 0; u<(int)((Q).width); ++u) Q(u) = u; | |
15356 | cimg::swap(Q(starting_node),Q(0)); | |
15357 | unsigned int sizeQ = nb_nodes; | |
15358 | while (sizeQ) { | |
15359 | const unsigned int umin = Q(0); | |
15360 | if (umin==ending_node) sizeQ = 0; | |
15361 | else { | |
15362 | const T dmin = dist(umin); | |
15363 | const T infty = cimg::type<T>::max(); | |
15364 | for (unsigned int q=1; q<sizeQ; ++q) { | |
15365 | const unsigned int v = Q(q); | |
15366 | const T d = (T)distance(v,umin); | |
15367 | if (d<infty) { | |
15368 | const T alt = dmin + d; | |
15369 | if (alt<dist(v)) { | |
15370 | dist(v) = alt; | |
15371 | previous(v) = (t)umin; | |
15372 | const T distpos = dist(Q(q)); | |
15373 | for (unsigned int pos = q, par = 0; pos && distpos<dist(Q(par=(pos+1)/2-1)); pos=par) cimg::swap(Q(pos),Q(par)); | |
15374 | } | |
15375 | } | |
15376 | } | |
15377 | Q(0) = Q(--sizeQ); | |
15378 | const T distpos = dist(Q(0)); | |
15379 | for (unsigned int pos = 0, left = 0, right = 0; | |
15380 | ((right=2*(pos+1),(left=right-1))<sizeQ && distpos>dist(Q(left))) || (right<sizeQ && distpos>dist(Q(right)));) { | |
15381 | if (right<sizeQ) { | |
15382 | if (dist(Q(left))<dist(Q(right))) { cimg::swap(Q(pos),Q(left)); pos = left; } | |
15383 | else { cimg::swap(Q(pos),Q(right)); pos = right; } | |
15384 | } else { cimg::swap(Q(pos),Q(left)); pos = left; } | |
15385 | } | |
15386 | } | |
15387 | } | |
15388 | return dist; | |
15389 | } | |
15390 | template<typename tf, typename t> | |
15391 | static CImg<T> get_dijkstra(const tf& distance, const unsigned int nb_nodes, | |
15392 | const unsigned int starting_node, const unsigned int ending_node=~0U) { | |
15393 | typedef typename cimg::last<T,unsigned int>::type uitype; | |
15394 | CImg<uitype> foo; | |
15395 | return get_dijkstra(distance,nb_nodes,starting_node,ending_node,foo); | |
15396 | } | |
15397 | template<typename t> CImg<T> get_dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg<t>& previous) const { | |
15398 | if (width!=height || depth!=1 || dim!=1) | |
15399 | throw CImgInstanceException("CImg<%s>::dijkstra() : Instance image (%u,%u,%u,%u,%p) is not a graph adjacency matrix", | |
15400 | pixel_type(),width,height,depth,dim,data); | |
15401 | return CImg<T>::get_dijkstra(*this,width,starting_node,ending_node,previous); | |
15402 | } | |
15403 | template<typename t> CImg<T>& dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg<t>& previous) { | |
15404 | return get_dijkstra(starting_node,ending_node,previous).transfer_to(*this); | |
15405 | } | |
15406 | CImg<typename cimg::superset<T,float>::type> get_dijkstra(const unsigned int starting_node, const unsigned int ending_node=~0U) const { | |
15407 | typedef typename cimg::last<T,unsigned int>::type uitype; | |
15408 | CImg<uitype> foo; | |
15409 | return get_dijkstra(starting_node,ending_node,foo); | |
15410 | } | |
15411 | CImg<T>& dijkstra(const unsigned int starting_node, const unsigned int ending_node=~0U) { | |
15412 | return get_dijkstra(starting_node,ending_node).transfer_to(*this); | |
15413 | } | |
15414 | struct _marching_squares_func { | |
15415 | const CImg<T>& ref; | |
15416 | _marching_squares_func(const CImg<T>& pref):ref(pref) {} | |
15417 | float operator()(const float x, const float y) const { | |
15418 | return (float)ref((int)x,(int)y); | |
15419 | } | |
15420 | }; | |
15421 | struct _marching_cubes_func { | |
15422 | const CImg<T>& ref; | |
15423 | _marching_cubes_func(const CImg<T>& pref):ref(pref) {} | |
15424 | float operator()(const float x, const float y, const float z) const { | |
15425 | return (float)ref((int)x,(int)y,(int)z); | |
15426 | } | |
15427 | }; | |
15428 | struct _marching_squares_func_float { | |
15429 | const CImg<T>& ref; | |
15430 | _marching_squares_func_float(const CImg<T>& pref):ref(pref) {} | |
15431 | float operator()(const float x, const float y) const { | |
15432 | return (float)ref.linear_pix2d(x,y); | |
15433 | } | |
15434 | }; | |
15435 | struct _marching_cubes_func_float { | |
15436 | const CImg<T>& ref; | |
15437 | _marching_cubes_func_float(const CImg<T>& pref):ref(pref) {} | |
15438 | float operator()(const float x, const float y, const float z) const { | |
15439 | return (float)ref.linear_pix3d(x,y,z); | |
15440 | } | |
15441 | }; | |
15442 | template<typename tp, typename tf> | |
15443 | const CImg<T>& marching_squares(const float isovalue, CImgList<tp>& points, CImgList<tf>& primitives) const { | |
15444 | if (height<=1 || depth>1 || dim>1) | |
15445 | throw CImgInstanceException("CImg<%s>::marching_squares() : Instance image (%u,%u,%u,%u,%p) is not a 2D scalar image.", | |
15446 | pixel_type(),width,height,depth,dim,data); | |
15447 | const _marching_squares_func func(*this); | |
15448 | cimg::marching_squares(func,isovalue,0.0f,0.0f,dimx()-1.0f,dimy()-1.0f,1.0f,1.0f,points,primitives); | |
15449 | return *this; | |
15450 | } | |
15451 | template<typename tp, typename tf> | |
15452 | const CImg<T>& marching_squares(const float isovalue, | |
15453 | const float resx, const float resy, | |
15454 | CImgList<tp>& points, CImgList<tf>& primitives) const { | |
15455 | if (height<=1 || depth>1 || dim>1) | |
15456 | throw CImgInstanceException("CImg<%s>::marching_squares() : Instance image (%u,%u,%u,%u,%p) is not a 2D scalar image.", | |
15457 | pixel_type(),width,height,depth,dim,data); | |
15458 | const _marching_squares_func_float func(*this); | |
15459 | cimg::marching_squares(func,isovalue,0.0f,0.0f,dimx()-1.0f,dimy()-1.0f,resx,resy,points,primitives); | |
15460 | return *this; | |
15461 | } | |
15462 | template<typename tp, typename tf> | |
15463 | const CImg<T>& marching_cubes(const float isovalue, CImgList<tp>& points, CImgList<tf>& primitives, | |
15464 | const bool invert_faces = false) const { | |
15465 | if (depth<=1 || dim>1) | |
15466 | throw CImgInstanceException("CImg<%s>::marching_cubes() : Instance image (%u,%u,%u,%u,%p) is not a 3D scalar image.", | |
15467 | pixel_type(),width,height,depth,dim,data); | |
15468 | const _marching_cubes_func func(*this); | |
15469 | cimg::marching_cubes(func,isovalue,0.0f,0.0f,0.0f,dimx()-1.0f,dimy()-1.0f,dimz()-1.0f, | |
15470 | 1.0f,1.0f,1.0f,points,primitives,invert_faces); | |
15471 | return *this; | |
15472 | } | |
15473 | template<typename tp, typename tf> | |
15474 | const CImg<T>& marching_cubes(const float isovalue, | |
15475 | const float resx, const float resy, const float resz, | |
15476 | CImgList<tp>& points, CImgList<tf>& primitives, | |
15477 | const bool invert_faces = false) const { | |
15478 | if (depth<=1 || dim>1) | |
15479 | throw CImgInstanceException("CImg<%s>::marching_cubes() : Instance image (%u,%u,%u,%u,%p) is not a 3D scalar image.", | |
15480 | pixel_type(),width,height,depth,dim,data); | |
15481 | const _marching_cubes_func_float func(*this); | |
15482 | cimg::marching_cubes(func,isovalue,0.0f,0.0f,0.0f,dimx()-1.0f,dimy()-1.0f,dimz()-1.0f, | |
15483 | resx,resy,resz,points,primitives,invert_faces); | |
15484 | return *this; | |
15485 | } | |
15486 | static CImg<T> get_default_LUT8() { | |
15487 | static CImg<T> palette; | |
15488 | if (!palette) { | |
15489 | palette.assign(1,256,1,3); | |
15490 | for (unsigned int index=0, r=16; r<256; r+=32) | |
15491 | for (unsigned int g=16; g<256; g+=32) | |
15492 | for (unsigned int b=32; b<256; b+=64) { | |
15493 | palette(0,index,0) = (T)r; | |
15494 | palette(0,index,1) = (T)g; | |
15495 | palette(0,index++,2) = (T)b; | |
15496 | } | |
15497 | } | |
15498 | return palette; | |
15499 | } | |
15500 | static CImg<T> get_rainbow_LUT8() { | |
15501 | static CImg<T> palette; | |
15502 | if (!palette) { | |
15503 | typedef typename cimg::superset<T,int>::type itype; | |
15504 | CImg<itype> tmp(1,256,1,3,255); | |
15505 | tmp.get_shared_channel(0).sequence(0,359); | |
15506 | tmp.HSVtoRGB(); | |
15507 | palette = tmp; | |
15508 | } | |
15509 | return palette; | |
15510 | } | |
15511 | static CImg<T> get_cluster_LUT8() { | |
15512 | static const unsigned char pal[] = | |
15513 | { 217,62,88,75,1,237,240,12,56,160,165,116,1,1,204,2,15,248,148,185,133,141,46,246,222,116,16,5,207,226, | |
15514 | 17,114,247,1,214,53,238,0,95,55,233,235,109,0,17,54,33,0,90,30,3,0,94,27,19,0,68,212,166,130,0,15,7,119, | |
15515 | 238,2,246,198,0,3,16,10,13,2,25,28,12,6,2,99,18,141,30,4,3,140,12,4,30,233,7,10,0,136,35,160,168,184,20, | |
15516 | 233,0,1,242,83,90,56,180,44,41,0,6,19,207,5,31,214,4,35,153,180,75,21,76,16,202,218,22,17,2,136,71,74, | |
15517 | 81,251,244,148,222,17,0,234,24,0,200,16,239,15,225,102,230,186,58,230,110,12,0,7,129,249,22,241,37,219, | |
15518 | 1,3,254,210,3,212,113,131,197,162,123,252,90,96,209,60,0,17,0,180,249,12,112,165,43,27,229,77,40,195,12, | |
15519 | 87,1,210,148,47,80,5,9,1,137,2,40,57,205,244,40,8,252,98,0,40,43,206,31,187,0,180,1,69,70,227,131,108,0, | |
15520 | 223,94,228,35,248,243,4,16,0,34,24,2,9,35,73,91,12,199,51,1,249,12,103,131,20,224,2,70,32, | |
15521 | 233,1,165,3,8,154,246,233,196,5,0,6,183,227,247,195,208,36,0,0,226,160,210,198,69,153,210,1,23,8,192,2,4, | |
15522 | 137,1,0,52,2,249,241,129,0,0,234,7,238,71,7,32,15,157,157,252,158,2,250,6,13,30,11,162,0,199,21,11,27,224, | |
15523 | 4,157,20,181,111,187,218,3,0,11,158,230,196,34,223,22,248,135,254,210,157,219,0,117,239,3,255,4,227,5,247, | |
15524 | 11,4,3,188,111,11,105,195,2,0,14,1,21,219,192,0,183,191,113,241,1,12,17,248,0,48,7,19,1,254,212,0,239,246, | |
15525 | 0,23,0,250,165,194,194,17,3,253,0,24,6,0,141,167,221,24,212,2,235,243,0,0,205,1,251,133,204,28,4,6,1,10, | |
15526 | 141,21,74,12,236,254,228,19,1,0,214,1,186,13,13,6,13,16,27,209,6,216,11,207,251,59,32,9,155,23,19,235,143, | |
15527 | 116,6,213,6,75,159,23,6,0,228,4,10,245,249,1,7,44,234,4,102,174,0,19,239,103,16,15,18,8,214,22,4,47,244, | |
15528 | 255,8,0,251,173,1,212,252,250,251,252,6,0,29,29,222,233,246,5,149,0,182,180,13,151,0,203,183,0,35,149,0, | |
15529 | 235,246,254,78,9,17,203,73,11,195,0,3,5,44,0,0,237,5,106,6,130,16,214,20,168,247,168,4,207,11,5,1,232,251, | |
15530 | 129,210,116,231,217,223,214,27,45,38,4,177,186,249,7,215,172,16,214,27,249,230,236,2,34,216,217,0,175,30, | |
15531 | 243,225,244,182,20,212,2,226,21,255,20,0,2,13,62,13,191,14,76,64,20,121,4,118,0,216,1,147,0,2,210,1,215, | |
15532 | 95,210,236,225,184,46,0,248,24,11,1,9,141,250,243,9,221,233,160,11,147,2,55,8,23,12,253,9,0,54,0,231,6,3, | |
15533 | 141,8,2,246,9,180,5,11,8,227,8,43,110,242,1,130,5,97,36,10,6,219,86,133,11,108,6,1,5,244,67,19,28,0,174, | |
15534 | 154,16,127,149,252,188,196,196,228,244,9,249,0,0,0,37,170,32,250,0,73,255,23,3,224,234,38,195,198,0,255,87, | |
15535 | 33,221,174,31,3,0,189,228,6,153,14,144,14,108,197,0,9,206,245,254,3,16,253,178,248,0,95,125,8,0,3,168,21, | |
15536 | 23,168,19,50,240,244,185,0,1,144,10,168,31,82,1,13 }; | |
15537 | static const CImg<T> palette(pal,256,1,1,3,false); | |
15538 | return palette; | |
15539 | } | |
15540 | template<typename t> CImg<t> get_RGBtoLUT(const CImg<t>& palette, const bool dithering=true, const bool indexing=false) const { | |
15541 | if (is_empty()) return CImg<t>(); | |
15542 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoLUT() : Input image dimension is dim=%u, " | |
15543 | "should be a (R,G,B) image.",pixel_type(),dim); | |
15544 | if (palette.data && palette.dim!=3) | |
15545 | throw CImgArgumentException("CImg<%s>::RGBtoLUT() : Given palette dimension is dim=%u, " | |
15546 | "should be a (R,G,B) palette",pixel_type(),palette.dim); | |
15547 | CImg<t> res(width,height,depth,indexing?1:3), pal = palette.data?palette:CImg<t>::get_default_LUT8(); | |
15548 | float *line1 = new float[3*width], *line2 = new float[3*width], *pline1 = line1, *pline2 = line2; | |
15549 | for (int z = 0; z<(int)((*this).depth); ++z) { | |
15550 | float *ptr = pline2; for (int x = 0; x<(int)((*this).width); ++x) { *(ptr++) = (*this)(x,0,z,0); *(ptr++) = (*this)(x,0,z,1); *(ptr++) = (*this)(x,0,z,2); } | |
15551 | for (int y = 0; y<(int)((*this).height); ++y) { | |
15552 | cimg::swap(pline1,pline2); | |
15553 | if (y<dimy()-1) { | |
15554 | const int ny = y+1; | |
15555 | float *ptr = pline2; for (int x = 0; x<(int)((*this).width); ++x) { *(ptr++) = (*this)(x,ny,z,0); *(ptr++) = (*this)(x,ny,z,1); *(ptr++) = (*this)(x,ny,z,2); } | |
15556 | } | |
15557 | float *ptr1=pline1, *ptr2=pline2; | |
15558 | for (int x = 0; x<(int)((*this).width); ++x) { | |
15559 | float R = *(ptr1++), G = *(ptr1++), B = *(ptr1++); | |
15560 | R = R<0?0:(R>255?255:R); G = G<0?0:(G>255?255:G); B = B<0?0:(B>255?255:B); | |
15561 | int best_index = 0; | |
15562 | t Rbest = 0, Gbest = 0, Bbest = 0; | |
15563 | if (palette.data) { | |
15564 | float min = cimg::type<float>::max(); | |
15565 | for (int off = 0; off<(int)((palette).width); ++off) { | |
15566 | const t Rp = palette(off,0), Gp = palette(off,1), Bp = palette(off,2); | |
15567 | const float error = (float)((Rp-R)*(Rp-R) + (Gp-G)*(Gp-G) + (Bp-B)*(Bp-B)); | |
15568 | if (error<min) { min=error; best_index=off; Rbest=Rp; Gbest=Gp; Bbest=Bp; } | |
15569 | } | |
15570 | } else { | |
15571 | Rbest = (t)((unsigned char)R&0xe0); Gbest = (t)((unsigned char)G&0xe0); Bbest = (t)((unsigned char)B&0xc0); | |
15572 | best_index = (unsigned char)Rbest | ((unsigned char)Gbest>>3) | ((unsigned char)Bbest>>6); | |
15573 | } | |
15574 | if (indexing) res(x,y,z) = best_index; | |
15575 | else { res(x,y,z,0) = Rbest; res(x,y,z,1) = Gbest; res(x,y,z,2) = Bbest; } | |
15576 | if (dithering) { | |
15577 | const float dR = (float)(R-Rbest), dG = (float)(G-Gbest), dB = (float)(B-Bbest); | |
15578 | if (x<dimx()-1) { *(ptr1++)+= dR*7/16; *(ptr1++)+= dG*7/16; *(ptr1++)+= dB*7/16; ptr1-=3; } | |
15579 | if (y<dimy()-1) { | |
15580 | *(ptr2++)+= dR*5/16; *(ptr2++)+= dG*5/16; *ptr2+= dB*5/16; ptr2-=2; | |
15581 | if (x>0) { *(--ptr2)+= dB*3/16; *(--ptr2)+= dG*3/16; *(--ptr2)+= dR*3/16; ptr2+=3; } | |
15582 | if (x<dimx()-1) { ptr2+=3; *(ptr2++)+= dR/16; *(ptr2++)+= dG/16; *ptr2+= dB/16; ptr2-=5; } | |
15583 | } | |
15584 | } | |
15585 | ptr2+=3; | |
15586 | } | |
15587 | } | |
15588 | } | |
15589 | delete[] line1; delete[] line2; | |
15590 | return res; | |
15591 | } | |
15592 | CImg<T>& RGBtoLUT(const CImg<T>& palette, const bool dithering=true, const bool indexing=false) { | |
15593 | return get_RGBtoLUT(palette,dithering,indexing).transfer_to(*this); | |
15594 | } | |
15595 | CImg<T> get_RGBtoLUT(const bool dithering=true, const bool indexing=false) const { | |
15596 | CImg<T> foo; | |
15597 | return get_RGBtoLUT(foo,dithering,indexing); | |
15598 | } | |
15599 | CImg<T>& RGBtoLUT(const bool dithering=true, const bool indexing=false) { | |
15600 | CImg<T> foo; | |
15601 | return get_RGBtoLUT(foo,dithering,indexing).transfer_to(*this); | |
15602 | } | |
15603 | template<typename t> CImg<t> get_LUTtoRGB(const CImg<t>& palette) const { | |
15604 | if (is_empty()) return CImg<t>(); | |
15605 | if (dim!=1) throw CImgInstanceException("CImg<%s>::LUTtoRGB() : Input image dimension is dim=%u, " | |
15606 | "should be a LUT image",pixel_type(),dim); | |
15607 | if (palette.data && palette.dim!=3) | |
15608 | throw CImgArgumentException("CImg<%s>::LUTtoRGB() : Given palette dimension is dim=%u, " | |
15609 | "should be a (R,G,B) palette",pixel_type(),palette.dim); | |
15610 | CImg<t> res(width,height,depth,3); | |
15611 | CImg<t> pal = palette.data?palette:CImg<t>::get_default_LUT8(); | |
15612 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15613 | const unsigned int index = (unsigned int)(*this)(x,y,z); | |
15614 | res(x,y,z,0) = pal(index,0); | |
15615 | res(x,y,z,1) = pal(index,1); | |
15616 | res(x,y,z,2) = pal(index,2); | |
15617 | } | |
15618 | return res; | |
15619 | } | |
15620 | CImg<T>& LUTtoRGB(const CImg<T>& palette) { | |
15621 | return get_LUTtoRGB(palette).transfer_to(*this); | |
15622 | } | |
15623 | CImg<T> get_LUTtoRGB() const { | |
15624 | CImg<T> foo; | |
15625 | return get_LUTtoRGB(foo); | |
15626 | } | |
15627 | CImg<T>& LUTtoRGB() { | |
15628 | CImg<T> foo; | |
15629 | return get_LUTtoRGB(foo).transfer_to(*this); | |
15630 | } | |
15631 | CImg<typename cimg::superset<T,float>::type> get_RGBtoHSV() const { | |
15632 | typedef typename cimg::superset<T,float>::type ftype; | |
15633 | return CImg<ftype>(*this).RGBtoHSV(); | |
15634 | } | |
15635 | CImg<T>& RGBtoHSV() { | |
15636 | if (!is_empty()) { | |
15637 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoHSV() : Input image dimension is dim=%u, " | |
15638 | "should be a (R,G,B) image.",pixel_type(),dim); | |
15639 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15640 | const float | |
15641 | R = (float)((*this)(x,y,z,0)), | |
15642 | G = (float)((*this)(x,y,z,1)), | |
15643 | B = (float)((*this)(x,y,z,2)), | |
15644 | nR = (R<0?0:(R>255?255:R))/255.0f, | |
15645 | nG = (G<0?0:(G>255?255:G))/255.0f, | |
15646 | nB = (B<0?0:(B>255?255:B))/255.0f, | |
15647 | m = cimg::min(nR,nG,nB), | |
15648 | M = cimg::max(nR,nG,nB); | |
15649 | float H = 0, S = 0; | |
15650 | if (M!=m) { | |
15651 | const float | |
15652 | f = (nR==m)?(nG-nB):((nG==m)?(nB-nR):(nR-nG)), | |
15653 | i = (nR==m)?3.0f:((nG==m)?5.0f:1.0f); | |
15654 | H = (i-f/(M-m)); | |
15655 | if (H>=6.0f) H-=6.0f; | |
15656 | H*=60; | |
15657 | S = (M-m)/M; | |
15658 | } | |
15659 | (*this)(x,y,z,0) = (T)H; | |
15660 | (*this)(x,y,z,1) = (T)S; | |
15661 | (*this)(x,y,z,2) = (T)M; | |
15662 | } | |
15663 | } | |
15664 | return *this; | |
15665 | } | |
15666 | CImg<T> get_HSVtoRGB() const { | |
15667 | return (+*this).HSVtoRGB(); | |
15668 | } | |
15669 | CImg<T>& HSVtoRGB() { | |
15670 | if (!is_empty()) { | |
15671 | if (dim!=3) throw CImgInstanceException("CImg<%s>::HSVtoRGB() : Input image dimension is dim=%u, " | |
15672 | "should be a (H,S,V) image",pixel_type(),dim); | |
15673 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15674 | float | |
15675 | H = (float)((*this)(x,y,z,0)), | |
15676 | S = (float)((*this)(x,y,z,1)), | |
15677 | V = (float)((*this)(x,y,z,2)); | |
15678 | float R = 0, G = 0, B = 0; | |
15679 | if (H==0 && S==0) R = G = B = V; | |
15680 | else { | |
15681 | H/=60.0f; | |
15682 | const int i = (int)std::floor(H); | |
15683 | const float | |
15684 | f = (i&1)?(H-i):(1.0f-H+i), | |
15685 | m = V*(1.0f-S), | |
15686 | n = V*(1.0f-S*f); | |
15687 | switch(i) { | |
15688 | case 6: | |
15689 | case 0: R = V; G = n; B = m; break; | |
15690 | case 1: R = n; G = V; B = m; break; | |
15691 | case 2: R = m; G = V; B = n; break; | |
15692 | case 3: R = m; G = n; B = V; break; | |
15693 | case 4: R = n; G = m; B = V; break; | |
15694 | case 5: R = V; G = m; B = n; break; | |
15695 | } | |
15696 | } | |
15697 | R*=255; G*=255; B*=255; | |
15698 | (*this)(x,y,z,0) = (T)(R<0?0:(R>255?255:R)); | |
15699 | (*this)(x,y,z,1) = (T)(G<0?0:(G>255?255:G)); | |
15700 | (*this)(x,y,z,2) = (T)(B<0?0:(B>255?255:B)); | |
15701 | } | |
15702 | } | |
15703 | return *this; | |
15704 | } | |
15705 | CImg<typename cimg::superset<T,float>::type> get_RGBtoHSL() const { | |
15706 | typedef typename cimg::superset<T,float>::type ftype; | |
15707 | return CImg<ftype>(*this).RGBtoHSL(); | |
15708 | } | |
15709 | CImg<T>& RGBtoHSL() { | |
15710 | if (!is_empty()) { | |
15711 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoHSL() : Input image dimension is dim=%u, " | |
15712 | "should be a (R,G,B) image.",pixel_type(),dim); | |
15713 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15714 | const float | |
15715 | R = (float)((*this)(x,y,z,0)), | |
15716 | G = (float)((*this)(x,y,z,1)), | |
15717 | B = (float)((*this)(x,y,z,2)), | |
15718 | nR = (R<0?0:(R>255?255:R))/255.0f, | |
15719 | nG = (G<0?0:(G>255?255:G))/255.0f, | |
15720 | nB = (B<0?0:(B>255?255:B))/255.0f, | |
15721 | m = cimg::min(nR,nG,nB), | |
15722 | M = cimg::max(nR,nG,nB), | |
15723 | L = 0.5f*(m+M); | |
15724 | float H = 0, S = 0; | |
15725 | if (M==m) H = S = 0; | |
15726 | else { | |
15727 | const float | |
15728 | f = (nR==m)?(nG-nB):((nG==m)?(nB-nR):(nR-nG)), | |
15729 | i = (nR==m)?3.0f:((nG==m)?5.0f:1.0f); | |
15730 | H = (i-f/(M-m)); | |
15731 | if (H>=6.0f) H-=6.0f; | |
15732 | H*=60; | |
15733 | S = (L<=0.5f)?((M-m)/(M+m)):((M-m)/(2-M-m)); | |
15734 | } | |
15735 | (*this)(x,y,z,0) = (T)H; | |
15736 | (*this)(x,y,z,1) = (T)S; | |
15737 | (*this)(x,y,z,2) = (T)L; | |
15738 | } | |
15739 | } | |
15740 | return *this; | |
15741 | } | |
15742 | CImg<T> get_HSLtoRGB() const { | |
15743 | return (+*this).HSLtoRGB(); | |
15744 | } | |
15745 | CImg<T>& HSLtoRGB() { | |
15746 | if (!is_empty()) { | |
15747 | if (dim!=3) throw CImgInstanceException("CImg<%s>::HSLtoRGB() : Input image dimension is dim=%u, " | |
15748 | "should be a (H,S,V) image",pixel_type(),dim); | |
15749 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15750 | float | |
15751 | H = (float)((*this)(x,y,z,0)), | |
15752 | S = (float)((*this)(x,y,z,1)), | |
15753 | L = (float)((*this)(x,y,z,2)); | |
15754 | const float | |
15755 | q = L<0.5f?L*(1+S):(L+S-L*S), | |
15756 | p = 2*L-q, | |
15757 | h = H/360; | |
15758 | float | |
15759 | tr = h+1.0f/3, | |
15760 | tg = h, | |
15761 | tb = h-1.0f/3, | |
15762 | ntr = tr<0?tr+1:(tr>1?tr-1:tr), | |
15763 | ntg = tg<0?tg+1:(tg>1?tg-1:tg), | |
15764 | ntb = tb<0?tb+1:(tb>1?tb-1:tb), | |
15765 | R = ntr<1.0f/6?p+(q-p)*6*ntr:(ntr<0.5f?q:(ntr<2.0f/3?p+(q-p)*6*(2.0f/3-ntr):p)), | |
15766 | G = ntg<1.0f/6?p+(q-p)*6*ntg:(ntg<0.5f?q:(ntg<2.0f/3?p+(q-p)*6*(2.0f/3-ntg):p)), | |
15767 | B = ntb<1.0f/6?p+(q-p)*6*ntb:(ntb<0.5f?q:(ntb<2.0f/3?p+(q-p)*6*(2.0f/3-ntb):p)); | |
15768 | R*=255; G*=255; B*=255; | |
15769 | (*this)(x,y,z,0) = (T)(R<0?0:(R>255?255:R)); | |
15770 | (*this)(x,y,z,1) = (T)(G<0?0:(G>255?255:G)); | |
15771 | (*this)(x,y,z,2) = (T)(B<0?0:(B>255?255:B)); | |
15772 | } | |
15773 | } | |
15774 | return *this; | |
15775 | } | |
15776 | CImg<typename cimg::superset<T,float>::type> get_RGBtoHSI() const { | |
15777 | typedef typename cimg::superset<T,float>::type ftype; | |
15778 | return CImg<ftype>(*this).RGBtoHSI(); | |
15779 | } | |
15780 | CImg<T>& RGBtoHSI() { | |
15781 | if (!is_empty()) { | |
15782 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoHSI() : Input image dimension is dim=%u, " | |
15783 | "should be a (R,G,B) image.",pixel_type(),dim); | |
15784 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15785 | const float | |
15786 | R = (float)((*this)(x,y,z,0)), | |
15787 | G = (float)((*this)(x,y,z,1)), | |
15788 | B = (float)((*this)(x,y,z,2)), | |
15789 | nR = (R<0?0:(R>255?255:R))/255.0f, | |
15790 | nG = (G<0?0:(G>255?255:G))/255.0f, | |
15791 | nB = (B<0?0:(B>255?255:B))/255.0f, | |
15792 | m = cimg::min(nR,nG,nB), | |
15793 | theta = std::acos(0.5f*((nR-nG)+(nR-nB))/std::sqrt(std::pow(nR-nG,2)+(nR-nB)*(nG-nB)))*180/cimg::valuePI, | |
15794 | sum = nR + nG + nB; | |
15795 | float H = 0, S = 0, I = 0; | |
15796 | if (theta>0) H = (nB<=nG)?theta:360-theta; | |
15797 | if (sum>0) S = 1-3/sum*m; | |
15798 | I = sum/3; | |
15799 | (*this)(x,y,z,0) = (T)H; | |
15800 | (*this)(x,y,z,1) = (T)S; | |
15801 | (*this)(x,y,z,2) = (T)I; | |
15802 | } | |
15803 | } | |
15804 | return *this; | |
15805 | } | |
15806 | CImg<T> get_HSItoRGB() const { | |
15807 | return (+*this).HSItoRGB(); | |
15808 | } | |
15809 | CImg<T>& HSItoRGB() { | |
15810 | if (!is_empty()) { | |
15811 | if (dim!=3) throw CImgInstanceException("CImg<%s>::HSItoRGB() : Input image dimension is dim=%u, " | |
15812 | "should be a (H,S,I) image",pixel_type(),dim); | |
15813 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15814 | float | |
15815 | H = (float)((*this)(x,y,z,0)), | |
15816 | S = (float)((*this)(x,y,z,1)), | |
15817 | I = (float)((*this)(x,y,z,2)); | |
15818 | float R = 0, G = 0, B = 0, a = I*(1-S); | |
15819 | if (H<120) { | |
15820 | B = a; | |
15821 | R = I*(1+S*std::cos(H*cimg::valuePI/180)/std::cos((60-H)*cimg::valuePI/180)); | |
15822 | G = 3*I-(R+B); | |
15823 | } else if (H<240) { | |
15824 | H-=120; | |
15825 | R = a; | |
15826 | G = I*(1+S*std::cos(H*cimg::valuePI/180)/std::cos((60-H)*cimg::valuePI/180)); | |
15827 | B = 3*I-(R+G); | |
15828 | } else { | |
15829 | H-=240; | |
15830 | G = a; | |
15831 | B = I*(1+S*std::cos(H*cimg::valuePI/180)/std::cos((60-H)*cimg::valuePI/180)); | |
15832 | R = 3*I-(G+B); | |
15833 | } | |
15834 | R*=255; G*=255; B*=255; | |
15835 | (*this)(x,y,z,0) = (T)(R<0?0:(R>255?255:R)); | |
15836 | (*this)(x,y,z,1) = (T)(G<0?0:(G>255?255:G)); | |
15837 | (*this)(x,y,z,2) = (T)(B<0?0:(B>255?255:B)); | |
15838 | } | |
15839 | } | |
15840 | return *this; | |
15841 | } | |
15842 | CImg<T> get_RGBtoYCbCr() const { | |
15843 | return (+*this).RGBtoYCbCr(); | |
15844 | } | |
15845 | CImg<T>& RGBtoYCbCr() { | |
15846 | if (!is_empty()) { | |
15847 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoYCbCr() : Input image dimension is dim=%u, " | |
15848 | "should be a (R,G,B) image (dim=3)",pixel_type(),dim); | |
15849 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15850 | const int | |
15851 | R = (int)((*this)(x,y,z,0)), | |
15852 | G = (int)((*this)(x,y,z,1)), | |
15853 | B = (int)((*this)(x,y,z,2)); | |
15854 | const int | |
15855 | Y = ((66*R+129*G+25*B+128)>>8) + 16, | |
15856 | Cb = ((-38*R-74*G+112*B+128)>>8) + 128, | |
15857 | Cr = ((112*R-94*G-18*B+128)>>8) + 128; | |
15858 | (*this)(x,y,z,0) = (T)(Y<0?0:(Y>255?255:Y)); | |
15859 | (*this)(x,y,z,1) = (T)(Cb<0?0:(Cb>255?255:Cb)); | |
15860 | (*this)(x,y,z,2) = (T)(Cr<0?0:(Cr>255?255:Cr)); | |
15861 | } | |
15862 | } | |
15863 | return *this; | |
15864 | } | |
15865 | CImg<T> get_YCbCrtoRGB() const { | |
15866 | return (+*this).YCbCrtoRGB(); | |
15867 | } | |
15868 | CImg<T>& YCbCrtoRGB() { | |
15869 | if (!is_empty()) { | |
15870 | if (dim!=3) throw CImgInstanceException("CImg<%s>::YCbCrtoRGB() : Input image dimension is dim=%u, " | |
15871 | "should be a (Y,Cb,Cr)_8 image (dim=3)",pixel_type(),dim); | |
15872 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15873 | const int | |
15874 | Y = (int)((*this)(x, y, z, 0)-16), | |
15875 | Cb = (int)((*this)(x, y, z, 1)-128), | |
15876 | Cr = (int)((*this)(x, y, z, 2)-128); | |
15877 | const int | |
15878 | R = ((298*Y + 409*Cr + 128) >> 8 ), | |
15879 | G = ((298*Y - 100*Cb - 208*Cr + 128) >> 8 ), | |
15880 | B = ((298*Y + 516*Cb + 128) >> 8 ); | |
15881 | (*this)(x,y,z,0) = (T)(R<0?0:(R>255?255:R)); | |
15882 | (*this)(x,y,z,1) = (T)(G<0?0:(G>255?255:G)); | |
15883 | (*this)(x,y,z,2) = (T)(B<0?0:(B>255?255:B)); | |
15884 | } | |
15885 | } | |
15886 | return *this; | |
15887 | } | |
15888 | CImg<typename cimg::superset<T,float>::type> get_RGBtoYUV() const { | |
15889 | typedef typename cimg::superset<T,float>::type restype; | |
15890 | return CImg<restype>(*this,false).RGBtoYUV(); | |
15891 | } | |
15892 | CImg<T>& RGBtoYUV() { | |
15893 | if (!is_empty()) { | |
15894 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoYUV() : Input image dimension is dim=%u, " | |
15895 | "should be a (R,G,B) image (dim=3)",pixel_type(),dim); | |
15896 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15897 | const float | |
15898 | R = (*this)(x,y,z,0)/255.0f, | |
15899 | G = (*this)(x,y,z,1)/255.0f, | |
15900 | B = (*this)(x,y,z,2)/255.0f, | |
15901 | Y = (T)(0.299*R + 0.587*G + 0.114*B); | |
15902 | (*this)(x,y,z,0) = (T)Y; | |
15903 | (*this)(x,y,z,1) = (T)(0.492*(B-Y)); | |
15904 | (*this)(x,y,z,2) = (T)(0.877*(R-Y)); | |
15905 | } | |
15906 | } | |
15907 | return *this; | |
15908 | } | |
15909 | CImg<T> get_YUVtoRGB() const { | |
15910 | return (+*this).YUVtoRGB(); | |
15911 | } | |
15912 | CImg<T>& YUVtoRGB() { | |
15913 | if (!is_empty()) { | |
15914 | if (dim!=3) throw CImgInstanceException("CImg<%s>::YUVtoRGB() : Input image dimension is dim=%u, " | |
15915 | "should be a (Y,U,V) image (dim=3)",pixel_type(),dim); | |
15916 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15917 | const T Y = (*this)(x,y,z,0), U = (*this)(x,y,z,1), V = (*this)(x,y,z,2); | |
15918 | (*this)(x,y,z,0) = (T)((Y + 1.140*V)*255.0f); | |
15919 | (*this)(x,y,z,1) = (T)((Y - 0.395*U - 0.581*V)*255.0f); | |
15920 | (*this)(x,y,z,2) = (T)((Y + 2.032*U)*255.0f); | |
15921 | } | |
15922 | } | |
15923 | return *this; | |
15924 | } | |
15925 | CImg<typename cimg::superset<T,float>::type> get_RGBtoXYZ() const { | |
15926 | typedef typename cimg::superset<T,float>::type restype; | |
15927 | return CImg<restype>(*this,false).RGBtoXYZ(); | |
15928 | } | |
15929 | CImg<T>& RGBtoXYZ() { | |
15930 | if (!is_empty()) { | |
15931 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoXYZ() : Input image dimension is dim=%u, " | |
15932 | "should be a (R,G,B) image (dim=3)",pixel_type(),dim); | |
15933 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15934 | const float | |
15935 | R = (float)((*this)(x,y,z,0)/255.0f), | |
15936 | G = (float)((*this)(x,y,z,1)/255.0f), | |
15937 | B = (float)((*this)(x,y,z,2)/255.0f); | |
15938 | (*this)(x,y,z,0) = (T)(0.412453*R + 0.357580*G + 0.180423*B); | |
15939 | (*this)(x,y,z,1) = (T)(0.212671*R + 0.715160*G + 0.072169*B); | |
15940 | (*this)(x,y,z,2) = (T)(0.019334*R + 0.119193*G + 0.950227*B); | |
15941 | } | |
15942 | } | |
15943 | return *this; | |
15944 | } | |
15945 | CImg<T> get_XYZtoRGB() const { | |
15946 | return (+*this).XYZtoRGB(); | |
15947 | } | |
15948 | CImg<T>& XYZtoRGB() { | |
15949 | if (!is_empty()) { | |
15950 | if (dim!=3) throw CImgInstanceException("CImg<%s>::XYZtoRGB() : Input image dimension is dim=%u, " | |
15951 | "should be a (X,Y,Z) image (dim=3)",pixel_type(),dim); | |
15952 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15953 | const float | |
15954 | X = (float)(255.0f*(*this)(x,y,z,0)), | |
15955 | Y = (float)(255.0f*(*this)(x,y,z,1)), | |
15956 | Z = (float)(255.0f*(*this)(x,y,z,2)); | |
15957 | (*this)(x,y,z,0) = (T)(3.240479*X - 1.537150*Y - 0.498535*Z); | |
15958 | (*this)(x,y,z,1) = (T)(-0.969256*X + 1.875992*Y + 0.041556*Z); | |
15959 | (*this)(x,y,z,2) = (T)(0.055648*X - 0.204043*Y + 1.057311*Z); | |
15960 | } | |
15961 | } | |
15962 | return *this; | |
15963 | } | |
15964 | CImg<T> get_XYZtoLab() const { | |
15965 | return (+*this).XYZtoLab(); | |
15966 | } | |
15967 | CImg<T>& XYZtoLab() { | |
15968 | if (!is_empty()) { | |
15969 | if (dim!=3) throw CImgInstanceException("CImg<%s>::XYZtoLab() : Input image dimension is dim=%u, " | |
15970 | "should be a (X,Y,Z) image (dim=3)",pixel_type(),dim); | |
15971 | const double | |
15972 | Xn = 0.412453 + 0.357580 + 0.180423, | |
15973 | Yn = 0.212671 + 0.715160 + 0.072169, | |
15974 | Zn = 0.019334 + 0.119193 + 0.950227; | |
15975 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15976 | const T X = (*this)(x,y,z,0), Y = (*this)(x,y,z,1), Z = (*this)(x,y,z,2); | |
15977 | const double | |
15978 | XXn = X/Xn, YYn = Y/Yn, ZZn = Z/Zn, | |
15979 | fX = ((XXn)>=0.008856?(std::pow(XXn,1/3.0)):(7.787*(XXn)+16.0/116.0)), fY = ((YYn)>=0.008856?(std::pow(YYn,1/3.0)):(7.787*(YYn)+16.0/116.0)), fZ = ((ZZn)>=0.008856?(std::pow(ZZn,1/3.0)):(7.787*(ZZn)+16.0/116.0)); | |
15980 | (*this)(x,y,z,0) = (T)(116*fY-16); | |
15981 | (*this)(x,y,z,1) = (T)(500*(fX-fY)); | |
15982 | (*this)(x,y,z,2) = (T)(200*(fY-fZ)); | |
15983 | } | |
15984 | } | |
15985 | return *this; | |
15986 | } | |
15987 | CImg<T> get_LabtoXYZ() const { | |
15988 | return (+*this).LabtoXYZ(); | |
15989 | } | |
15990 | CImg<T>& LabtoXYZ() { | |
15991 | if (!is_empty()) { | |
15992 | if (dim!=3) throw CImgInstanceException("CImg<%s>::LabtoXYZ() : Input image dimension is dim=%u, " | |
15993 | "should be a (X,Y,Z) image (dim=3)",pixel_type(),dim); | |
15994 | const double | |
15995 | Xn = 0.412453 + 0.357580 + 0.180423, | |
15996 | Yn = 0.212671 + 0.715160 + 0.072169, | |
15997 | Zn = 0.019334 + 0.119193 + 0.950227; | |
15998 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
15999 | const T L = (*this)(x,y,z,0), a = (*this)(x,y,z,1), b = (*this)(x,y,z,2); | |
16000 | const double | |
16001 | cY = (L+16)/116.0, | |
16002 | Y = Yn*((cY)>=0.206893?((cY)*(cY)*(cY)):(((cY)-16.0/116.0)/7.787)), | |
16003 | pY = std::pow(Y/Yn,1.0/3), | |
16004 | cX = a/500+pY, | |
16005 | X = Xn*cX*cX*cX, | |
16006 | cZ = pY-b/200, | |
16007 | Z = Zn*cZ*cZ*cZ; | |
16008 | (*this)(x,y,z,0) = (T)(X); | |
16009 | (*this)(x,y,z,1) = (T)(Y); | |
16010 | (*this)(x,y,z,2) = (T)(Z); | |
16011 | } | |
16012 | } | |
16013 | return *this; | |
16014 | } | |
16015 | CImg<T> get_XYZtoxyY() const { | |
16016 | return (+*this).XYZtoxyY(); | |
16017 | } | |
16018 | CImg<T>& XYZtoxyY() { | |
16019 | if (!is_empty()) { | |
16020 | if (dim!=3) throw CImgInstanceException("CImg<%s>::XYZtoxyY() : Input image dimension is dim=%u, " | |
16021 | "should be a (X,Y,Z) image (dim=3)",pixel_type(),dim); | |
16022 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16023 | const T X = (*this)(x,y,z,0), Y = (*this)(x,y,z,1), Z = (*this)(x,y,z,2), sum = (X+Y+Z), nsum = sum>0?sum:1; | |
16024 | (*this)(x,y,z,0) = X/nsum; | |
16025 | (*this)(x,y,z,1) = Y/nsum; | |
16026 | (*this)(x,y,z,2) = Y; | |
16027 | } | |
16028 | } | |
16029 | return *this; | |
16030 | } | |
16031 | CImg<T> get_xyYtoXYZ() const { | |
16032 | return (+*this).xyYtoXYZ(); | |
16033 | } | |
16034 | CImg<T>& xyYtoXYZ() { | |
16035 | if (!is_empty()) { | |
16036 | if (dim!=3) throw CImgInstanceException("CImg<%s>::xyYtoXYZ() : Input image dimension is dim=%u, " | |
16037 | "should be a (x,y,Y) image (dim=3)",pixel_type(),dim); | |
16038 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16039 | const T px = (*this)(x,y,z,0), py = (*this)(x,y,z,1), Y = (*this)(x,y,z,2), ny = py>0?py:1; | |
16040 | (*this)(x,y,z,0) = (T)(px*Y/ny); | |
16041 | (*this)(x,y,z,1) = Y; | |
16042 | (*this)(x,y,z,2) = (T)((1-px-py)*Y/ny); | |
16043 | } | |
16044 | } | |
16045 | return *this; | |
16046 | } | |
16047 | CImg<T> get_RGBtoLab() const { | |
16048 | return (+*this).RGBtoLab(); | |
16049 | } | |
16050 | CImg<T>& RGBtoLab() { | |
16051 | return RGBtoXYZ().XYZtoLab(); | |
16052 | } | |
16053 | CImg<T> get_LabtoRGB() const { | |
16054 | return (+*this).LabtoRGB(); | |
16055 | } | |
16056 | CImg<T>& LabtoRGB() { | |
16057 | return LabtoXYZ().XYZtoRGB(); | |
16058 | } | |
16059 | CImg<T> get_RGBtoxyY() const { | |
16060 | return (+*this).RGBtoxyY(); | |
16061 | } | |
16062 | CImg<T>& RGBtoxyY() { | |
16063 | return RGBtoXYZ().XYZtoxyY(); | |
16064 | } | |
16065 | CImg<T> get_xyYtoRGB() const { | |
16066 | return (+*this).xyYtoRGB(); | |
16067 | } | |
16068 | CImg<T>& xyYtoRGB() { | |
16069 | return xyYtoXYZ().XYZtoRGB(); | |
16070 | } | |
16071 | CImg<T> get_RGBtoBayer() const { | |
16072 | if (is_empty()) return *this; | |
16073 | if (dim!=3) throw CImgInstanceException("CImg<%s>::RGBtoBayer() : Input image dimension is dim=%u, " | |
16074 | "should be a (R,G,B) image (dim=3)",pixel_type(),dim); | |
16075 | CImg<T> res(width,height,depth,1); | |
16076 | const T | |
16077 | *pR = ptr(0,0,0,0), | |
16078 | *pG = ptr(0,0,0,1), | |
16079 | *pB = ptr(0,0,0,2); | |
16080 | T *ptrd = res.data; | |
16081 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16082 | if (y%2) { | |
16083 | if (x%2) *(ptrd++) = *pB; | |
16084 | else *(ptrd++) = *pG; | |
16085 | } else { | |
16086 | if (x%2) *(ptrd++) = *pG; | |
16087 | else *(ptrd++) = *pR; | |
16088 | } | |
16089 | ++pR; ++pG; ++pB; | |
16090 | } | |
16091 | return res; | |
16092 | } | |
16093 | CImg<T>& RGBtoBayer() { | |
16094 | return get_RGBtoBayer().transfer_to(*this); | |
16095 | } | |
16096 | CImg<T> get_BayertoRGB(const unsigned int interpolation_type=3) const { | |
16097 | if (is_empty()) return *this; | |
16098 | if (dim!=1) throw CImgInstanceException("CImg<%s>::BayertoRGB() : Input image dimension is dim=%u, " | |
16099 | "should be a Bayer image (dim=1)",pixel_type(),dim); | |
16100 | CImg<T> res(width,height,depth,3); | |
16101 | T I[9]; T& Ipp = I[0]; T& Icp = I[1]; T& Inp = I[2]; T& Ipc = I[3]; T& Icc = I[4]; T& Inc = I[5]; T& Ipn = I[6]; T& Icn = I[7]; T& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
16102 | T | |
16103 | *pR = res.ptr(0,0,0,0), | |
16104 | *pG = res.ptr(0,0,0,1), | |
16105 | *pB = res.ptr(0,0,0,2); | |
16106 | switch(interpolation_type) { | |
16107 | case 3: { | |
16108 | T R[9]; T& Rpp = R[0]; T& Rcp = R[1]; T& Rnp = R[2]; T& Rpc = R[3]; T& Rcc = R[4]; T& Rnc = R[5]; T& Rpn = R[6]; T& Rcn = R[7]; T& Rnn = R[8]; Rpp = Rcp = Rnp = Rpc = Rcc = Rnc = Rpn = Rcn = Rnn = 0; | |
16109 | T G[9]; T& Gpp = G[0]; T& Gcp = G[1]; T& Gnp = G[2]; T& Gpc = G[3]; T& Gcc = G[4]; T& Gnc = G[5]; T& Gpn = G[6]; T& Gcn = G[7]; T& Gnn = G[8]; Gpp = Gcp = Gnp = Gpc = Gcc = Gnc = Gpn = Gcn = Gnn = 0; | |
16110 | T B[9]; T& Bpp = B[0]; T& Bcp = B[1]; T& Bnp = B[2]; T& Bpc = B[3]; T& Bcc = B[4]; T& Bnc = B[5]; T& Bpn = B[6]; T& Bcn = B[7]; T& Bnn = B[8]; Bpp = Bcp = Bnp = Bpc = Bcc = Bnc = Bpn = Bcn = Bnn = 0; | |
16111 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16112 | const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1; | |
16113 | I[0] = (*this)(_p1x,_p1y,z,0), I[1] = (*this)(x,_p1y,z,0), I[2] = (*this)(_n1x,_p1y,z,0), I[3] = (*this)(_p1x, y,z,0), I[4] = (*this)(x, y,z,0), I[5] = (*this)(_n1x, y,z,0), I[6] = (*this)(_p1x,_n1y,z,0), I[7] = (*this)(x,_n1y,z,0), I[8] = (*this)(_n1x,_n1y,z,0); | |
16114 | if (y%2) { | |
16115 | if (x%2) { | |
16116 | const float alpha = cimg::sqr(Inc-Ipc), beta = cimg::sqr(Icn-Icp), cx = 1/(1+alpha), cy = 1/(1+beta); | |
16117 | *pG = (T)((cx*(Inc+Ipc) + cy*(Icn+Icp))/(2*(cx+cy))); | |
16118 | } else *pG = Icc; | |
16119 | } else { | |
16120 | if (x%2) *pG = Icc; | |
16121 | else { | |
16122 | const float alpha = cimg::sqr(Inc-Ipc), beta = cimg::sqr(Icn-Icp), cx = 1/(1+alpha), cy = 1/(1+beta); | |
16123 | *pG = (T)((cx*(Inc+Ipc) + cy*(Icn+Icp))/(2*(cx+cy))); | |
16124 | } | |
16125 | } | |
16126 | ++pG; | |
16127 | } | |
16128 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16129 | const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1; | |
16130 | I[0] = (*this)(_p1x,_p1y,z,0), I[1] = (*this)(x,_p1y,z,0), I[2] = (*this)(_n1x,_p1y,z,0), I[3] = (*this)(_p1x, y,z,0), I[4] = (*this)(x, y,z,0), I[5] = (*this)(_n1x, y,z,0), I[6] = (*this)(_p1x,_n1y,z,0), I[7] = (*this)(x,_n1y,z,0), I[8] = (*this)(_n1x,_n1y,z,0); | |
16131 | G[0] = (res)(_p1x,_p1y,z,1), G[1] = (res)(x,_p1y,z,1), G[2] = (res)(_n1x,_p1y,z,1), G[3] = (res)(_p1x, y,z,1), G[4] = (res)(x, y,z,1), G[5] = (res)(_n1x, y,z,1), G[6] = (res)(_p1x,_n1y,z,1), G[7] = (res)(x,_n1y,z,1), G[8] = (res)(_n1x,_n1y,z,1); | |
16132 | if (y%2) { | |
16133 | if (x%2) *pB = Icc; | |
16134 | else { *pR = (T)((Icn+Icp)/2); *pB = (T)((Inc+Ipc)/2); } | |
16135 | } else { | |
16136 | if (x%2) { *pR = (T)((Inc+Ipc)/2); *pB = (T)((Icn+Icp)/2); } | |
16137 | else *pR = Icc; | |
16138 | } | |
16139 | ++pR; ++pB; | |
16140 | } | |
16141 | pR = res.ptr(0,0,0,0); | |
16142 | pG = res.ptr(0,0,0,1); | |
16143 | pB = res.ptr(0,0,0,2); | |
16144 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16145 | const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1; | |
16146 | R[0] = (res)(_p1x,_p1y,z,0), R[1] = (res)(x,_p1y,z,0), R[2] = (res)(_n1x,_p1y,z,0), R[3] = (res)(_p1x, y,z,0), R[4] = (res)(x, y,z,0), R[5] = (res)(_n1x, y,z,0), R[6] = (res)(_p1x,_n1y,z,0), R[7] = (res)(x,_n1y,z,0), R[8] = (res)(_n1x,_n1y,z,0); | |
16147 | G[0] = (res)(_p1x,_p1y,z,1), G[1] = (res)(x,_p1y,z,1), G[2] = (res)(_n1x,_p1y,z,1), G[3] = (res)(_p1x, y,z,1), G[4] = (res)(x, y,z,1), G[5] = (res)(_n1x, y,z,1), G[6] = (res)(_p1x,_n1y,z,1), G[7] = (res)(x,_n1y,z,1), G[8] = (res)(_n1x,_n1y,z,1); | |
16148 | B[0] = (res)(_p1x,_p1y,z,2), B[1] = (res)(x,_p1y,z,2), B[2] = (res)(_n1x,_p1y,z,2), B[3] = (res)(_p1x, y,z,2), B[4] = (res)(x, y,z,2), B[5] = (res)(_n1x, y,z,2), B[6] = (res)(_p1x,_n1y,z,2), B[7] = (res)(x,_n1y,z,2), B[8] = (res)(_n1x,_n1y,z,2); | |
16149 | if (y%2) { | |
16150 | if (x%2) { | |
16151 | const float alpha = cimg::sqr(Rnc-Rpc), beta = cimg::sqr(Rcn-Rcp), cx = 1/(1+alpha), cy = 1/(1+beta); | |
16152 | *pR = (T)((cx*(Rnc+Rpc) + cy*(Rcn+Rcp))/(2*(cx+cy))); | |
16153 | } | |
16154 | } else { | |
16155 | if (!(x%2)) { | |
16156 | const float alpha = cimg::sqr(Bnc-Bpc), beta = cimg::sqr(Bcn-Bcp), cx = 1/(1+alpha), cy = 1/(1+beta); | |
16157 | *pB = (T)((cx*(Bnc+Bpc) + cy*(Bcn+Bcp))/(2*(cx+cy))); | |
16158 | } | |
16159 | } | |
16160 | ++pR; ++pG; ++pB; | |
16161 | } | |
16162 | } break; | |
16163 | case 2: { | |
16164 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16165 | const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1; | |
16166 | I[0] = (*this)(_p1x,_p1y,z,0), I[1] = (*this)(x,_p1y,z,0), I[2] = (*this)(_n1x,_p1y,z,0), I[3] = (*this)(_p1x, y,z,0), I[4] = (*this)(x, y,z,0), I[5] = (*this)(_n1x, y,z,0), I[6] = (*this)(_p1x,_n1y,z,0), I[7] = (*this)(x,_n1y,z,0), I[8] = (*this)(_n1x,_n1y,z,0); | |
16167 | if (y%2) { | |
16168 | if (x%2) { *pR = (Ipp+Inn+Ipn+Inp)/4; *pG = (Inc+Ipc+Icn+Icp)/4; *pB = Icc; } | |
16169 | else { *pR = (Icp+Icn)/2; *pG = Icc; *pB = (Inc+Ipc)/2; } | |
16170 | } else { | |
16171 | if (x%2) { *pR = (Ipc+Inc)/2; *pG = Icc; *pB = (Icn+Icp)/2; } | |
16172 | else { *pR = Icc; *pG = (Inc+Ipc+Icn+Icp)/4; *pB = (Ipp+Inn+Ipn+Inp)/4; } | |
16173 | } | |
16174 | ++pR; ++pG; ++pB; | |
16175 | } | |
16176 | } break; | |
16177 | case 1: { | |
16178 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16179 | const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1; | |
16180 | I[0] = (*this)(_p1x,_p1y,z,0), I[1] = (*this)(x,_p1y,z,0), I[2] = (*this)(_n1x,_p1y,z,0), I[3] = (*this)(_p1x, y,z,0), I[4] = (*this)(x, y,z,0), I[5] = (*this)(_n1x, y,z,0), I[6] = (*this)(_p1x,_n1y,z,0), I[7] = (*this)(x,_n1y,z,0), I[8] = (*this)(_n1x,_n1y,z,0); | |
16181 | if (y%2) { | |
16182 | if (x%2) { *pR = cimg::min(Ipp,Inn,Ipn,Inp); *pG = cimg::min(Inc,Ipc,Icn,Icp); *pB = Icc; } | |
16183 | else { *pR = cimg::min(Icn,Icp); *pG = Icc; *pB = cimg::min(Inc,Ipc); } | |
16184 | } else { | |
16185 | if (x%2) { *pR = cimg::min(Inc,Ipc); *pG = Icc; *pB = cimg::min(Icn,Icp); } | |
16186 | else { *pR = Icc; *pG = cimg::min(Inc,Ipc,Icn,Icp); *pB = cimg::min(Ipp,Inn,Ipn,Inp); } | |
16187 | } | |
16188 | ++pR; ++pG; ++pB; | |
16189 | } | |
16190 | } break; | |
16191 | default: { | |
16192 | const T *ptrs = data; | |
16193 | res.fill(0); | |
16194 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
16195 | const T val = *(ptrs++); | |
16196 | if (y%2) { if (x%2) *pB = val; else *pG = val; } else { if (x%2) *pG = val; else *pR = val; } | |
16197 | ++pR; ++pG; ++pB; | |
16198 | } | |
16199 | } break; | |
16200 | } | |
16201 | return res; | |
16202 | } | |
16203 | CImg<T>& BayertoRGB(const unsigned int interpolation_type=3) { | |
16204 | return get_BayertoRGB(interpolation_type).transfer_to(*this); | |
16205 | } | |
16206 | template<typename tc> | |
16207 | CImg<T>& _draw_scanline(const int x0, const int x1, const int y, const tc *const color, | |
16208 | const float opacity=1.0f, const float brightness=1.0f, const bool init=false) { | |
16209 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max()); | |
16210 | static float nopacity = 0, copacity = 0; | |
16211 | static unsigned int whz = 0; | |
16212 | static const tc *col = 0; | |
16213 | if (init) { | |
16214 | nopacity = cimg::abs(opacity); | |
16215 | copacity = 1.0f - cimg::max(opacity,0.0f); | |
16216 | whz = width*height*depth; | |
16217 | } else { | |
16218 | const int nx0 = x0>0?x0:0, nx1 = x1<dimx()?x1:dimx()-1, dx = nx1 - nx0; | |
16219 | if (dx>=0) { | |
16220 | col = color; | |
16221 | const unsigned int off = whz-dx-1; | |
16222 | T *ptrd = ptr(nx0,y); | |
16223 | if (opacity>=1) { | |
16224 | if (brightness==1) { | |
16225 | if (sizeof(T)!=1) for (int k = 0; k<(int)((*this).dim); ++k) { | |
16226 | const T val = (T)*(col++); | |
16227 | for (int x=dx; x>=0; --x) *(ptrd++) = val; | |
16228 | ptrd+=off; | |
16229 | } else for (int k = 0; k<(int)((*this).dim); ++k) { | |
16230 | const T val = (T)*(col++); | |
16231 | std::memset(ptrd,(int)val,dx+1); | |
16232 | ptrd+=whz; | |
16233 | } | |
16234 | } else if (brightness<1) { | |
16235 | if (sizeof(T)!=1) for (int k = 0; k<(int)((*this).dim); ++k) { | |
16236 | const T val = (T)(*(col++)*brightness); | |
16237 | for (int x=dx; x>=0; --x) *(ptrd++) = val; | |
16238 | ptrd+=off; | |
16239 | } else for (int k = 0; k<(int)((*this).dim); ++k) { | |
16240 | const T val = (T)(*(col++)*brightness); | |
16241 | std::memset(ptrd,(int)val,dx+1); | |
16242 | ptrd+=whz; | |
16243 | } | |
16244 | } else { | |
16245 | if (sizeof(T)!=1) for (int k = 0; k<(int)((*this).dim); ++k) { | |
16246 | const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval); | |
16247 | for (int x=dx; x>=0; --x) *(ptrd++) = val; | |
16248 | ptrd+=off; | |
16249 | } else for (int k = 0; k<(int)((*this).dim); ++k) { | |
16250 | const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval); | |
16251 | std::memset(ptrd,(int)val,dx+1); | |
16252 | ptrd+=whz; | |
16253 | } | |
16254 | } | |
16255 | } else { | |
16256 | if (brightness==1) { | |
16257 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
16258 | const T val = (T)*(col++); | |
16259 | for (int x=dx; x>=0; --x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; } | |
16260 | ptrd+=off; | |
16261 | } | |
16262 | } else if (brightness<=1) { | |
16263 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
16264 | const T val = (T)(*(col++)*brightness); | |
16265 | for (int x=dx; x>=0; --x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; } | |
16266 | ptrd+=off; | |
16267 | } | |
16268 | } else { | |
16269 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
16270 | const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval); | |
16271 | for (int x=dx; x>=0; --x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; } | |
16272 | ptrd+=off; | |
16273 | } | |
16274 | } | |
16275 | } | |
16276 | } | |
16277 | } | |
16278 | return *this; | |
16279 | } | |
16280 | template<typename tc> | |
16281 | CImg<T>& _draw_scanline(const tc *const color, const float opacity=1.0f) { | |
16282 | return _draw_scanline(0,0,0,color,opacity,0,true); | |
16283 | } | |
16284 | template<typename tc> | |
16285 | CImg<T>& draw_point(const int x0, const int y0, const tc *const color, const float opacity=1.0f) { | |
16286 | return draw_point(x0,y0,0,color,opacity); | |
16287 | } | |
16288 | template<typename tc> | |
16289 | CImg<T>& draw_point(const int x0, const int y0, const CImg<tc>& color, const float opacity=1.0f) { | |
16290 | return draw_point(x0,y0,color.data,opacity); | |
16291 | } | |
16292 | template<typename tc> | |
16293 | CImg<T>& draw_point(const int x0, const int y0, const int z0, const tc *const color, const float opacity=1.0f) { | |
16294 | if (!is_empty()) { | |
16295 | if (!color) throw CImgArgumentException("CImg<%s>::draw_point() : Specified color is (null)",pixel_type()); | |
16296 | if (x0>=0 && y0>=0 && z0>=0 && x0<dimx() && y0<dimy() && z0<dimz()) { | |
16297 | const tc *col = color; | |
16298 | const unsigned int whz = width*height*depth; | |
16299 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
16300 | T *ptrd = ptr(x0,y0,z0,0); | |
16301 | if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } | |
16302 | else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } | |
16303 | } | |
16304 | } | |
16305 | return *this; | |
16306 | } | |
16307 | template<typename tc> | |
16308 | CImg<T>& draw_point(const int x0, const int y0, const int z0, const CImg<tc>& color, const float opacity=1.0f) { | |
16309 | return draw_point(x0,y0,z0,color.data,opacity); | |
16310 | } | |
16311 | template<typename t, typename tc> | |
16312 | CImg<T>& _draw_point(const t& points, const tc *const color, | |
16313 | const float opacity, const unsigned int W, const unsigned int H) { | |
16314 | if (points && W && H>1) { | |
16315 | if (H==2) for (unsigned int i=0; i<W; ++i) { | |
16316 | const int x = (int)points(i,0), y = (int)points(i,1); | |
16317 | draw_point(x,y,color,opacity); | |
16318 | } else for (unsigned int i=0; i<W; ++i) { | |
16319 | const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2); | |
16320 | draw_point(x,y,z,color,opacity); | |
16321 | } | |
16322 | } | |
16323 | return *this; | |
16324 | } | |
16325 | template<typename t, typename tc> | |
16326 | CImg<T>& draw_point(const CImgList<t>& points, const tc *const color, const float opacity=1.0f) { | |
16327 | unsigned int H = ~0U; for (unsigned int p=0; p<(points).size; ++p) H = cimg::min(H,(unsigned int)(points[p].size())); | |
16328 | return _draw_point(points,color,opacity,points.size,H); | |
16329 | } | |
16330 | template<typename t, typename tc> | |
16331 | CImg<T>& draw_point(const CImgList<t>& points, const CImg<tc>& color, const float opacity=1.0f) { | |
16332 | return draw_point(points,color.data,opacity); | |
16333 | } | |
16334 | template<typename t, typename tc> | |
16335 | CImg<T>& draw_point(const CImg<t>& points, const tc *const color, const float opacity=1.0f) { | |
16336 | return _draw_point(points,color,opacity,points.width,points.height); | |
16337 | } | |
16338 | template<typename t, typename tc> | |
16339 | CImg<T>& draw_point(const CImg<t>& points, const CImg<tc>& color, const float opacity=1.0f) { | |
16340 | return draw_point(points,color.data,opacity); | |
16341 | } | |
16342 | template<typename tc> | |
16343 | CImg<T>& draw_line(const int x0, const int y0, const int x1, const int y1, | |
16344 | const tc *const color, const float opacity=1.0f, | |
16345 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16346 | if (!is_empty()) { | |
16347 | if (!color) throw CImgArgumentException("CImg<%s>::draw_line() : Specified color is (null)",pixel_type()); | |
16348 | static unsigned int hatch = ~0U-(~0U>>1); | |
16349 | if (init_hatch) hatch = ~0U-(~0U>>1); | |
16350 | const tc* col = color; | |
16351 | const bool xdir = x0<x1, ydir = y0<y1; | |
16352 | int | |
16353 | nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1, | |
16354 | &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1, | |
16355 | &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0, | |
16356 | &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1, | |
16357 | &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0; | |
16358 | if (xright<0 || xleft>=dimx()) return *this; | |
16359 | if (xleft<0) { yleft-=xleft*(yright-yleft)/(xright-xleft); xleft = 0; } | |
16360 | if (xright>=dimx()) { yright-=(xright-dimx())*(yright-yleft)/(xright-xleft); xright = dimx()-1; } | |
16361 | if (ydown<0 || yup>=dimy()) return *this; | |
16362 | if (yup<0) { xup-=yup*(xdown-xup)/(ydown-yup); yup = 0; } | |
16363 | if (ydown>=dimy()) { xdown-=(ydown-dimy())*(xdown-xup)/(ydown-yup); ydown = dimy()-1; } | |
16364 | T *ptrd0 = ptr(nx0,ny0,0,0); | |
16365 | int dx = xright-xleft, dy = ydown-yup; | |
16366 | const bool steep = dy>dx; | |
16367 | if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy); | |
16368 | const int | |
16369 | offx = (nx0<nx1?1:-1)*(steep?width:1), | |
16370 | offy = (ny0<ny1?1:-1)*(steep?1:width), | |
16371 | wh = width*height; | |
16372 | if (opacity>=1) { | |
16373 | if (~pattern) for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16374 | T *ptrd = ptrd0; | |
16375 | if (pattern&hatch) { for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=wh; } col-=dim; } | |
16376 | hatch>>=1; if (!hatch) hatch = ~0U-(~0U>>1); | |
16377 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16378 | } else for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16379 | T *ptrd = ptrd0; | |
16380 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=wh; } col-=dim; | |
16381 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16382 | } | |
16383 | } else { | |
16384 | const float nopacity = cimg::abs(opacity), copacity=1-cimg::max(opacity,0.0f); | |
16385 | if (~pattern) for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16386 | T *ptrd = ptrd0; | |
16387 | if (pattern&hatch) { for (int k = 0; k<(int)((*this).dim); ++k) { const tc& c = *(col++); *ptrd = (T)(c*nopacity + *ptrd*copacity); ptrd+=wh; } col-=dim; } | |
16388 | hatch>>=1; if (!hatch) hatch = ~0U-(~0U>>1); | |
16389 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16390 | } else for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16391 | T *ptrd = ptrd0; | |
16392 | for (int k = 0; k<(int)((*this).dim); ++k) { const tc& c = *(col++); *ptrd = (T)(c*nopacity + *ptrd*copacity); ptrd+=wh; } col-=dim; | |
16393 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16394 | } | |
16395 | } | |
16396 | } | |
16397 | return *this; | |
16398 | } | |
16399 | template<typename tc> | |
16400 | CImg<T>& draw_line(const int x0, const int y0, const int x1, const int y1, | |
16401 | const CImg<tc>& color, const float opacity=1.0f, | |
16402 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16403 | return draw_line(x0,y0,x1,y1,color.data,opacity,pattern,init_hatch); | |
16404 | } | |
16405 | template<typename tc> | |
16406 | CImg<T>& draw_line(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, | |
16407 | const tc *const color, const float opacity=1.0f, | |
16408 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16409 | if (!is_empty()) { | |
16410 | if (!color) throw CImgArgumentException("CImg<%s>::draw_line() : Specified color is (null)",pixel_type()); | |
16411 | static unsigned int hatch = ~0U-(~0U>>1); | |
16412 | if (init_hatch) hatch = ~0U-(~0U>>1); | |
16413 | const tc *col = color; | |
16414 | int nx0 = x0, ny0 = y0, nz0 = z0, nx1 = x1, ny1 = y1, nz1 = z1; | |
16415 | if (nx0>nx1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1); | |
16416 | if (nx1<0 || nx0>=dimx()) return *this; | |
16417 | if (nx0<0) { const int D=1+nx1-nx0; ny0-=nx0*(1+ny1-ny0)/D; nz0-=nx0*(1+nz1-nz0)/D; nx0 = 0; } | |
16418 | if (nx1>=dimx()) { const int d=nx1-dimx(), D=1+nx1-nx0; ny1+=d*(1+ny0-ny1)/D; nz1+=d*(1+nz0-nz1)/D; nx1 = dimx()-1; } | |
16419 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1); | |
16420 | if (ny1<0 || ny0>=dimy()) return *this; | |
16421 | if (ny0<0) { const int D=1+ny1-ny0; nx0-=ny0*(1+nx1-nx0)/D; nz0-=ny0*(1+nz1-nz0)/D; ny0 = 0; } | |
16422 | if (ny1>=dimy()) { const int d=ny1-dimy(), D=1+ny1-ny0; nx1+=d*(1+nx0-nx1)/D; nz1+=d*(1+nz0-nz1)/D; ny1 = dimy()-1; } | |
16423 | if (nz0>nz1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1); | |
16424 | if (nz1<0 || nz0>=dimz()) return *this; | |
16425 | if (nz0<0) { const int D=1+nz1-nz0; nx0-=nz0*(1+nx1-nx0)/D; ny0-=nz0*(1+ny1-ny0)/D; nz0 = 0; } | |
16426 | if (nz1>=dimz()) { const int d=nz1-dimz(), D=1+nz1-nz0; nx1+=d*(1+nx0-nx1)/D; ny1+=d*(1+ny0-ny1)/D; nz1 = dimz()-1; } | |
16427 | const unsigned int dmax = cimg::max(cimg::abs(nx1-nx0),cimg::abs(ny1-ny0),nz1-nz0), whz = width*height*depth; | |
16428 | const float px = (nx1-nx0)/(float)dmax, py = (ny1-ny0)/(float)dmax, pz = (nz1-nz0)/(float)dmax; | |
16429 | float x = (float)nx0, y = (float)ny0, z = (float)nz0; | |
16430 | if (opacity>=1) for (unsigned int t=0; t<=dmax; ++t) { | |
16431 | if (!(~pattern) || (~pattern && pattern&hatch)) { | |
16432 | T* ptrd = ptr((unsigned int)x,(unsigned int)y,(unsigned int)z,0); | |
16433 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } | |
16434 | col-=dim; | |
16435 | } | |
16436 | x+=px; y+=py; z+=pz; if (pattern) hatch=(hatch<<1)+(hatch>>(sizeof(unsigned int)*8-1)); | |
16437 | } else { | |
16438 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
16439 | for (unsigned int t=0; t<=dmax; ++t) { | |
16440 | if (!(~pattern) || (~pattern && pattern&hatch)) { | |
16441 | T* ptrd = ptr((unsigned int)x,(unsigned int)y,(unsigned int)z,0); | |
16442 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } | |
16443 | col-=dim; | |
16444 | } | |
16445 | x+=px; y+=py; z+=pz; if (pattern) hatch=(hatch<<1)+(hatch>>(sizeof(unsigned int)*8-1)); | |
16446 | } | |
16447 | } | |
16448 | } | |
16449 | return *this; | |
16450 | } | |
16451 | template<typename tc> | |
16452 | CImg<T>& draw_line(const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, | |
16453 | const CImg<tc>& color, const float opacity=1.0f, | |
16454 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16455 | return draw_line(x0,y0,z0,x1,y1,z1,color.data,opacity,pattern,init_hatch); | |
16456 | } | |
16457 | template<typename t> | |
16458 | CImg<T>& draw_line(const int x0, const int y0, const int x1, const int y1, | |
16459 | const CImg<t>& texture, | |
16460 | const int tx0, const int ty0, const int tx1, const int ty1, | |
16461 | const float opacity=1.0f, const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16462 | if (!is_empty()) { | |
16463 | if (!texture || texture.dim<dim) | |
16464 | throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
16465 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
16466 | if (is_overlapping(texture)) return draw_line(x0,y0,x1,y1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch); | |
16467 | static unsigned int hatch = ~0U-(~0U>>1); | |
16468 | if (init_hatch) hatch = ~0U-(~0U>>1); | |
16469 | const bool xdir = x0<x1, ydir = y0<y1; | |
16470 | int | |
16471 | dtx = tx1-tx0, dty = ty1-ty0, | |
16472 | nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1, | |
16473 | tnx0 = tx0, tnx1 = tx1, tny0 = ty0, tny1 = ty1, | |
16474 | &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1, &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0, | |
16475 | &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0, | |
16476 | &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1, &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0, | |
16477 | &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0; | |
16478 | if (xright<0 || xleft>=dimx()) return *this; | |
16479 | if (xleft<0) { | |
16480 | const int D = xright-xleft; | |
16481 | yleft-=xleft*(yright-yleft)/D; | |
16482 | txleft-=xleft*(txright-txleft)/D; | |
16483 | tyleft-=xleft*(tyright-tyleft)/D; | |
16484 | xleft = 0; | |
16485 | } | |
16486 | if (xright>=dimx()) { | |
16487 | const int d = xright-dimx(), D = xright-xleft; | |
16488 | yright-=d*(yright-yleft)/D; | |
16489 | txright-=d*(txright-txleft)/D; | |
16490 | tyright-=d*(tyright-tyleft)/D; | |
16491 | xright = dimx()-1; | |
16492 | } | |
16493 | if (ydown<0 || yup>=dimy()) return *this; | |
16494 | if (yup<0) { | |
16495 | const int D = ydown-yup; | |
16496 | xup-=yup*(xdown-xup)/D; | |
16497 | txup-=yup*(txdown-txup)/D; | |
16498 | tyup-=yup*(tydown-tyup)/D; | |
16499 | yup = 0; | |
16500 | } | |
16501 | if (ydown>=dimy()) { | |
16502 | const int d = ydown-dimy(), D = ydown-yup; | |
16503 | xdown-=d*(xdown-xup)/D; | |
16504 | txdown-=d*(txdown-txup)/D; | |
16505 | tydown-=d*(tydown-tyup)/D; | |
16506 | ydown = dimy()-1; | |
16507 | } | |
16508 | T *ptrd0 = ptr(nx0,ny0,0,0); | |
16509 | int dx = xright-xleft, dy = ydown-yup; | |
16510 | const bool steep = dy>dx; | |
16511 | if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy); | |
16512 | const int | |
16513 | offx = (nx0<nx1?1:-1)*(steep?width:1), | |
16514 | offy = (ny0<ny1?1:-1)*(steep?1:width), | |
16515 | wh = width*height, | |
16516 | ndx = dx>0?dx:1; | |
16517 | if (opacity>=1) { | |
16518 | if (~pattern) for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16519 | T *ptrd = ptrd0; | |
16520 | if (pattern&hatch) { | |
16521 | const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx; | |
16522 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = texture(tx,ty,0,k); ptrd+=wh; } | |
16523 | } | |
16524 | hatch>>=1; if (!hatch) hatch = ~0U-(~0U>>1); | |
16525 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16526 | } else for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16527 | T *ptrd = ptrd0; | |
16528 | const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx; | |
16529 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = texture(tx,ty,0,k); ptrd+=wh; } | |
16530 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16531 | } | |
16532 | } else { | |
16533 | const float nopacity = cimg::abs(opacity), copacity=1-cimg::max(opacity,0.0f); | |
16534 | if (~pattern) for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16535 | T *ptrd = ptrd0; | |
16536 | if (pattern&hatch) { | |
16537 | const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx; | |
16538 | for (int k = 0; k<(int)((*this).dim); ++k) { const T c = (T)texture(tx,ty,0,k); *ptrd = (T)(c*nopacity + *ptrd*copacity); ptrd+=wh; } | |
16539 | } | |
16540 | hatch>>=1; if (!hatch) hatch = ~0U-(~0U>>1); | |
16541 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16542 | } else for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16543 | T *ptrd = ptrd0; | |
16544 | const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx; | |
16545 | for (int k = 0; k<(int)((*this).dim); ++k) { const T c = (T)texture(tx,ty,0,k); *ptrd = (T)(c*nopacity + *ptrd*copacity); ptrd+=wh; } | |
16546 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16547 | } | |
16548 | } | |
16549 | } | |
16550 | return *this; | |
16551 | } | |
16552 | template<typename t> | |
16553 | CImg<T>& draw_line(const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, | |
16554 | const CImg<t>& texture, | |
16555 | const int tx0, const int ty0, const int tx1, const int ty1, | |
16556 | const float opacity=1.0f, const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16557 | if (!is_empty() && z0>0 && z1>0) { | |
16558 | if (!texture || texture.dim<dim) | |
16559 | throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
16560 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
16561 | if (is_overlapping(texture)) return draw_line(x0,y0,z0,x1,y1,z1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch); | |
16562 | static unsigned int hatch = ~0U-(~0U>>1); | |
16563 | if (init_hatch) hatch = ~0U-(~0U>>1); | |
16564 | const bool xdir = x0<x1, ydir = y0<y1; | |
16565 | int | |
16566 | nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1, | |
16567 | &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1, | |
16568 | &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0, | |
16569 | &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1, | |
16570 | &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0; | |
16571 | float | |
16572 | Tx0 = tx0/z0, Tx1 = tx1/z1, | |
16573 | Ty0 = ty0/z0, Ty1 = ty1/z1, | |
16574 | Z0 = 1.0f/z0, Z1 = 1.0f/z1, | |
16575 | dz = Z1-Z0, dtx = Tx1-Tx0, dty = Ty1-Ty0, | |
16576 | tnx0 = Tx0, tnx1 = Tx1, tny0 = Ty0, tny1 = Ty1, nz0 = Z0, nz1 = Z1, | |
16577 | &zleft = xdir?nz0:nz1, &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1, | |
16578 | &zright = xdir?nz1:nz0, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0, | |
16579 | &zup = ydir?nz0:nz1, &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1, | |
16580 | &zdown = ydir?nz1:nz0, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0; | |
16581 | if (xright<0 || xleft>=dimx()) return *this; | |
16582 | if (xleft<0) { | |
16583 | const int D = xright-xleft; | |
16584 | yleft-=xleft*(yright-yleft)/D; | |
16585 | zleft-=xleft*(zright-zleft)/D; | |
16586 | txleft-=xleft*(txright-txleft)/D; | |
16587 | tyleft-=xleft*(tyright-tyleft)/D; | |
16588 | xleft = 0; | |
16589 | } | |
16590 | if (xright>=dimx()) { | |
16591 | const int d = xright-dimx(), D = xright-xleft; | |
16592 | yright-=d*(yright-yleft)/D; | |
16593 | zright-=d*(zright-zleft)/D; | |
16594 | txright-=d*(txright-txleft)/D; | |
16595 | tyright-=d*(tyright-tyleft)/D; | |
16596 | xright = dimx()-1; | |
16597 | } | |
16598 | if (ydown<0 || yup>=dimy()) return *this; | |
16599 | if (yup<0) { | |
16600 | const int D = ydown-yup; | |
16601 | xup-=yup*(xdown-xup)/D; | |
16602 | zup-=yup*(zdown-zup)/D; | |
16603 | txup-=yup*(txdown-txup)/D; | |
16604 | tyup-=yup*(tydown-tyup)/D; | |
16605 | yup = 0; | |
16606 | } | |
16607 | if (ydown>=dimy()) { | |
16608 | const int d = ydown-dimy(), D = ydown-yup; | |
16609 | xdown-=d*(xdown-xup)/D; | |
16610 | zdown-=d*(zdown-zup)/D; | |
16611 | txdown-=d*(txdown-txup)/D; | |
16612 | tydown-=d*(tydown-tyup)/D; | |
16613 | ydown = dimy()-1; | |
16614 | } | |
16615 | T *ptrd0 = ptr(nx0,ny0,0,0); | |
16616 | int dx = xright-xleft, dy = ydown-yup; | |
16617 | const bool steep = dy>dx; | |
16618 | if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy); | |
16619 | const int | |
16620 | offx = (nx0<nx1?1:-1)*(steep?width:1), | |
16621 | offy = (ny0<ny1?1:-1)*(steep?1:width), | |
16622 | wh = width*height, | |
16623 | ndx = dx>0?dx:1; | |
16624 | if (opacity>=1) { | |
16625 | if (~pattern) for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16626 | T *ptrd = ptrd0; | |
16627 | if (pattern&hatch) { | |
16628 | const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx; | |
16629 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = texture((int)(tx/z),(int)(ty/z),0,k); ptrd+=wh; } | |
16630 | } | |
16631 | hatch>>=1; if (!hatch) hatch = ~0U-(~0U>>1); | |
16632 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16633 | } else for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16634 | T *ptrd = ptrd0; | |
16635 | const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx; | |
16636 | for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = texture((int)(tx/z),(int)(ty/z),0,k); ptrd+=wh; } | |
16637 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16638 | } | |
16639 | } else { | |
16640 | const float nopacity = cimg::abs(opacity), copacity=1-cimg::max(opacity,0.0f); | |
16641 | if (~pattern) for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16642 | T *ptrd = ptrd0; | |
16643 | if (pattern&hatch) { | |
16644 | const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx; | |
16645 | for (int k = 0; k<(int)((*this).dim); ++k) { const T c = (T)texture((int)(tx/z),(int)(ty/z),0,k); *ptrd = (T)(c*nopacity + *ptrd*copacity); ptrd+=wh; } | |
16646 | } | |
16647 | hatch>>=1; if (!hatch) hatch = ~0U-(~0U>>1); | |
16648 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16649 | } else for (int error=dx>>1, x=0; x<=dx; ++x) { | |
16650 | T *ptrd = ptrd0; | |
16651 | const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx; | |
16652 | for (int k = 0; k<(int)((*this).dim); ++k) { const T c = (T)texture((int)(tx/z),(int)(ty/z),0,k); *ptrd = (T)(c*nopacity + *ptrd*copacity); ptrd+=wh; } | |
16653 | ptrd0+=offx; if ((error-=dy)<0) { ptrd0+=offy; error+=dx; } | |
16654 | } | |
16655 | } | |
16656 | } | |
16657 | return *this; | |
16658 | } | |
16659 | template<typename t, typename tc> | |
16660 | CImg<T>& _draw_line(const t& points, const tc *const color, | |
16661 | const float opacity, const unsigned int pattern, const bool init_hatch, | |
16662 | const unsigned int W, const unsigned int H) { | |
16663 | bool ninit_hatch = init_hatch; | |
16664 | if (points && W>1 && H>1) { | |
16665 | if (H==2) { | |
16666 | const int x0 = (int)points(0,0), y0 = (int)points(0,1); | |
16667 | int ox = x0, oy = y0; | |
16668 | for (unsigned int i=1; i<W; ++i) { | |
16669 | const int x = (int)points(i,0), y = (int)points(i,1); | |
16670 | draw_line(ox,oy,x,y,color,opacity,pattern,ninit_hatch); | |
16671 | ninit_hatch = false; | |
16672 | ox = x; oy = y; | |
16673 | } | |
16674 | } else { | |
16675 | const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2); | |
16676 | int ox = x0, oy = y0, oz = z0; | |
16677 | for (unsigned int i=1; i<W; ++i) { | |
16678 | const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2); | |
16679 | draw_line(ox,oy,oz,x,y,z,color,opacity,pattern,ninit_hatch); | |
16680 | ninit_hatch = false; | |
16681 | ox = x; oy = y; oz = z; | |
16682 | } | |
16683 | } | |
16684 | } | |
16685 | return *this; | |
16686 | } | |
16687 | template<typename t, typename tc> | |
16688 | CImg<T>& draw_line(const CImgList<t>& points, const tc *const color, | |
16689 | const float opacity=1.0f, const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16690 | unsigned int H = ~0U; for (unsigned int p=0; p<(points).size; ++p) H = cimg::min(H,(unsigned int)(points[p].size())); | |
16691 | return _draw_line(points,color,opacity,pattern,init_hatch,points.size,H); | |
16692 | } | |
16693 | template<typename t, typename tc> | |
16694 | CImg<T>& draw_line(const CImgList<t>& points, const CImg<tc>& color, | |
16695 | const float opacity=1.0f, const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16696 | return draw_line(points,color.data,opacity,pattern,init_hatch); | |
16697 | } | |
16698 | template<typename t, typename tc> | |
16699 | CImg<T>& draw_line(const CImg<t>& points, const tc *const color, | |
16700 | const float opacity=1.0f, const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16701 | return _draw_line(points,color,opacity,pattern,init_hatch,points.width,points.height); | |
16702 | } | |
16703 | template<typename t, typename tc> | |
16704 | CImg<T>& draw_line(const CImg<t>& points, const CImg<tc>& color, | |
16705 | const float opacity=1.0f, const unsigned int pattern=~0U, const bool init_hatch=true) { | |
16706 | return draw_line(points,color.data,opacity,pattern,init_hatch); | |
16707 | } | |
16708 | template<typename t, typename tc> | |
16709 | CImg<T>& _draw_polygon(const t& points, const tc *const color, const float opacity, const unsigned int N) { | |
16710 | if (!is_empty() && N>2) { | |
16711 | if (!color) throw CImgArgumentException("CImg<%s>::draw_polygon() : Specified color is (null).",pixel_type()); | |
16712 | _draw_scanline(color,opacity); | |
16713 | int xmin = (int)(~0U>>1), xmax = 0, ymin = (int)(~0U>>1), ymax = 0; | |
16714 | { for (unsigned int p = 0; p<N; ++p) { | |
16715 | const int x = (int)points(p,0), y = (int)points(p,1); | |
16716 | if (x<xmin) xmin = x; | |
16717 | if (x>xmax) xmax = x; | |
16718 | if (y<ymin) ymin = y; | |
16719 | if (y>ymax) ymax = y; | |
16720 | }} | |
16721 | if (xmax<0 || xmin>=dimx() || ymax<0 || ymin>=dimx()) return *this; | |
16722 | const unsigned int | |
16723 | nymin = ymin<0?0:(unsigned int)ymin, | |
16724 | nymax = ymax>=dimy()?height-1:(unsigned int)ymax, | |
16725 | dy = 1 + nymax - nymin; | |
16726 | typedef typename cimg::last<T,int>::type cint; | |
16727 | CImg<cint> X(1+2*N,dy,1,1,0), tmp; | |
16728 | int cx = (int)points(0,0), cy = (int)points(0,1); | |
16729 | for (unsigned int cp = 0, p = 0; p<N; ++p) { | |
16730 | const unsigned int np = (p!=N-1)?p+1:0, ap = (np!=N-1)?np+1:0; | |
16731 | const int | |
16732 | nx = (int)points(np,0), ny = (int)points(np,1), ay = (int)points(ap,1), | |
16733 | y0 = cy-nymin, y1 = ny-nymin; | |
16734 | if (y0!=y1) { | |
16735 | const int countermin = ((ny<ay && cy<ny) || (ny>ay && cy>ny))?1:0; | |
16736 | for (int x = cx, y = y0, _sx = 1, _sy = 1, | |
16737 | _dx = nx>cx?nx-cx:((_sx=-1),cx-nx), | |
16738 | _dy = y1>y0?y1-y0:((_sy=-1),y0-y1), | |
16739 | _counter = ((_dx-=_dy?_dy*(_dx/_dy):0),_dy), | |
16740 | _err = _dx>>1, | |
16741 | _rx = _dy?(nx-cx)/_dy:0; | |
16742 | _counter>=countermin; | |
16743 | --_counter, y+=_sy, x+=_rx + ((_err-=_dx)<0?_err+=_dy,_sx:0)) | |
16744 | if (y>=0 && y<(int)dy) X(++X(0,y),y) = x; | |
16745 | cp = np; cx = nx; cy = ny; | |
16746 | } else { | |
16747 | const int pp = (cp?cp-1:N-1), py = (int)points(pp,1); | |
16748 | if ((cy>py && ay>cy) || (cy<py && ay<cy)) X(++X(0,y0),y0) = nx; | |
16749 | if (cy!=ay) { cp = np; cx = nx; cy = ny; } | |
16750 | } | |
16751 | } | |
16752 | for (int y = 0; y<(int)dy; ++y) { | |
16753 | tmp.assign(X.ptr(1,y),X(0,y),1,1,1,true).sort(); | |
16754 | for (int i = 1; i<=X(0,y); ) { | |
16755 | const int xb = X(i++,y), xe = X(i++,y); | |
16756 | _draw_scanline(xb,xe,nymin+y,color,opacity); | |
16757 | } | |
16758 | } | |
16759 | } | |
16760 | return *this; | |
16761 | } | |
16762 | template<typename t, typename tc> | |
16763 | CImg<T>& draw_polygon(const CImgList<t>& points, const tc *const color, const float opacity=1.0f) { | |
16764 | return _draw_polygon(points,color,opacity,points.size); | |
16765 | } | |
16766 | template<typename t, typename tc> | |
16767 | CImg<T>& draw_polygon(const CImgList<t>& points, const CImg<tc>& color, const float opacity=1.0f) { | |
16768 | return draw_polygon(points,color.data,opacity); | |
16769 | } | |
16770 | template<typename t, typename tc> | |
16771 | CImg<T>& draw_polygon(const CImg<t>& points, const tc *const color, const float opacity=1.0f) { | |
16772 | return _draw_polygon(points,color,opacity,points.width); | |
16773 | } | |
16774 | template<typename t, typename tc> | |
16775 | CImg<T>& draw_polygon(const CImg<t>& points, const CImg<tc>& color, const float opacity=1.0f) { | |
16776 | return draw_polygon(points,color.data,opacity); | |
16777 | } | |
16778 | template<typename t, typename tc> | |
16779 | CImg<T>& _draw_polygon(const t& points, const tc *const color, | |
16780 | const float opacity, const unsigned int pattern, | |
16781 | const unsigned int W, const unsigned int H) { | |
16782 | bool ninit_hatch = true; | |
16783 | if (points && W>2 && H>1) { | |
16784 | if (H==2) { | |
16785 | const int x0 = (int)points(0,0), y0 = (int)points(0,1); | |
16786 | int ox = x0, oy = y0; | |
16787 | for (unsigned int i=1; i<W; ++i) { | |
16788 | const int x = (int)points(i,0), y = (int)points(i,1); | |
16789 | draw_line(ox,oy,x,y,color,opacity,pattern,ninit_hatch); | |
16790 | ninit_hatch = false; | |
16791 | ox = x; oy = y; | |
16792 | } | |
16793 | draw_line(ox,oy,x0,y0,color,opacity,pattern,false); | |
16794 | } else { | |
16795 | const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2); | |
16796 | int ox = x0, oy = y0, oz = z0; | |
16797 | for (unsigned int i=1; i<W; ++i) { | |
16798 | const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2); | |
16799 | draw_line(ox,oy,oz,x,y,z,color,opacity,pattern,ninit_hatch); | |
16800 | ninit_hatch = false; | |
16801 | ox = x; oy = y; oz = z; | |
16802 | } | |
16803 | draw_line(ox,oy,oz,x0,y0,z0,color,opacity,pattern,false); | |
16804 | } | |
16805 | } | |
16806 | return *this; | |
16807 | } | |
16808 | template<typename t, typename tc> | |
16809 | CImg<T>& draw_polygon(const CImgList<t>& points, const tc *const color, | |
16810 | const float opacity, const unsigned int pattern) { | |
16811 | unsigned int H = ~0U; for (unsigned int p=0; p<(points).size; ++p) H = cimg::min(H,(unsigned int)(points[p].size())); | |
16812 | return _draw_polygon(points,color,opacity,pattern,points.size,H); | |
16813 | } | |
16814 | template<typename t, typename tc> | |
16815 | CImg<T>& draw_polygon(const CImgList<t>& points, const CImg<tc>& color, | |
16816 | const float opacity, const unsigned int pattern) { | |
16817 | return draw_polygon(points,color.data,opacity,pattern); | |
16818 | } | |
16819 | template<typename t, typename tc> | |
16820 | CImg<T>& draw_polygon(const CImg<t>& points, const tc *const color, | |
16821 | const float opacity, const unsigned int pattern) { | |
16822 | return _draw_polygon(points,color,opacity,pattern,points.width,points.height); | |
16823 | } | |
16824 | template<typename t, typename tc> | |
16825 | CImg<T>& draw_polygon(const CImg<t>& points, const CImg<tc>& color, | |
16826 | const float opacity, const unsigned int pattern) { | |
16827 | return draw_polygon(points,color.data,opacity,pattern); | |
16828 | } | |
16829 | template<typename tc> | |
16830 | CImg<T>& draw_spline(const int x0, const int y0, const float u0, const float v0, | |
16831 | const int x1, const int y1, const float u1, const float v1, | |
16832 | const tc *const color, | |
16833 | const float precision=4.0f, const float opacity=1.0f, const unsigned int pattern=~0U, | |
16834 | const bool init_hatch=true) { | |
16835 | if (!is_empty()) { | |
16836 | if (!color) throw CImgArgumentException("CImg<%s>::draw_spline() : Specified color is (null)",pixel_type()); | |
16837 | bool ninit_hatch = init_hatch; | |
16838 | const float | |
16839 | dx = (float)(x1-x0), | |
16840 | dy = (float)(y1-y0), | |
16841 | dmax = cimg::max(cimg::abs(dx),cimg::abs(dy)), | |
16842 | ax = -2*dx + u0 + u1, | |
16843 | bx = 3*dx - 2*u0 - u1, | |
16844 | ay = -2*dy + v0 + v1, | |
16845 | by = 3*dy - 2*v0 - v1, | |
16846 | xprecision = dmax>0?precision/dmax:1.0f, | |
16847 | tmax = 1.0f + (dmax>0?xprecision:0.0f); | |
16848 | int ox = x0, oy = y0; | |
16849 | for (float t=0.0f; t<tmax; t+=xprecision) { | |
16850 | const float | |
16851 | t2 = t*t, | |
16852 | t3 = t2*t; | |
16853 | const int | |
16854 | nx = (int)(ax*t3 + bx*t2 + u0*t + x0), | |
16855 | ny = (int)(ay*t3 + by*t2 + v0*t + y0); | |
16856 | draw_line(ox,oy,nx,ny,color,opacity,pattern,ninit_hatch); | |
16857 | ninit_hatch = false; | |
16858 | ox = nx; oy = ny; | |
16859 | } | |
16860 | } | |
16861 | return *this; | |
16862 | } | |
16863 | template<typename tc> | |
16864 | CImg<T>& draw_spline(const int x0, const int y0, const float u0, const float v0, | |
16865 | const int x1, const int y1, const float u1, const float v1, | |
16866 | const CImg<tc>& color, | |
16867 | const float precision=4.0f, const float opacity=1.0f, const unsigned int pattern=~0U, | |
16868 | const bool init_hatch=true) { | |
16869 | return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,color.data,precision,opacity,pattern,init_hatch); | |
16870 | } | |
16871 | template<typename tc> | |
16872 | CImg<T>& draw_spline(const int x0, const int y0, const int z0, const float u0, const float v0, const float w0, | |
16873 | const int x1, const int y1, const int z1, const float u1, const float v1, const float w1, | |
16874 | const tc *const color, | |
16875 | const float precision=4.0f, const float opacity=1.0f, const unsigned int pattern=~0U, | |
16876 | const bool init_hatch=true) { | |
16877 | if (!is_empty()) { | |
16878 | if (!color) throw CImgArgumentException("CImg<%s>::draw_spline() : Specified color is (null)",pixel_type()); | |
16879 | bool ninit_hatch = init_hatch; | |
16880 | const float | |
16881 | dx = (float)(x1-x0), | |
16882 | dy = (float)(y1-y0), | |
16883 | dz = (float)(z1-z0), | |
16884 | dmax = cimg::max(cimg::abs(dx),cimg::abs(dy),cimg::abs(dz)), | |
16885 | ax = -2*dx + u0 + u1, | |
16886 | bx = 3*dx - 2*u0 - u1, | |
16887 | ay = -2*dy + v0 + v1, | |
16888 | by = 3*dy - 2*v0 - v1, | |
16889 | az = -2*dz + w0 + w1, | |
16890 | bz = 3*dz - 2*w0 - w1, | |
16891 | xprecision = dmax>0?precision/dmax:1.0f, | |
16892 | tmax = 1.0f + (dmax>0?xprecision:0.0f); | |
16893 | int ox = x0, oy = y0, oz = z0; | |
16894 | for (float t=0.0f; t<tmax; t+=xprecision) { | |
16895 | const float | |
16896 | t2 = t*t, | |
16897 | t3 = t2*t; | |
16898 | const int | |
16899 | nx = (int)(ax*t3 + bx*t2 + u0*t + x0), | |
16900 | ny = (int)(ay*t3 + by*t2 + v0*t + y0), | |
16901 | nz = (int)(az*t3 + bz*t2 + w0*t + z0); | |
16902 | draw_line(ox,oy,oz,nx,ny,nz,color,opacity,pattern,ninit_hatch); | |
16903 | ninit_hatch = false; | |
16904 | ox = nx; oy = ny; oz = nz; | |
16905 | } | |
16906 | } | |
16907 | return *this; | |
16908 | } | |
16909 | template<typename tc> | |
16910 | CImg<T>& draw_spline(const int x0, const int y0, const int z0, const float u0, const float v0, const float w0, | |
16911 | const int x1, const int y1, const int z1, const float u1, const float v1, const float w1, | |
16912 | const CImg<tc>& color, | |
16913 | const float precision=4.0f, const float opacity=1.0f, const unsigned int pattern=~0U, | |
16914 | const bool init_hatch=true) { | |
16915 | return draw_spline(x0,y0,z0,u0,v0,w0,x1,y1,z1,u1,v1,w1,color.data,precision,opacity,pattern,init_hatch); | |
16916 | } | |
16917 | template<typename t> | |
16918 | CImg<T>& draw_spline(const int x0, const int y0, const float u0, const float v0, | |
16919 | const int x1, const int y1, const float u1, const float v1, | |
16920 | const CImg<t>& texture, | |
16921 | const int tx0, const int ty0, const int tx1, const int ty1, | |
16922 | const float precision=4.0f, const float opacity=1.0f, const unsigned int pattern=~0U, | |
16923 | const bool init_hatch=true) { | |
16924 | if (!is_empty()) { | |
16925 | if (!texture || texture.dim<dim) | |
16926 | throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
16927 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
16928 | if (is_overlapping(texture)) return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,+texture,tx0,ty0,tx1,ty1,precision,opacity,pattern,init_hatch); | |
16929 | bool ninit_hatch = true; | |
16930 | const float | |
16931 | dx = (float)(x1-x0), | |
16932 | dy = (float)(y1-y0), | |
16933 | dmax = cimg::max(cimg::abs(dx),cimg::abs(dy)), | |
16934 | ax = -2*dx + u0 + u1, | |
16935 | bx = 3*dx - 2*u0 - u1, | |
16936 | ay = -2*dy + v0 + v1, | |
16937 | by = 3*dy - 2*v0 - v1, | |
16938 | xprecision = dmax>0?precision/dmax:1.0f, | |
16939 | tmax = 1.0f + (dmax>0?xprecision:0.0f); | |
16940 | int ox = x0, oy = y0, otx = tx0, oty = ty0; | |
16941 | for (float t1=0.0f; t1<tmax; t1+=xprecision) { | |
16942 | const float | |
16943 | t2 = t1*t1, | |
16944 | t3 = t2*t1; | |
16945 | const int | |
16946 | nx = (int)(ax*t3 + bx*t2 + u0*t1 + x0), | |
16947 | ny = (int)(ay*t3 + by*t2 + v0*t1 + y0), | |
16948 | ntx = tx0 + (int)((tx1-tx0)*t1/tmax), | |
16949 | nty = ty0 + (int)((ty1-ty0)*t1/tmax); | |
16950 | draw_line(ox,oy,nx,ny,texture,otx,oty,ntx,nty,opacity,pattern,ninit_hatch); | |
16951 | ninit_hatch = false; | |
16952 | ox = nx; oy = ny; otx = ntx; oty = nty; | |
16953 | } | |
16954 | } | |
16955 | return *this; | |
16956 | } | |
16957 | template<typename tp, typename tt, typename tc> | |
16958 | CImg<T>& _draw_spline(const tp& points, const tt& tangents, | |
16959 | const tc *const color, const bool close_set, | |
16960 | const float precision, const float opacity, const unsigned int pattern, const bool init_hatch, | |
16961 | const unsigned int W, const unsigned int H) { | |
16962 | bool ninit_hatch = init_hatch; | |
16963 | if (points && tangents && W>1 && H>1) { | |
16964 | if (H==2) { | |
16965 | const int x0 = (int)points(0,0), y0 = (int)points(0,1); | |
16966 | const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1); | |
16967 | int ox = x0, oy = y0; | |
16968 | float ou = u0, ov = v0; | |
16969 | for (unsigned int i=1; i<W; ++i) { | |
16970 | const int x = (int)points(i,0), y = (int)points(i,1); | |
16971 | const float u = (float)tangents(i,0), v = (float)tangents(i,1); | |
16972 | draw_spline(ox,oy,ou,ov,x,y,u,v,color,precision,opacity,pattern,ninit_hatch); | |
16973 | ninit_hatch = false; | |
16974 | ox = x; oy = y; ou = u; ov = v; | |
16975 | } | |
16976 | if (close_set) draw_spline(ox,oy,ou,ov,x0,y0,u0,v0,color,precision,opacity,pattern,false); | |
16977 | } else { | |
16978 | const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2); | |
16979 | const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1), w0 = (float)tangents(0,2); | |
16980 | int ox = x0, oy = y0, oz = z0; | |
16981 | float ou = u0, ov = v0, ow = w0; | |
16982 | for (unsigned int i=1; i<W; ++i) { | |
16983 | const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2); | |
16984 | const float u = (float)tangents(i,0), v = (float)tangents(i,1), w = (float)tangents(i,2); | |
16985 | draw_spline(ox,oy,oz,ou,ov,ow,x,y,z,u,v,w,color,opacity,pattern,ninit_hatch); | |
16986 | ninit_hatch = false; | |
16987 | ox = x; oy = y; oz = z; ou = u; ov = v; ow = w; | |
16988 | } | |
16989 | if (close_set) draw_spline(ox,oy,oz,ou,ov,ow,x0,y0,z0,u0,v0,w0,color,precision,opacity,pattern,false); | |
16990 | } | |
16991 | } | |
16992 | return *this; | |
16993 | } | |
16994 | template<typename tp, typename tc> | |
16995 | CImg<T>& _draw_spline(const tp& points, | |
16996 | const tc *const color, const bool close_set, | |
16997 | const float precision, const float opacity, const unsigned int pattern, const bool init_hatch, | |
16998 | const unsigned int W, const unsigned int H) { | |
16999 | typedef typename cimg::superset<T,float>::type ftype; | |
17000 | CImg<ftype> tangents; | |
17001 | if (points && W>1 && H>1) { | |
17002 | if (H==2) { | |
17003 | tangents.assign(W,H); | |
17004 | for (unsigned int p=0; p<W; ++p) { | |
17005 | const unsigned int | |
17006 | p0 = close_set?(p+W-1)%W:(p?p-1:0), | |
17007 | p1 = close_set?(p+1)%W:(p+1<W?p+1:p); | |
17008 | const float | |
17009 | x = (float)points(p,0), | |
17010 | y = (float)points(p,1), | |
17011 | x0 = (float)points(p0,0), | |
17012 | y0 = (float)points(p0,1), | |
17013 | x1 = (float)points(p1,0), | |
17014 | y1 = (float)points(p1,1), | |
17015 | u0 = x-x0, | |
17016 | v0 = y-y0, | |
17017 | n0 = 1e-8f + (float)std::sqrt(u0*u0+v0*v0), | |
17018 | u1 = x1-x, | |
17019 | v1 = y1-y, | |
17020 | n1 = 1e-8f + (float)std::sqrt(u1*u1+v1*v1), | |
17021 | u = u0/n0 + u1/n1, | |
17022 | v = v0/n0 + v1/n1, | |
17023 | n = 1e-8f + (float)std::sqrt(u*u+v*v), | |
17024 | fact = 0.5f*(n0 + n1); | |
17025 | tangents(p,0) = (ftype)(fact*u/n); | |
17026 | tangents(p,1) = (ftype)(fact*v/n); | |
17027 | } | |
17028 | } else { | |
17029 | tangents.assign(W,H); | |
17030 | for (unsigned int p=0; p<W; ++p) { | |
17031 | const unsigned int | |
17032 | p0 = close_set?(p+W-1)%W:(p?p-1:0), | |
17033 | p1 = close_set?(p+1)%W:(p+1<W?p+1:p); | |
17034 | const float | |
17035 | x = (float)points(p,0), | |
17036 | y = (float)points(p,1), | |
17037 | z = (float)points(p,2), | |
17038 | x0 = (float)points(p0,0), | |
17039 | y0 = (float)points(p0,1), | |
17040 | z0 = (float)points(p0,2), | |
17041 | x1 = (float)points(p1,0), | |
17042 | y1 = (float)points(p1,1), | |
17043 | z1 = (float)points(p1,2), | |
17044 | u0 = x-x0, | |
17045 | v0 = y-y0, | |
17046 | w0 = z-z0, | |
17047 | n0 = 1e-8f + (float)std::sqrt(u0*u0+v0*v0+w0*w0), | |
17048 | u1 = x1-x, | |
17049 | v1 = y1-y, | |
17050 | w1 = z1-z, | |
17051 | n1 = 1e-8f + (float)std::sqrt(u1*u1+v1*v1+w1*w1), | |
17052 | u = u0/n0 + u1/n1, | |
17053 | v = v0/n0 + v1/n1, | |
17054 | w = w0/n0 + w1/n1, | |
17055 | n = 1e-8f + (float)std::sqrt(u*u+v*v+w*w), | |
17056 | fact = 0.5f*(n0 + n1); | |
17057 | tangents(p,0) = (ftype)(fact*u/n); | |
17058 | tangents(p,1) = (ftype)(fact*v/n); | |
17059 | tangents(p,2) = (ftype)(fact*w/n); | |
17060 | } | |
17061 | } | |
17062 | _draw_spline(points,tangents,color,close_set,precision,opacity,pattern,init_hatch,W,H); | |
17063 | } | |
17064 | return *this; | |
17065 | } | |
17066 | template<typename tp, typename tt, typename tc> | |
17067 | CImg<T>& draw_spline(const CImgList<tp>& points, const CImgList<tt>& tangents, | |
17068 | const tc *const color, const bool close_set=false, | |
17069 | const float precision=4.0f, const float opacity=1.0f, | |
17070 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17071 | unsigned int H = ~0U; for (unsigned int p=0; p<(points).size; ++p) H = cimg::min(H,(unsigned int)(points[p].size()),(unsigned int)(tangents[p].size())); | |
17072 | return _draw_spline(points,tangents,color,close_set,precision,opacity,pattern,init_hatch,points.size,H); | |
17073 | } | |
17074 | template<typename tp, typename tt, typename tc> | |
17075 | CImg<T>& draw_spline(const CImgList<tp>& points, const CImgList<tt>& tangents, | |
17076 | const CImg<tc>& color, const bool close_set=false, | |
17077 | const float precision=4.0f, const float opacity=1.0f, | |
17078 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17079 | return draw_spline(points,tangents,color.data,close_set,precision,opacity,pattern,init_hatch); | |
17080 | } | |
17081 | template<typename tp, typename tt, typename tc> | |
17082 | CImg<T>& draw_spline(const CImg<tp>& points, const CImg<tt>& tangents, | |
17083 | const tc *const color, const bool close_set=false, | |
17084 | const float precision=4.0f, const float opacity=1.0f, | |
17085 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17086 | return _draw_spline(points,tangents,color,close_set,precision,opacity,pattern,init_hatch,points.width,points.height); | |
17087 | } | |
17088 | template<typename tp, typename tt, typename tc> | |
17089 | CImg<T>& draw_spline(const CImg<tp>& points, const CImg<tt>& tangents, | |
17090 | const CImg<tc>& color, const bool close_set=false, | |
17091 | const float precision=4.0f, const float opacity=1.0f, | |
17092 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17093 | return draw_spline(points,tangents,color.data,close_set,precision,opacity,pattern,init_hatch); | |
17094 | } | |
17095 | template<typename t, typename tc> | |
17096 | CImg<T>& draw_spline(const CImgList<t>& points, const tc *const color, | |
17097 | const bool close_set=false, const float precision=4.0f, const float opacity=1.0f, | |
17098 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17099 | unsigned int H = ~0U; | |
17100 | for (unsigned int p=0; p<(points).size; ++p) { | |
17101 | const unsigned int s = points[p].size(); | |
17102 | if (s<H) H = s; | |
17103 | } | |
17104 | return _draw_spline(points,color,close_set,precision,opacity,pattern,init_hatch,points.size,H); | |
17105 | } | |
17106 | template<typename t, typename tc> | |
17107 | CImg<T>& draw_spline(const CImgList<t>& points, CImg<tc>& color, | |
17108 | const bool close_set=false, const float precision=4.0f, const float opacity=1.0f, | |
17109 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17110 | return draw_spline(points,color.data,close_set,precision,opacity,pattern,init_hatch); | |
17111 | } | |
17112 | template<typename t, typename tc> | |
17113 | CImg<T>& draw_spline(const CImg<t>& points, const tc *const color, | |
17114 | const bool close_set=false, const float precision=4.0f, const float opacity=1.0f, | |
17115 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17116 | return _draw_spline(points,color,close_set,precision,opacity,pattern,init_hatch,points.width,points.height); | |
17117 | } | |
17118 | template<typename t, typename tc> | |
17119 | CImg<T>& draw_spline(const CImg<t>& points, const CImg<tc>& color, | |
17120 | const bool close_set=false, const float precision=4.0f, const float opacity=1.0f, | |
17121 | const unsigned int pattern=~0U, const bool init_hatch=true) { | |
17122 | return draw_spline(points,color.data,close_set,precision,opacity,pattern,init_hatch); | |
17123 | } | |
17124 | template<typename tc> | |
17125 | CImg<T>& draw_arrow(const int x0, const int y0, const int x1, const int y1, | |
17126 | const tc *const color, | |
17127 | const float angle=30, const float length=-10, | |
17128 | const float opacity=1.0f, const unsigned int pattern=~0U) { | |
17129 | if (!is_empty()) { | |
17130 | const float u = (float)(x0-x1), v = (float)(y0-y1), sq = u*u+v*v, | |
17131 | deg = (float)(angle*cimg::valuePI/180), ang = (sq>0)?(float)std::atan2(v,u):0.0f, | |
17132 | l = (length>=0)?length:-length*(float)std::sqrt(sq)/100; | |
17133 | if (sq>0) { | |
17134 | const double cl = std::cos(ang-deg), sl = std::sin(ang-deg), cr = std::cos(ang+deg), sr = std::sin(ang+deg); | |
17135 | const int | |
17136 | xl = x1+(int)(l*cl), yl = y1+(int)(l*sl), | |
17137 | xr = x1+(int)(l*cr), yr = y1+(int)(l*sr), | |
17138 | xc = x1+(int)((l+1)*(cl+cr))/2, yc = y1+(int)((l+1)*(sl+sr))/2; | |
17139 | draw_line(x0,y0,xc,yc,color,opacity,pattern).draw_triangle(x1,y1,xl,yl,xr,yr,color,opacity); | |
17140 | } else draw_point(x0,y0,color,opacity); | |
17141 | } | |
17142 | return *this; | |
17143 | } | |
17144 | template<typename tc> | |
17145 | CImg<T>& draw_arrow(const int x0, const int y0, const int x1, const int y1, | |
17146 | const CImg<tc>& color, | |
17147 | const float angle=30, const float length=-10, | |
17148 | const float opacity=1.0f, const unsigned int pattern=~0U) { | |
17149 | return draw_arrow(x0,y0,x1,y1,color.data,angle,length,opacity,pattern); | |
17150 | } | |
17151 | template<typename t> | |
17152 | CImg<T>& draw_image(const CImg<t>& sprite, | |
17153 | const int x0, const int y0=0, const int z0=0, const int v0=0, | |
17154 | const float opacity=1.0f) { | |
17155 | if (!is_empty()) { | |
17156 | if (!sprite) | |
17157 | throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.", | |
17158 | pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data); | |
17159 | if (is_overlapping(sprite)) return draw_image(+sprite,x0,y0,z0,v0,opacity); | |
17160 | const bool bx=(x0<0), by=(y0<0), bz=(z0<0), bv=(v0<0); | |
17161 | const int | |
17162 | lX = sprite.dimx() - (x0+sprite.dimx()>dimx()?x0+sprite.dimx()-dimx():0) + (bx?x0:0), | |
17163 | lY = sprite.dimy() - (y0+sprite.dimy()>dimy()?y0+sprite.dimy()-dimy():0) + (by?y0:0), | |
17164 | lZ = sprite.dimz() - (z0+sprite.dimz()>dimz()?z0+sprite.dimz()-dimz():0) + (bz?z0:0), | |
17165 | lV = sprite.dimv() - (v0+sprite.dimv()>dimv()?v0+sprite.dimv()-dimv():0) + (bv?v0:0); | |
17166 | const t | |
17167 | *ptrs = sprite.data - | |
17168 | (bx?x0:0) - | |
17169 | (by?y0*sprite.dimx():0) - | |
17170 | (bz?z0*sprite.dimx()*sprite.dimy():0) - | |
17171 | (bv?v0*sprite.dimx()*sprite.dimy()*sprite.dimz():0); | |
17172 | const unsigned int | |
17173 | offX = width-lX, soffX = sprite.width-lX, | |
17174 | offY = width*(height-lY), soffY = sprite.width*(sprite.height-lY), | |
17175 | offZ = width*height*(depth-lZ), soffZ = sprite.width*sprite.height*(sprite.depth-lZ); | |
17176 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17177 | T *ptrd = ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0); | |
17178 | if (lX>0 && lY>0 && lZ>0 && lV>0) | |
17179 | for (int v=0; v<lV; ++v) { | |
17180 | for (int z=0; z<lZ; ++z) { | |
17181 | for (int y=0; y<lY; ++y) { | |
17182 | if (opacity>=1) for (int x=0; x<lX; ++x) *(ptrd++) = (T)*(ptrs++); | |
17183 | else for (int x=0; x<lX; ++x) { *ptrd = (T)(nopacity*(*(ptrs++)) + *ptrd*copacity); ++ptrd; } | |
17184 | ptrd+=offX; ptrs+=soffX; | |
17185 | } | |
17186 | ptrd+=offY; ptrs+=soffY; | |
17187 | } | |
17188 | ptrd+=offZ; ptrs+=soffZ; | |
17189 | } | |
17190 | } | |
17191 | return *this; | |
17192 | } | |
17193 | CImg<T>& draw_image(const CImg<T>& sprite, | |
17194 | const int x0, const int y0=0, const int z0=0, const int v0=0, | |
17195 | const float opacity=1.0f) { | |
17196 | if (!is_empty()) { | |
17197 | if (!sprite) | |
17198 | throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.", | |
17199 | pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data); | |
17200 | if (is_overlapping(sprite)) return draw_image(+sprite,x0,y0,z0,v0,opacity); | |
17201 | const bool bx=(x0<0), by=(y0<0), bz=(z0<0), bv=(v0<0); | |
17202 | const int | |
17203 | lX = sprite.dimx() - (x0+sprite.dimx()>dimx()?x0+sprite.dimx()-dimx():0) + (bx?x0:0), | |
17204 | lY = sprite.dimy() - (y0+sprite.dimy()>dimy()?y0+sprite.dimy()-dimy():0) + (by?y0:0), | |
17205 | lZ = sprite.dimz() - (z0+sprite.dimz()>dimz()?z0+sprite.dimz()-dimz():0) + (bz?z0:0), | |
17206 | lV = sprite.dimv() - (v0+sprite.dimv()>dimv()?v0+sprite.dimv()-dimv():0) + (bv?v0:0); | |
17207 | const T | |
17208 | *ptrs = sprite.data - | |
17209 | (bx?x0:0) - | |
17210 | (by?y0*sprite.dimx():0) - | |
17211 | (bz?z0*sprite.dimx()*sprite.dimy():0) - | |
17212 | (bv?v0*sprite.dimx()*sprite.dimy()*sprite.dimz():0); | |
17213 | const unsigned int | |
17214 | offX = width-lX, soffX = sprite.width-lX, | |
17215 | offY = width*(height-lY), soffY = sprite.width*(sprite.height-lY), | |
17216 | offZ = width*height*(depth-lZ), soffZ = sprite.width*sprite.height*(sprite.depth-lZ), | |
17217 | slX = lX*sizeof(T); | |
17218 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17219 | T *ptrd = ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0); | |
17220 | if (lX>0 && lY>0 && lZ>0 && lV>0) | |
17221 | for (int v=0; v<lV; ++v) { | |
17222 | for (int z=0; z<lZ; ++z) { | |
17223 | if (opacity>=1) for (int y=0; y<lY; ++y) { std::memcpy(ptrd,ptrs,slX); ptrd+=width; ptrs+=sprite.width; } | |
17224 | else for (int y=0; y<lY; ++y) { | |
17225 | for (int x=0; x<lX; ++x) { *ptrd = (T)(nopacity*(*(ptrs++)) + *ptrd*copacity); ++ptrd; } | |
17226 | ptrd+=offX; ptrs+=soffX; | |
17227 | } | |
17228 | ptrd+=offY; ptrs+=soffY; | |
17229 | } | |
17230 | ptrd+=offZ; ptrs+=soffZ; | |
17231 | } | |
17232 | } | |
17233 | return *this; | |
17234 | } | |
17235 | template<typename ti, typename tm> | |
17236 | CImg<T>& draw_image(const CImg<ti>& sprite, const CImg<tm>& mask, | |
17237 | const int x0, const int y0=0, const int z0=0, const int v0=0, | |
17238 | const float mask_valmax=1.0f, const float opacity=1.0f) { | |
17239 | if (!is_empty()) { | |
17240 | if (!sprite) | |
17241 | throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.", | |
17242 | pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data); | |
17243 | if (!mask) | |
17244 | throw CImgArgumentException("CImg<%s>::draw_image() : Specified mask image (%u,%u,%u,%u,%p) is empty.", | |
17245 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data); | |
17246 | if (is_overlapping(sprite)) return draw_image(+sprite,mask,x0,y0,z0,v0,mask_valmax,opacity); | |
17247 | if (is_overlapping(mask)) return draw_image(sprite,+mask,x0,y0,z0,v0,mask_valmax,opacity); | |
17248 | if (mask.width!=sprite.width || mask.height!=sprite.height || mask.depth!=sprite.depth) | |
17249 | throw CImgArgumentException("CImg<%s>::draw_image() : Mask dimension is (%u,%u,%u,%u), while sprite is (%u,%u,%u,%u)", | |
17250 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,sprite.width,sprite.height,sprite.depth,sprite.dim); | |
17251 | const bool bx=(x0<0), by=(y0<0), bz=(z0<0), bv=(v0<0); | |
17252 | const int | |
17253 | lX = sprite.dimx() - (x0+sprite.dimx()>dimx()?x0+sprite.dimx()-dimx():0) + (bx?x0:0), | |
17254 | lY = sprite.dimy() - (y0+sprite.dimy()>dimy()?y0+sprite.dimy()-dimy():0) + (by?y0:0), | |
17255 | lZ = sprite.dimz() - (z0+sprite.dimz()>dimz()?z0+sprite.dimz()-dimz():0) + (bz?z0:0), | |
17256 | lV = sprite.dimv() - (v0+sprite.dimv()>dimv()?v0+sprite.dimv()-dimv():0) + (bv?v0:0); | |
17257 | const int | |
17258 | coff = -(bx?x0:0)-(by?y0*mask.dimx():0)-(bz?z0*mask.dimx()*mask.dimy():0)-(bv?v0*mask.dimx()*mask.dimy()*mask.dimz():0), | |
17259 | ssize = mask.dimx()*mask.dimy()*mask.dimz(); | |
17260 | const ti *ptrs = sprite.data + coff; | |
17261 | const tm *ptrm = mask.data + coff; | |
17262 | const unsigned int | |
17263 | offX = width-lX, soffX = sprite.width-lX, | |
17264 | offY = width*(height-lY), soffY = sprite.width*(sprite.height-lY), | |
17265 | offZ = width*height*(depth-lZ), soffZ = sprite.width*sprite.height*(sprite.depth-lZ); | |
17266 | T *ptrd = ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0); | |
17267 | if (lX>0 && lY>0 && lZ>0 && lV>0) | |
17268 | for (int v=0; v<lV; ++v) { | |
17269 | ptrm = mask.data + (ptrm - mask.data)%ssize; | |
17270 | for (int z=0; z<lZ; ++z) { | |
17271 | for (int y=0; y<lY; ++y) { | |
17272 | for (int x=0; x<lX; ++x) { | |
17273 | const float mopacity = (float)(*(ptrm++)*opacity), | |
17274 | nopacity = cimg::abs(mopacity), copacity = mask_valmax-cimg::max(mopacity,0.0f); | |
17275 | *ptrd = (T)((nopacity*(*(ptrs++)) + *ptrd*copacity)/mask_valmax); | |
17276 | ++ptrd; | |
17277 | } | |
17278 | ptrd+=offX; ptrs+=soffX; ptrm+=soffX; | |
17279 | } | |
17280 | ptrd+=offY; ptrs+=soffY; ptrm+=soffY; | |
17281 | } | |
17282 | ptrd+=offZ; ptrs+=soffZ; ptrm+=soffZ; | |
17283 | } | |
17284 | } | |
17285 | return *this; | |
17286 | } | |
17287 | CImg<T>& draw_rectangle(const int x0, const int y0, const int z0, const int v0, | |
17288 | const int x1, const int y1, const int z1, const int v1, | |
17289 | const T val, const float opacity=1.0f) { | |
17290 | if (!is_empty()) { | |
17291 | const bool bx=(x0<x1), by=(y0<y1), bz=(z0<z1), bv=(v0<v1); | |
17292 | const int nx0=bx?x0:x1, nx1=bx?x1:x0, ny0=by?y0:y1, ny1=by?y1:y0, nz0=bz?z0:z1, nz1=bz?z1:z0, nv0=bv?v0:v1, nv1=bv?v1:v0; | |
17293 | const int | |
17294 | lX = (1+nx1-nx0) + (nx1>=dimx()?dimx()-1-nx1:0) + (nx0<0?nx0:0), | |
17295 | lY = (1+ny1-ny0) + (ny1>=dimy()?dimy()-1-ny1:0) + (ny0<0?ny0:0), | |
17296 | lZ = (1+nz1-nz0) + (nz1>=dimz()?dimz()-1-nz1:0) + (nz0<0?nz0:0), | |
17297 | lV = (1+nv1-nv0) + (nv1>=dimv()?dimv()-1-nv1:0) + (nv0<0?nv0:0); | |
17298 | const unsigned int offX = width-lX, offY = width*(height-lY), offZ = width*height*(depth-lZ); | |
17299 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17300 | T *ptrd = ptr(nx0<0?0:nx0,ny0<0?0:ny0,nz0<0?0:nz0,nv0<0?0:nv0); | |
17301 | if (lX>0 && lY>0 && lZ>0 && lV>0) | |
17302 | for (int v=0; v<lV; ++v) { | |
17303 | for (int z=0; z<lZ; ++z) { | |
17304 | for (int y=0; y<lY; ++y) { | |
17305 | if (opacity>=1) { | |
17306 | if (sizeof(T)!=1) { for (int x=0; x<lX; ++x) *(ptrd++) = val; ptrd+=offX; } | |
17307 | else { std::memset(ptrd,(int)val,lX); ptrd+=width; } | |
17308 | } else { for (int x=0; x<lX; ++x) { *ptrd = (T)(nopacity*val + *ptrd*copacity); ++ptrd; } ptrd+=offX; } | |
17309 | } | |
17310 | ptrd+=offY; | |
17311 | } | |
17312 | ptrd+=offZ; | |
17313 | } | |
17314 | } | |
17315 | return *this; | |
17316 | } | |
17317 | template<typename tc> | |
17318 | CImg<T>& draw_rectangle(const int x0, const int y0, const int z0, | |
17319 | const int x1, const int y1, const int z1, | |
17320 | const tc *const color, const float opacity=1.0f) { | |
17321 | if (!color) throw CImgArgumentException("CImg<%s>::draw_rectangle : specified color is (null)",pixel_type()); | |
17322 | for (int k = 0; k<(int)((*this).dim); ++k) draw_rectangle(x0,y0,z0,k,x1,y1,z1,k,color[k],opacity); | |
17323 | return *this; | |
17324 | } | |
17325 | template<typename tc> | |
17326 | CImg<T>& draw_rectangle(const int x0, const int y0, const int z0, | |
17327 | const int x1, const int y1, const int z1, | |
17328 | const CImg<tc>& color, const float opacity=1.0f) { | |
17329 | return draw_rectangle(x0,y0,z0,x1,y1,z1,color.data,opacity); | |
17330 | } | |
17331 | template<typename tc> | |
17332 | CImg<T>& draw_rectangle(const int x0, const int y0, const int z0, | |
17333 | const int x1, const int y1, const int z1, | |
17334 | const tc *const color, const float opacity, const unsigned int pattern) { | |
17335 | return draw_line(x0,y0,z0,x1,y0,z0,color,opacity,pattern,true). | |
17336 | draw_line(x1,y0,z0,x1,y1,z0,color,opacity,pattern,false). | |
17337 | draw_line(x1,y1,z0,x0,y1,z0,color,opacity,pattern,false). | |
17338 | draw_line(x0,y1,z0,x0,y0,z0,color,opacity,pattern,false). | |
17339 | draw_line(x0,y0,z1,x1,y0,z1,color,opacity,pattern,true). | |
17340 | draw_line(x1,y0,z1,x1,y1,z1,color,opacity,pattern,false). | |
17341 | draw_line(x1,y1,z1,x0,y1,z1,color,opacity,pattern,false). | |
17342 | draw_line(x0,y1,z1,x0,y0,z1,color,opacity,pattern,false). | |
17343 | draw_line(x0,y0,z0,x0,y0,z1,color,opacity,pattern,true). | |
17344 | draw_line(x1,y0,z0,x1,y0,z1,color,opacity,pattern,true). | |
17345 | draw_line(x1,y1,z0,x1,y1,z1,color,opacity,pattern,true). | |
17346 | draw_line(x0,y1,z0,x0,y1,z1,color,opacity,pattern,true); | |
17347 | } | |
17348 | template<typename tc> | |
17349 | CImg<T>& draw_rectangle(const int x0, const int y0, const int z0, | |
17350 | const int x1, const int y1, const int z1, | |
17351 | const CImg<tc>& color, const float opacity, const unsigned int pattern) { | |
17352 | return draw_rectangle(x0,y0,z0,x1,y1,z1,color.data,opacity,pattern); | |
17353 | } | |
17354 | template<typename tc> | |
17355 | CImg<T>& draw_rectangle(const int x0, const int y0, const int x1, const int y1, | |
17356 | const tc *const color, const float opacity=1.0f) { | |
17357 | return draw_rectangle(x0,y0,0,x1,y1,depth-1,color,opacity); | |
17358 | } | |
17359 | template<typename tc> | |
17360 | CImg<T>& draw_rectangle(const int x0, const int y0, const int x1, const int y1, | |
17361 | const CImg<tc>& color, const float opacity=1.0f) { | |
17362 | return draw_rectangle(x0,y0,x1,y1,color.data,opacity); | |
17363 | } | |
17364 | template<typename tc> | |
17365 | CImg<T>& draw_rectangle(const int x0, const int y0, const int x1, const int y1, | |
17366 | const tc *const color, const float opacity, const unsigned int pattern) { | |
17367 | return draw_line(x0,y0,x1,y0,color,opacity,pattern,true). | |
17368 | draw_line(x1,y0,x1,y1,color,opacity,pattern,false). | |
17369 | draw_line(x1,y1,x0,y1,color,opacity,pattern,false). | |
17370 | draw_line(x0,y1,x0,y0,color,opacity,pattern,false); | |
17371 | } | |
17372 | template<typename tc> | |
17373 | CImg<T>& draw_rectangle(const int x0, const int y0, const int x1, const int y1, | |
17374 | const CImg<tc>& color, const float opacity, const unsigned int pattern) { | |
17375 | return draw_rectangle(x0,y0,x1,y1,color.data,opacity,pattern); | |
17376 | } | |
17377 | template<typename tc> | |
17378 | CImg<T>& _draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, | |
17379 | const tc *const color, const float opacity, const float brightness) { | |
17380 | _draw_scanline(color,opacity); | |
17381 | const float nbrightness = brightness<0?0:(brightness>2?2:brightness); | |
17382 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2; | |
17383 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1); | |
17384 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2); | |
17385 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2); | |
17386 | if (ny0<dimy() && ny2>=0) { | |
17387 | if ((nx1-nx0)*(ny2-ny0)-(nx2-nx0)*(ny1-ny0)<0) | |
17388 | for (int y = ny0<0?0:ny0, xr = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), xl = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), _sxn=1, _sxr=1, _sxl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter = (_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errr = _dyr/2, _errl = _dyl/2, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn); _counter>=0; --_counter, ++y, xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), xl+=(y!=ny1)?_rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xl)) _draw_scanline(xl,xr,y,color,opacity,nbrightness); | |
17389 | else | |
17390 | for (int y = ny0<0?0:ny0, xr = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), xl = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), _sxn=1, _sxr=1, _sxl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter = (_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errr = _dyr/2, _errl = _dyl/2, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn); _counter>=0; --_counter, ++y, xr+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), xl+=(y!=ny1)?_rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xl)) _draw_scanline(xr,xl,y,color,opacity,nbrightness); | |
17391 | } | |
17392 | return *this; | |
17393 | } | |
17394 | template<typename tc> | |
17395 | CImg<T>& draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, | |
17396 | const tc *const color, const float opacity=1.0f) { | |
17397 | if (!is_empty()) { | |
17398 | if (!color) throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",pixel_type()); | |
17399 | _draw_triangle(x0,y0,x1,y1,x2,y2,color,opacity,1.0f); | |
17400 | } | |
17401 | return *this; | |
17402 | } | |
17403 | template<typename tc> | |
17404 | CImg<T>& draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, | |
17405 | const CImg<tc>& color, const float opacity=1.0f) { | |
17406 | return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opacity); | |
17407 | } | |
17408 | template<typename tc> | |
17409 | CImg<T>& draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, | |
17410 | const tc *const color, const float opacity, const unsigned int pattern) { | |
17411 | if (!is_empty()) { | |
17412 | if (!color) throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",pixel_type()); | |
17413 | draw_line(x0,y0,x1,y1,color,opacity,pattern,true). | |
17414 | draw_line(x1,y1,x2,y2,color,opacity,pattern,false). | |
17415 | draw_line(x2,y2,x0,y0,color,opacity,pattern,false); | |
17416 | } | |
17417 | return *this; | |
17418 | } | |
17419 | template<typename tc> | |
17420 | CImg<T>& draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, | |
17421 | const CImg<tc>& color, const float opacity, const unsigned int pattern) { | |
17422 | return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opacity,pattern); | |
17423 | } | |
17424 | template<typename tc> | |
17425 | CImg<T>& draw_triangle(const int x0, const int y0, | |
17426 | const int x1, const int y1, | |
17427 | const int x2, const int y2, | |
17428 | const tc *const color, | |
17429 | const float brightness0, | |
17430 | const float brightness1, | |
17431 | const float brightness2, | |
17432 | const float opacity=1.0f) { | |
17433 | if (!is_empty()) { | |
17434 | if (!color) throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",pixel_type()); | |
17435 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max()); | |
17436 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17437 | const int whz = width*height*depth, offx = dim*whz-1; | |
17438 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
17439 | nc0 = (int)((brightness0<0?0:(brightness0>2?2:brightness0))*256), | |
17440 | nc1 = (int)((brightness1<0?0:(brightness1>2?2:brightness1))*256), | |
17441 | nc2 = (int)((brightness2<0?0:(brightness2>2?2:brightness2))*256); | |
17442 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nc0,nc1); | |
17443 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nc0,nc2); | |
17444 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nc1,nc2); | |
17445 | if (ny0<dimy() && ny2>=0) { | |
17446 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), cright0 = ny0>=0?nc0:(nc0-ny0*(nc2-nc0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), cleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nc1:nc0):(nc0-ny0*(nc1-nc0)/(ny1-ny0))):(nc1-ny1*(nc2-nc1)/(ny2-ny1)), _sxn=1, _scn=1, _sxr=1, _scr=1, _sxl=1, _scl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dcn = nc2>nc1?nc2-nc1:(_scn=-1,nc1-nc2), _dcr = nc2>nc0?nc2-nc0:(_scr=-1,nc0-nc2), _dcl = nc1>nc0?nc1-nc0:(_scl=-1,nc0-nc1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dcn-=_dyn?_dyn*(_dcn/_dyn):0, _dcr-=_dyr?_dyr*(_dcr/_dyr):0, _dcl-=_dyl?_dyl*(_dcl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errcn = _errn, _errr = _dyr/2, _errcr = _errr, _errl = _dyl/2, _errcl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rcn = _dyn?(nc2-nc1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rcr = _dyr?(nc2-nc0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rcl = (ny0!=ny1 && ny1>0)?(_dyl?(nc1-nc0)/_dyl:0): (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), cright0+=_rcr+((_errcr-=_dcr)<0?_errcr+=_dyr,_scr:0), xleft0+=(y!=ny1)?(cleft0+=_rcl+((_errcl-=_dcl)<0?(_errcl+=_dyl,_scl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcl=_rcn, cleft0=nc1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
17447 | int xleft = xleft0, xright = xright0, cleft = cleft0, cright = cright0; | |
17448 | if (xright<xleft) cimg::swap(xleft,xright,cleft,cright); | |
17449 | const int | |
17450 | dx = xright-xleft, | |
17451 | dc = cright>cleft?cright-cleft:cleft-cright, | |
17452 | rc = dx?(cright-cleft)/dx:0, | |
17453 | sc = cright>cleft?1:-1, | |
17454 | ndc = dc-(dx?dx*(dc/dx):0); | |
17455 | int errc = dx>>1; | |
17456 | if (xleft<0 && dx) cleft-=xleft*(cright-cleft)/dx; | |
17457 | if (xleft<0) xleft=0; | |
17458 | if (xright>=dimx()-1) xright=dimx()-1; | |
17459 | T* ptrd = ptr(xleft,y,0,0); | |
17460 | if (opacity>=1) for (int x=xleft; x<=xright; ++x) { | |
17461 | const tc *col = color; | |
17462 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17463 | *ptrd = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256); | |
17464 | ptrd+=whz; | |
17465 | } | |
17466 | ptrd-=offx; | |
17467 | cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0); | |
17468 | } else for (int x=xleft; x<=xright; ++x) { | |
17469 | const tc *col = color; | |
17470 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17471 | const T val = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256); | |
17472 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
17473 | ptrd+=whz; | |
17474 | } | |
17475 | ptrd-=offx; | |
17476 | cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0); | |
17477 | } | |
17478 | } | |
17479 | } | |
17480 | } | |
17481 | return *this; | |
17482 | } | |
17483 | template<typename tc> | |
17484 | CImg<T>& draw_triangle(const int x0, const int y0, | |
17485 | const int x1, const int y1, | |
17486 | const int x2, const int y2, | |
17487 | const CImg<tc>& color, | |
17488 | const float brightness0, | |
17489 | const float brightness1, | |
17490 | const float brightness2, | |
17491 | const float opacity=1.0f) { | |
17492 | return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,brightness0,brightness1,brightness2,opacity); | |
17493 | } | |
17494 | template<typename t> CImg<T>& draw_triangle(const int x0, const int y0, | |
17495 | const int x1, const int y1, | |
17496 | const int x2, const int y2, | |
17497 | const CImg<t>& texture, | |
17498 | const int tx0, const int ty0, | |
17499 | const int tx1, const int ty1, | |
17500 | const int tx2, const int ty2, | |
17501 | const float opacity=1.0f, | |
17502 | const float brightness=1.0f) { | |
17503 | if (!is_empty()) { | |
17504 | if (!texture || texture.dim<dim) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
17505 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
17506 | if (is_overlapping(texture)) return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness); | |
17507 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<t>::max()); | |
17508 | const float | |
17509 | nopacity = cimg::abs(opacity), | |
17510 | copacity = 1-cimg::max(opacity,0.0f), | |
17511 | nbrightness = brightness<0?0:(brightness>2?2:brightness); | |
17512 | const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1; | |
17513 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
17514 | ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2; | |
17515 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1); | |
17516 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2); | |
17517 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2); | |
17518 | if (ny0<dimy() && ny2>=0) { | |
17519 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), txright0 = ny0>=0?ntx0:(ntx0-ny0*(ntx2-ntx0)/(ny2-ny0)), tyright0 = ny0>=0?nty0:(nty0-ny0*(nty2-nty0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), txleft0 = ny1>=0?(ny0>=0?(ny0==ny1?ntx1:ntx0):(ntx0-ny0*(ntx1-ntx0)/(ny1-ny0))):(ntx1-ny1*(ntx2-ntx1)/(ny2-ny1)), tyleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nty1:nty0):(nty0-ny0*(nty1-nty0)/(ny1-ny0))):(nty1-ny1*(nty2-nty1)/(ny2-ny1)), _sxn=1, _stxn=1, _styn=1, _sxr=1, _stxr=1, _styr=1, _sxl=1, _stxl=1, _styl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dtxn = ntx2>ntx1?ntx2-ntx1:(_stxn=-1,ntx1-ntx2), _dtxr = ntx2>ntx0?ntx2-ntx0:(_stxr=-1,ntx0-ntx2), _dtxl = ntx1>ntx0?ntx1-ntx0:(_stxl=-1,ntx0-ntx1), _dtyn = nty2>nty1?nty2-nty1:(_styn=-1,nty1-nty2), _dtyr = nty2>nty0?nty2-nty0:(_styr=-1,nty0-nty2), _dtyl = nty1>nty0?nty1-nty0:(_styl=-1,nty0-nty1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errtxn = _errn, _errtyn = _errn, _errr = _dyr/2, _errtxr = _errr, _errtyr = _errr, _errl = _dyl/2, _errtxl = _errl, _errtyl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rtxn = _dyn?(ntx2-ntx1)/_dyn:0, _rtyn = _dyn?(nty2-nty1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rtxr = _dyr?(ntx2-ntx0)/_dyr:0, _rtyr = _dyr?(nty2-nty0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rtxl = (ny0!=ny1 && ny1>0)?(_dyl?(ntx1-ntx0)/_dyl:0): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), _rtyl = (ny0!=ny1 && ny1>0)?(_dyl?(nty1-nty0)/_dyl:0): (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), txright0+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), tyright0+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), xleft0+=(y!=ny1)?(txleft0+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), tyleft0+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, txleft0=ntx1, _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, tyleft0=nty1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
17520 | int | |
17521 | xleft = xleft0, xright = xright0, | |
17522 | txleft = txleft0, txright = txright0, | |
17523 | tyleft = tyleft0, tyright = tyright0; | |
17524 | if (xright<xleft) cimg::swap(xleft,xright,txleft,txright,tyleft,tyright); | |
17525 | const int | |
17526 | dx = xright-xleft, | |
17527 | dtx = txright>txleft?txright-txleft:txleft-txright, | |
17528 | dty = tyright>tyleft?tyright-tyleft:tyleft-tyright, | |
17529 | rtx = dx?(txright-txleft)/dx:0, | |
17530 | rty = dx?(tyright-tyleft)/dx:0, | |
17531 | stx = txright>txleft?1:-1, | |
17532 | sty = tyright>tyleft?1:-1, | |
17533 | ndtx = dtx-(dx?dx*(dtx/dx):0), | |
17534 | ndty = dty-(dx?dx*(dty/dx):0); | |
17535 | int errtx = dx>>1, errty = errtx; | |
17536 | if (xleft<0 && dx) { | |
17537 | txleft-=xleft*(txright-txleft)/dx; | |
17538 | tyleft-=xleft*(tyright-tyleft)/dx; | |
17539 | } | |
17540 | if (xleft<0) xleft=0; | |
17541 | if (xright>=dimx()-1) xright=dimx()-1; | |
17542 | T* ptrd = ptr(xleft,y,0,0); | |
17543 | if (opacity>=1) { | |
17544 | if (nbrightness==1) for (int x=xleft; x<=xright; ++x) { | |
17545 | const t *col = texture.ptr(txleft,tyleft); | |
17546 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17547 | *ptrd = (T)*col; | |
17548 | ptrd+=whz; col+=twhz; | |
17549 | } | |
17550 | ptrd-=offx; | |
17551 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17552 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17553 | } else if (nbrightness<1) for (int x=xleft; x<=xright; ++x) { | |
17554 | const t *col = texture.ptr(txleft,tyleft); | |
17555 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17556 | *ptrd = (T)(nbrightness**col); | |
17557 | ptrd+=whz; col+=twhz; | |
17558 | } | |
17559 | ptrd-=offx; | |
17560 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17561 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17562 | } else for (int x=xleft; x<=xright; ++x) { | |
17563 | const t *col = texture.ptr(txleft,tyleft); | |
17564 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17565 | *ptrd = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval); | |
17566 | ptrd+=whz; col+=twhz; | |
17567 | } | |
17568 | ptrd-=offx; | |
17569 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17570 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17571 | } | |
17572 | } else { | |
17573 | if (nbrightness==1) for (int x=xleft; x<=xright; ++x) { | |
17574 | const t *col = texture.ptr(txleft,tyleft); | |
17575 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17576 | *ptrd = (T)(nopacity**col + *ptrd*copacity); | |
17577 | ptrd+=whz; col+=twhz; | |
17578 | } | |
17579 | ptrd-=offx; | |
17580 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17581 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17582 | } else if (nbrightness<1) for (int x=xleft; x<=xright; ++x) { | |
17583 | const t *col = texture.ptr(txleft,tyleft); | |
17584 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17585 | *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity); | |
17586 | ptrd+=whz; col+=twhz; | |
17587 | } | |
17588 | ptrd-=offx; | |
17589 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17590 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17591 | } else for (int x=xleft; x<=xright; ++x) { | |
17592 | const t *col = texture.ptr(txleft,tyleft); | |
17593 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17594 | const T val = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval); | |
17595 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
17596 | ptrd+=whz; col+=twhz; | |
17597 | } | |
17598 | ptrd-=offx; | |
17599 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17600 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17601 | } | |
17602 | } | |
17603 | } | |
17604 | } | |
17605 | } | |
17606 | return *this; | |
17607 | } | |
17608 | template<typename t> CImg<T>& draw_triangle(const int x0, const int y0, const float z0, | |
17609 | const int x1, const int y1, const float z1, | |
17610 | const int x2, const int y2, const float z2, | |
17611 | const CImg<t>& texture, | |
17612 | const int tx0, const int ty0, | |
17613 | const int tx1, const int ty1, | |
17614 | const int tx2, const int ty2, | |
17615 | const float opacity=1.0f, | |
17616 | const float brightness=1.0f) { | |
17617 | if (!is_empty() && z0>0 && z1>0 && z2>0) { | |
17618 | if (!texture || texture.dim<dim) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
17619 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
17620 | if (is_overlapping(texture)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness); | |
17621 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<t>::max()); | |
17622 | const float | |
17623 | nopacity = cimg::abs(opacity), | |
17624 | copacity = 1-cimg::max(opacity,0.0f), | |
17625 | nbrightness = brightness<0?0:(brightness>2?2:brightness); | |
17626 | const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1; | |
17627 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2; | |
17628 | float | |
17629 | ntx0 = tx0/z0, nty0 = ty0/z0, | |
17630 | ntx1 = tx1/z1, nty1 = ty1/z1, | |
17631 | ntx2 = tx2/z2, nty2 = ty2/z2, | |
17632 | nz0 = 1.0f/z0, nz1 = 1.0f/z1, nz2 = 1.0f/z2; | |
17633 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1); | |
17634 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2); | |
17635 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2); | |
17636 | if (ny0<dimy() && ny2>=0) { | |
17637 | float | |
17638 | ptxl = (ntx1-ntx0)/(ny1-ny0), | |
17639 | ptxr = (ntx2-ntx0)/(ny2-ny0), | |
17640 | ptxn = (ntx2-ntx1)/(ny2-ny1), | |
17641 | ptyl = (nty1-nty0)/(ny1-ny0), | |
17642 | ptyr = (nty2-nty0)/(ny2-ny0), | |
17643 | ptyn = (nty2-nty1)/(ny2-ny1), | |
17644 | pzl = (nz1-nz0)/(ny1-ny0), | |
17645 | pzr = (nz2-nz0)/(ny2-ny0), | |
17646 | pzn = (nz2-nz1)/(ny2-ny1), | |
17647 | zr = ny0>=0?nz0:(nz0-ny0*(nz2-nz0)/(ny2-ny0)), | |
17648 | txr = ny0>=0?ntx0:(ntx0-ny0*(ntx2-ntx0)/(ny2-ny0)), | |
17649 | tyr = ny0>=0?nty0:(nty0-ny0*(nty2-nty0)/(ny2-ny0)), | |
17650 | zl = ny1>=0?(ny0>=0?nz0:(nz0-ny0*(nz1-nz0)/(ny1-ny0))):(pzl=pzn,(nz1-ny1*(nz2-nz1)/(ny2-ny1))), | |
17651 | txl = ny1>=0?(ny0>=0?ntx0:(ntx0-ny0*(ntx1-ntx0)/(ny1-ny0))):(ptxl=ptxn,(ntx1-ny1*(ntx2-ntx1)/(ny2-ny1))), | |
17652 | tyl = ny1>=0?(ny0>=0?nty0:(nty0-ny0*(nty1-nty0)/(ny1-ny0))):(ptyl=ptyn,(nty1-ny1*(nty2-nty1)/(ny2-ny1))); | |
17653 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), _sxn=1, _sxr=1, _sxl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter = (_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errr = _dyr/2, _errl = _dyl/2, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), xleft0+=(y!=ny1)?_rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
17654 | if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; } | |
17655 | int xleft = xleft0, xright = xright0; | |
17656 | float | |
17657 | zleft = zl, zright = zr, | |
17658 | txleft = txl, txright = txr, | |
17659 | tyleft = tyl, tyright = tyr; | |
17660 | if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright); | |
17661 | const int dx = xright-xleft; | |
17662 | const float | |
17663 | pentez = (zright-zleft)/dx, | |
17664 | pentetx = (txright-txleft)/dx, | |
17665 | pentety = (tyright-tyleft)/dx; | |
17666 | if (xleft<0 && dx) { | |
17667 | zleft-=xleft*(zright-zleft)/dx; | |
17668 | txleft-=xleft*(txright-txleft)/dx; | |
17669 | tyleft-=xleft*(tyright-tyleft)/dx; | |
17670 | } | |
17671 | if (xleft<0) xleft=0; | |
17672 | if (xright>=dimx()-1) xright=dimx()-1; | |
17673 | T* ptrd = ptr(xleft,y,0,0); | |
17674 | if (opacity>=1) { | |
17675 | if (nbrightness==1) for (int x=xleft; x<=xright; ++x) { | |
17676 | const float invz = 1.0f/zleft; | |
17677 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17678 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17679 | *ptrd = (T)*col; | |
17680 | ptrd+=whz; col+=twhz; | |
17681 | } | |
17682 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17683 | } else if (nbrightness<1) for (int x=xleft; x<=xright; ++x) { | |
17684 | const float invz = 1.0f/zleft; | |
17685 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17686 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17687 | *ptrd = (T)(nbrightness**col); | |
17688 | ptrd+=whz; col+=twhz; | |
17689 | } | |
17690 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17691 | } else for (int x=xleft; x<=xright; ++x) { | |
17692 | const float invz = 1.0f/zleft; | |
17693 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17694 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17695 | *ptrd = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval); | |
17696 | ptrd+=whz; col+=twhz; | |
17697 | } | |
17698 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17699 | } | |
17700 | } else { | |
17701 | if (nbrightness==1) for (int x=xleft; x<=xright; ++x) { | |
17702 | const float invz = 1.0f/zleft; | |
17703 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17704 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17705 | *ptrd = (T)(nopacity**col + *ptrd*copacity); | |
17706 | ptrd+=whz; col+=twhz; | |
17707 | } | |
17708 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17709 | } else if (nbrightness<1) for (int x=xleft; x<=xright; ++x) { | |
17710 | const float invz = 1.0f/zleft; | |
17711 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17712 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17713 | *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity); | |
17714 | ptrd+=whz; col+=twhz; | |
17715 | } | |
17716 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17717 | } else for (int x=xleft; x<=xright; ++x) { | |
17718 | const float invz = 1.0f/zleft; | |
17719 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17720 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17721 | const T val = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval); | |
17722 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
17723 | ptrd+=whz; col+=twhz; | |
17724 | } | |
17725 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17726 | } | |
17727 | } | |
17728 | zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl; | |
17729 | } | |
17730 | } | |
17731 | } | |
17732 | return *this; | |
17733 | } | |
17734 | template<typename tc, typename t> | |
17735 | CImg<T>& draw_triangle(const int x0, const int y0, | |
17736 | const int x1, const int y1, | |
17737 | const int x2, const int y2, | |
17738 | const tc *const color, | |
17739 | const CImg<t>& light, | |
17740 | const int lx0, const int ly0, | |
17741 | const int lx1, const int ly1, | |
17742 | const int lx2, const int ly2, | |
17743 | const float opacity=1.0f) { | |
17744 | if (!is_empty()) { | |
17745 | if (!color) throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",pixel_type()); | |
17746 | if (!light) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.", | |
17747 | pixel_type(),light.width,light.height,light.depth,light.dim,light.data); | |
17748 | if (is_overlapping(light)) return draw_triangle(x0,y0,x1,y1,x2,y2,color,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity); | |
17749 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max()); | |
17750 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17751 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
17752 | nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2; | |
17753 | const int whz = width*height*depth, offx = dim*whz-1; | |
17754 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nlx0,nlx1,nly0,nly1); | |
17755 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nlx0,nlx2,nly0,nly2); | |
17756 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nlx1,nlx2,nly1,nly2); | |
17757 | if (ny0<dimy() && ny2>=0) { | |
17758 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), lxright0 = ny0>=0?nlx0:(nlx0-ny0*(nlx2-nlx0)/(ny2-ny0)), lyright0 = ny0>=0?nly0:(nly0-ny0*(nly2-nly0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), lxleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nlx1:nlx0):(nlx0-ny0*(nlx1-nlx0)/(ny1-ny0))):(nlx1-ny1*(nlx2-nlx1)/(ny2-ny1)), lyleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nly1:nly0):(nly0-ny0*(nly1-nly0)/(ny1-ny0))):(nly1-ny1*(nly2-nly1)/(ny2-ny1)), _sxn=1, _stxn=1, _styn=1, _sxr=1, _stxr=1, _styr=1, _sxl=1, _stxl=1, _styl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dtxn = nlx2>nlx1?nlx2-nlx1:(_stxn=-1,nlx1-nlx2), _dtxr = nlx2>nlx0?nlx2-nlx0:(_stxr=-1,nlx0-nlx2), _dtxl = nlx1>nlx0?nlx1-nlx0:(_stxl=-1,nlx0-nlx1), _dtyn = nly2>nly1?nly2-nly1:(_styn=-1,nly1-nly2), _dtyr = nly2>nly0?nly2-nly0:(_styr=-1,nly0-nly2), _dtyl = nly1>nly0?nly1-nly0:(_styl=-1,nly0-nly1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errtxn = _errn, _errtyn = _errn, _errr = _dyr/2, _errtxr = _errr, _errtyr = _errr, _errl = _dyl/2, _errtxl = _errl, _errtyl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rtxn = _dyn?(nlx2-nlx1)/_dyn:0, _rtyn = _dyn?(nly2-nly1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rtxr = _dyr?(nlx2-nlx0)/_dyr:0, _rtyr = _dyr?(nly2-nly0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rtxl = (ny0!=ny1 && ny1>0)?(_dyl?(nlx1-nlx0)/_dyl:0): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), _rtyl = (ny0!=ny1 && ny1>0)?(_dyl?(nly1-nly0)/_dyl:0): (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), lxright0+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), lyright0+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), xleft0+=(y!=ny1)?(lxleft0+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), lyleft0+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, lxleft0=nlx1, _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, lyleft0=nly1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
17759 | int | |
17760 | xleft = xleft0, xright = xright0, | |
17761 | lxleft = lxleft0, lxright = lxright0, | |
17762 | lyleft = lyleft0, lyright = lyright0; | |
17763 | if (xright<xleft) cimg::swap(xleft,xright,lxleft,lxright,lyleft,lyright); | |
17764 | const int | |
17765 | dx = xright-xleft, | |
17766 | dlx = lxright>lxleft?lxright-lxleft:lxleft-lxright, | |
17767 | dly = lyright>lyleft?lyright-lyleft:lyleft-lyright, | |
17768 | rlx = dx?(lxright-lxleft)/dx:0, | |
17769 | rly = dx?(lyright-lyleft)/dx:0, | |
17770 | slx = lxright>lxleft?1:-1, | |
17771 | sly = lyright>lyleft?1:-1, | |
17772 | ndlx = dlx-(dx?dx*(dlx/dx):0), | |
17773 | ndly = dly-(dx?dx*(dly/dx):0); | |
17774 | int errlx = dx>>1, errly = errlx; | |
17775 | if (xleft<0 && dx) { | |
17776 | lxleft-=xleft*(lxright-lxleft)/dx; | |
17777 | lyleft-=xleft*(lyright-lyleft)/dx; | |
17778 | } | |
17779 | if (xleft<0) xleft=0; | |
17780 | if (xright>=dimx()-1) xright=dimx()-1; | |
17781 | T* ptrd = ptr(xleft,y,0,0); | |
17782 | if (opacity>=1) for (int x=xleft; x<=xright; ++x) { | |
17783 | const t l = light(lxleft,lyleft); | |
17784 | const tc *col = color; | |
17785 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17786 | *ptrd = (T)(l<1?l**(col++):((2-l)**(col++)+(l-1)*maxval)); | |
17787 | ptrd+=whz; | |
17788 | } | |
17789 | ptrd-=offx; | |
17790 | lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0); | |
17791 | lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0); | |
17792 | } else for (int x=xleft; x<=xright; ++x) { | |
17793 | const t l = light(lxleft,lyleft); | |
17794 | const tc *col = color; | |
17795 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17796 | const T val = (T)(l<1?l**(col++):((2-l)**(col++)+(l-1)*maxval)); | |
17797 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
17798 | ptrd+=whz; | |
17799 | } | |
17800 | ptrd-=offx; | |
17801 | lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0); | |
17802 | lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0); | |
17803 | } | |
17804 | } | |
17805 | } | |
17806 | } | |
17807 | return *this; | |
17808 | } | |
17809 | template<typename tc, typename t> | |
17810 | CImg<T>& draw_triangle(const int x0, const int y0, | |
17811 | const int x1, const int y1, | |
17812 | const int x2, const int y2, | |
17813 | const CImg<tc>& color, | |
17814 | const CImg<t>& light, | |
17815 | const int lx0, const int ly0, | |
17816 | const int lx1, const int ly1, | |
17817 | const int lx2, const int ly2, | |
17818 | const float opacity=1.0f) { | |
17819 | return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity); | |
17820 | } | |
17821 | template<typename t> CImg<T>& draw_triangle(const int x0, const int y0, | |
17822 | const int x1, const int y1, | |
17823 | const int x2, const int y2, | |
17824 | const CImg<t>& texture, | |
17825 | const int tx0, const int ty0, | |
17826 | const int tx1, const int ty1, | |
17827 | const int tx2, const int ty2, | |
17828 | const float brightness0, | |
17829 | const float brightness1, | |
17830 | const float brightness2, | |
17831 | const float opacity=1) { | |
17832 | if (!is_empty()) { | |
17833 | if (!texture || texture.dim<dim) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
17834 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
17835 | if (is_overlapping(texture)) | |
17836 | return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,brightness0,brightness1,brightness2,opacity); | |
17837 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<t>::max()); | |
17838 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17839 | const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1; | |
17840 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
17841 | ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2, | |
17842 | nc0 = (int)((brightness0<0?0:(brightness0>2?2:brightness0))*256), | |
17843 | nc1 = (int)((brightness1<0?0:(brightness1>2?2:brightness1))*256), | |
17844 | nc2 = (int)((brightness2<0?0:(brightness2>2?2:brightness2))*256); | |
17845 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nc0,nc1); | |
17846 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nc0,nc2); | |
17847 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nc1,nc2); | |
17848 | if (ny0<dimy() && ny2>=0) { | |
17849 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), cright0 = ny0>=0?nc0:(nc0-ny0*(nc2-nc0)/(ny2-ny0)), txright0 = ny0>=0?ntx0:(ntx0-ny0*(ntx2-ntx0)/(ny2-ny0)), tyright0 = ny0>=0?nty0:(nty0-ny0*(nty2-nty0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), cleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nc1:nc0):(nc0-ny0*(nc1-nc0)/(ny1-ny0))):(nc1-ny1*(nc2-nc1)/(ny2-ny1)), txleft0 = ny1>=0?(ny0>=0?(ny0==ny1?ntx1:ntx0):(ntx0-ny0*(ntx1-ntx0)/(ny1-ny0))):(ntx1-ny1*(ntx2-ntx1)/(ny2-ny1)), tyleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nty1:nty0):(nty0-ny0*(nty1-nty0)/(ny1-ny0))):(nty1-ny1*(nty2-nty1)/(ny2-ny1)), _sxn=1, _scn=1, _stxn=1, _styn=1, _sxr=1, _scr=1, _stxr=1, _styr=1, _sxl=1, _scl=1, _stxl=1, _styl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dcn = nc2>nc1?nc2-nc1:(_scn=-1,nc1-nc2), _dcr = nc2>nc0?nc2-nc0:(_scr=-1,nc0-nc2), _dcl = nc1>nc0?nc1-nc0:(_scl=-1,nc0-nc1), _dtxn = ntx2>ntx1?ntx2-ntx1:(_stxn=-1,ntx1-ntx2), _dtxr = ntx2>ntx0?ntx2-ntx0:(_stxr=-1,ntx0-ntx2), _dtxl = ntx1>ntx0?ntx1-ntx0:(_stxl=-1,ntx0-ntx1), _dtyn = nty2>nty1?nty2-nty1:(_styn=-1,nty1-nty2), _dtyr = nty2>nty0?nty2-nty0:(_styr=-1,nty0-nty2), _dtyl = nty1>nty0?nty1-nty0:(_styl=-1,nty0-nty1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dcn-=_dyn?_dyn*(_dcn/_dyn):0, _dcr-=_dyr?_dyr*(_dcr/_dyr):0, _dcl-=_dyl?_dyl*(_dcl/_dyl):0, _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errcn = _errn, _errtxn = _errn, _errtyn = _errn, _errr = _dyr/2, _errcr = _errr, _errtxr = _errr, _errtyr = _errr, _errl = _dyl/2, _errcl = _errl, _errtxl = _errl, _errtyl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rcn = _dyn?(nc2-nc1)/_dyn:0, _rtxn = _dyn?(ntx2-ntx1)/_dyn:0, _rtyn = _dyn?(nty2-nty1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rcr = _dyr?(nc2-nc0)/_dyr:0, _rtxr = _dyr?(ntx2-ntx0)/_dyr:0, _rtyr = _dyr?(nty2-nty0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rcl = (ny0!=ny1 && ny1>0)?(_dyl?(nc1-nc0)/_dyl:0): (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcn ), _rtxl = (ny0!=ny1 && ny1>0)?(_dyl?(ntx1-ntx0)/_dyl:0): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), _rtyl = (ny0!=ny1 && ny1>0)?(_dyl?(nty1-nty0)/_dyl:0): (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), cright0+=_rcr+((_errcr-=_dcr)<0?_errcr+=_dyr,_scr:0), txright0+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), tyright0+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), xleft0+=(y!=ny1)?(cleft0+=_rcl+((_errcl-=_dcl)<0?(_errcl+=_dyl,_scl):0), txleft0+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), tyleft0+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcl=_rcn, cleft0=nc1, _errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, txleft0=ntx1, _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, tyleft0=nty1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
17850 | int | |
17851 | xleft = xleft0, xright = xright0, | |
17852 | cleft = cleft0, cright = cright0, | |
17853 | txleft = txleft0, txright = txright0, | |
17854 | tyleft = tyleft0, tyright = tyright0; | |
17855 | if (xright<xleft) cimg::swap(xleft,xright,cleft,cright,txleft,txright,tyleft,tyright); | |
17856 | const int | |
17857 | dx = xright-xleft, | |
17858 | dc = cright>cleft?cright-cleft:cleft-cright, | |
17859 | dtx = txright>txleft?txright-txleft:txleft-txright, | |
17860 | dty = tyright>tyleft?tyright-tyleft:tyleft-tyright, | |
17861 | rc = dx?(cright-cleft)/dx:0, | |
17862 | rtx = dx?(txright-txleft)/dx:0, | |
17863 | rty = dx?(tyright-tyleft)/dx:0, | |
17864 | sc = cright>cleft?1:-1, | |
17865 | stx = txright>txleft?1:-1, | |
17866 | sty = tyright>tyleft?1:-1, | |
17867 | ndc = dc-(dx?dx*(dc/dx):0), | |
17868 | ndtx = dtx-(dx?dx*(dtx/dx):0), | |
17869 | ndty = dty-(dx?dx*(dty/dx):0); | |
17870 | int errc = dx>>1, errtx = errc, errty = errc; | |
17871 | if (xleft<0 && dx) { | |
17872 | cleft-=xleft*(cright-cleft)/dx; | |
17873 | txleft-=xleft*(txright-txleft)/dx; | |
17874 | tyleft-=xleft*(tyright-tyleft)/dx; | |
17875 | } | |
17876 | if (xleft<0) xleft=0; | |
17877 | if (xright>=dimx()-1) xright=dimx()-1; | |
17878 | T* ptrd = ptr(xleft,y,0,0); | |
17879 | if (opacity>=1) for (int x=xleft; x<=xright; ++x) { | |
17880 | const t *col = texture.ptr(txleft,tyleft); | |
17881 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17882 | *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256); | |
17883 | ptrd+=whz; col+=twhz; | |
17884 | } | |
17885 | ptrd-=offx; | |
17886 | cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0); | |
17887 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17888 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17889 | } else for (int x=xleft; x<=xright; ++x) { | |
17890 | const t *col = texture.ptr(txleft,tyleft); | |
17891 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17892 | const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256); | |
17893 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
17894 | ptrd+=whz; col+=twhz; | |
17895 | } | |
17896 | ptrd-=offx; | |
17897 | cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0); | |
17898 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
17899 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
17900 | } | |
17901 | } | |
17902 | } | |
17903 | } | |
17904 | return *this; | |
17905 | } | |
17906 | template<typename t> CImg<T>& draw_triangle(const int x0, const int y0, const float z0, | |
17907 | const int x1, const int y1, const float z1, | |
17908 | const int x2, const int y2, const float z2, | |
17909 | const CImg<t>& texture, | |
17910 | const int tx0, const int ty0, | |
17911 | const int tx1, const int ty1, | |
17912 | const int tx2, const int ty2, | |
17913 | const float c0, | |
17914 | const float c1, | |
17915 | const float c2, | |
17916 | const float opacity=1.0f) { | |
17917 | if (!is_empty() && z0>0 && z1>0 && z2>0) { | |
17918 | if (!texture || texture.dim<dim) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
17919 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
17920 | if (is_overlapping(texture)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,c0,c1,c2,opacity); | |
17921 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<t>::max()); | |
17922 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
17923 | const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1; | |
17924 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
17925 | nc0 = (int)(c0*256), nc1 = (int)(c1*256), nc2 = (int)(c2*256); | |
17926 | float | |
17927 | ntx0 = tx0/z0, nty0 = ty0/z0, | |
17928 | ntx1 = tx1/z1, nty1 = ty1/z1, | |
17929 | ntx2 = tx2/z2, nty2 = ty2/z2, | |
17930 | nz0 = 1.0f/z0, nz1 = 1.0f/z1, nz2 = 1.0f/z2; | |
17931 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1,nc0,nc1); | |
17932 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2,nc0,nc2); | |
17933 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2,nc1,nc2); | |
17934 | if (ny0<dimy() && ny2>=0) { | |
17935 | float | |
17936 | ptxl = (ntx1-ntx0)/(ny1-ny0), | |
17937 | ptxr = (ntx2-ntx0)/(ny2-ny0), | |
17938 | ptxn = (ntx2-ntx1)/(ny2-ny1), | |
17939 | ptyl = (nty1-nty0)/(ny1-ny0), | |
17940 | ptyr = (nty2-nty0)/(ny2-ny0), | |
17941 | ptyn = (nty2-nty1)/(ny2-ny1), | |
17942 | pzl = (nz1-nz0)/(ny1-ny0), | |
17943 | pzr = (nz2-nz0)/(ny2-ny0), | |
17944 | pzn = (nz2-nz1)/(ny2-ny1), | |
17945 | zr = ny0>=0?nz0:(nz0-ny0*(nz2-nz0)/(ny2-ny0)), | |
17946 | txr = ny0>=0?ntx0:(ntx0-ny0*(ntx2-ntx0)/(ny2-ny0)), | |
17947 | tyr = ny0>=0?nty0:(nty0-ny0*(nty2-nty0)/(ny2-ny0)), | |
17948 | zl = ny1>=0?(ny0>=0?nz0:(nz0-ny0*(nz1-nz0)/(ny1-ny0))):(pzl=pzn,(nz1-ny1*(nz2-nz1)/(ny2-ny1))), | |
17949 | txl = ny1>=0?(ny0>=0?ntx0:(ntx0-ny0*(ntx1-ntx0)/(ny1-ny0))):(ptxl=ptxn,(ntx1-ny1*(ntx2-ntx1)/(ny2-ny1))), | |
17950 | tyl = ny1>=0?(ny0>=0?nty0:(nty0-ny0*(nty1-nty0)/(ny1-ny0))):(ptyl=ptyn,(nty1-ny1*(nty2-nty1)/(ny2-ny1))); | |
17951 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), cright0 = ny0>=0?nc0:(nc0-ny0*(nc2-nc0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), cleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nc1:nc0):(nc0-ny0*(nc1-nc0)/(ny1-ny0))):(nc1-ny1*(nc2-nc1)/(ny2-ny1)), _sxn=1, _scn=1, _sxr=1, _scr=1, _sxl=1, _scl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dcn = nc2>nc1?nc2-nc1:(_scn=-1,nc1-nc2), _dcr = nc2>nc0?nc2-nc0:(_scr=-1,nc0-nc2), _dcl = nc1>nc0?nc1-nc0:(_scl=-1,nc0-nc1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dcn-=_dyn?_dyn*(_dcn/_dyn):0, _dcr-=_dyr?_dyr*(_dcr/_dyr):0, _dcl-=_dyl?_dyl*(_dcl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errcn = _errn, _errr = _dyr/2, _errcr = _errr, _errl = _dyl/2, _errcl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rcn = _dyn?(nc2-nc1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rcr = _dyr?(nc2-nc0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rcl = (ny0!=ny1 && ny1>0)?(_dyl?(nc1-nc0)/_dyl:0): (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), cright0+=_rcr+((_errcr-=_dcr)<0?_errcr+=_dyr,_scr:0), xleft0+=(y!=ny1)?(cleft0+=_rcl+((_errcl-=_dcl)<0?(_errcl+=_dyl,_scl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errcl=_errcn, _dcl=_dcn, _dyl=_dyn, _scl=_scn, _rcl=_rcn, cleft0=nc1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
17952 | if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; } | |
17953 | int | |
17954 | xleft = xleft0, xright = xright0, | |
17955 | cleft = cleft0, cright = cright0; | |
17956 | float | |
17957 | zleft = zl, zright = zr, | |
17958 | txleft = txl, txright = txr, | |
17959 | tyleft = tyl, tyright = tyr; | |
17960 | if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,cleft,cright); | |
17961 | const int | |
17962 | dx = xright-xleft, | |
17963 | dc = cright>cleft?cright-cleft:cleft-cright, | |
17964 | rc = dx?(cright-cleft)/dx:0, | |
17965 | sc = cright>cleft?1:-1, | |
17966 | ndc = dc-(dx?dx*(dc/dx):0); | |
17967 | const float | |
17968 | pentez = (zright-zleft)/dx, | |
17969 | pentetx = (txright-txleft)/dx, | |
17970 | pentety = (tyright-tyleft)/dx; | |
17971 | int errc = dx>>1; | |
17972 | if (xleft<0 && dx) { | |
17973 | cleft-=xleft*(cright-cleft)/dx; | |
17974 | zleft-=xleft*(zright-zleft)/dx; | |
17975 | txleft-=xleft*(txright-txleft)/dx; | |
17976 | tyleft-=xleft*(tyright-tyleft)/dx; | |
17977 | } | |
17978 | if (xleft<0) xleft=0; | |
17979 | if (xright>=dimx()-1) xright=dimx()-1; | |
17980 | T* ptrd = ptr(xleft,y,0,0); | |
17981 | if (opacity>=1) for (int x=xleft; x<=xright; ++x) { | |
17982 | const float invz = 1.0f/zleft; | |
17983 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17984 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17985 | *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256); | |
17986 | ptrd+=whz; col+=twhz; | |
17987 | } | |
17988 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17989 | cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0); | |
17990 | } else for (int x=xleft; x<=xright; ++x) { | |
17991 | const float invz = 1.0f/zleft; | |
17992 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
17993 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
17994 | const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256); | |
17995 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
17996 | ptrd+=whz; col+=twhz; | |
17997 | } | |
17998 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
17999 | cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0); | |
18000 | } | |
18001 | zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl; | |
18002 | } | |
18003 | } | |
18004 | } | |
18005 | return *this; | |
18006 | } | |
18007 | template<typename t, typename tl> CImg<T>& draw_triangle(const int x0, const int y0, | |
18008 | const int x1, const int y1, | |
18009 | const int x2, const int y2, | |
18010 | const CImg<t>& texture, | |
18011 | const int tx0, const int ty0, | |
18012 | const int tx1, const int ty1, | |
18013 | const int tx2, const int ty2, | |
18014 | const CImg<tl>& light, | |
18015 | const int lx0, const int ly0, | |
18016 | const int lx1, const int ly1, | |
18017 | const int lx2, const int ly2, | |
18018 | const float opacity=1.0f) { | |
18019 | if (!is_empty()) { | |
18020 | if (!texture || texture.dim<dim) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
18021 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
18022 | if (!light) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.", | |
18023 | pixel_type(),light.width,light.height,light.depth,light.dim,light.data); | |
18024 | if (is_overlapping(texture)) return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity); | |
18025 | if (is_overlapping(light)) return draw_triangle(x0,y0,x1,y1,x2,y2,texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity); | |
18026 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<t>::max()); | |
18027 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
18028 | const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1; | |
18029 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
18030 | ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2, | |
18031 | nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2; | |
18032 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1); | |
18033 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2); | |
18034 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2); | |
18035 | if (ny0<dimy() && ny2>=0) { | |
18036 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), lxright0 = ny0>=0?nlx0:(nlx0-ny0*(nlx2-nlx0)/(ny2-ny0)), lyright0 = ny0>=0?nly0:(nly0-ny0*(nly2-nly0)/(ny2-ny0)), txright0 = ny0>=0?ntx0:(ntx0-ny0*(ntx2-ntx0)/(ny2-ny0)), tyright0 = ny0>=0?nty0:(nty0-ny0*(nty2-nty0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), lxleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nlx1:nlx0):(nlx0-ny0*(nlx1-nlx0)/(ny1-ny0))):(nlx1-ny1*(nlx2-nlx1)/(ny2-ny1)), lyleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nly1:nly0):(nly0-ny0*(nly1-nly0)/(ny1-ny0))):(nly1-ny1*(nly2-nly1)/(ny2-ny1)), txleft0 = ny1>=0?(ny0>=0?(ny0==ny1?ntx1:ntx0):(ntx0-ny0*(ntx1-ntx0)/(ny1-ny0))):(ntx1-ny1*(ntx2-ntx1)/(ny2-ny1)), tyleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nty1:nty0):(nty0-ny0*(nty1-nty0)/(ny1-ny0))):(nty1-ny1*(nty2-nty1)/(ny2-ny1)), _sxn=1, _stxn=1, _styn=1, _slxn=1, _slyn=1, _sxr=1, _stxr=1, _styr=1, _slxr=1, _slyr=1, _sxl=1, _stxl=1, _styl=1, _slxl=1, _slyl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dyn = ny2-ny1, _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dyr = ny2-ny0, _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dyl = ny1-ny0, _dtxn = nlx2>nlx1?nlx2-nlx1:(_stxn=-1,nlx1-nlx2), _dtxr = nlx2>nlx0?nlx2-nlx0:(_stxr=-1,nlx0-nlx2), _dtxl = nlx1>nlx0?nlx1-nlx0:(_stxl=-1,nlx0-nlx1), _dtyn = nly2>nly1?nly2-nly1:(_styn=-1,nly1-nly2), _dtyr = nly2>nly0?nly2-nly0:(_styr=-1,nly0-nly2), _dtyl = nly1>nly0?nly1-nly0:(_styl=-1,nly0-nly1), _dlxn = ntx2>ntx1?ntx2-ntx1:(_slxn=-1,ntx1-ntx2), _dlxr = ntx2>ntx0?ntx2-ntx0:(_slxr=-1,ntx0-ntx2), _dlxl = ntx1>ntx0?ntx1-ntx0:(_slxl=-1,ntx0-ntx1), _dlyn = nty2>nty1?nty2-nty1:(_slyn=-1,nty1-nty2), _dlyr = nty2>nty0?nty2-nty0:(_slyr=-1,nty0-nty2), _dlyl = nty1>nty0?nty1-nty0:(_slyl=-1,nty0-nty1), _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, _dlxn-=_dyn?_dyn*(_dlxn/_dyn):0, _dlxr-=_dyr?_dyr*(_dlxr/_dyr):0, _dlxl-=_dyl?_dyl*(_dlxl/_dyl):0, _dlyn-=_dyn?_dyn*(_dlyn/_dyn):0, _dlyr-=_dyr?_dyr*(_dlyr/_dyr):0, _dlyl-=_dyl?_dyl*(_dlyl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errtxn = _errn, _errtyn = _errn, _errlxn = _errn, _errlyn = _errn, _errr = _dyr/2, _errtxr = _errr, _errtyr = _errr, _errlxr = _errr, _errlyr = _errr, _errl = _dyl/2, _errtxl = _errl, _errtyl = _errl, _errlxl = _errl, _errlyl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rtxn = _dyn?(nlx2-nlx1)/_dyn:0, _rtyn = _dyn?(nly2-nly1)/_dyn:0, _rlxn = _dyn?(ntx2-ntx1)/_dyn:0, _rlyn = _dyn?(nty2-nty1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rtxr = _dyr?(nlx2-nlx0)/_dyr:0, _rtyr = _dyr?(nly2-nly0)/_dyr:0, _rlxr = _dyr?(ntx2-ntx0)/_dyr:0, _rlyr = _dyr?(nty2-nty0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rtxl = (ny0!=ny1 && ny1>0)?(_dyl?(nlx1-nlx0)/_dyl:0): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), _rtyl = (ny0!=ny1 && ny1>0)?(_dyl?(nly1-nly0)/_dyl:0): (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ), _rlxl = (ny0!=ny1 && ny1>0)?(_dyl?(ntx1-ntx0)/_dyl:0): (_errlxl=_errlxn, _dlxl=_dlxn, _dyl=_dyn, _slxl=_slxn, _rlxn ), _rlyl = (ny0!=ny1 && ny1>0)?(_dyl?(nty1-nty0)/_dyl:0): (_errlyl=_errlyn, _dlyl=_dlyn, _dyl=_dyn, _slyl=_slyn, _rlyn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), lxright0+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), lyright0+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), txright0+=_rlxr+((_errlxr-=_dlxr)<0?_errlxr+=_dyr,_slxr:0), tyright0+=_rlyr+((_errlyr-=_dlyr)<0?_errlyr+=_dyr,_slyr:0), xleft0+=(y!=ny1)?(lxleft0+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), lyleft0+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), txleft0+=_rlxl+((_errlxl-=_dlxl)<0?(_errlxl+=_dyl,_slxl):0), tyleft0+=_rlyl+((_errlyl-=_dlyl)<0?(_errlyl+=_dyl,_slyl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, lxleft0=nlx1, _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, lyleft0=nly1, _errlxl=_errlxn, _dlxl=_dlxn, _dyl=_dyn, _slxl=_slxn, _rlxl=_rlxn, txleft0=ntx1, _errlyl=_errlyn, _dlyl=_dlyn, _dyl=_dyn, _slyl=_slyn, _rlyl=_rlyn, tyleft0=nty1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
18037 | int | |
18038 | xleft = xleft0, xright = xright0, | |
18039 | lxleft = lxleft0, lxright = lxright0, | |
18040 | lyleft = lyleft0, lyright = lyright0, | |
18041 | txleft = txleft0, txright = txright0, | |
18042 | tyleft = tyleft0, tyright = tyright0; | |
18043 | if (xright<xleft) cimg::swap(xleft,xright,lxleft,lxright,lyleft,lyright,txleft,txright,tyleft,tyright); | |
18044 | const int | |
18045 | dx = xright-xleft, | |
18046 | dlx = lxright>lxleft?lxright-lxleft:lxleft-lxright, | |
18047 | dly = lyright>lyleft?lyright-lyleft:lyleft-lyright, | |
18048 | dtx = txright>txleft?txright-txleft:txleft-txright, | |
18049 | dty = tyright>tyleft?tyright-tyleft:tyleft-tyright, | |
18050 | rlx = dx?(lxright-lxleft)/dx:0, | |
18051 | rly = dx?(lyright-lyleft)/dx:0, | |
18052 | rtx = dx?(txright-txleft)/dx:0, | |
18053 | rty = dx?(tyright-tyleft)/dx:0, | |
18054 | slx = lxright>lxleft?1:-1, | |
18055 | sly = lyright>lyleft?1:-1, | |
18056 | stx = txright>txleft?1:-1, | |
18057 | sty = tyright>tyleft?1:-1, | |
18058 | ndlx = dlx-(dx?dx*(dlx/dx):0), | |
18059 | ndly = dly-(dx?dx*(dly/dx):0), | |
18060 | ndtx = dtx-(dx?dx*(dtx/dx):0), | |
18061 | ndty = dty-(dx?dx*(dty/dx):0); | |
18062 | int errlx = dx>>1, errly = errlx, errtx = errlx, errty = errlx; | |
18063 | if (xleft<0 && dx) { | |
18064 | lxleft-=xleft*(lxright-lxleft)/dx; | |
18065 | lyleft-=xleft*(lyright-lyleft)/dx; | |
18066 | txleft-=xleft*(txright-txleft)/dx; | |
18067 | tyleft-=xleft*(tyright-tyleft)/dx; | |
18068 | } | |
18069 | if (xleft<0) xleft=0; | |
18070 | if (xright>=dimx()-1) xright=dimx()-1; | |
18071 | T* ptrd = ptr(xleft,y,0,0); | |
18072 | if (opacity>=1) for (int x=xleft; x<=xright; ++x) { | |
18073 | const tl l = light(lxleft,lyleft); | |
18074 | const t *col = texture.ptr(txleft,tyleft); | |
18075 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
18076 | *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval); | |
18077 | ptrd+=whz; col+=twhz; | |
18078 | } | |
18079 | ptrd-=offx; | |
18080 | lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0); | |
18081 | lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0); | |
18082 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
18083 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
18084 | } else for (int x=xleft; x<=xright; ++x) { | |
18085 | const tl l = light(lxleft,lyleft); | |
18086 | const t *col = texture.ptr(txleft,tyleft); | |
18087 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
18088 | const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval); | |
18089 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
18090 | ptrd+=whz; col+=twhz; | |
18091 | } | |
18092 | ptrd-=offx; | |
18093 | lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0); | |
18094 | lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0); | |
18095 | txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0); | |
18096 | tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0); | |
18097 | } | |
18098 | } | |
18099 | } | |
18100 | } | |
18101 | return *this; | |
18102 | } | |
18103 | template<typename t, typename tl> CImg<T>& draw_triangle(const int x0, const int y0, const float z0, | |
18104 | const int x1, const int y1, const float z1, | |
18105 | const int x2, const int y2, const float z2, | |
18106 | const CImg<t>& texture, | |
18107 | const int tx0, const int ty0, | |
18108 | const int tx1, const int ty1, | |
18109 | const int tx2, const int ty2, | |
18110 | const CImg<tl>& light, | |
18111 | const int lx0, const int ly0, | |
18112 | const int lx1, const int ly1, | |
18113 | const int lx2, const int ly2, | |
18114 | const float opacity=1.0f) { | |
18115 | if (!is_empty() && z0>0 && z1>0 && z2>0) { | |
18116 | if (!texture || texture.dim<dim) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.", | |
18117 | pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data); | |
18118 | if (!light) throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.", | |
18119 | pixel_type(),light.width,light.height,light.depth,light.dim,light.data); | |
18120 | if (is_overlapping(texture)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity); | |
18121 | if (is_overlapping(light)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity); | |
18122 | static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<t>::max()); | |
18123 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
18124 | const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1; | |
18125 | int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2, | |
18126 | nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2; | |
18127 | float | |
18128 | ntx0 = tx0/z0, nty0 = ty0/z0, | |
18129 | ntx1 = tx1/z1, nty1 = ty1/z1, | |
18130 | ntx2 = tx2/z2, nty2 = ty2/z2, | |
18131 | nz0 = 1.0f/z0, nz1 = 1.0f/z1, nz2 = 1.0f/z2; | |
18132 | if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1,nz0,nz1); | |
18133 | if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2,nz0,nz2); | |
18134 | if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2,nz1,nz2); | |
18135 | if (ny0<dimy() && ny2>=0) { | |
18136 | float | |
18137 | ptxl = (ntx1-ntx0)/(ny1-ny0), | |
18138 | ptxr = (ntx2-ntx0)/(ny2-ny0), | |
18139 | ptxn = (ntx2-ntx1)/(ny2-ny1), | |
18140 | ptyl = (nty1-nty0)/(ny1-ny0), | |
18141 | ptyr = (nty2-nty0)/(ny2-ny0), | |
18142 | ptyn = (nty2-nty1)/(ny2-ny1), | |
18143 | pzl = (nz1-nz0)/(ny1-ny0), | |
18144 | pzr = (nz2-nz0)/(ny2-ny0), | |
18145 | pzn = (nz2-nz1)/(ny2-ny1), | |
18146 | zr = ny0>=0?nz0:(nz0-ny0*(nz2-nz0)/(ny2-ny0)), | |
18147 | txr = ny0>=0?ntx0:(ntx0-ny0*(ntx2-ntx0)/(ny2-ny0)), | |
18148 | tyr = ny0>=0?nty0:(nty0-ny0*(nty2-nty0)/(ny2-ny0)), | |
18149 | zl = ny1>=0?(ny0>=0?nz0:(nz0-ny0*(nz1-nz0)/(ny1-ny0))):(pzl=pzn,(nz1-ny1*(nz2-nz1)/(ny2-ny1))), | |
18150 | txl = ny1>=0?(ny0>=0?ntx0:(ntx0-ny0*(ntx1-ntx0)/(ny1-ny0))):(ptxl=ptxn,(ntx1-ny1*(ntx2-ntx1)/(ny2-ny1))), | |
18151 | tyl = ny1>=0?(ny0>=0?nty0:(nty0-ny0*(nty1-nty0)/(ny1-ny0))):(ptyl=ptyn,(nty1-ny1*(nty2-nty1)/(ny2-ny1))); | |
18152 | for (int y = ny0<0?0:ny0, xright0 = ny0>=0?nx0:(nx0-ny0*(nx2-nx0)/(ny2-ny0)), lxright0 = ny0>=0?nlx0:(nlx0-ny0*(nlx2-nlx0)/(ny2-ny0)), lyright0 = ny0>=0?nly0:(nly0-ny0*(nly2-nly0)/(ny2-ny0)), xleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nx1:nx0):(nx0-ny0*(nx1-nx0)/(ny1-ny0))):(nx1-ny1*(nx2-nx1)/(ny2-ny1)), lxleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nlx1:nlx0):(nlx0-ny0*(nlx1-nlx0)/(ny1-ny0))):(nlx1-ny1*(nlx2-nlx1)/(ny2-ny1)), lyleft0 = ny1>=0?(ny0>=0?(ny0==ny1?nly1:nly0):(nly0-ny0*(nly1-nly0)/(ny1-ny0))):(nly1-ny1*(nly2-nly1)/(ny2-ny1)), _sxn=1, _stxn=1, _styn=1, _sxr=1, _stxr=1, _styr=1, _sxl=1, _stxl=1, _styl=1, _dxn = nx2>nx1?nx2-nx1:(_sxn=-1,nx1-nx2), _dxr = nx2>nx0?nx2-nx0:(_sxr=-1,nx0-nx2), _dxl = nx1>nx0?nx1-nx0:(_sxl=-1,nx0-nx1), _dtxn = nlx2>nlx1?nlx2-nlx1:(_stxn=-1,nlx1-nlx2), _dtxr = nlx2>nlx0?nlx2-nlx0:(_stxr=-1,nlx0-nlx2), _dtxl = nlx1>nlx0?nlx1-nlx0:(_stxl=-1,nlx0-nlx1), _dtyn = nly2>nly1?nly2-nly1:(_styn=-1,nly1-nly2), _dtyr = nly2>nly0?nly2-nly0:(_styr=-1,nly0-nly2), _dtyl = nly1>nly0?nly1-nly0:(_styl=-1,nly0-nly1), _dyn = ny2-ny1, _dyr = ny2-ny0, _dyl = ny1-ny0, _counter =(_dxn-=_dyn?_dyn*(_dxn/_dyn):0, _dxr-=_dyr?_dyr*(_dxr/_dyr):0, _dxl-=_dyl?_dyl*(_dxl/_dyl):0, _dtxn-=_dyn?_dyn*(_dtxn/_dyn):0, _dtxr-=_dyr?_dyr*(_dtxr/_dyr):0, _dtxl-=_dyl?_dyl*(_dtxl/_dyl):0, _dtyn-=_dyn?_dyn*(_dtyn/_dyn):0, _dtyr-=_dyr?_dyr*(_dtyr/_dyr):0, _dtyl-=_dyl?_dyl*(_dtyl/_dyl):0, cimg::min((int)(*this).height-y-1,ny2-y)), _errn = _dyn/2, _errtxn = _errn, _errtyn = _errn, _errr = _dyr/2, _errtxr = _errr, _errtyr = _errr, _errl = _dyl/2, _errtxl = _errl, _errtyl = _errl, _rxn = _dyn?(nx2-nx1)/_dyn:0, _rtxn = _dyn?(nlx2-nlx1)/_dyn:0, _rtyn = _dyn?(nly2-nly1)/_dyn:0, _rxr = _dyr?(nx2-nx0)/_dyr:0, _rtxr = _dyr?(nlx2-nlx0)/_dyr:0, _rtyr = _dyr?(nly2-nly0)/_dyr:0, _rxl = (ny0!=ny1 && ny1>0)?(_dyl?(nx1-nx0)/_dyl:0): (_errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxn), _rtxl = (ny0!=ny1 && ny1>0)?(_dyl?(nlx1-nlx0)/_dyl:0): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxn ), _rtyl = (ny0!=ny1 && ny1>0)?(_dyl?(nly1-nly0)/_dyl:0): (_errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyn ); _counter>=0; --_counter, ++y, xright0+=_rxr+((_errr-=_dxr)<0?_errr+=_dyr,_sxr:0), lxright0+=_rtxr+((_errtxr-=_dtxr)<0?_errtxr+=_dyr,_stxr:0), lyright0+=_rtyr+((_errtyr-=_dtyr)<0?_errtyr+=_dyr,_styr:0), xleft0+=(y!=ny1)?(lxleft0+=_rtxl+((_errtxl-=_dtxl)<0?(_errtxl+=_dyl,_stxl):0), lyleft0+=_rtyl+((_errtyl-=_dtyl)<0?(_errtyl+=_dyl,_styl):0), _rxl+((_errl-=_dxl)<0?(_errl+=_dyl,_sxl):0)): (_errtxl=_errtxn, _dtxl=_dtxn, _dyl=_dyn, _stxl=_stxn, _rtxl=_rtxn, lxleft0=nlx1, _errtyl=_errtyn, _dtyl=_dtyn, _dyl=_dyn, _styl=_styn, _rtyl=_rtyn, lyleft0=nly1, _errl=_errn, _dxl=_dxn, _dyl=_dyn, _sxl=_sxn, _rxl=_rxn, nx1-xleft0)) { | |
18153 | if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; } | |
18154 | int | |
18155 | xleft = xleft0, xright = xright0, | |
18156 | lxleft = lxleft0, lxright = lxright0, | |
18157 | lyleft = lyleft0, lyright = lyright0; | |
18158 | float | |
18159 | zleft = zl, zright = zr, | |
18160 | txleft = txl, txright = txr, | |
18161 | tyleft = tyl, tyright = tyr; | |
18162 | if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,lxleft,lxright,lyleft,lyright); | |
18163 | const int | |
18164 | dx = xright-xleft, | |
18165 | dlx = lxright>lxleft?lxright-lxleft:lxleft-lxright, | |
18166 | dly = lyright>lyleft?lyright-lyleft:lyleft-lyright, | |
18167 | rlx = dx?(lxright-lxleft)/dx:0, | |
18168 | rly = dx?(lyright-lyleft)/dx:0, | |
18169 | slx = lxright>lxleft?1:-1, | |
18170 | sly = lyright>lyleft?1:-1, | |
18171 | ndlx = dlx-(dx?dx*(dlx/dx):0), | |
18172 | ndly = dly-(dx?dx*(dly/dx):0); | |
18173 | const float | |
18174 | pentez = (zright-zleft)/dx, | |
18175 | pentetx = (txright-txleft)/dx, | |
18176 | pentety = (tyright-tyleft)/dx; | |
18177 | int errlx = dx>>1, errly = errlx; | |
18178 | if (xleft<0 && dx) { | |
18179 | zleft-=xleft*(zright-zleft)/dx; | |
18180 | lxleft-=xleft*(lxright-lxleft)/dx; | |
18181 | lyleft-=xleft*(lyright-lyleft)/dx; | |
18182 | txleft-=xleft*(txright-txleft)/dx; | |
18183 | tyleft-=xleft*(tyright-tyleft)/dx; | |
18184 | } | |
18185 | if (xleft<0) xleft=0; | |
18186 | if (xright>=dimx()-1) xright=dimx()-1; | |
18187 | T* ptrd = ptr(xleft,y,0,0); | |
18188 | if (opacity>=1) for (int x=xleft; x<=xright; ++x) { | |
18189 | const float invz = 1.0f/zleft; | |
18190 | const tl l = light(lxleft,lyleft); | |
18191 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
18192 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
18193 | *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval); | |
18194 | ptrd+=whz; col+=twhz; | |
18195 | } | |
18196 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
18197 | lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0); | |
18198 | lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0); | |
18199 | } else for (int x=xleft; x<=xright; ++x) { | |
18200 | const float invz = 1.0f/zleft; | |
18201 | const tl l = light(lxleft,lyleft); | |
18202 | const t *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz)); | |
18203 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
18204 | const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval); | |
18205 | *ptrd = (T)(nopacity*val + *ptrd*copacity); | |
18206 | ptrd+=whz; col+=twhz; | |
18207 | } | |
18208 | ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety; | |
18209 | lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0); | |
18210 | lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0); | |
18211 | } | |
18212 | zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl; | |
18213 | } | |
18214 | } | |
18215 | } | |
18216 | return *this; | |
18217 | } | |
18218 | template<typename tc> | |
18219 | CImg<T>& _draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float ru, const float rv, | |
18220 | const tc *const color, const float opacity, const unsigned int pattern) { | |
18221 | if (!is_empty()) { | |
18222 | if (!color) throw CImgArgumentException("CImg<%s>::draw_ellipse : Specified color is (null).",pixel_type()); | |
18223 | _draw_scanline(color,opacity); | |
18224 | const float | |
18225 | nr1 = cimg::abs(r1), nr2 = cimg::abs(r2), | |
18226 | norm = (float)std::sqrt(ru*ru+rv*rv), | |
18227 | u = norm>0?ru/norm:1, | |
18228 | v = norm>0?rv/norm:0, | |
18229 | rmax = cimg::max(nr1,nr2), | |
18230 | l1 = (float)std::pow(rmax/(nr1>0?nr1:1e-6),2), | |
18231 | l2 = (float)std::pow(rmax/(nr2>0?nr2:1e-6),2), | |
18232 | a = l1*u*u + l2*v*v, | |
18233 | b = u*v*(l1-l2), | |
18234 | c = l1*v*v + l2*u*u; | |
18235 | const int | |
18236 | yb = (int)std::sqrt(a*rmax*rmax/(a*c-b*b)), | |
18237 | tymin = y0-yb, | |
18238 | tymax = y0+yb, | |
18239 | ymin = tymin<0?0:tymin, | |
18240 | ymax = tymax>=dimy()?height-1:tymax; | |
18241 | int oxmin = 0, oxmax = 0; | |
18242 | bool first_line = true; | |
18243 | for (int y=ymin; y<=ymax; ++y) { | |
18244 | const float | |
18245 | Y = y-y0 + (y<y0?0.5f:-0.5f), | |
18246 | delta = b*b*Y*Y-a*(c*Y*Y-rmax*rmax), | |
18247 | sdelta = delta>0?(float)std::sqrt(delta)/a:0.0f, | |
18248 | bY = b*Y/a, | |
18249 | fxmin = x0-0.5f-bY-sdelta, | |
18250 | fxmax = x0+0.5f-bY+sdelta; | |
18251 | const int xmin = (int)fxmin, xmax = (int)fxmax; | |
18252 | if (!pattern) _draw_scanline(xmin,xmax,y,color,opacity); | |
18253 | else { | |
18254 | if (first_line) { | |
18255 | if (y0-yb>=0) _draw_scanline(xmin,xmax,y,color,opacity); | |
18256 | else draw_point(xmin,y,color,opacity).draw_point(xmax,y,color,opacity); | |
18257 | first_line = false; | |
18258 | } else { | |
18259 | if (xmin<oxmin) _draw_scanline(xmin,oxmin-1,y,color,opacity); | |
18260 | else _draw_scanline(oxmin+(oxmin==xmin?0:1),xmin,y,color,opacity); | |
18261 | if (xmax<oxmax) _draw_scanline(xmax,oxmax-1,y,color,opacity); | |
18262 | else _draw_scanline(oxmax+(oxmax==xmax?0:1),xmax,y,color,opacity); | |
18263 | if (y==tymax) _draw_scanline(xmin+1,xmax-1,y,color,opacity); | |
18264 | } | |
18265 | } | |
18266 | oxmin = xmin; oxmax = xmax; | |
18267 | } | |
18268 | } | |
18269 | return *this; | |
18270 | } | |
18271 | template<typename tc> | |
18272 | CImg<T>& draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float ru, const float rv, | |
18273 | const tc *const color, const float opacity, const unsigned int pattern) { | |
18274 | if (pattern) _draw_ellipse(x0,y0,r1,r2,ru,rv,color,opacity,pattern); | |
18275 | return *this; | |
18276 | } | |
18277 | template<typename tc> | |
18278 | CImg<T>& draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float ru, const float rv, | |
18279 | const CImg<tc>& color, const float opacity, const unsigned int pattern) { | |
18280 | return draw_ellipse(x0,y0,r1,r2,ru,rv,color.data,opacity,pattern); | |
18281 | } | |
18282 | template<typename tc> | |
18283 | CImg<T>& draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float ru, const float rv, | |
18284 | const tc *const color, const float opacity=1.0f) { | |
18285 | return _draw_ellipse(x0,y0,r1,r2,ru,rv,color,opacity,0U); | |
18286 | } | |
18287 | template<typename tc> | |
18288 | CImg<T>& draw_ellipse(const int x0, const int y0, const float r1, const float r2, const float ru, const float rv, | |
18289 | const CImg<tc>& color, const float opacity=1.0f) { | |
18290 | return draw_ellipse(x0,y0,r1,r2,ru,rv,color.data,opacity); | |
18291 | } | |
18292 | template<typename t, typename tc> | |
18293 | CImg<T>& draw_ellipse(const int x0, const int y0, const CImg<t> &tensor, | |
18294 | const tc *const color, const float opacity=1.0f) { | |
18295 | CImgList<t> eig = tensor.get_symmetric_eigen(); | |
18296 | const CImg<t> &val = eig[0], &vec = eig[1]; | |
18297 | return draw_ellipse(x0,y0,val(0),val(1),vec(0,0),vec(0,1),color,opacity); | |
18298 | } | |
18299 | template<typename t, typename tc> | |
18300 | CImg<T>& draw_ellipse(const int x0, const int y0, const CImg<t> &tensor, | |
18301 | const CImg<tc>& color, const float opacity=1.0f) { | |
18302 | return draw_ellipse(x0,y0,tensor,color.data,opacity); | |
18303 | } | |
18304 | template<typename t, typename tc> | |
18305 | CImg<T>& draw_ellipse(const int x0, const int y0, const CImg<t> &tensor, | |
18306 | const tc *const color, const float opacity, const unsigned int pattern) { | |
18307 | CImgList<t> eig = tensor.get_symmetric_eigen(); | |
18308 | const CImg<t> &val = eig[0], &vec = eig[1]; | |
18309 | return draw_ellipse(x0,y0,val(0),val(1),vec(0,0),vec(0,1),color,opacity,pattern); | |
18310 | } | |
18311 | template<typename t, typename tc> | |
18312 | CImg<T>& draw_ellipse(const int x0, const int y0, const CImg<t> &tensor, | |
18313 | const CImg<tc>& color, const float opacity, const unsigned int pattern) { | |
18314 | return draw_ellipse(x0,y0,tensor,color.data,opacity,pattern); | |
18315 | } | |
18316 | template<typename tc> | |
18317 | CImg<T>& draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity=1.0f) { | |
18318 | if (!is_empty()) { | |
18319 | if (!color) throw CImgArgumentException("CImg<%s>::draw_circle : Specified color is (null).",pixel_type()); | |
18320 | _draw_scanline(color,opacity); | |
18321 | if (radius<0 || x0-radius>=dimx() || y0+radius<0 || y0-radius>=dimy()) return *this; | |
18322 | if (y0>=0 && y0<dimy()) _draw_scanline(x0-radius,x0+radius,y0,color,opacity); | |
18323 | for (int f=1-radius, ddFx=0, ddFy=-(radius<<1), x=0, y=radius; x<y; ) { | |
18324 | if (f>=0) { | |
18325 | const int x1 = x0-x, x2 = x0+x, y1 = y0-y, y2 = y0+y; | |
18326 | if (y1>=0 && y1<dimy()) _draw_scanline(x1,x2,y1,color,opacity); | |
18327 | if (y2>=0 && y2<dimy()) _draw_scanline(x1,x2,y2,color,opacity); | |
18328 | f+=(ddFy+=2); --y; | |
18329 | } | |
18330 | const bool no_diag = y!=(x++); | |
18331 | ++(f+=(ddFx+=2)); | |
18332 | const int x1 = x0-y, x2 = x0+y, y1 = y0-x, y2 = y0+x; | |
18333 | if (no_diag) { | |
18334 | if (y1>=0 && y1<dimy()) _draw_scanline(x1,x2,y1,color,opacity); | |
18335 | if (y2>=0 && y2<dimy()) _draw_scanline(x1,x2,y2,color,opacity); | |
18336 | } | |
18337 | } | |
18338 | } | |
18339 | return *this; | |
18340 | } | |
18341 | template<typename tc> | |
18342 | CImg<T>& draw_circle(const int x0, const int y0, int radius, const CImg<tc>& color, const float opacity=1.0f) { | |
18343 | return draw_circle(x0,y0,radius,color.data,opacity); | |
18344 | } | |
18345 | template<typename tc> | |
18346 | CImg<T>& draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity, const unsigned int) { | |
18347 | if (!is_empty()) { | |
18348 | if (!color) throw CImgArgumentException("CImg<%s>::draw_circle : Specified color is (null).",pixel_type()); | |
18349 | if (radius<0 || x0-radius>=dimx() || y0+radius<0 || y0-radius>=dimy()) return *this; | |
18350 | if (!radius) return draw_point(x0,y0,color,opacity); | |
18351 | draw_point(x0-radius,y0,color,opacity).draw_point(x0+radius,y0,color,opacity). | |
18352 | draw_point(x0,y0-radius,color,opacity).draw_point(x0,y0+radius,color,opacity); | |
18353 | if (radius==1) return *this; | |
18354 | for (int f=1-radius, ddFx=0, ddFy=-(radius<<1), x=0, y=radius; x<y; ) { | |
18355 | if (f>=0) { f+=(ddFy+=2); --y; } | |
18356 | ++x; ++(f+=(ddFx+=2)); | |
18357 | if (x!=y+1) { | |
18358 | const int x1 = x0-y, x2 = x0+y, y1 = y0-x, y2 = y0+x, x3 = x0-x, x4 = x0+x, y3 = y0-y, y4 = y0+y; | |
18359 | draw_point(x1,y1,color,opacity).draw_point(x1,y2,color,opacity). | |
18360 | draw_point(x2,y1,color,opacity).draw_point(x2,y2,color,opacity); | |
18361 | if (x!=y) | |
18362 | draw_point(x3,y3,color,opacity).draw_point(x4,y4,color,opacity). | |
18363 | draw_point(x4,y3,color,opacity).draw_point(x3,y4,color,opacity); | |
18364 | } | |
18365 | } | |
18366 | } | |
18367 | return *this; | |
18368 | } | |
18369 | template<typename tc> | |
18370 | CImg<T>& draw_circle(const int x0, const int y0, int radius, const CImg<tc>& color, const float opacity, const unsigned int foo) { | |
18371 | return draw_circle(x0,y0,radius,color.data,opacity,foo); | |
18372 | } | |
18373 | template<typename t> | |
18374 | CImg<T>& draw_text(const char *const text, | |
18375 | const int x0, const int y0, | |
18376 | const T *const fgcolor, const T *const bgcolor, | |
18377 | const CImgList<t>& font, const float opacity=1.0f) { | |
18378 | if (!text) | |
18379 | throw CImgArgumentException("CImg<%s>::draw_text() : Specified input string is (null).",pixel_type()); | |
18380 | if (!font) | |
18381 | throw CImgArgumentException("CImg<%s>::draw_text() : Specified font (%u,%p) is empty.", | |
18382 | pixel_type(),font.size,font.data); | |
18383 | if (is_empty()) { | |
18384 | int x = 0, y = 0, w = 0; | |
18385 | for (int i=0; i<cimg::strlen(text); ++i) { | |
18386 | const unsigned char c = text[i]; | |
18387 | switch (c) { | |
18388 | case '\n': y+=font[' '].height; if (x>w) w = x; x = 0; break; | |
18389 | case '\t': x+=4*font[' '].width; break; | |
18390 | default: if (c<font.size) x+=font[c].width; | |
18391 | } | |
18392 | } | |
18393 | if (x!=0) { | |
18394 | if (x>w) w=x; | |
18395 | y+=font[' '].height; | |
18396 | } | |
18397 | assign(x0+w,y0+y,1,font[' '].dim,0); | |
18398 | if (bgcolor) for (int k = 0; k<(int)((*this).dim); ++k) get_shared_channel(k).fill((T)bgcolor[k]); | |
18399 | } | |
18400 | int x = x0, y = y0; | |
18401 | CImg<T> letter; | |
18402 | for (int i=0; i<cimg::strlen(text); ++i) { | |
18403 | const unsigned char c = text[i]; | |
18404 | switch (c) { | |
18405 | case '\n': y+=font[' '].height; x=x0; break; | |
18406 | case '\t': x+=4*font[' '].width; break; | |
18407 | default: if (c<font.size) { | |
18408 | letter = font[c]; | |
18409 | const CImg<T>& mask = (c+256)<(int)font.size?font[c+256]:font[c]; | |
18410 | if (fgcolor) for (unsigned int p=0; p<letter.width*letter.height; ++p) | |
18411 | if (mask(p)) for (int k = 0; k<(int)((*this).dim); ++k) letter(p,0,0,k) = (T)(letter(p,0,0,k)*fgcolor[k]); | |
18412 | if (bgcolor) for (unsigned int p=0; p<letter.width*letter.height; ++p) | |
18413 | if (!mask(p)) for (int k = 0; k<(int)((*this).dim); ++k) letter(p,0,0,k) = (T)bgcolor[k]; | |
18414 | if (!bgcolor && font.size>=512) draw_image(letter,mask,x,y,0,0,(T)1,opacity); | |
18415 | else draw_image(letter,x,y,0,0,opacity); | |
18416 | x+=letter.width; | |
18417 | } | |
18418 | break; | |
18419 | } | |
18420 | } | |
18421 | return *this; | |
18422 | } | |
18423 | template<typename tc, typename t> | |
18424 | CImg<T>& draw_text(const char *const text, | |
18425 | const int x0, const int y0, | |
18426 | const CImg<tc>& fgcolor, const CImg<tc>& bgcolor, | |
18427 | const CImgList<t>& font, const float opacity=1.0f) { | |
18428 | const CImg<T> fgcol(fgcolor), bgcol(bgcolor); | |
18429 | return draw_text(text,x0,y0,fgcol.data,bgcol.data,font,opacity); | |
18430 | } | |
18431 | CImg<T>& draw_text(const char *const text, | |
18432 | const int x0, const int y0, | |
18433 | const T *const fgcolor, const T *const bgcolor=0, | |
18434 | const unsigned int font_size=11, const float opacity=1.0f) { | |
18435 | return draw_text(text,x0,y0,fgcolor,bgcolor,CImgList<T>::get_font(font_size),opacity); | |
18436 | } | |
18437 | template<typename tc> | |
18438 | CImg<T>& draw_text(const char *const text, | |
18439 | const int x0, const int y0, | |
18440 | const CImg<tc>& fgcolor, const CImg<tc>& bgcolor, | |
18441 | const unsigned int font_size=11, const float opacity=1.0f) { | |
18442 | const CImg<T> fgcol(fgcolor), bgcol(bgcolor); | |
18443 | return draw_text(text,x0,y0,fgcol.data,bgcol.data,font_size,opacity); | |
18444 | } | |
18445 | CImg<T>& draw_text(const int x0, const int y0, | |
18446 | const T *const fgcolor, const T *const bgcolor, const unsigned int font_size, | |
18447 | const float opacity, const char *format, ...) { | |
18448 | char tmp[2048] = { 0 }; | |
18449 | std::va_list ap; | |
18450 | __builtin_va_start(ap,format); | |
18451 | std::vsprintf(tmp,format,ap); | |
18452 | __builtin_va_end(ap); | |
18453 | return draw_text(tmp,x0,y0,fgcolor,bgcolor,font_size,opacity); | |
18454 | } | |
18455 | template<typename tc> | |
18456 | CImg<T>& draw_text(const int x0, const int y0, | |
18457 | const CImg<tc>& fgcolor, const CImg<tc>& bgcolor, const unsigned int font_size, | |
18458 | const float opacity, const char *format, ...) { | |
18459 | char tmp[2048] = { 0 }; | |
18460 | std::va_list ap; | |
18461 | __builtin_va_start(ap,format); | |
18462 | std::vsprintf(tmp,format,ap); | |
18463 | __builtin_va_end(ap); | |
18464 | return draw_text(tmp,x0,y0,fgcolor,bgcolor,font_size,opacity); | |
18465 | } | |
18466 | template<typename t> | |
18467 | CImg<T>& draw_text(const int x0, const int y0, | |
18468 | const T *const fgcolor, const T *const bgcolor, | |
18469 | const CImgList<t>& font, const float opacity, const char *format, ...) { | |
18470 | char tmp[2048] = { 0 }; | |
18471 | std::va_list ap; | |
18472 | __builtin_va_start(ap,format); | |
18473 | std::vsprintf(tmp,format,ap); | |
18474 | __builtin_va_end(ap); | |
18475 | return draw_text(tmp,x0,y0,fgcolor,bgcolor,font,opacity); | |
18476 | } | |
18477 | template<typename tc, typename t> | |
18478 | CImg<T>& draw_text(const int x0, const int y0, | |
18479 | const CImg<tc>& fgcolor, const CImg<tc>& bgcolor, | |
18480 | const CImgList<t>& font, const float opacity, const char *format, ...) { | |
18481 | char tmp[2048] = { 0 }; | |
18482 | std::va_list ap; | |
18483 | __builtin_va_start(ap,format); | |
18484 | std::vsprintf(tmp,format,ap); | |
18485 | __builtin_va_end(ap); | |
18486 | return draw_text(tmp,x0,y0,fgcolor,bgcolor,font,opacity); | |
18487 | } | |
18488 | template<typename t1, typename t2> | |
18489 | CImg<T>& draw_quiver(const CImg<t1>& flow, const t2 *const color, | |
18490 | const unsigned int sampling=25, const float factor=-20, | |
18491 | const int quiver_type=0, const float opacity=1.0f, const unsigned int pattern=~0U) { | |
18492 | return draw_quiver(flow,CImg<t2>(color,dim,1,1,1,true),sampling,factor,quiver_type,opacity,pattern); | |
18493 | } | |
18494 | template<typename t1, typename t2> | |
18495 | CImg<T>& draw_quiver(const CImg<t1>& flow, const CImg<t2>& color, | |
18496 | const unsigned int sampling=25, const float factor=-20, | |
18497 | const int quiver_type=0, const float opacity=1.0f, const unsigned int pattern=~0U) { | |
18498 | if (!is_empty()) { | |
18499 | if (!flow || flow.dim!=2) | |
18500 | throw CImgArgumentException("CImg<%s>::draw_quiver() : Specified flow (%u,%u,%u,%u,%p) has wrong dimensions.", | |
18501 | pixel_type(),flow.width,flow.height,flow.depth,flow.dim,flow.data); | |
18502 | if (sampling<=0) | |
18503 | throw CImgArgumentException("CImg<%s>::draw_quiver() : Incorrect sampling value = %g",pixel_type(),sampling); | |
18504 | const bool colorfield = (color.width==flow.width && color.height==flow.height && color.depth==1 && color.dim==dim); | |
18505 | if (is_overlapping(flow)) return draw_quiver(+flow,color,sampling,factor,quiver_type,opacity,pattern); | |
18506 | float vmax,fact; | |
18507 | if (factor<=0) { | |
18508 | float m, M = (float)flow.get_norm_pointwise(2).maxmin(m); | |
18509 | vmax = (float)cimg::max(cimg::abs(m),cimg::abs(M)); | |
18510 | fact = -factor; | |
18511 | } else { fact = factor; vmax = 1; } | |
18512 | for (unsigned int y=sampling/2; y<height; y+=sampling) | |
18513 | for (unsigned int x=sampling/2; x<width; x+=sampling) { | |
18514 | const unsigned int X = x*flow.width/width, Y = y*flow.height/height; | |
18515 | float u = (float)flow(X,Y,0,0)*fact/vmax, v = (float)flow(X,Y,0,1)*fact/vmax; | |
18516 | if (!quiver_type) { | |
18517 | const int xx = x+(int)u, yy = y+(int)v; | |
18518 | if (colorfield) draw_arrow(x,y,xx,yy,color.get_vector_at(X,Y).data,45.0f,sampling/5.0f,opacity,pattern); | |
18519 | else draw_arrow(x,y,xx,yy,color,45.0f,sampling/5.0f,opacity,pattern); | |
18520 | } else { | |
18521 | if (colorfield) draw_line((int)(x-0.5*u),(int)(y-0.5*v),(int)(x+0.5*u),(int)(y+0.5*v),color.get_vector_at(X,Y),opacity,pattern); | |
18522 | else draw_line((int)(x-0.5*u),(int)(y-0.5*v),(int)(x+0.5*u),(int)(y+0.5*v),color,opacity,pattern); | |
18523 | } | |
18524 | } | |
18525 | } | |
18526 | return *this; | |
18527 | } | |
18528 | template<typename t, typename tc> | |
18529 | CImg<T>& draw_graph(const CImg<t>& data, const tc *const color, const unsigned int gtype=1, | |
18530 | const double ymin=0, const double ymax=0, const float opacity=1.0f, | |
18531 | const unsigned int pattern=~0U) { | |
18532 | if (!is_empty()) { | |
18533 | if (!color) throw CImgArgumentException("CImg<%s>::draw_graph() : Specified color is (null)",pixel_type()); | |
18534 | tc *color1 = new tc[dim], *color2 = new tc[dim]; | |
18535 | for (int k = 0; k<(int)((*this).dim); ++k) { color1[k]=(tc)(color[k]*0.6f); color2[k]=(tc)(color[k]*0.3f); } | |
18536 | float m = (float)ymin, M = (float)ymax; | |
18537 | if (ymin==ymax) m = (float)data.maxmin(M); | |
18538 | if (m==M) { --m; ++M; } | |
18539 | const float ca = height>1?(float)(M-m)/(height-1):0; | |
18540 | const int Y0 = (int)(-m/ca); | |
18541 | int pY = 0; | |
18542 | bool init_hatch = true; | |
18543 | if (gtype<3) for (unsigned int off = 0; off<(data).size(); ++off) { | |
18544 | const int Y = (int)((data[off]-m)/ca); | |
18545 | switch (gtype) { | |
18546 | case 0: { | |
18547 | const unsigned int X = off*width/data.size(); | |
18548 | draw_point(X,Y,color,opacity); | |
18549 | } break; | |
18550 | case 1: | |
18551 | if (off>0) { | |
18552 | draw_line((int)((off-1)*width/data.size()),pY,(int)(off*width/data.size()),Y,color,opacity,pattern,init_hatch); | |
18553 | init_hatch = false; | |
18554 | } | |
18555 | break; | |
18556 | case 2: { | |
18557 | const unsigned int X = off*width/data.size(), nX = (off+1)*width/data.size()-1; | |
18558 | draw_rectangle(X,(int)Y0,nX,Y,color1,opacity); | |
18559 | draw_line(X,Y,X,(int)Y0,color2,opacity); | |
18560 | draw_line(X,(int)Y0,nX,(int)Y0,Y<=Y0?color2:color,opacity); | |
18561 | draw_line(nX,Y,nX,(int)Y0,color,opacity); | |
18562 | draw_line(X,Y,nX,Y,Y<=Y0?color:color2,opacity); | |
18563 | } break; | |
18564 | } | |
18565 | pY = Y; | |
18566 | } else { | |
18567 | const CImg<t> ndata = data.get_shared_points(0,data.size()-1); | |
18568 | for (int x = 0; x<(int)((*this).width); ++x) { | |
18569 | const int Y = (int)((ndata.cubic_pix1d((float)x*ndata.width/width)-m)/ca); | |
18570 | if (x>0) draw_line(x,pY,x+1,Y,color,opacity,pattern,init_hatch); | |
18571 | init_hatch = false; | |
18572 | pY = Y; | |
18573 | } | |
18574 | } | |
18575 | delete[] color1; delete[] color2; | |
18576 | } | |
18577 | return *this; | |
18578 | } | |
18579 | template<typename t, typename tc> | |
18580 | CImg<T>& draw_graph(const CImg<t>& data, const CImg<tc>& color, const unsigned int gtype=1, | |
18581 | const double ymin=0, const double ymax=0, const float opacity=1.0f, | |
18582 | const unsigned int pattern=~0U) { | |
18583 | return draw_graph(data,color.data,gtype,ymin,ymax,opacity,pattern); | |
18584 | } | |
18585 | template<typename t, typename tc> | |
18586 | CImg<T>& draw_axis(const CImg<t>& xvalues, const int y, | |
18587 | const tc *const color, const float opacity=1.0f, const unsigned int pattern=~0U) { | |
18588 | if (!is_empty()) { | |
18589 | int siz = (int)xvalues.size()-1; | |
18590 | if (siz<=0) draw_line(0,y,width-1,y,color,opacity,pattern); | |
18591 | else { | |
18592 | if (xvalues[0]<xvalues[siz]) draw_arrow(0,y,width-1,y,color,30,5,opacity,pattern); | |
18593 | else draw_arrow(width-1,y,0,y,color,30,5,opacity,pattern); | |
18594 | const int yt = (y+14)<dimy()?(y+3):(y-14); | |
18595 | char txt[32]; | |
18596 | for (unsigned int x = 0; x<(xvalues).size(); ++x) { | |
18597 | std::sprintf(txt,"%g",(double)xvalues(x)); | |
18598 | const int xi=(int)(x*(width-1)/siz), xt = xi-(int)std::strlen(txt)*3; | |
18599 | draw_point(xi,y-1,color,opacity).draw_point(xi,y+1,color,opacity). | |
18600 | draw_text(txt,xt<0?0:xt,yt,color,(tc*)0,11,opacity); | |
18601 | } | |
18602 | } | |
18603 | } | |
18604 | return *this; | |
18605 | } | |
18606 | template<typename t, typename tc> | |
18607 | CImg<T>& draw_axis(const CImg<t>& xvalues, const int y, | |
18608 | const CImg<tc>& color, const float opacity=1.0f, const unsigned int pattern=~0U) { | |
18609 | return draw_axis(xvalues,y,color.data,opacity,pattern); | |
18610 | } | |
18611 | template<typename t, typename tc> | |
18612 | CImg<T>& draw_axis(const int x, const CImg<t>& yvalues, | |
18613 | const tc *const color, const float opacity=1.0f, const unsigned int pattern=~0U) { | |
18614 | if (!is_empty()) { | |
18615 | int siz = (int)yvalues.size()-1; | |
18616 | if (siz<=0) draw_line(x,0,x,height-1,color,opacity,pattern); | |
18617 | else { | |
18618 | if (yvalues[0]<yvalues[siz]) draw_arrow(x,0,x,height-1,color,30,5,opacity,pattern); | |
18619 | else draw_arrow(x,height-1,x,0,color,30,5,opacity,pattern); | |
18620 | char txt[32]; | |
18621 | for (unsigned int y = 0; y<(yvalues).size(); ++y) { | |
18622 | std::sprintf(txt,"%g",(double)yvalues(y)); | |
18623 | const int | |
18624 | yi = (int)(y*(height-1)/siz), | |
18625 | tmp = yi-5, | |
18626 | nyi = tmp<0?0:(tmp>=dimy()-11?dimy()-11:tmp), | |
18627 | xt = x-(int)std::strlen(txt)*7; | |
18628 | draw_point(x-1,yi,color,opacity).draw_point(x+1,yi,color,opacity); | |
18629 | if (xt>0) draw_text(txt,xt,nyi,color,(tc*)0,11,opacity); | |
18630 | else draw_text(txt,x+3,nyi,color,(tc*)0,11,opacity); | |
18631 | } | |
18632 | } | |
18633 | } | |
18634 | return *this; | |
18635 | } | |
18636 | template<typename t, typename tc> | |
18637 | CImg<T>& draw_axis(const int x, const CImg<t>& yvalues, | |
18638 | const CImg<tc>& color, const float opacity=1.0f, const unsigned int pattern=~0U) { | |
18639 | return draw_axis(x,yvalues,color.data,opacity,pattern); | |
18640 | } | |
18641 | template<typename tx, typename ty, typename tc> | |
18642 | CImg<T>& draw_axis(const CImg<tx>& xvalues, const CImg<ty>& yvalues, | |
18643 | const tc *const color, | |
18644 | const float opacity=1.0f, | |
18645 | const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18646 | if (!is_empty()) { | |
18647 | const CImg<tx> nxvalues(xvalues.data,xvalues.size(),1,1,1,true); | |
18648 | const int sizx = (int)xvalues.size()-1, wm1 = (int)(width)-1; | |
18649 | if (sizx>0) { | |
18650 | float ox = (float)nxvalues[0]; | |
18651 | for (unsigned int x=1; x<width; ++x) { | |
18652 | const float nx = (float)nxvalues.linear_pix1d((float)x*sizx/wm1); | |
18653 | if (nx*ox<=0) { draw_axis(nx==0?x:x-1,yvalues,color,opacity,patterny); break; } | |
18654 | ox = nx; | |
18655 | } | |
18656 | } | |
18657 | const CImg<ty> nyvalues(yvalues.data,yvalues.size(),1,1,1,true); | |
18658 | const int sizy = (int)yvalues.size()-1, hm1 = (int)(height)-1; | |
18659 | if (sizy>0) { | |
18660 | float oy = (float)nyvalues[0]; | |
18661 | for (unsigned int y=1; y<height; ++y) { | |
18662 | const float ny = (float)nyvalues.linear_pix1d((float)y*sizy/hm1); | |
18663 | if (ny*oy<=0) { draw_axis(xvalues,ny==0?y:y-1,color,opacity,patternx); break; } | |
18664 | oy = ny; | |
18665 | } | |
18666 | } | |
18667 | } | |
18668 | return *this; | |
18669 | } | |
18670 | template<typename tx, typename ty, typename tc> | |
18671 | CImg<T>& draw_axis(const CImg<tx>& xvalues, const CImg<ty>& yvalues, | |
18672 | const CImg<tc>& color, | |
18673 | const float opacity=1.0f, | |
18674 | const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18675 | return draw_axis(xvalues,yvalues,color.data,opacity,patternx,patterny); | |
18676 | } | |
18677 | template<typename tc> | |
18678 | CImg<T>& draw_axis(const float x0, const float x1, const float y0, const float y1, | |
18679 | const tc *const color, | |
18680 | const int subdivisionx=-60, const int subdivisiony=-60, | |
18681 | const float precisionx=0, const float precisiony=0, | |
18682 | const float opacity=1.0f, | |
18683 | const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18684 | const float dx = cimg::abs(x1-x0), dy = cimg::abs(y1-y0); | |
18685 | const float | |
18686 | px = (precisionx==0)?(float)std::pow(10.0,(int)std::log10(dx)-2.0):precisionx, | |
18687 | py = (precisiony==0)?(float)std::pow(10.0,(int)std::log10(dy)-2.0):precisiony; | |
18688 | return draw_axis(CImg<float>::sequence(subdivisionx>0?subdivisionx:1-dimx()/subdivisionx,x0,x1).round(px), | |
18689 | CImg<float>::sequence(subdivisiony>0?subdivisiony:1-dimy()/subdivisiony,y0,y1).round(py), | |
18690 | color,opacity,patternx,patterny); | |
18691 | } | |
18692 | template<typename tc> | |
18693 | CImg<T>& draw_axis(const float x0, const float x1, const float y0, const float y1, | |
18694 | const CImg<tc>& color, | |
18695 | const int subdivisionx=-60, const int subdivisiony=-60, | |
18696 | const float precisionx=0, const float precisiony=0, | |
18697 | const float opacity=1.0f, | |
18698 | const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18699 | return draw_axis(x0,x1,y0,y1,color.data,subdivisionx,subdivisiony,precisionx,precisiony,opacity,patternx,patterny); | |
18700 | } | |
18701 | template<typename tx, typename ty, typename tc> | |
18702 | CImg<T>& draw_grid(const CImg<tx>& xvalues, const CImg<ty>& yvalues, const tc *const color, | |
18703 | const float opacity=1.0f, const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18704 | if (!is_empty()) { | |
18705 | if (xvalues) for (unsigned int x = 0; x<(xvalues).size(); ++x) { | |
18706 | const int xi = (int)xvalues[x]; | |
18707 | if (xi>=0 && xi<dimx()) draw_line(xi,0,xi,height-1,color,opacity,patternx); | |
18708 | } | |
18709 | if (yvalues) for (unsigned int y = 0; y<(yvalues).size(); ++y) { | |
18710 | const int yi = (int)yvalues[y]; | |
18711 | if (yi>=0 && yi<dimy()) draw_line(0,yi,width-1,yi,color,opacity,patterny); | |
18712 | } | |
18713 | } | |
18714 | return *this; | |
18715 | } | |
18716 | template<typename tx, typename ty, typename tc> | |
18717 | CImg<T>& draw_grid(const CImg<tx>& xvalues, const CImg<ty>& yvalues, const CImg<tc>& color, | |
18718 | const float opacity=1.0f, const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18719 | return draw_grid(xvalues,yvalues,color.data,opacity,patternx,patterny); | |
18720 | } | |
18721 | template<typename tc> | |
18722 | CImg<T>& draw_grid(const float deltax, const float deltay, | |
18723 | const float offsetx, const float offsety, | |
18724 | const bool invertx, const bool inverty, | |
18725 | const tc *const color, | |
18726 | const float opacity=1.0f, const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18727 | CImg<unsigned int> seqx, seqy; | |
18728 | if (deltax!=0) { | |
18729 | const float dx = deltax>0?deltax:width*-deltax/100; | |
18730 | const unsigned int nx = (unsigned int)(width/dx); | |
18731 | seqx = CImg<unsigned int>::sequence(1+nx,0,(unsigned int)(dx*nx)); | |
18732 | if (offsetx) for (unsigned int x = 0; x<(seqx).size(); ++x) seqx(x) = (unsigned int)cimg::mod(seqx(x)+offsetx,(float)width); | |
18733 | if (invertx) for (unsigned int x = 0; x<(seqx).size(); ++x) seqx(x) = width-1-seqx(x); | |
18734 | } | |
18735 | if (deltay!=0) { | |
18736 | const float dy = deltay>0?deltay:height*-deltay/100; | |
18737 | const unsigned int ny = (unsigned int)(height/dy); | |
18738 | seqy = CImg<unsigned int>::sequence(1+ny,0,(unsigned int)(dy*ny)); | |
18739 | if (offsety) for (unsigned int y = 0; y<(seqy).size(); ++y) seqy(y) = (unsigned int)cimg::mod(seqy(y)+offsety,(float)height); | |
18740 | if (inverty) for (unsigned int y = 0; y<(seqy).size(); ++y) seqy(y) = height-1-seqy(y); | |
18741 | } | |
18742 | return draw_grid(seqx,seqy,color,opacity,patternx,patterny); | |
18743 | } | |
18744 | template<typename tc> | |
18745 | CImg<T>& draw_grid(const float deltax, const float deltay, | |
18746 | const float offsetx, const float offsety, | |
18747 | const bool invertx, const bool inverty, | |
18748 | const CImg<tc>& color, | |
18749 | const float opacity=1.0f, const unsigned int patternx=~0U, const unsigned int patterny=~0U) { | |
18750 | return draw_grid(deltax,deltay,offsetx,offsety,invertx,inverty,color.data,opacity,patternx,patterny); | |
18751 | } | |
18752 | template<typename tc, typename t> | |
18753 | CImg<T>& draw_fill(const int x, const int y, const int z, | |
18754 | const tc *const color, CImg<t>& region, const float sigma=0, | |
18755 | const float opacity=1.0f, const bool high_connexity=false) { | |
18756 | if (!color) throw CImgArgumentException("CImg<%s>::draw_fill() : Specified color is (null).",pixel_type()); | |
18757 | region.assign(width,height,depth,1,(t)0); | |
18758 | if (x>=0 || x<dimx() || y>=0 || y<dimy() || z>=0 || z<dimz()) { | |
18759 | typedef typename cimg::last<T,unsigned int>::type itype; | |
18760 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
18761 | const unsigned int whz = width*height*depth, siz = dim*whz, W1 = width-1, H1 = height-1, D1 = depth-1; | |
18762 | const bool threed = depth>1; | |
18763 | const CImg<T> reference_color = get_vector_at(x,y,z); | |
18764 | CImg<itype> remaining(3,512,1,1,0); | |
18765 | remaining(0,0) = x; remaining(1,0) = y; remaining(2,0) = z; | |
18766 | unsigned int posr0 = 0, posr1 = 1; | |
18767 | region(x,y,z) = (t)1; | |
18768 | const t noregion = ((t)1==(t)2)?(t)0:(t)(-1); | |
18769 | if (threed) do { | |
18770 | const unsigned int *pcurr = remaining.ptr(0,posr0++), xc = *(pcurr++), yc = *(pcurr++), zc = *(pcurr++); | |
18771 | if (posr0>=512) { remaining.translate(0,posr0); posr1-=posr0; posr0 = 0; } | |
18772 | bool cont, res; | |
18773 | unsigned int nxc = xc; | |
18774 | do { | |
18775 | { const tc *col = color; T *ptrd = ptr(nxc,yc,zc); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18776 | if (yc!=0) { const unsigned int tx = nxc, ty = yc-1, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18777 | if (yc<H1) { const unsigned int tx = nxc, ty = yc+1, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18778 | if (zc!=0) { const unsigned int tx = nxc, ty = yc, tz = zc-1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18779 | if (zc<D1) { const unsigned int tx = nxc, ty = yc, tz = zc+1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18780 | if (nxc) { --nxc; if (region(nxc,yc,zc)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(nxc,yc,zc) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(nxc,yc,zc) = (t)(cont?1:noregion); }; } else cont = false; | |
18781 | } while (cont); | |
18782 | nxc = xc; | |
18783 | do { | |
18784 | if ((++nxc)<=W1) { if (region(nxc,yc,zc)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(nxc,yc,zc) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(nxc,yc,zc) = (t)(cont?1:noregion); }; } else cont = false; | |
18785 | if (cont) { | |
18786 | { const tc *col = color; T *ptrd = ptr(nxc,yc,zc); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18787 | if (yc!=0) { const unsigned int tx = nxc, ty = yc-1, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18788 | if (yc<H1) { const unsigned int tx = nxc, ty = yc+1, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18789 | if (zc!=0) { const unsigned int tx = nxc, ty = yc, tz = zc-1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18790 | if (zc<D1) { const unsigned int tx = nxc, ty = yc, tz = zc+1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18791 | } | |
18792 | } while (cont); | |
18793 | unsigned int nyc = yc; | |
18794 | do { | |
18795 | if (nyc) { --nyc; if (region(xc,nyc,zc)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(xc,nyc,zc) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(xc,nyc,zc) = (t)(cont?1:noregion); }; } else cont = false; | |
18796 | if (cont) { | |
18797 | { const tc *col = color; T *ptrd = ptr(xc,nyc,zc); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18798 | if (xc!=0) { const unsigned int tx = xc-1, ty = nyc, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18799 | if (xc<W1) { const unsigned int tx = xc+1, ty = nyc, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18800 | if (zc!=0) { const unsigned int tx = xc, ty = nyc, tz = zc-1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18801 | if (zc<D1) { const unsigned int tx = xc, ty = nyc, tz = zc+1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18802 | } | |
18803 | } while (cont); | |
18804 | nyc = yc; | |
18805 | do { | |
18806 | if ((++nyc)<=H1) { if (region(xc,nyc,zc)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(xc,nyc,zc) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(xc,nyc,zc) = (t)(cont?1:noregion); }; } else cont = false; | |
18807 | if (cont) { | |
18808 | { const tc *col = color; T *ptrd = ptr(xc,nyc,zc); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18809 | if (xc!=0) { const unsigned int tx = xc-1, ty = nyc, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18810 | if (xc<W1) { const unsigned int tx = xc+1, ty = nyc, tz = zc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18811 | if (zc!=0) { const unsigned int tx = xc, ty = nyc, tz = zc-1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18812 | if (zc<D1) { const unsigned int tx = xc, ty = nyc, tz = zc+1; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18813 | } | |
18814 | } while (cont); | |
18815 | unsigned int nzc = zc; | |
18816 | do { | |
18817 | if (nzc) { --nzc; if (region(xc,yc,nzc)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(xc,yc,nzc) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(xc,yc,nzc) = (t)(cont?1:noregion); }; } else cont = false; | |
18818 | if (cont) { | |
18819 | { const tc *col = color; T *ptrd = ptr(xc,yc,nzc); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18820 | if (xc!=0) { const unsigned int tx = xc-1, ty = yc, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18821 | if (xc<W1) { const unsigned int tx = xc+1, ty = yc, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18822 | if (yc!=0) { const unsigned int tx = xc, ty = yc-1, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18823 | if (yc<H1) { const unsigned int tx = xc, ty = yc+1, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18824 | } | |
18825 | } while (cont); | |
18826 | nzc = zc; | |
18827 | do { | |
18828 | if ((++nzc)<=D1) { if (region(xc,yc,nzc)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(xc,yc,nzc) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(xc,yc,nzc) = (t)(cont?1:noregion); }; } else cont = false; | |
18829 | if (cont) { | |
18830 | { const tc *col = color; T *ptrd = ptr(xc,nyc,zc); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18831 | if (xc!=0) { const unsigned int tx = xc-1, ty = yc, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18832 | if (xc<W1) { const unsigned int tx = xc+1, ty = yc, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18833 | if (yc!=0) { const unsigned int tx = xc, ty = yc-1, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18834 | if (yc<H1) { const unsigned int tx = xc, ty = yc+1, tz = nzc; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18835 | } | |
18836 | } while (cont); | |
18837 | } while (posr1>posr0); | |
18838 | else do { | |
18839 | const unsigned int *pcurr = remaining.ptr(0,posr0++), xc = *(pcurr++), yc = *(pcurr++); | |
18840 | if (posr0>=512) { remaining.translate(0,posr0); posr1-=posr0; posr0 = 0; } | |
18841 | bool cont, res; | |
18842 | unsigned int nxc = xc; | |
18843 | do { | |
18844 | { const tc *col = color; T *ptrd = ptr(nxc,yc,0); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18845 | if (yc!=0) { const unsigned int tx = nxc, ty = yc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18846 | if (yc<H1) { const unsigned int tx = nxc, ty = yc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18847 | if (high_connexity) { | |
18848 | if ((nxc!=0 && yc!=0)) { const unsigned int tx = nxc-1, ty = yc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18849 | if ((nxc<W1 && yc!=0)) { const unsigned int tx = nxc+1, ty = yc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18850 | if ((nxc!=0 && yc<H1)) { const unsigned int tx = nxc-1, ty = yc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18851 | if ((nxc<W1 && yc<H1)) { const unsigned int tx = nxc+1, ty = yc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18852 | } | |
18853 | if (nxc) { --nxc; if (region(nxc,yc,0)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(nxc,yc,0) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(nxc,yc,0) = (t)(cont?1:noregion); }; } else cont = false; | |
18854 | } while (cont); | |
18855 | nxc = xc; | |
18856 | do { | |
18857 | if ((++nxc)<=W1) { if (region(nxc,yc,0)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(nxc,yc,0) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(nxc,yc,0) = (t)(cont?1:noregion); }; } else cont = false; | |
18858 | if (cont) { | |
18859 | { const tc *col = color; T *ptrd = ptr(nxc,yc,0); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18860 | if (yc!=0) { const unsigned int tx = nxc, ty = yc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18861 | if (yc<H1) { const unsigned int tx = nxc, ty = yc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18862 | if (high_connexity) { | |
18863 | if ((nxc!=0 && yc!=0)) { const unsigned int tx = nxc-1, ty = yc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18864 | if ((nxc<W1 && yc!=0)) { const unsigned int tx = nxc+1, ty = yc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18865 | if ((nxc!=0 && yc<H1)) { const unsigned int tx = nxc-1, ty = yc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18866 | if ((nxc<W1 && yc<H1)) { const unsigned int tx = nxc+1, ty = yc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18867 | } | |
18868 | } | |
18869 | } while (cont); | |
18870 | unsigned int nyc = yc; | |
18871 | do { | |
18872 | if (nyc) { --nyc; if (region(xc,nyc,0)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(xc,nyc,0) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(xc,nyc,0) = (t)(cont?1:noregion); }; } else cont = false; | |
18873 | if (cont) { | |
18874 | { const tc *col = color; T *ptrd = ptr(xc,nyc,0); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18875 | if (xc!=0) { const unsigned int tx = xc-1, ty = nyc, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18876 | if (xc<W1) { const unsigned int tx = xc+1, ty = nyc, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18877 | if (high_connexity) { | |
18878 | if ((xc!=0 && nyc!=0)) { const unsigned int tx = xc-1, ty = nyc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18879 | if ((xc<W1 && nyc!=0)) { const unsigned int tx = xc+1, ty = nyc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18880 | if ((xc!=0 && nyc<H1)) { const unsigned int tx = xc-1, ty = nyc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18881 | if ((xc<W1 && nyc<H1)) { const unsigned int tx = xc+1, ty = nyc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18882 | } | |
18883 | } | |
18884 | } while (cont); | |
18885 | nyc = yc; | |
18886 | do { | |
18887 | if ((++nyc)<=H1) { if (region(xc,nyc,0)) cont = false; else { cont = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(xc,nyc,0) + siz; for (unsigned int i = dim; cont && i; --i) { ptrs-=whz; cont = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(xc,nyc,0) = (t)(cont?1:noregion); }; } else cont = false; | |
18888 | if (cont) { | |
18889 | { const tc *col = color; T *ptrd = ptr(xc,nyc,0); if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)*(col++); ptrd+=whz; } else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } }; | |
18890 | if (xc!=0) { const unsigned int tx = xc-1, ty = nyc, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18891 | if (xc<W1) { const unsigned int tx = xc+1, ty = nyc, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18892 | if (high_connexity) { | |
18893 | if ((xc!=0 && nyc!=0)) { const unsigned int tx = xc-1, ty = nyc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18894 | if ((xc<W1 && nyc!=0)) { const unsigned int tx = xc+1, ty = nyc-1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18895 | if ((xc!=0 && nyc<H1)) { const unsigned int tx = xc-1, ty = nyc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18896 | if ((xc<W1 && nyc<H1)) { const unsigned int tx = xc+1, ty = nyc+1, tz = 0; if (region(tx,ty,tz)) res = false; else { res = true; const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(tx,ty,tz) + siz; for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } region(tx,ty,tz) = (t)(res?1:noregion); }; if (res) { if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); unsigned int *ptrr = remaining.ptr(0,posr1); *(ptrr++) = tx; *(ptrr++) = ty; *(ptrr++) = tz; ++posr1; }; }; | |
18897 | } | |
18898 | } | |
18899 | } while (cont); | |
18900 | } while (posr1>posr0); | |
18901 | if (noregion) for (t *ptr = (region).data + (region).size(); (ptr--)>(region).data; ) if (*ptr==noregion) *ptr = (t)0; | |
18902 | } | |
18903 | return *this; | |
18904 | } | |
18905 | template<typename tc, typename t> | |
18906 | CImg<T>& draw_fill(const int x, const int y, const int z, | |
18907 | const CImg<tc>& color, CImg<t>& region, const float sigma=0, | |
18908 | const float opacity=1.0f, const bool high_connexity=false) { | |
18909 | return draw_fill(x,y,z,color.data,region,sigma,opacity,high_connexity); | |
18910 | } | |
18911 | template<typename tc> | |
18912 | CImg<T>& draw_fill(const int x, const int y, const int z, const tc *const color, const float sigma=0, | |
18913 | const float opacity=1.0f, const bool high_connexity=false) { | |
18914 | CImg<bool> tmp; | |
18915 | return draw_fill(x,y,z,color,tmp,sigma,opacity,high_connexity); | |
18916 | } | |
18917 | template<typename tc> | |
18918 | CImg<T>& draw_fill(const int x, const int y, const int z, const CImg<tc>& color, const float sigma=0, | |
18919 | const float opacity=1.0f, const bool high_connexity=false) { | |
18920 | return draw_fill(x,y,z,color.data,sigma,opacity,high_connexity); | |
18921 | } | |
18922 | template<typename tc> | |
18923 | CImg<T>& draw_fill(const int x, const int y, const tc *const color, const float sigma=0, | |
18924 | const float opacity=1.0f, const bool high_connexity=false) { | |
18925 | CImg<bool> tmp; | |
18926 | return draw_fill(x,y,0,color,tmp,sigma,opacity,high_connexity); | |
18927 | } | |
18928 | template<typename tc> | |
18929 | CImg<T>& draw_fill(const int x, const int y, const CImg<tc>& color, const float sigma=0, | |
18930 | const float opacity=1.0f, const bool high_connexity=false) { | |
18931 | return draw_fill(x,y,color.data,sigma,opacity,high_connexity); | |
18932 | } | |
18933 | CImg<T>& draw_plasma(const int x0, const int y0, const int x1, const int y1, | |
18934 | const double alpha=1.0, const double beta=1.0, const float opacity=1.0f) { | |
18935 | if (!is_empty()) { | |
18936 | typedef typename cimg::superset<T,float>::type ftype; | |
18937 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
18938 | int nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1; | |
18939 | if (nx1<nx0) cimg::swap(nx0,nx1); | |
18940 | if (ny1<ny0) cimg::swap(ny0,ny1); | |
18941 | if (nx0<0) nx0 = 0; | |
18942 | if (nx1>=dimx()) nx1 = width-1; | |
18943 | if (ny0<0) ny0 = 0; | |
18944 | if (ny1>=dimy()) ny1 = height-1; | |
18945 | const int xc = (nx0+nx1)/2, yc = (ny0+ny1)/2, dx = (xc-nx0), dy = (yc-ny0); | |
18946 | const ftype dc = (ftype)(std::sqrt((double)(dx*dx+dy*dy))*alpha + beta); | |
18947 | ftype val = 0; | |
18948 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
18949 | if (opacity>=1) { | |
18950 | const ftype | |
18951 | val0 = (*this)(nx0,ny0,0,k), val1 = (*this)(nx1,ny0,0,k), | |
18952 | val2 = (*this)(nx0,ny1,0,k), val3 = (*this)(nx1,ny1,0,k); | |
18953 | (*this)(xc,ny0,0,k) = (T)((val0+val1)/2); | |
18954 | (*this)(xc,ny1,0,k) = (T)((val2+val3)/2); | |
18955 | (*this)(nx0,yc,0,k) = (T)((val0+val2)/2); | |
18956 | (*this)(nx1,yc,0,k) = (T)((val1+val3)/2); | |
18957 | do { | |
18958 | val = (ftype)(0.25f*((ftype)((*this)(nx0,ny0,0,k)) + | |
18959 | (ftype)((*this)(nx1,ny0,0,k)) + | |
18960 | (ftype)((*this)(nx1,ny1,0,k)) + | |
18961 | (ftype)((*this)(nx0,ny1,0,k))) + | |
18962 | dc*cimg::grand()); | |
18963 | } while (val<(ftype)cimg::type<T>::min() || val>(ftype)cimg::type<T>::max()); | |
18964 | (*this)(xc,yc,0,k) = (T)val; | |
18965 | } else { | |
18966 | const ftype | |
18967 | val0 = (*this)(nx0,ny0,0,k), val1 = (*this)(nx1,ny0,0,k), | |
18968 | val2 = (*this)(nx0,ny1,0,k), val3 = (*this)(nx1,ny1,0,k); | |
18969 | (*this)(xc,ny0,0,k) = (T)(((val0+val1)*nopacity + copacity*(*this)(xc,ny0,0,k))/2); | |
18970 | (*this)(xc,ny1,0,k) = (T)(((val2+val3)*nopacity + copacity*(*this)(xc,ny1,0,k))/2); | |
18971 | (*this)(nx0,yc,0,k) = (T)(((val0+val2)*nopacity + copacity*(*this)(nx0,yc,0,k))/2); | |
18972 | (*this)(nx1,yc,0,k) = (T)(((val1+val3)*nopacity + copacity*(*this)(nx1,yc,0,k))/2); | |
18973 | do { | |
18974 | val = (ftype)(0.25f*(((ftype)((*this)(nx0,ny0,0,k)) + | |
18975 | (ftype)((*this)(nx1,ny0,0,k)) + | |
18976 | (ftype)((*this)(nx1,ny1,0,k)) + | |
18977 | (ftype)((*this)(nx0,ny1,0,k))) + | |
18978 | dc*cimg::grand())*nopacity + copacity*(*this)(xc,yc,0,k)); | |
18979 | } while (val<(ftype)cimg::type<T>::min() || val>(ftype)cimg::type<T>::max()); | |
18980 | (*this)(xc,yc,0,k) = (T)val; | |
18981 | } | |
18982 | } | |
18983 | if (xc!=nx0 || yc!=ny0) { | |
18984 | draw_plasma(nx0,ny0,xc,yc,alpha,beta,opacity); | |
18985 | draw_plasma(xc,ny0,nx1,yc,alpha,beta,opacity); | |
18986 | draw_plasma(nx0,yc,xc,ny1,alpha,beta,opacity); | |
18987 | draw_plasma(xc,yc,nx1,ny1,alpha,beta,opacity); | |
18988 | } | |
18989 | } | |
18990 | return *this; | |
18991 | } | |
18992 | CImg<T>& draw_plasma(const double alpha=1.0, const double beta=1.0, const float opacity=1.0f) { | |
18993 | return draw_plasma(0,0,width-1,height-1,alpha,beta,opacity); | |
18994 | } | |
18995 | template<typename tc> | |
18996 | CImg<T>& draw_gaussian(const float xc, const double sigma, const tc *const color, const float opacity=1.0f) { | |
18997 | if (!is_empty()) { | |
18998 | if (!color) throw CImgArgumentException("CImg<%s>::draw_gaussian() : Specified color is (null)",pixel_type()); | |
18999 | const double sigma2 = 2*sigma*sigma; | |
19000 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
19001 | const unsigned int whz = width*height*depth; | |
19002 | const tc *col = color; | |
19003 | for (int x = 0; x<(int)((*this).width); ++x) { | |
19004 | const float dx = (x-xc); | |
19005 | const double val = std::exp( -dx*dx/sigma2 ); | |
19006 | T *ptrd = ptr(x,0,0,0); | |
19007 | if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; } | |
19008 | else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; } | |
19009 | col-=dim; | |
19010 | } | |
19011 | } | |
19012 | return *this; | |
19013 | } | |
19014 | template<typename tc> | |
19015 | CImg<T>& draw_gaussian(const float xc, const double sigma, const CImg<tc>& color, const float opacity=1.0f) { | |
19016 | return draw_gaussian(xc,sigma,color.data,opacity); | |
19017 | } | |
19018 | template<typename t, typename tc> | |
19019 | CImg<T>& draw_gaussian(const float xc, const float yc, const CImg<t>& tensor, | |
19020 | const tc *const color, const float opacity=1.0f) { | |
19021 | typedef typename cimg::superset<t,float>::type ftype; | |
19022 | if (!is_empty()) { | |
19023 | if (tensor.width!=2 || tensor.height!=2 || tensor.depth!=1 || tensor.dim!=1) | |
19024 | throw CImgArgumentException("CImg<%s>::draw_gaussian() : Tensor parameter (%u,%u,%u,%u,%p) is not a 2x2 matrix.", | |
19025 | pixel_type(),tensor.width,tensor.height,tensor.depth,tensor.dim,tensor.data); | |
19026 | if (!color) throw CImgArgumentException("CImg<%s>::draw_gaussian() : Specified color is (null)",pixel_type()); | |
19027 | const CImg<ftype> invT = tensor.get_invert(), invT2 = (invT*invT)/(-2.0); | |
19028 | const ftype a = invT2(0,0), b = 2*invT2(1,0), c = invT2(1,1); | |
19029 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
19030 | const unsigned int whz = width*height*depth; | |
19031 | const tc *col = color; | |
19032 | float dy = -yc; | |
19033 | for (int y = 0; y<(int)((*this).height); ++y) { | |
19034 | float dx = -xc; | |
19035 | for (int x = 0; x<(int)((*this).width); ++x) { | |
19036 | const float val = (float)std::exp(a*dx*dx + b*dx*dy + c*dy*dy); | |
19037 | T *ptrd = ptr(x,y,0,0); | |
19038 | if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; } | |
19039 | else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; } | |
19040 | col-=dim; | |
19041 | ++dx; | |
19042 | } | |
19043 | ++dy; | |
19044 | } | |
19045 | } | |
19046 | return *this; | |
19047 | } | |
19048 | template<typename t, typename tc> | |
19049 | CImg<T>& draw_gaussian(const float xc, const float yc, const CImg<t>& tensor, | |
19050 | const CImg<tc>& color, const float opacity=1.0f) { | |
19051 | return draw_gaussian(xc,yc,tensor,color.data,opacity); | |
19052 | } | |
19053 | template<typename tc> | |
19054 | CImg<T>& draw_gaussian(const float xc, const float yc, const float sigma, const tc *const color, const float opacity=1.0f) { | |
19055 | return draw_gaussian(xc,yc,CImg<float>::diagonal(sigma,sigma),color,opacity); | |
19056 | } | |
19057 | template<typename tc> | |
19058 | CImg<T>& draw_gaussian(const float xc, const float yc, const float sigma, const CImg<tc>& color, const float opacity=1.0f) { | |
19059 | return draw_gaussian(xc,yc,sigma,color.data,opacity); | |
19060 | } | |
19061 | template<typename t, typename tc> | |
19062 | CImg<T>& draw_gaussian(const float xc, const float yc, const float zc, const CImg<t>& tensor, | |
19063 | const tc *const color, const float opacity=1.0f) { | |
19064 | if (!is_empty()) { | |
19065 | if (tensor.width!=3 || tensor.height!=3 || tensor.depth!=1 || tensor.dim!=1) | |
19066 | throw CImgArgumentException("CImg<%s>::draw_gaussian() : Tensor parameter (%u,%u,%u,%u,%p) is not a 3x3 matrix.", | |
19067 | pixel_type(),tensor.width,tensor.height,tensor.depth,tensor.dim,tensor.data); | |
19068 | const CImg<t> invT = tensor.get_invert(), invT2 = (invT*invT)/(-2.0); | |
19069 | const t a=invT(0,0), b=2*invT(1,0), c=2*invT(2,0), d=invT(1,1), e=2*invT(2,1), f=invT(2,2); | |
19070 | const float nopacity = cimg::abs(opacity), copacity = 1-cimg::max(opacity,0.0f); | |
19071 | const unsigned int whz = width*height*depth; | |
19072 | const tc *col = color; | |
19073 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
19074 | const float dx = (x-xc), dy = (y-yc), dz = (z-zc); | |
19075 | const double val = std::exp(a*dx*dx + b*dx*dy + c*dx*dz + d*dy*dy + e*dy*dz + f*dz*dz); | |
19076 | T *ptrd = ptr(x,y,z,0); | |
19077 | if (opacity>=1) for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; } | |
19078 | else for (int k = 0; k<(int)((*this).dim); ++k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; } | |
19079 | col-=dim; | |
19080 | } | |
19081 | } | |
19082 | return *this; | |
19083 | } | |
19084 | template<typename t, typename tc> | |
19085 | CImg<T>& draw_gaussian(const float xc, const float yc, const float zc, const CImg<t>& tensor, | |
19086 | const CImg<tc>& color, const float opacity=1.0f) { | |
19087 | return draw_gaussian(xc,yc,zc,tensor,color.data,opacity); | |
19088 | } | |
19089 | template<typename tc> | |
19090 | CImg<T>& draw_gaussian(const float xc, const float yc, const float zc, | |
19091 | const double sigma, const tc *const color, const float opacity=1.0f) { | |
19092 | return draw_gaussian(xc,yc,zc,CImg<float>::diagonal(sigma,sigma,sigma),color,opacity); | |
19093 | } | |
19094 | template<typename tc> | |
19095 | CImg<T>& draw_gaussian(const float xc, const float yc, const float zc, | |
19096 | const double sigma, const CImg<tc>& color, const float opacity=1.0f) { | |
19097 | return draw_gaussian(xc,yc,zc,sigma,color.data,opacity); | |
19098 | } | |
19099 | template<typename tp, typename tf, typename tc, typename to> | |
19100 | CImg<T>& draw_object3d(const float X, const float Y, const float Z, | |
19101 | const CImg<tp>& points, const CImgList<tf>& primitives, | |
19102 | const CImgList<tc>& colors, const CImgList<to>& opacities, | |
19103 | const unsigned int render_type=4, | |
19104 | const bool double_sided=false, const float focale=500, | |
19105 | const float lightx=0, const float lighty=0, const float lightz=-5000, | |
19106 | const float specular_light=0.2f, const float specular_shine=0.1f) { | |
19107 | static CImg<float> light_texture; | |
19108 | if (is_empty() || !points || !primitives) return *this; | |
19109 | if (!colors || !opacities) | |
19110 | throw CImgArgumentException("CImg<%s>::draw_object3d() : Undefined colors or opacities",pixel_type()); | |
19111 | if (points.height<3) | |
19112 | return draw_object3d(X,Y,Z,points.get_resize(-100,3,1,1,0),primitives,colors,opacities, | |
19113 | render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine); | |
19114 | const float | |
19115 | nspec = 1-(specular_light<0?0:(specular_light>1?1:specular_light)), | |
19116 | nspec2 = 1+(specular_shine<0?0:specular_shine), | |
19117 | nsl1 = (nspec2-1)/cimg::sqr(nspec-1), | |
19118 | nsl2 = (1-2*nsl1*nspec), | |
19119 | nsl3 = nspec2-nsl1-nsl2; | |
19120 | if (render_type==5) { | |
19121 | if (colors.size>primitives.size) light_texture.assign(colors[primitives.size])/=255; | |
19122 | else { | |
19123 | static float olightx = 0, olighty = 0, olightz = 0, ospecular_shine = 0; | |
19124 | if (!light_texture || lightx!=olightx || lighty!=olighty || lightz!=olightz || specular_shine!=ospecular_shine) { | |
19125 | light_texture.assign(512,512); | |
19126 | const float white[] = { 1.0f }, | |
19127 | dlx = lightx-X, dly = lighty-Y, dlz = lightz-Z, | |
19128 | nl = (float)std::sqrt(dlx*dlx+dly*dly+dlz*dlz), | |
19129 | nlx = light_texture.width/2*(1+dlx/nl), | |
19130 | nly = light_texture.height/2*(1+dly/nl); | |
19131 | light_texture.draw_gaussian(nlx,nly,light_texture.width/3.0f,white); | |
19132 | for (int y = 0; y<(int)((light_texture).height); ++y) for (int x = 0; x<(int)((light_texture).width); ++x) { | |
19133 | const float factor = light_texture(x,y); | |
19134 | if (factor>nspec) light_texture(x,y) = cimg::min(2.0f,nsl1*factor*factor+nsl2*factor+nsl3); | |
19135 | } | |
19136 | olightx = lightx; olighty = lighty; olightz = lightz; ospecular_shine = specular_shine; | |
19137 | } | |
19138 | } | |
19139 | } | |
19140 | CImg<float> projections(points.width,2); | |
19141 | for (int l = 0; l<(int)((points).width); ++l) { | |
19142 | const float | |
19143 | x = (float)points(l,0), | |
19144 | y = (float)points(l,1), | |
19145 | z = (float)points(l,2); | |
19146 | const float projectedz = z + Z + focale; | |
19147 | projections(l,1) = Y + focale*y/projectedz; | |
19148 | projections(l,0) = X + focale*x/projectedz; | |
19149 | } | |
19150 | CImg<unsigned int> visibles(primitives.size); | |
19151 | CImg<float> zrange(primitives.size); | |
19152 | unsigned int nb_visibles = 0; | |
19153 | const float zmin = -focale+1.5f; | |
19154 | { for (unsigned int l=0; l<(primitives).size; ++l) { | |
19155 | const CImg<tf>& primitive = primitives[l]; | |
19156 | switch (primitive.size()) { | |
19157 | case 1: { | |
19158 | const unsigned int i0 = (unsigned int)primitive(0); | |
19159 | const float x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z+points(i0,2)); | |
19160 | if (z0>zmin && x0>=0 && x0<width && y0>=0 && y0<height) { | |
19161 | visibles(nb_visibles) = (unsigned int)l; | |
19162 | zrange(nb_visibles++) = z0; | |
19163 | } | |
19164 | } break; | |
19165 | case 5: { | |
19166 | const unsigned int | |
19167 | i0 = (unsigned int)primitive(0), | |
19168 | i1 = (unsigned int)primitive(1), | |
19169 | i2 = (unsigned int)primitive(2); | |
19170 | const float x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z+points(i0,2)); | |
19171 | int radius; | |
19172 | if (i2) radius = (int)(i2*focale/(z0+focale)); | |
19173 | else { | |
19174 | const float x1 = projections(i1,0), y1 = projections(i1,1); | |
19175 | const int deltax = (int)(x1-x0), deltay = (int)(y1-y0); | |
19176 | radius = (int)std::sqrt((float)(deltax*deltax + deltay*deltay)); | |
19177 | } | |
19178 | if (z0>zmin && x0+radius>=0 && x0-radius<width && y0+radius>=0 && y0-radius<height) { | |
19179 | visibles(nb_visibles) = (unsigned int)l; | |
19180 | zrange(nb_visibles++) = z0; | |
19181 | } | |
19182 | } break; | |
19183 | case 2: | |
19184 | case 6: { | |
19185 | const unsigned int | |
19186 | i0 = (unsigned int)primitive(0), | |
19187 | i1 = (unsigned int)primitive(1); | |
19188 | const float | |
19189 | x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z+points(i0,2)), | |
19190 | x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z+points(i1,2)); | |
19191 | float xm, xM, ym, yM; | |
19192 | if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; } | |
19193 | if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; } | |
19194 | if (z0>zmin && z1>zmin && xM>=0 && xm<width && yM>=0 && ym<height) { | |
19195 | visibles(nb_visibles) = (unsigned int)l; | |
19196 | zrange(nb_visibles++) = 0.5f*(z0+z1); | |
19197 | } | |
19198 | } break; | |
19199 | case 3: | |
19200 | case 9: { | |
19201 | const unsigned int | |
19202 | i0 = (unsigned int)primitive(0), | |
19203 | i1 = (unsigned int)primitive(1), | |
19204 | i2 = (unsigned int)primitive(2); | |
19205 | const float | |
19206 | x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z+points(i0,2)), | |
19207 | x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z+points(i1,2)), | |
19208 | x2 = projections(i2,0), y2 = projections(i2,1), z2 = (float)(Z+points(i2,2)); | |
19209 | float xm, xM, ym, yM; | |
19210 | if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; } | |
19211 | if (x2<xm) xm = x2; | |
19212 | if (x2>xM) xM = x2; | |
19213 | if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; } | |
19214 | if (y2<ym) ym = y2; | |
19215 | if (y2>yM) yM = y2; | |
19216 | if (z0>zmin && z1>zmin && z2>zmin && xM>=0 && xm<width && yM>=0 && ym<height) { | |
19217 | const float d = (x1-x0)*(y2-y0)-(x2-x0)*(y1-y0); | |
19218 | if (double_sided || d<0) { | |
19219 | visibles(nb_visibles) = (unsigned int)l; | |
19220 | zrange(nb_visibles++) = (z0+z1+z2)/3; | |
19221 | } | |
19222 | } | |
19223 | } break; | |
19224 | case 4: | |
19225 | case 12: { | |
19226 | const unsigned int | |
19227 | i0 = (unsigned int)primitive(0), | |
19228 | i1 = (unsigned int)primitive(1), | |
19229 | i2 = (unsigned int)primitive(2), | |
19230 | i3 = (unsigned int)primitive(3); | |
19231 | const float | |
19232 | x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z+points(i0,2)), | |
19233 | x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z+points(i1,2)), | |
19234 | x2 = projections(i2,0), y2 = projections(i2,1), z2 = (float)(Z+points(i2,2)), | |
19235 | x3 = projections(i3,0), y3 = projections(i3,1), z3 = (float)(Z+points(i3,2)); | |
19236 | float xm, xM, ym, yM; | |
19237 | if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; } | |
19238 | if (x2<xm) xm = x2; | |
19239 | if (x2>xM) xM = x2; | |
19240 | if (x3<xm) xm = x3; | |
19241 | if (x3>xM) xM = x3; | |
19242 | if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; } | |
19243 | if (y2<ym) ym = y2; | |
19244 | if (y2>yM) yM = y2; | |
19245 | if (y3<ym) ym = y3; | |
19246 | if (y3>yM) yM = y3; | |
19247 | if (z0>zmin && z1>zmin && z2>zmin && z3>zmin && xM>=0 && xm<width && yM>=0 && ym<height) { | |
19248 | const float d = (x1-x0)*(y2-y0)-(x2-x0)*(y1-y0); | |
19249 | if (double_sided || d<0) { | |
19250 | visibles(nb_visibles) = (unsigned int)l; | |
19251 | zrange(nb_visibles++) = (z0+z1+z2+z3)/4; | |
19252 | } | |
19253 | } | |
19254 | } break; | |
19255 | default: | |
19256 | throw CImgArgumentException("CImg<%s>::draw_object3d() : Primitive %u is invalid (size = %u, can be 1,2,3,4,5,6,9 or 12)", | |
19257 | pixel_type(),l,primitive.size()); | |
19258 | }} | |
19259 | } | |
19260 | if (nb_visibles<=0) return *this; | |
19261 | CImg<unsigned int> permutations; | |
19262 | CImg<float>(zrange.data,nb_visibles,1,1,1,true).sort(permutations,false); | |
19263 | CImg<float> lightprops; | |
19264 | switch (render_type) { | |
19265 | case 3: { | |
19266 | lightprops.assign(nb_visibles); | |
19267 | for (int l = 0; l<(int)((lightprops).width); ++l) { | |
19268 | const CImg<tf>& primitive = primitives(visibles(permutations(l))); | |
19269 | const unsigned int psize = primitive.size(); | |
19270 | if (psize==3 || psize==4 || psize==9 || psize==12) { | |
19271 | const unsigned int | |
19272 | i0 = (unsigned int)primitive(0), | |
19273 | i1 = (unsigned int)primitive(1), | |
19274 | i2 = (unsigned int)primitive(2); | |
19275 | const float | |
19276 | x0 = (float)points(i0,0), y0 = (float)points(i0,1), z0 = (float)points(i0,2), | |
19277 | x1 = (float)points(i1,0), y1 = (float)points(i1,1), z1 = (float)points(i1,2), | |
19278 | x2 = (float)points(i2,0), y2 = (float)points(i2,1), z2 = (float)points(i2,2), | |
19279 | dx1 = x1-x0, dy1 = y1-y0, dz1 = z1-z0, | |
19280 | dx2 = x2-x0, dy2 = y2-y0, dz2 = z2-z0, | |
19281 | nx = dy1*dz2-dz1*dy2, | |
19282 | ny = dz1*dx2-dx1*dz2, | |
19283 | nz = dx1*dy2-dy1*dx2, | |
19284 | norm = (float)std::sqrt(1e-5f+nx*nx+ny*ny+nz*nz), | |
19285 | lx = X+(x0+x1+x2)/3-lightx, | |
19286 | ly = Y+(y0+y1+y2)/3-lighty, | |
19287 | lz = Z+(z0+z1+z2)/3-lightz, | |
19288 | nl = (float)std::sqrt(1e-5f+lx*lx+ly*ly+lz*lz), | |
19289 | factor = cimg::max(cimg::abs(-lx*nx-ly*ny-lz*nz)/(norm*nl),0.0f); | |
19290 | lightprops[l] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3); | |
19291 | } else lightprops[l] = 1.0f; | |
19292 | } | |
19293 | } break; | |
19294 | case 4: | |
19295 | case 5: { | |
19296 | CImg<float> points_normals(points.width,double_sided?7:3,1,1,0); | |
19297 | for (unsigned int l=0; l<nb_visibles; ++l) { | |
19298 | const CImg<tf>& primitive = primitives[visibles(l)]; | |
19299 | const unsigned int psize = primitive.size(); | |
19300 | const bool | |
19301 | triangle_flag = (psize==3) || (psize==9), | |
19302 | rectangle_flag = (psize==4) || (psize==12); | |
19303 | if (triangle_flag || rectangle_flag) { | |
19304 | const unsigned int | |
19305 | i0 = (unsigned int)primitive(0), | |
19306 | i1 = (unsigned int)primitive(1), | |
19307 | i2 = (unsigned int)primitive(2), | |
19308 | i3 = rectangle_flag?(unsigned int)primitive(3):0; | |
19309 | const float | |
19310 | x0 = (float)points(i0,0), y0 = (float)points(i0,1), z0 = (float)points(i0,2), | |
19311 | x1 = (float)points(i1,0), y1 = (float)points(i1,1), z1 = (float)points(i1,2), | |
19312 | x2 = (float)points(i2,0), y2 = (float)points(i2,1), z2 = (float)points(i2,2), | |
19313 | dx1 = x1-x0, dy1 = y1-y0, dz1 = z1-z0, | |
19314 | dx2 = x2-x0, dy2 = y2-y0, dz2 = z2-z0, | |
19315 | nnx = dy1*dz2-dz1*dy2, | |
19316 | nny = dz1*dx2-dx1*dz2, | |
19317 | nnz = dx1*dy2-dy1*dx2, | |
19318 | norm = 1e-5f + (float)std::sqrt(nnx*nnx+nny*nny+nnz*nnz), | |
19319 | nx = nnx/norm, | |
19320 | ny = nny/norm, | |
19321 | nz = nnz/norm; | |
19322 | if (double_sided) { | |
19323 | unsigned int ind = nz>0?3U:0U; | |
19324 | const float incr = nz>0?-1.0f:1.0f; | |
19325 | points_normals(i0, ind)+=nx; points_normals(i1,ind)+=nx; points_normals(i2,ind)+=nx; | |
19326 | points_normals(i0,++ind)+=ny; points_normals(i1,ind)+=ny; points_normals(i2,ind)+=ny; | |
19327 | points_normals(i0,++ind)+=nz; points_normals(i1,ind)+=nz; points_normals(i2,ind)+=nz; | |
19328 | points_normals(i0,6)+=incr; points_normals(i1,6)+=incr; points_normals(i2,6)+=incr; | |
19329 | if (rectangle_flag) { | |
19330 | points_normals(i3,ind)+=nz; points_normals(i3,--ind)+=ny; points_normals(i3,--ind)+=nz; points_normals(i3,6)+=incr; | |
19331 | } | |
19332 | } else { | |
19333 | points_normals(i0,0)+=nx; points_normals(i0,1)+=ny; points_normals(i0,2)+=nz; | |
19334 | points_normals(i1,0)+=nx; points_normals(i1,1)+=ny; points_normals(i1,2)+=nz; | |
19335 | points_normals(i2,0)+=nx; points_normals(i2,1)+=ny; points_normals(i2,2)+=nz; | |
19336 | if (rectangle_flag) { points_normals(i3,0)+=nx; points_normals(i3,1)+=ny; points_normals(i3,2)+=nz; } | |
19337 | } | |
19338 | } | |
19339 | } | |
19340 | if (double_sided) for (int l = 0; l<(int)((points_normals).width); ++l) if (points_normals(l,6)<0) { | |
19341 | points_normals(l,0) = -points_normals(l,3); | |
19342 | points_normals(l,1) = -points_normals(l,4); | |
19343 | points_normals(l,2) = -points_normals(l,5); | |
19344 | } | |
19345 | if (render_type==4) { | |
19346 | lightprops.assign(points.width); | |
19347 | for (int ll = 0; ll<(int)((points).width); ++ll) { | |
19348 | const float | |
19349 | nx = points_normals(ll,0), | |
19350 | ny = points_normals(ll,1), | |
19351 | nz = points_normals(ll,2), | |
19352 | norm = (float)std::sqrt(1e-5f+nx*nx+ny*ny+nz*nz), | |
19353 | lx = (float)(X+points(ll,0)-lightx), | |
19354 | ly = (float)(Y+points(ll,1)-lighty), | |
19355 | lz = (float)(Z+points(ll,2)-lightz), | |
19356 | nl = (float)std::sqrt(1e-5f+lx*lx+ly*ly+lz*lz), | |
19357 | factor = cimg::max((-lx*nx-ly*ny-lz*nz)/(norm*nl),0.0f); | |
19358 | lightprops[ll] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3); | |
19359 | } | |
19360 | } else { | |
19361 | const unsigned int | |
19362 | lw2 = light_texture.width/2-1, | |
19363 | lh2 = light_texture.height/2-1; | |
19364 | lightprops.assign(points.width,2); | |
19365 | for (int ll = 0; ll<(int)((points).width); ++ll) { | |
19366 | const float | |
19367 | nx = points_normals(ll,0), | |
19368 | ny = points_normals(ll,1), | |
19369 | nz = points_normals(ll,2), | |
19370 | norm = (float)std::sqrt(1e-5f+nx*nx+ny*ny+nz*nz), | |
19371 | nnx = nx/norm, | |
19372 | nny = ny/norm; | |
19373 | lightprops(ll,0) = lw2*(1+nnx); | |
19374 | lightprops(ll,1) = lh2*(1+nny); | |
19375 | } | |
19376 | } | |
19377 | } break; | |
19378 | } | |
19379 | const unsigned int opacsize = opacities.size; | |
19380 | { for (unsigned int l=0; l<nb_visibles; ++l) { | |
19381 | const unsigned int n_primitive = visibles(permutations(l)); | |
19382 | const CImg<tf>& primitive = primitives[n_primitive]; | |
19383 | const CImg<tc>& color = colors[n_primitive%colors.size]; | |
19384 | const CImg<to>& opacity = opacities[n_primitive%opacsize]; | |
19385 | const float opac = opacity.size()?(float)opacity(0):1.0f; | |
19386 | switch (primitive.size()) { | |
19387 | case 1: { | |
19388 | const unsigned int n0 = (unsigned int)primitive[0]; | |
19389 | const int x0 = (int)projections(n0,0), y0 = (int)projections(n0,1); | |
19390 | if (color.size()==dim) draw_point(x0,y0,color,opac); | |
19391 | else { | |
19392 | const float z = Z + points(n0,2); | |
19393 | const int | |
19394 | factor = (int)(focale*100/(z+focale)), | |
19395 | sw = color.width*factor/200, | |
19396 | sh = color.height*factor/200; | |
19397 | if (x0+sw>=0 && x0-sw<dimx() && y0+sh>=0 && y0-sh<dimy()) { | |
19398 | const CImg<T> sprite = color.get_resize(-factor,-factor,1,-100,render_type<=3?1:3); | |
19399 | if (opacity.width==color.width && opacity.height==color.height) | |
19400 | draw_image(sprite,opacity.get_resize(sprite.width,sprite.height,1,sprite.dim,1),x0-sw,y0-sh,0,0); | |
19401 | else draw_image(sprite,x0-sw,y0-sh,0,0,opac); | |
19402 | } | |
19403 | } | |
19404 | } break; | |
19405 | case 2: { | |
19406 | const unsigned int | |
19407 | n0 = (unsigned int)primitive[0], | |
19408 | n1 = (unsigned int)primitive[1]; | |
19409 | const int | |
19410 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1), | |
19411 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1); | |
19412 | if (render_type) draw_line(x0,y0,x1,y1,color,opac); | |
19413 | else draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac); | |
19414 | } break; | |
19415 | case 5: { | |
19416 | const unsigned int | |
19417 | n0 = (unsigned int)primitive[0], | |
19418 | n1 = (unsigned int)primitive[1], | |
19419 | n2 = (unsigned int)primitive[2]; | |
19420 | const int | |
19421 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1); | |
19422 | int radius; | |
19423 | if (n2) radius = (int)(n2*focale/(Z+points(n0,2)+focale)); | |
19424 | else { | |
19425 | const int | |
19426 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1), | |
19427 | deltax = x1-x0, deltay = y1-y0; | |
19428 | radius = (int)std::sqrt((float)(deltax*deltax + deltay*deltay)); | |
19429 | } | |
19430 | switch (render_type) { | |
19431 | case 0: | |
19432 | draw_point(x0,y0,color,opac); | |
19433 | break; | |
19434 | case 1: | |
19435 | draw_circle(x0,y0,radius,color,opac,~0U); | |
19436 | break; | |
19437 | default: | |
19438 | draw_circle(x0,y0,radius,color,opac); | |
19439 | break; | |
19440 | } | |
19441 | } break; | |
19442 | case 6: { | |
19443 | const unsigned int | |
19444 | n0 = (unsigned int)primitive[0], | |
19445 | n1 = (unsigned int)primitive[1], | |
19446 | tx0 = (unsigned int)primitive[2], | |
19447 | ty0 = (unsigned int)primitive[3], | |
19448 | tx1 = (unsigned int)primitive[4], | |
19449 | ty1 = (unsigned int)primitive[5]; | |
19450 | const int | |
19451 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1), | |
19452 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1); | |
19453 | const float | |
19454 | z0 = points(n0,2) + Z + focale, | |
19455 | z1 = points(n1,2) + Z + focale; | |
19456 | if (render_type) draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac); | |
19457 | else draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac). | |
19458 | draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac); | |
19459 | } break; | |
19460 | case 3: { | |
19461 | const unsigned int | |
19462 | n0 = (unsigned int)primitive[0], | |
19463 | n1 = (unsigned int)primitive[1], | |
19464 | n2 = (unsigned int)primitive[2]; | |
19465 | const int | |
19466 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1), | |
19467 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1), | |
19468 | x2 = (int)projections(n2,0), y2 = (int)projections(n2,1); | |
19469 | switch(render_type) { | |
19470 | case 0: | |
19471 | draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac).draw_point(x2,y2,color,opac); | |
19472 | break; | |
19473 | case 1: | |
19474 | draw_line(x0,y0,x1,y1,color,opac).draw_line(x0,y0,x2,y2,color,opac). | |
19475 | draw_line(x1,y1,x2,y2,color,opac); | |
19476 | break; | |
19477 | case 2: | |
19478 | draw_triangle(x0,y0,x1,y1,x2,y2,color,opac); | |
19479 | break; | |
19480 | case 3: | |
19481 | _draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opac,lightprops(l)); | |
19482 | break; | |
19483 | case 4: | |
19484 | draw_triangle(x0,y0,x1,y1,x2,y2,color,lightprops(n0),lightprops(n1),lightprops(n2),opac); | |
19485 | break; | |
19486 | case 5: | |
19487 | const unsigned int | |
19488 | lx0 = (unsigned int)lightprops(n0,0), ly0 = (unsigned int)lightprops(n0,1), | |
19489 | lx1 = (unsigned int)lightprops(n1,0), ly1 = (unsigned int)lightprops(n1,1), | |
19490 | lx2 = (unsigned int)lightprops(n2,0), ly2 = (unsigned int)lightprops(n2,1); | |
19491 | draw_triangle(x0,y0,x1,y1,x2,y2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac); | |
19492 | break; | |
19493 | } | |
19494 | } break; | |
19495 | case 4: { | |
19496 | const unsigned int | |
19497 | n0 = (unsigned int)primitive[0], | |
19498 | n1 = (unsigned int)primitive[1], | |
19499 | n2 = (unsigned int)primitive[2], | |
19500 | n3 = (unsigned int)primitive[3]; | |
19501 | const int | |
19502 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1), | |
19503 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1), | |
19504 | x2 = (int)projections(n2,0), y2 = (int)projections(n2,1), | |
19505 | x3 = (int)projections(n3,0), y3 = (int)projections(n3,1); | |
19506 | switch(render_type) { | |
19507 | case 0: | |
19508 | draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac). | |
19509 | draw_point(x2,y2,color,opac).draw_point(x3,y3,color,opac); | |
19510 | break; | |
19511 | case 1: | |
19512 | draw_line(x0,y0,x1,y1,color,opac).draw_line(x1,y1,x2,y2,color,opac). | |
19513 | draw_line(x2,y2,x3,y3,color,opac).draw_line(x3,y3,x0,y0,color,opac); | |
19514 | break; | |
19515 | case 2: | |
19516 | draw_triangle(x0,y0,x1,y1,x2,y2,color,opac).draw_triangle(x0,y0,x2,y2,x3,y3,color,opac); | |
19517 | break; | |
19518 | case 3: | |
19519 | _draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opac,lightprops(l)). | |
19520 | _draw_triangle(x0,y0,x2,y2,x3,y3,color.data,opac,lightprops(l)); | |
19521 | break; | |
19522 | case 4: { | |
19523 | const float | |
19524 | lightprop0 = lightprops(n0), lightprop1 = lightprops(n1), | |
19525 | lightprop2 = lightprops(n2), lightprop3 = lightprops(n3); | |
19526 | draw_triangle(x0,y0,x1,y1,x2,y2,color,lightprop0,lightprop1,lightprop2,opac). | |
19527 | draw_triangle(x0,y0,x2,y2,x3,y3,color,lightprop0,lightprop2,lightprop3,opac); | |
19528 | } break; | |
19529 | case 5: { | |
19530 | const unsigned int | |
19531 | lx0 = (unsigned int)lightprops(n0,0), ly0 = (unsigned int)lightprops(n0,1), | |
19532 | lx1 = (unsigned int)lightprops(n1,0), ly1 = (unsigned int)lightprops(n1,1), | |
19533 | lx2 = (unsigned int)lightprops(n2,0), ly2 = (unsigned int)lightprops(n2,1), | |
19534 | lx3 = (unsigned int)lightprops(n3,0), ly3 = (unsigned int)lightprops(n3,1); | |
19535 | draw_triangle(x0,y0,x1,y1,x2,y2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac). | |
19536 | draw_triangle(x0,y0,x2,y2,x3,y3,color,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac); | |
19537 | } break; | |
19538 | } | |
19539 | } break; | |
19540 | case 9: { | |
19541 | const unsigned int | |
19542 | n0 = (unsigned int)primitive[0], | |
19543 | n1 = (unsigned int)primitive[1], | |
19544 | n2 = (unsigned int)primitive[2], | |
19545 | tx0 = (unsigned int)primitive[3], | |
19546 | ty0 = (unsigned int)primitive[4], | |
19547 | tx1 = (unsigned int)primitive[5], | |
19548 | ty1 = (unsigned int)primitive[6], | |
19549 | tx2 = (unsigned int)primitive[7], | |
19550 | ty2 = (unsigned int)primitive[8]; | |
19551 | const int | |
19552 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1), | |
19553 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1), | |
19554 | x2 = (int)projections(n2,0), y2 = (int)projections(n2,1); | |
19555 | const float | |
19556 | z0 = points(n0,2) + Z + focale, | |
19557 | z1 = points(n1,2) + Z + focale, | |
19558 | z2 = points(n2,2) + Z + focale; | |
19559 | switch(render_type) { | |
19560 | case 0: | |
19561 | draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac). | |
19562 | draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac). | |
19563 | draw_point(x2,y2,color.get_vector_at(tx2,ty2),opac); | |
19564 | break; | |
19565 | case 1: | |
19566 | draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac). | |
19567 | draw_line(x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opac). | |
19568 | draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac); | |
19569 | break; | |
19570 | case 2: | |
19571 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac); | |
19572 | break; | |
19573 | case 3: | |
19574 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l)); | |
19575 | break; | |
19576 | case 4: | |
19577 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprops(n0),lightprops(n1),lightprops(n2),opac); | |
19578 | break; | |
19579 | case 5: | |
19580 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture, | |
19581 | (unsigned int)lightprops(n0,0), (unsigned int)lightprops(n0,1), | |
19582 | (unsigned int)lightprops(n1,0), (unsigned int)lightprops(n1,1), | |
19583 | (unsigned int)lightprops(n2,0), (unsigned int)lightprops(n2,1), | |
19584 | opac); | |
19585 | break; | |
19586 | } | |
19587 | } break; | |
19588 | case 12: { | |
19589 | const unsigned int | |
19590 | n0 = (unsigned int)primitive[0], | |
19591 | n1 = (unsigned int)primitive[1], | |
19592 | n2 = (unsigned int)primitive[2], | |
19593 | n3 = (unsigned int)primitive[3], | |
19594 | tx0 = (unsigned int)primitive[4], | |
19595 | ty0 = (unsigned int)primitive[5], | |
19596 | tx1 = (unsigned int)primitive[6], | |
19597 | ty1 = (unsigned int)primitive[7], | |
19598 | tx2 = (unsigned int)primitive[8], | |
19599 | ty2 = (unsigned int)primitive[9], | |
19600 | tx3 = (unsigned int)primitive[10], | |
19601 | ty3 = (unsigned int)primitive[11]; | |
19602 | const int | |
19603 | x0 = (int)projections(n0,0), y0 = (int)projections(n0,1), | |
19604 | x1 = (int)projections(n1,0), y1 = (int)projections(n1,1), | |
19605 | x2 = (int)projections(n2,0), y2 = (int)projections(n2,1), | |
19606 | x3 = (int)projections(n3,0), y3 = (int)projections(n3,1); | |
19607 | const float | |
19608 | z0 = points(n0,2) + Z + focale, | |
19609 | z1 = points(n1,2) + Z + focale, | |
19610 | z2 = points(n2,2) + Z + focale, | |
19611 | z3 = points(n3,2) + Z + focale; | |
19612 | switch(render_type) { | |
19613 | case 0: | |
19614 | draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac). | |
19615 | draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac). | |
19616 | draw_point(x2,y2,color.get_vector_at(tx2,ty2),opac). | |
19617 | draw_point(x3,y3,color.get_vector_at(tx3,ty3),opac); | |
19618 | break; | |
19619 | case 1: | |
19620 | draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac). | |
19621 | draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac). | |
19622 | draw_line(x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opac). | |
19623 | draw_line(x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opac); | |
19624 | break; | |
19625 | case 2: | |
19626 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac). | |
19627 | draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac); | |
19628 | break; | |
19629 | case 3: | |
19630 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l)). | |
19631 | draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac,lightprops(l)); | |
19632 | break; | |
19633 | case 4: { | |
19634 | const float | |
19635 | lightprop0 = lightprops(n0), lightprop1 = lightprops(n1), | |
19636 | lightprop2 = lightprops(n2), lightprop3 = lightprops(n3); | |
19637 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprop0,lightprop1,lightprop2,opac). | |
19638 | draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,lightprop0,lightprop2,lightprop3,opac); | |
19639 | } break; | |
19640 | case 5: { | |
19641 | const unsigned int | |
19642 | lx0 = (unsigned int)lightprops(n0,0), ly0 = (unsigned int)lightprops(n0,1), | |
19643 | lx1 = (unsigned int)lightprops(n1,0), ly1 = (unsigned int)lightprops(n1,1), | |
19644 | lx2 = (unsigned int)lightprops(n2,0), ly2 = (unsigned int)lightprops(n2,1), | |
19645 | lx3 = (unsigned int)lightprops(n3,0), ly3 = (unsigned int)lightprops(n3,1); | |
19646 | draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac). | |
19647 | draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac); | |
19648 | } break; | |
19649 | } | |
19650 | } break; | |
19651 | } | |
19652 | } | |
19653 | } | |
19654 | return *this; | |
19655 | } | |
19656 | template<typename tp, typename tf, typename tc, typename to> | |
19657 | CImg<T>& draw_object3d(const float X, const float Y, const float Z, | |
19658 | const CImgList<tp>& points, const CImgList<tf>& primitives, | |
19659 | const CImgList<tc>& colors, const CImgList<to>& opacities, | |
19660 | const unsigned int render_type=4, | |
19661 | const bool double_sided=false, const float focale=500, | |
19662 | const float lightx=0, const float lighty=0, const float lightz=-5000, | |
19663 | const float specular_light=0.2f, const float specular_shine=0.1f) { | |
19664 | if (!points) return *this; | |
19665 | CImg<tp> npoints(points.size,3,1,1,0); | |
19666 | tp *ptrX = npoints.data, *ptrY = npoints.ptr(0,1), *ptrZ = npoints.ptr(0,2); | |
19667 | for (int l = 0; l<(int)((npoints).width); ++l) { | |
19668 | const CImg<tp>& point = points[l]; | |
19669 | const unsigned int siz = point.size(); | |
19670 | if (!siz) | |
19671 | throw CImgArgumentException("CImg<%s>::draw_object3d() : Given points (size=%u) contains a null element at " | |
19672 | "position %u.",pixel_type(),points.size,l); | |
19673 | *(ptrZ++) = (siz>2)?point(2):0; | |
19674 | *(ptrY++) = (siz>1)?point(1):0; | |
19675 | *(ptrX++) = point(0); | |
19676 | } | |
19677 | return draw_object3d(X,Y,Z,npoints,primitives,colors,opacities, | |
19678 | render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine); | |
19679 | } | |
19680 | template<typename tp, typename tf, typename tc, typename to> | |
19681 | CImg<T>& draw_object3d(const float X, const float Y, const float Z, | |
19682 | const CImg<tp>& points, const CImgList<tf>& primitives, | |
19683 | const CImgList<tc>& colors, const CImg<to>& opacities, | |
19684 | const unsigned int render_type=4, | |
19685 | const bool double_sided=false, const float focale=500, | |
19686 | const float lightx=0, const float lighty=0, const float lightz=-5000, | |
19687 | const float specular_light=0.2f, const float specular_shine=0.1f) { | |
19688 | CImgList<to> nopacities(opacities.size(),1); | |
19689 | for (unsigned int l=0; l<(nopacities).size; ++l) nopacities(l,0) = opacities(l); | |
19690 | return draw_object3d(X,Y,Z,points,primitives,colors,nopacities, | |
19691 | render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine); | |
19692 | } | |
19693 | template<typename tp, typename tf, typename tc, typename to> | |
19694 | CImg<T>& draw_object3d(const float X, const float Y, const float Z, | |
19695 | const CImgList<tp>& points, const CImgList<tf>& primitives, | |
19696 | const CImgList<tc>& colors, const CImg<to>& opacities, | |
19697 | const unsigned int render_type=4, | |
19698 | const bool double_sided=false, const float focale=500, | |
19699 | const float lightx=0, const float lighty=0, const float lightz=-5000, | |
19700 | const float specular_light=0.2f, const float specular_shine=0.1f) { | |
19701 | CImgList<to> nopacities(opacities.size(),1); | |
19702 | { for (unsigned int l=0; l<(nopacities).size; ++l) nopacities(l,0) = opacities(l); } | |
19703 | if (!points) return *this; | |
19704 | CImg<tp> npoints(points.size,3,1,1,0); | |
19705 | tp *ptrX = npoints.data, *ptrY = npoints.ptr(0,1), *ptrZ = npoints.ptr(0,2); | |
19706 | for (int l = 0; l<(int)((npoints).width); ++l) { | |
19707 | const CImg<tp>& point = points[l]; | |
19708 | const unsigned int siz = point.size(); | |
19709 | if (!siz) | |
19710 | throw CImgArgumentException("CImg<%s>::draw_object3d() : Given points (size=%u) contains a null element at " | |
19711 | "position %u.",pixel_type(),points.size,l); | |
19712 | *(ptrZ++) = (siz>2)?point(2):0; | |
19713 | *(ptrY++) = (siz>1)?point(1):0; | |
19714 | *(ptrX++) = point(0); | |
19715 | } | |
19716 | return draw_object3d(X,Y,Z,npoints,primitives,colors,nopacities, | |
19717 | render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine); | |
19718 | } | |
19719 | template<typename tp, typename tf, typename tc> | |
19720 | CImg<T>& draw_object3d(const float X, const float Y, const float Z, | |
19721 | const tp& points, const CImgList<tf>& primitives, | |
19722 | const CImgList<tc>& colors, | |
19723 | const unsigned int render_type=4, | |
19724 | const bool double_sided=false, const float focale=500, | |
19725 | const float lightx=0, const float lighty=0, const float lightz=-5000, | |
19726 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
19727 | const float opacity=1.0f) { | |
19728 | return draw_object3d(X,Y,Z,points,primitives,colors, | |
19729 | CImg<float>(primitives.size,1,1,1,opacity), | |
19730 | render_type,double_sided,focale,lightx,lighty,lightz, | |
19731 | specular_light,specular_shine); | |
19732 | } | |
19733 | template<typename t> CImg<typename cimg::superset2<T,t,float>::type> | |
19734 | get_correlate(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_correl=false) const { | |
19735 | typedef typename cimg::superset2<T,t,float>::type ftype; | |
19736 | if (is_empty()) return CImg<ftype>(); | |
19737 | if (!mask || mask.dim!=1) | |
19738 | throw CImgArgumentException("CImg<%s>::correlate() : Specified mask (%u,%u,%u,%u,%p) is not scalar.", | |
19739 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data); | |
19740 | CImg<ftype> dest(width,height,depth,dim); | |
19741 | if (cond && mask.width==mask.height && ((mask.depth==1 && mask.width<=5) || (mask.depth==mask.width && mask.width<=3))) { | |
19742 | switch (mask.depth) { | |
19743 | case 3: { | |
19744 | T I[27] = { 0 }; | |
19745 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,v)), (I[3] = I[4] = (*this)(0,y,_p1z,v)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,v)), (I[9] = I[10] = (*this)(0,_p1y,z,v)), (I[12] = I[13] = (*this)(0,y,z,v)), (I[15] = I[16] = (*this)(0,_n1y,z,v)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,v)), (I[21] = I[22] = (*this)(0,y,_n1z,v)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,v)), (I[5] = (*this)(_n1x,y,_p1z,v)), (I[8] = (*this)(_n1x,_n1y,_p1z,v)), (I[11] = (*this)(_n1x,_p1y,z,v)), (I[14] = (*this)(_n1x,y,z,v)), (I[17] = (*this)(_n1x,_n1y,z,v)), (I[20] = (*this)(_n1x,_p1y,_n1z,v)), (I[23] = (*this)(_n1x,y,_n1z,v)), (I[26] = (*this)(_n1x,_n1y,_n1z,v)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) dest(x,y,z,v) = (ftype) | |
19746 | (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + | |
19747 | I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + I[ 5]*mask[ 5] + | |
19748 | I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + | |
19749 | I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] + | |
19750 | I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + | |
19751 | I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] + | |
19752 | I[18]*mask[18] + I[19]*mask[19] + I[20]*mask[20] + | |
19753 | I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] + | |
19754 | I[24]*mask[24] + I[25]*mask[25] + I[26]*mask[26]); | |
19755 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,v)), (I[3] = I[4] = (*this)(0,y,_p1z,v)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,v)), (I[9] = I[10] = (*this)(0,_p1y,z,v)), (I[12] = I[13] = (*this)(0,y,z,v)), (I[15] = I[16] = (*this)(0,_n1y,z,v)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,v)), (I[21] = I[22] = (*this)(0,y,_n1z,v)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,v)), (I[5] = (*this)(_n1x,y,_p1z,v)), (I[8] = (*this)(_n1x,_n1y,_p1z,v)), (I[11] = (*this)(_n1x,_p1y,z,v)), (I[14] = (*this)(_n1x,y,z,v)), (I[17] = (*this)(_n1x,_n1y,z,v)), (I[20] = (*this)(_n1x,_p1y,_n1z,v)), (I[23] = (*this)(_n1x,y,_n1z,v)), (I[26] = (*this)(_n1x,_n1y,_n1z,v)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
19756 | const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + | |
19757 | I[ 3]*I[ 3] + I[ 4]*I[ 4] + I[ 5]*I[ 5] + | |
19758 | I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + | |
19759 | I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] + | |
19760 | I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + | |
19761 | I[15]*I[15] + I[16]*I[16] + I[17]*I[17] + | |
19762 | I[18]*I[18] + I[19]*I[19] + I[20]*I[20] + | |
19763 | I[21]*I[21] + I[22]*I[22] + I[23]*I[23] + | |
19764 | I[24]*I[24] + I[25]*I[25] + I[26]*I[26]); | |
19765 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19766 | } | |
19767 | } break; | |
19768 | case 2: { | |
19769 | T I[8] = { 0 }; | |
19770 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; ++z, ++_n1z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = (int)( (I[0] = (*this)(0,y,z,v)), (I[2] = (*this)(0,_n1y,z,v)), (I[4] = (*this)(0,y,_n1z,v)), (I[6] = (*this)(0,_n1y,_n1z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[1] = (*this)(_n1x,y,z,v)), (I[3] = (*this)(_n1x,_n1y,z,v)), (I[5] = (*this)(_n1x,y,_n1z,v)), (I[7] = (*this)(_n1x,_n1y,_n1z,v)),1)) || x==--_n1x; I[0] = I[1], I[2] = I[3], I[4] = I[5], I[6] = I[7], ++x, ++_n1x) dest(x,y,z,v) = (ftype) | |
19771 | (I[0]*mask[0] + I[1]*mask[1] + | |
19772 | I[2]*mask[2] + I[3]*mask[3] + | |
19773 | I[4]*mask[4] + I[5]*mask[5] + | |
19774 | I[6]*mask[6] + I[7]*mask[7]); | |
19775 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; ++z, ++_n1z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = (int)( (I[0] = (*this)(0,y,z,v)), (I[2] = (*this)(0,_n1y,z,v)), (I[4] = (*this)(0,y,_n1z,v)), (I[6] = (*this)(0,_n1y,_n1z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[1] = (*this)(_n1x,y,z,v)), (I[3] = (*this)(_n1x,_n1y,z,v)), (I[5] = (*this)(_n1x,y,_n1z,v)), (I[7] = (*this)(_n1x,_n1y,_n1z,v)),1)) || x==--_n1x; I[0] = I[1], I[2] = I[3], I[4] = I[5], I[6] = I[7], ++x, ++_n1x) { | |
19776 | const double weight = (double)(I[0]*I[0] + I[1]*I[1] + | |
19777 | I[2]*I[2] + I[3]*I[3] + | |
19778 | I[4]*I[4] + I[5]*I[5] + | |
19779 | I[6]*I[6] + I[7]*I[7]); | |
19780 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19781 | } | |
19782 | } break; | |
19783 | default: | |
19784 | case 1: | |
19785 | switch (mask.width) { | |
19786 | case 6: { | |
19787 | T I[36] = { 0 }; | |
19788 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3; _n3y<(int)((*this).height) || _n2y==--_n3y || _n1y==--_n2y || y==(_n3y = _n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = 2>=(*this).width?(int)((*this).width)-1:2, _n3x = (int)( (I[0] = I[1] = I[2] = (*this)(0,_p2y,z,v)), (I[6] = I[7] = I[8] = (*this)(0,_p1y,z,v)), (I[12] = I[13] = I[14] = (*this)(0,y,z,v)), (I[18] = I[19] = I[20] = (*this)(0,_n1y,z,v)), (I[24] = I[25] = I[26] = (*this)(0,_n2y,z,v)), (I[30] = I[31] = I[32] = (*this)(0,_n3y,z,v)), (I[3] = (*this)(_n1x,_p2y,z,v)), (I[9] = (*this)(_n1x,_p1y,z,v)), (I[15] = (*this)(_n1x,y,z,v)), (I[21] = (*this)(_n1x,_n1y,z,v)), (I[27] = (*this)(_n1x,_n2y,z,v)), (I[33] = (*this)(_n1x,_n3y,z,v)), (I[4] = (*this)(_n2x,_p2y,z,v)), (I[10] = (*this)(_n2x,_p1y,z,v)), (I[16] = (*this)(_n2x,y,z,v)), (I[22] = (*this)(_n2x,_n1y,z,v)), (I[28] = (*this)(_n2x,_n2y,z,v)), (I[34] = (*this)(_n2x,_n3y,z,v)), 3>=(*this).width?(int)((*this).width)-1:3); (_n3x<(int)((*this).width) && ( (I[5] = (*this)(_n3x,_p2y,z,v)), (I[11] = (*this)(_n3x,_p1y,z,v)), (I[17] = (*this)(_n3x,y,z,v)), (I[23] = (*this)(_n3x,_n1y,z,v)), (I[29] = (*this)(_n3x,_n2y,z,v)), (I[35] = (*this)(_n3x,_n3y,z,v)),1)) || _n2x==--_n3x || _n1x==--_n2x || x==(_n3x = _n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[8] = I[9], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[14] = I[15], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], I[26] = I[27], I[27] = I[28], I[28] = I[29], I[30] = I[31], I[31] = I[32], I[32] = I[33], I[33] = I[34], I[34] = I[35], _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x) dest(x,y,z,v) = (ftype) | |
19789 | (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + I[ 5]*mask[ 5] + | |
19790 | I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] + | |
19791 | I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] + | |
19792 | I[18]*mask[18] + I[19]*mask[19] + I[20]*mask[20] + I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] + | |
19793 | I[24]*mask[24] + I[25]*mask[25] + I[26]*mask[26] + I[27]*mask[27] + I[28]*mask[28] + I[29]*mask[29] + | |
19794 | I[30]*mask[30] + I[31]*mask[31] + I[32]*mask[32] + I[33]*mask[33] + I[34]*mask[34] + I[35]*mask[35]); | |
19795 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = (int)( (I[0] = I[1] = I[2] = (*this)(0,_p2y,z,v)), (I[5] = I[6] = I[7] = (*this)(0,_p1y,z,v)), (I[10] = I[11] = I[12] = (*this)(0,y,z,v)), (I[15] = I[16] = I[17] = (*this)(0,_n1y,z,v)), (I[20] = I[21] = I[22] = (*this)(0,_n2y,z,v)), (I[3] = (*this)(_n1x,_p2y,z,v)), (I[8] = (*this)(_n1x,_p1y,z,v)), (I[13] = (*this)(_n1x,y,z,v)), (I[18] = (*this)(_n1x,_n1y,z,v)), (I[23] = (*this)(_n1x,_n2y,z,v)), 2>=(*this).width?(int)((*this).width)-1:2); (_n2x<(int)((*this).width) && ( (I[4] = (*this)(_n2x,_p2y,z,v)), (I[9] = (*this)(_n2x,_p1y,z,v)), (I[14] = (*this)(_n2x,y,z,v)), (I[19] = (*this)(_n2x,_n1y,z,v)), (I[24] = (*this)(_n2x,_n2y,z,v)),1)) || _n1x==--_n2x || x==(_n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[5] = I[6], I[6] = I[7], I[7] = I[8], I[8] = I[9], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x) { | |
19796 | const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + I[ 4]*I[ 4] + I[ 5]*I[ 5] + | |
19797 | I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] + | |
19798 | I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + I[15]*I[15] + I[16]*I[16] + I[17]*I[17] + | |
19799 | I[18]*I[18] + I[19]*I[19] + I[20]*I[20] + I[21]*I[21] + I[22]*I[22] + I[23]*I[23] + | |
19800 | I[24]*I[24] + I[25]*I[25] + I[26]*I[26] + I[27]*I[27] + I[28]*I[28] + I[29]*I[29] + | |
19801 | I[30]*I[30] + I[31]*I[31] + I[32]*I[32] + I[33]*I[33] + I[34]*I[34] + I[35]*I[35]); | |
19802 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19803 | } | |
19804 | } break; | |
19805 | case 5: { | |
19806 | T I[25] = { 0 }; | |
19807 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = (int)( (I[0] = I[1] = I[2] = (*this)(0,_p2y,z,v)), (I[5] = I[6] = I[7] = (*this)(0,_p1y,z,v)), (I[10] = I[11] = I[12] = (*this)(0,y,z,v)), (I[15] = I[16] = I[17] = (*this)(0,_n1y,z,v)), (I[20] = I[21] = I[22] = (*this)(0,_n2y,z,v)), (I[3] = (*this)(_n1x,_p2y,z,v)), (I[8] = (*this)(_n1x,_p1y,z,v)), (I[13] = (*this)(_n1x,y,z,v)), (I[18] = (*this)(_n1x,_n1y,z,v)), (I[23] = (*this)(_n1x,_n2y,z,v)), 2>=(*this).width?(int)((*this).width)-1:2); (_n2x<(int)((*this).width) && ( (I[4] = (*this)(_n2x,_p2y,z,v)), (I[9] = (*this)(_n2x,_p1y,z,v)), (I[14] = (*this)(_n2x,y,z,v)), (I[19] = (*this)(_n2x,_n1y,z,v)), (I[24] = (*this)(_n2x,_n2y,z,v)),1)) || _n1x==--_n2x || x==(_n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[5] = I[6], I[6] = I[7], I[7] = I[8], I[8] = I[9], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x) dest(x,y,z,v) = (ftype) | |
19808 | (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + | |
19809 | I[ 5]*mask[ 5] + I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + | |
19810 | I[10]*mask[10] + I[11]*mask[11] + I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + | |
19811 | I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] + I[18]*mask[18] + I[19]*mask[19] + | |
19812 | I[20]*mask[20] + I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] + I[24]*mask[24]); | |
19813 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = (int)( (I[0] = I[1] = I[2] = (*this)(0,_p2y,z,v)), (I[5] = I[6] = I[7] = (*this)(0,_p1y,z,v)), (I[10] = I[11] = I[12] = (*this)(0,y,z,v)), (I[15] = I[16] = I[17] = (*this)(0,_n1y,z,v)), (I[20] = I[21] = I[22] = (*this)(0,_n2y,z,v)), (I[3] = (*this)(_n1x,_p2y,z,v)), (I[8] = (*this)(_n1x,_p1y,z,v)), (I[13] = (*this)(_n1x,y,z,v)), (I[18] = (*this)(_n1x,_n1y,z,v)), (I[23] = (*this)(_n1x,_n2y,z,v)), 2>=(*this).width?(int)((*this).width)-1:2); (_n2x<(int)((*this).width) && ( (I[4] = (*this)(_n2x,_p2y,z,v)), (I[9] = (*this)(_n2x,_p1y,z,v)), (I[14] = (*this)(_n2x,y,z,v)), (I[19] = (*this)(_n2x,_n1y,z,v)), (I[24] = (*this)(_n2x,_n2y,z,v)),1)) || _n1x==--_n2x || x==(_n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[5] = I[6], I[6] = I[7], I[7] = I[8], I[8] = I[9], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x) { | |
19814 | const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + I[ 4]*I[ 4] + | |
19815 | I[ 5]*I[ 5] + I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + I[ 9]*I[ 9] + | |
19816 | I[10]*I[10] + I[11]*I[11] + I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + | |
19817 | I[15]*I[15] + I[16]*I[16] + I[17]*I[17] + I[18]*I[18] + I[19]*I[19] + | |
19818 | I[20]*I[20] + I[21]*I[21] + I[22]*I[22] + I[23]*I[23] + I[24]*I[24]); | |
19819 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19820 | } | |
19821 | } break; | |
19822 | case 4: { | |
19823 | T I[16] = { 0 }; | |
19824 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,v)), (I[4] = I[5] = (*this)(0,y,z,v)), (I[8] = I[9] = (*this)(0,_n1y,z,v)), (I[12] = I[13] = (*this)(0,_n2y,z,v)), (I[2] = (*this)(_n1x,_p1y,z,v)), (I[6] = (*this)(_n1x,y,z,v)), (I[10] = (*this)(_n1x,_n1y,z,v)), (I[14] = (*this)(_n1x,_n2y,z,v)), 2>=(*this).width?(int)((*this).width)-1:2); (_n2x<(int)((*this).width) && ( (I[3] = (*this)(_n2x,_p1y,z,v)), (I[7] = (*this)(_n2x,y,z,v)), (I[11] = (*this)(_n2x,_n1y,z,v)), (I[15] = (*this)(_n2x,_n2y,z,v)),1)) || _n1x==--_n2x || x==(_n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[4] = I[5], I[5] = I[6], I[6] = I[7], I[8] = I[9], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[14] = I[15], _p1x = x++, ++_n1x, ++_n2x) dest(x,y,z,v) = (ftype) | |
19825 | (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + | |
19826 | I[ 4]*mask[ 4] + I[ 5]*mask[ 5] + I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + | |
19827 | I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] + | |
19828 | I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + I[15]*mask[15]); | |
19829 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,v)), (I[4] = I[5] = (*this)(0,y,z,v)), (I[8] = I[9] = (*this)(0,_n1y,z,v)), (I[12] = I[13] = (*this)(0,_n2y,z,v)), (I[2] = (*this)(_n1x,_p1y,z,v)), (I[6] = (*this)(_n1x,y,z,v)), (I[10] = (*this)(_n1x,_n1y,z,v)), (I[14] = (*this)(_n1x,_n2y,z,v)), 2>=(*this).width?(int)((*this).width)-1:2); (_n2x<(int)((*this).width) && ( (I[3] = (*this)(_n2x,_p1y,z,v)), (I[7] = (*this)(_n2x,y,z,v)), (I[11] = (*this)(_n2x,_n1y,z,v)), (I[15] = (*this)(_n2x,_n2y,z,v)),1)) || _n1x==--_n2x || x==(_n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[4] = I[5], I[5] = I[6], I[6] = I[7], I[8] = I[9], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[14] = I[15], _p1x = x++, ++_n1x, ++_n2x) { | |
19830 | const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + | |
19831 | I[ 4]*I[ 4] + I[ 5]*I[ 5] + I[ 6]*I[ 6] + I[ 7]*I[ 7] + | |
19832 | I[ 8]*I[ 8] + I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] + | |
19833 | I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + I[15]*I[15]); | |
19834 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19835 | } | |
19836 | } break; | |
19837 | case 3: { | |
19838 | T I[9] = { 0 }; | |
19839 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,v)), (I[3] = I[4] = (*this)(0,y,z,v)), (I[6] = I[7] = (*this)(0,_n1y,z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,v)), (I[5] = (*this)(_n1x,y,z,v)), (I[8] = (*this)(_n1x,_n1y,z,v)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) dest(x,y,z,v) = (ftype) | |
19840 | (I[0]*mask[0] + I[1]*mask[1] + I[2]*mask[2] + | |
19841 | I[3]*mask[3] + I[4]*mask[4] + I[5]*mask[5] + | |
19842 | I[6]*mask[6] + I[7]*mask[7] + I[8]*mask[8]); | |
19843 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,z,v)), (I[3] = I[4] = (*this)(0,y,z,v)), (I[6] = I[7] = (*this)(0,_n1y,z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,z,v)), (I[5] = (*this)(_n1x,y,z,v)), (I[8] = (*this)(_n1x,_n1y,z,v)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
19844 | const double weight = (double)(I[0]*I[0] + I[1]*I[1] + I[2]*I[2] + | |
19845 | I[3]*I[3] + I[4]*I[4] + I[5]*I[5] + | |
19846 | I[6]*I[6] + I[7]*I[7] + I[8]*I[8]); | |
19847 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19848 | } | |
19849 | } break; | |
19850 | case 2: { | |
19851 | T I[4] = { 0 }; | |
19852 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = (int)( (I[0] = (*this)(0,y,z,v)), (I[2] = (*this)(0,_n1y,z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[1] = (*this)(_n1x,y,z,v)), (I[3] = (*this)(_n1x,_n1y,z,v)),1)) || x==--_n1x; I[0] = I[1], I[2] = I[3], ++x, ++_n1x) dest(x,y,z,v) = (ftype) | |
19853 | (I[0]*mask[0] + I[1]*mask[1] + | |
19854 | I[2]*mask[2] + I[3]*mask[3]); | |
19855 | if (weighted_correl) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = (int)( (I[0] = (*this)(0,y,z,v)), (I[2] = (*this)(0,_n1y,z,v)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[1] = (*this)(_n1x,y,z,v)), (I[3] = (*this)(_n1x,_n1y,z,v)),1)) || x==--_n1x; I[0] = I[1], I[2] = I[3], ++x, ++_n1x) { | |
19856 | const double weight = (double)(I[0]*I[0] + I[1]*I[1] + | |
19857 | I[2]*I[2] + I[3]*I[3]); | |
19858 | if (weight>0) dest(x,y,z,v)/=(ftype)std::sqrt(weight); | |
19859 | } | |
19860 | } break; | |
19861 | case 1: (dest.assign(*this))*=mask(0); break; | |
19862 | } | |
19863 | } | |
19864 | } else { | |
19865 | const int | |
19866 | mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2, | |
19867 | mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2), | |
19868 | mxe = dimx() - mx2, mye = dimy() - my2, mze = dimz() - mz2; | |
19869 | for (int v = 0; v<(int)((*this).dim); ++v) | |
19870 | if (!weighted_correl) { | |
19871 | for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) { | |
19872 | ftype val = 0; | |
19873 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) | |
19874 | val+=(*this)(x+xm,y+ym,z+zm,v)*mask(mx1+xm,my1+ym,mz1+zm); | |
19875 | dest(x,y,z,v) = (ftype)val; | |
19876 | } | |
19877 | if (cond) | |
19878 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19879 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19880 | ftype val = 0; | |
19881 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) | |
19882 | val+=pix3d(x+xm,y+ym,z+zm,v)*mask(mx1+xm,my1+ym,mz1+zm); | |
19883 | dest(x,y,z,v) = (ftype)val; | |
19884 | } | |
19885 | else | |
19886 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19887 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19888 | ftype val = 0; | |
19889 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) | |
19890 | val+=pix3d(x+xm,y+ym,z+zm,v,0)*mask(mx1+xm,my1+ym,mz1+zm); | |
19891 | dest(x,y,z,v) = (ftype)val; | |
19892 | } | |
19893 | } else { | |
19894 | for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) { | |
19895 | ftype val = 0, weight = 0; | |
19896 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19897 | const ftype cval = (ftype)(*this)(x+xm,y+ym,z+zm,v); | |
19898 | val+=cval*mask(mx1+xm,my1+ym,mz1+zm); | |
19899 | weight+=cval*cval; | |
19900 | } | |
19901 | dest(x,y,z,v) = (weight>0)?(ftype)(val/std::sqrt((double)weight)):0; | |
19902 | } | |
19903 | if (cond) | |
19904 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19905 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19906 | ftype val = 0, weight = 0; | |
19907 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19908 | const ftype cval = (ftype)pix3d(x+xm,y+ym,z+zm,v); | |
19909 | val+=cval*mask(mx1+xm,my1+ym,mz1+zm); | |
19910 | weight+=cval*cval; | |
19911 | } | |
19912 | dest(x,y,z,v) = (weight>0)?(ftype)(val/std::sqrt((double)weight)):0; | |
19913 | } | |
19914 | else | |
19915 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19916 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19917 | ftype val = 0, weight = 0; | |
19918 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19919 | const ftype cval = (ftype)pix3d(x+xm,y+ym,z+zm,v,0); | |
19920 | val+=cval*mask(mx1+xm,my1+ym,mz1+zm); | |
19921 | weight+=cval*cval; | |
19922 | } | |
19923 | dest(x,y,z,v) = (weight>0)?(ftype)(val/std::sqrt((double)weight)):0; | |
19924 | } | |
19925 | } | |
19926 | } | |
19927 | return dest; | |
19928 | } | |
19929 | template<typename t> CImg<T>& correlate(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_correl=false) { | |
19930 | return get_correlate(mask,cond,weighted_correl).transfer_to(*this); | |
19931 | } | |
19932 | template<typename t> CImg<typename cimg::superset2<T,t,float>::type> | |
19933 | get_convolve(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_convol=false) const { | |
19934 | typedef typename cimg::superset2<T,t,float>::type ftype; | |
19935 | if (is_empty()) return CImg<ftype>(); | |
19936 | if (!mask || mask.dim!=1) | |
19937 | throw CImgArgumentException("CImg<%s>::convolve() : Specified mask (%u,%u,%u,%u,%p) is not scalar.", | |
19938 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data); | |
19939 | return get_correlate(CImg<t>(mask.ptr(),mask.size(),1,1,1,true).get_mirror('x').resize(mask,-1),cond,weighted_convol); | |
19940 | } | |
19941 | template<typename t> CImg<T>& convolve(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_convol=false) { | |
19942 | return get_convolve(mask,cond,weighted_convol).transfer_to(*this); | |
19943 | } | |
19944 | template<typename t> CImg<typename cimg::superset<T,t>::type> | |
19945 | get_erode(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_erosion=false) const { | |
19946 | typedef typename cimg::superset<T,t>::type restype; | |
19947 | if (is_empty()) return CImg<restype>(); | |
19948 | if (!mask || mask.dim!=1) | |
19949 | throw CImgArgumentException("CImg<%s>::erode() : Specified mask (%u,%u,%u,%u,%p) is not a scalar image.", | |
19950 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data); | |
19951 | CImg<restype> dest(width,height,depth,dim); | |
19952 | const int | |
19953 | mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2, | |
19954 | mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2), | |
19955 | mxe = dimx() - mx2, mye = dimy() - my2, mze = dimz() - mz2; | |
19956 | for (int v = 0; v<(int)((*this).dim); ++v) | |
19957 | if (!weighted_erosion) { | |
19958 | for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) { | |
19959 | restype min_val = cimg::type<restype>::max(); | |
19960 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19961 | const restype cval = (restype)(*this)(x+xm,y+ym,z+zm,v); | |
19962 | if (mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval; | |
19963 | } | |
19964 | dest(x,y,z,v) = min_val; | |
19965 | } | |
19966 | if (cond) | |
19967 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19968 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19969 | restype min_val = cimg::type<restype>::max(); | |
19970 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19971 | const T cval = (restype)pix3d(x+xm,y+ym,z+zm,v); | |
19972 | if (mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval; | |
19973 | } | |
19974 | dest(x,y,z,v) = min_val; | |
19975 | } | |
19976 | else | |
19977 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19978 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19979 | restype min_val = cimg::type<restype>::max(); | |
19980 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19981 | const T cval = (restype)pix3d(x+xm,y+ym,z+zm,v,0); | |
19982 | if (mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval; | |
19983 | } | |
19984 | dest(x,y,z,v) = min_val; | |
19985 | } | |
19986 | } else { | |
19987 | for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) { | |
19988 | restype min_val = cimg::type<restype>::max(); | |
19989 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
19990 | const t mval = mask(mx1+xm,my1+ym,mz1+zm); | |
19991 | const restype cval = (restype)((*this)(x+xm,y+ym,z+zm,v) + mval); | |
19992 | if (mval && cval<min_val) min_val = cval; | |
19993 | } | |
19994 | dest(x,y,z,v) = min_val; | |
19995 | } | |
19996 | if (cond) | |
19997 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
19998 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
19999 | restype min_val = cimg::type<restype>::max(); | |
20000 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20001 | const t mval = mask(mx1+xm,my1+ym,mz1+zm); | |
20002 | const restype cval = (restype)(pix3d(x+xm,y+ym,z+zm,v) + mval); | |
20003 | if (mval && cval<min_val) min_val = cval; | |
20004 | } | |
20005 | dest(x,y,z,v) = min_val; | |
20006 | } | |
20007 | else | |
20008 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
20009 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
20010 | restype min_val = cimg::type<restype>::max(); | |
20011 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20012 | const t mval = mask(mx1+xm,my1+ym,mz1+zm); | |
20013 | const restype cval = (restype)(pix3d(x+xm,y+ym,z+zm,v,0) + mval); | |
20014 | if (mval && cval<min_val) min_val = cval; | |
20015 | } | |
20016 | dest(x,y,z,v) = min_val; | |
20017 | } | |
20018 | } | |
20019 | return dest; | |
20020 | } | |
20021 | template<typename t> CImg<T>& erode(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_erosion=false) { | |
20022 | return get_erode(mask,cond,weighted_erosion).transfer_to(*this); | |
20023 | } | |
20024 | CImg<T> get_erode(const unsigned int n, const unsigned int cond=1) const { | |
20025 | static CImg<T> mask; | |
20026 | if (n<2) return *this; | |
20027 | if (mask.width!=n) mask.assign(n,n,1,1,1); | |
20028 | const CImg<T> res = get_erode(mask,cond,false); | |
20029 | if (n>20) mask.assign(); | |
20030 | return res; | |
20031 | } | |
20032 | CImg<T>& erode(const unsigned int n, const unsigned int cond=1) { | |
20033 | if (n<2) return *this; | |
20034 | return get_erode(n,cond).transfer_to(*this); | |
20035 | } | |
20036 | template<typename t> CImg<typename cimg::superset<T,t>::type> | |
20037 | get_dilate(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_dilatation=false) const { | |
20038 | typedef typename cimg::superset<T,t>::type restype; | |
20039 | if (is_empty()) return CImg<restype>(); | |
20040 | if (!mask || mask.dim!=1) | |
20041 | throw CImgArgumentException("CImg<%s>::dilate() : Specified mask (%u,%u,%u,%u,%p) is not a scalar image.", | |
20042 | pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data); | |
20043 | CImg<restype> dest(width,height,depth,dim); | |
20044 | const int | |
20045 | mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2, | |
20046 | mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2), | |
20047 | mxe = dimx() - mx2, mye = dimy() - my2, mze = dimz() - mz2; | |
20048 | for (int v = 0; v<(int)((*this).dim); ++v) | |
20049 | if (!weighted_dilatation) { | |
20050 | for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) { | |
20051 | restype max_val = cimg::type<restype>::min(); | |
20052 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20053 | const restype cval = (restype)(*this)(x+xm,y+ym,z+zm,v); | |
20054 | if (mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval; | |
20055 | } | |
20056 | dest(x,y,z,v) = max_val; | |
20057 | } | |
20058 | if (cond) | |
20059 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
20060 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
20061 | restype max_val = cimg::type<restype>::min(); | |
20062 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20063 | const T cval = (restype)pix3d(x+xm,y+ym,z+zm,v); | |
20064 | if (mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval; | |
20065 | } | |
20066 | dest(x,y,z,v) = max_val; | |
20067 | } | |
20068 | else | |
20069 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
20070 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
20071 | restype max_val = cimg::type<restype>::min(); | |
20072 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20073 | const T cval = (restype)pix3d(x+xm,y+ym,z+zm,v,0); | |
20074 | if (mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval; | |
20075 | } | |
20076 | dest(x,y,z,v) = max_val; | |
20077 | } | |
20078 | } else { | |
20079 | for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) { | |
20080 | restype max_val = cimg::type<restype>::min(); | |
20081 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20082 | const t mval = mask(mx1+xm,my1+ym,mz1+zm); | |
20083 | const restype cval = (restype)((*this)(x+xm,y+ym,z+zm,v) - mval); | |
20084 | if (mval && cval>max_val) max_val = cval; | |
20085 | } | |
20086 | dest(x,y,z,v) = max_val; | |
20087 | } | |
20088 | if (cond) | |
20089 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
20090 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
20091 | restype max_val = cimg::type<restype>::min(); | |
20092 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20093 | const t mval = mask(mx1+xm,my1+ym,mz1+zm); | |
20094 | const restype cval = (restype)(pix3d(x+xm,y+ym,z+zm,v) - mval); | |
20095 | if (mval && cval>max_val) max_val = cval; | |
20096 | } | |
20097 | dest(x,y,z,v) = max_val; | |
20098 | } | |
20099 | else | |
20100 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) | |
20101 | for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) { | |
20102 | restype max_val = cimg::type<restype>::min(); | |
20103 | for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) { | |
20104 | const t mval = mask(mx1+xm,my1+ym,mz1+zm); | |
20105 | const restype cval = (restype)(pix3d(x+xm,y+ym,z+zm,v,0) - mval); | |
20106 | if (mval && cval>max_val) max_val = cval; | |
20107 | } | |
20108 | dest(x,y,z,v) = max_val; | |
20109 | } | |
20110 | } | |
20111 | return dest; | |
20112 | } | |
20113 | template<typename t> CImg<T>& dilate(const CImg<t>& mask, const unsigned int cond=1, const bool weighted_dilatation=false) { | |
20114 | return get_dilate(mask,cond,weighted_dilatation).transfer_to(*this); | |
20115 | } | |
20116 | CImg<T> get_dilate(const unsigned int n, const unsigned int cond=1) const { | |
20117 | static CImg<T> mask; | |
20118 | if (n<2) return *this; | |
20119 | if (mask.width!=n) mask.assign(n,n,1,1,1); | |
20120 | const CImg<T> res = get_dilate(mask,cond,false); | |
20121 | if (n>20) mask.assign(); | |
20122 | return res; | |
20123 | } | |
20124 | CImg<T>& dilate(const unsigned int n, const unsigned int cond=1) { | |
20125 | if (n<2) return *this; | |
20126 | return get_dilate(n,cond).transfer_to(*this); | |
20127 | } | |
20128 | CImg<T> get_noise(const double sigma=-20, const unsigned int ntype=0) const { | |
20129 | return (+*this).noise(sigma,ntype); | |
20130 | } | |
20131 | CImg<T>& noise(const double sigma=-20, const unsigned int ntype=0) { | |
20132 | if (!is_empty()) { | |
20133 | double nsigma = sigma, max = (double)cimg::type<T>::max(), min = (double)cimg::type<T>::min(); | |
20134 | typedef typename cimg::superset<T,float>::type ftype; | |
20135 | cimg::srand(); | |
20136 | ftype m = 0, M = 0; | |
20137 | if (nsigma==0) return *this; | |
20138 | if (nsigma<0 || ntype==2) m = (ftype)minmax(M); | |
20139 | if (nsigma<0) nsigma = -nsigma*(M-m)/100.0; | |
20140 | switch (ntype) { | |
20141 | case 0: { | |
20142 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
20143 | double val = *ptr + nsigma*cimg::grand(); | |
20144 | if (val>max) val = max; | |
20145 | if (val<min) val = min; | |
20146 | *ptr = (T)val; | |
20147 | } | |
20148 | } break; | |
20149 | case 1: { | |
20150 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
20151 | double val = *ptr + nsigma*cimg::crand(); | |
20152 | if (val>max) val = max; | |
20153 | if (val<min) val = min; | |
20154 | *ptr = (T)val; | |
20155 | } | |
20156 | } break; | |
20157 | case 2: { | |
20158 | if (M==m) { m = 0; M = 255; } | |
20159 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) if (cimg::rand()*100<nsigma) *ptr = (T)(cimg::rand()<0.5?M:m); | |
20160 | } break; | |
20161 | case 3: { | |
20162 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
20163 | const double z = (double)*ptr; | |
20164 | if (z<=1.0e-10) *ptr = (T)0; | |
20165 | else { | |
20166 | if (z>100.0) *ptr = (T)(unsigned int)((std::sqrt(z) * cimg::grand()) + z); | |
20167 | else { | |
20168 | unsigned int k = 0; | |
20169 | const double y = std::exp(-z); | |
20170 | for (double s = 1.0; s>=y; ++k) s *= cimg::rand(); | |
20171 | *ptr = (T)(k-1); | |
20172 | } | |
20173 | } | |
20174 | } | |
20175 | } break; | |
20176 | case 4: { | |
20177 | const double sqrt2 = (double)std::sqrt(2.0); | |
20178 | for (T *ptr = (*this).data + (*this).size(); (ptr--)>(*this).data; ) { | |
20179 | const double | |
20180 | val0 = (double)*ptr/sqrt2, | |
20181 | re = val0 + nsigma*cimg::grand(), | |
20182 | im = val0 + nsigma*cimg::grand(); | |
20183 | double val = std::sqrt(re*re + im*im); | |
20184 | if (val>max) val = max; | |
20185 | if (val<min) val = min; | |
20186 | *ptr = (T)val; | |
20187 | } | |
20188 | } break; | |
20189 | } | |
20190 | } | |
20191 | return *this; | |
20192 | } | |
20193 | CImg<typename cimg::superset<T,float>::type> get_deriche(const float sigma, const int order=0, | |
20194 | const char axe='x', const bool cond=true) const { | |
20195 | typedef typename cimg::superset<T,float>::type ftype; | |
20196 | return CImg<ftype>(*this,false).deriche(sigma,order,axe,cond); | |
20197 | } | |
20198 | CImg<T>& deriche(const float sigma, const int order=0, const char axe='x', const bool cond=true) { | |
20199 | typedef typename cimg::superset<T,float>::type ftype; | |
20200 | if (sigma<0) | |
20201 | throw CImgArgumentException("CImg<%s>::deriche() : Given filter variance (sigma = %g) is negative",pixel_type(),sigma); | |
20202 | if (is_empty() || (sigma<0.1 && !order)) return *this; | |
20203 | const float | |
20204 | nsigma = sigma<0.1f?0.1f:sigma, | |
20205 | alpha = 1.695f/nsigma, | |
20206 | ema = (float)std::exp(-alpha), | |
20207 | ema2 = (float)std::exp(-2*alpha), | |
20208 | b1 = -2*ema, | |
20209 | b2 = ema2; | |
20210 | float a0 = 0, a1 = 0, a2 = 0, a3 = 0, coefp = 0, coefn = 0; | |
20211 | switch (order) { | |
20212 | case 0: { | |
20213 | const float k = (1-ema)*(1-ema)/(1+2*alpha*ema-ema2); | |
20214 | a0 = k; | |
20215 | a1 = k*(alpha-1)*ema; | |
20216 | a2 = k*(alpha+1)*ema; | |
20217 | a3 = -k*ema2; | |
20218 | } break; | |
20219 | case 1: { | |
20220 | const float k = (1-ema)*(1-ema)/ema; | |
20221 | a0 = k*ema; | |
20222 | a1 = a3 = 0; | |
20223 | a2 = -a0; | |
20224 | } break; | |
20225 | case 2: { | |
20226 | const float | |
20227 | ea = (float)std::exp(-alpha), | |
20228 | k = -(ema2-1)/(2*alpha*ema), | |
20229 | kn = (-2*(-1+3*ea-3*ea*ea+ea*ea*ea)/(3*ea+1+3*ea*ea+ea*ea*ea)); | |
20230 | a0 = kn; | |
20231 | a1 = -kn*(1+k*alpha)*ema; | |
20232 | a2 = kn*(1-k*alpha)*ema; | |
20233 | a3 = -kn*ema2; | |
20234 | } break; | |
20235 | default: | |
20236 | throw CImgArgumentException("CImg<%s>::deriche() : Given filter order (order = %u) must be 0,1 or 2",pixel_type(),order); | |
20237 | break; | |
20238 | } | |
20239 | coefp = (a0+a1)/(1+b1+b2); | |
20240 | coefn = (a2+a3)/(1+b1+b2); | |
20241 | switch (cimg::uncase(axe)) { | |
20242 | case 'x': { | |
20243 | const int N = width, off = 1; | |
20244 | CImg<ftype> Y(N); | |
20245 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { T *ptrX = ptr(0,y,z,v); ftype *ptrY = Y.data, yb = 0, yp = 0; T xp = (T)0; if (cond) { xp = *ptrX; yb = yp = (ftype)(coefp*xp); } for (int m=0; m<N; ++m) { const T xc = *ptrX; ptrX+=off; const ftype yc = *(ptrY++) = (ftype)(a0*xc + a1*xp - b1*yp - b2*yb); xp = xc; yb = yp; yp = yc; } T xn = (T)0, xa = (T)0; ftype yn = 0, ya = 0; if (cond) { xn = xa = *(ptrX-off); yn = ya = (ftype)coefn*xn; } for (int n=N-1; n>=0; --n) { const T xc = *(ptrX-=off); const ftype yc = (ftype)(a2*xn + a3*xa - b1*yn - b2*ya); xa = xn; xn = xc; ya = yn; yn = yc; *ptrX = (T)(*(--ptrY)+yc); }; } | |
20246 | } break; | |
20247 | case 'y': { | |
20248 | const int N = height, off = width; | |
20249 | CImg<ftype> Y(N); | |
20250 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int x = 0; x<(int)((*this).width); ++x) { T *ptrX = ptr(x,0,z,v); ftype *ptrY = Y.data, yb = 0, yp = 0; T xp = (T)0; if (cond) { xp = *ptrX; yb = yp = (ftype)(coefp*xp); } for (int m=0; m<N; ++m) { const T xc = *ptrX; ptrX+=off; const ftype yc = *(ptrY++) = (ftype)(a0*xc + a1*xp - b1*yp - b2*yb); xp = xc; yb = yp; yp = yc; } T xn = (T)0, xa = (T)0; ftype yn = 0, ya = 0; if (cond) { xn = xa = *(ptrX-off); yn = ya = (ftype)coefn*xn; } for (int n=N-1; n>=0; --n) { const T xc = *(ptrX-=off); const ftype yc = (ftype)(a2*xn + a3*xa - b1*yn - b2*ya); xa = xn; xn = xc; ya = yn; yn = yc; *ptrX = (T)(*(--ptrY)+yc); }; } | |
20251 | } break; | |
20252 | case 'z': { | |
20253 | const int N = depth, off = width*height; | |
20254 | CImg<ftype> Y(N); | |
20255 | for (int v = 0; v<(int)((*this).dim); ++v) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { T *ptrX = ptr(x,y,0,v); ftype *ptrY = Y.data, yb = 0, yp = 0; T xp = (T)0; if (cond) { xp = *ptrX; yb = yp = (ftype)(coefp*xp); } for (int m=0; m<N; ++m) { const T xc = *ptrX; ptrX+=off; const ftype yc = *(ptrY++) = (ftype)(a0*xc + a1*xp - b1*yp - b2*yb); xp = xc; yb = yp; yp = yc; } T xn = (T)0, xa = (T)0; ftype yn = 0, ya = 0; if (cond) { xn = xa = *(ptrX-off); yn = ya = (ftype)coefn*xn; } for (int n=N-1; n>=0; --n) { const T xc = *(ptrX-=off); const ftype yc = (ftype)(a2*xn + a3*xa - b1*yn - b2*ya); xa = xn; xn = xc; ya = yn; yn = yc; *ptrX = (T)(*(--ptrY)+yc); }; } | |
20256 | } break; | |
20257 | case 'v': { | |
20258 | const int N = dim, off = width*height*depth; | |
20259 | CImg<ftype> Y(N); | |
20260 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { T *ptrX = ptr(x,y,z,0); ftype *ptrY = Y.data, yb = 0, yp = 0; T xp = (T)0; if (cond) { xp = *ptrX; yb = yp = (ftype)(coefp*xp); } for (int m=0; m<N; ++m) { const T xc = *ptrX; ptrX+=off; const ftype yc = *(ptrY++) = (ftype)(a0*xc + a1*xp - b1*yp - b2*yb); xp = xc; yb = yp; yp = yc; } T xn = (T)0, xa = (T)0; ftype yn = 0, ya = 0; if (cond) { xn = xa = *(ptrX-off); yn = ya = (ftype)coefn*xn; } for (int n=N-1; n>=0; --n) { const T xc = *(ptrX-=off); const ftype yc = (ftype)(a2*xn + a3*xa - b1*yn - b2*ya); xa = xn; xn = xc; ya = yn; yn = yc; *ptrX = (T)(*(--ptrY)+yc); }; } | |
20261 | } break; | |
20262 | } | |
20263 | return *this; | |
20264 | } | |
20265 | CImg<typename cimg::superset<T,float>::type> get_blur(const float sigmax, const float sigmay, const float sigmaz, | |
20266 | const bool cond=true) const { | |
20267 | typedef typename cimg::superset<T,float>::type ftype; | |
20268 | return CImg<ftype>(*this,false).blur(sigmax,sigmay,sigmaz,cond); | |
20269 | } | |
20270 | CImg<T>& blur(const float sigmax, const float sigmay, const float sigmaz, const bool cond=true) { | |
20271 | if (!is_empty()) { | |
20272 | if (width>1 && sigmax>0) deriche(sigmax,0,'x',cond); | |
20273 | if (height>1 && sigmay>0) deriche(sigmay,0,'y',cond); | |
20274 | if (depth>1 && sigmaz>0) deriche(sigmaz,0,'z',cond); | |
20275 | } | |
20276 | return *this; | |
20277 | } | |
20278 | CImg<typename cimg::superset<T,float>::type> get_blur(const float sigma, const bool cond=true) const { | |
20279 | typedef typename cimg::superset<T,float>::type ftype; | |
20280 | return CImg<ftype>(*this,false).blur(sigma,cond); | |
20281 | } | |
20282 | CImg<T>& blur(const float sigma, const bool cond=true) { | |
20283 | return blur(sigma,sigma,sigma,cond); | |
20284 | } | |
20285 | template<typename t> | |
20286 | CImg<T> get_blur_anisotropic(const CImg<t>& G, const float amplitude=60.0f, const float dl=0.8f, const float da=30.0f, | |
20287 | const float gauss_prec=2.0f, const unsigned int interpolation=0, const bool fast_approx=true) const { | |
20288 | return (+*this).blur_anisotropic(G,amplitude,dl,da,gauss_prec,interpolation,fast_approx); | |
20289 | } | |
20290 | template<typename t> | |
20291 | CImg<T>& blur_anisotropic(const CImg<t>& G, const float amplitude=60.0f, const float dl=0.8f, const float da=30.0f, | |
20292 | const float gauss_prec=2.0f, const unsigned int interpolation=0, const bool fast_approx=true) { | |
20293 | typedef typename cimg::superset<T,float>::type ftype; | |
20294 | if (!is_empty() && amplitude>0) { | |
20295 | if (!G || (G.dim!=3 && G.dim!=6) || G.width!=width || G.height!=height || G.depth!=depth) | |
20296 | throw CImgArgumentException("CImg<%s>::blur_anisotropic() : Specified tensor field (%u,%u,%u,%u) is not valid.", | |
20297 | pixel_type(),G.width,G.height,G.depth,G.dim); | |
20298 | const float sqrt2amplitude = (float)std::sqrt(2*amplitude); | |
20299 | const bool threed = (G.dim>=6); | |
20300 | const int | |
20301 | dx1 = dimx()-1, | |
20302 | dy1 = dimy()-1, | |
20303 | dz1 = dimz()-1; | |
20304 | CImg<ftype> | |
20305 | dest(width,height,depth,dim,0), | |
20306 | W(width,height,depth,threed?4:3), | |
20307 | tmp(dim); | |
20308 | int N = 0; | |
20309 | if (threed) | |
20310 | for (float phi=(180%(int)da)/2.0f; phi<=180; phi+=da) { | |
20311 | const float | |
20312 | phir = (float)(phi*cimg::valuePI/180), | |
20313 | datmp = (float)(da/std::cos(phir)), | |
20314 | da2 = datmp<1?360.0f:datmp; | |
20315 | for (float theta=0; theta<360; (theta+=da2),++N) { | |
20316 | const float | |
20317 | thetar = (float)(theta*cimg::valuePI/180), | |
20318 | vx = (float)(std::cos(thetar)*std::cos(phir)), | |
20319 | vy = (float)(std::sin(thetar)*std::cos(phir)), | |
20320 | vz = (float)std::sin(phir); | |
20321 | const t | |
20322 | *pa = G.ptr(0,0,0,0), | |
20323 | *pb = G.ptr(0,0,0,1), | |
20324 | *pc = G.ptr(0,0,0,2), | |
20325 | *pd = G.ptr(0,0,0,3), | |
20326 | *pe = G.ptr(0,0,0,4), | |
20327 | *pf = G.ptr(0,0,0,5); | |
20328 | ftype | |
20329 | *pd0 = W.ptr(0,0,0,0), | |
20330 | *pd1 = W.ptr(0,0,0,1), | |
20331 | *pd2 = W.ptr(0,0,0,2), | |
20332 | *pd3 = W.ptr(0,0,0,3); | |
20333 | for (int zg = 0; zg<(int)((G).depth); ++zg) for (int yg = 0; yg<(int)((G).height); ++yg) for (int xg = 0; xg<(int)((G).width); ++xg) { | |
20334 | const t | |
20335 | a = *(pa++), b = *(pb++), c = *(pc++), | |
20336 | d = *(pd++), e = *(pe++), f = *(pf++); | |
20337 | const float | |
20338 | u = (float)(a*vx + b*vy + c*vz), | |
20339 | v = (float)(b*vx + d*vy + e*vz), | |
20340 | w = (float)(c*vx + e*vy + f*vz), | |
20341 | n = (float)std::sqrt(1e-5+u*u+v*v+w*w), | |
20342 | dln = dl/n; | |
20343 | *(pd0++) = (ftype)(u*dln); | |
20344 | *(pd1++) = (ftype)(v*dln); | |
20345 | *(pd2++) = (ftype)(w*dln); | |
20346 | *(pd3++) = (ftype)n; | |
20347 | } | |
20348 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20349 | tmp.fill(0); | |
20350 | const float | |
20351 | cu = (float)W(x,y,z,0), | |
20352 | cv = (float)W(x,y,z,1), | |
20353 | cw = (float)W(x,y,z,2), | |
20354 | n = (float)W(x,y,z,3), | |
20355 | fsigma = (float)(n*sqrt2amplitude), | |
20356 | length = gauss_prec*fsigma, | |
20357 | fsigma2 = 2*fsigma*fsigma; | |
20358 | float | |
20359 | S = 0, | |
20360 | pu = cu, | |
20361 | pv = cv, | |
20362 | pw = cw, | |
20363 | X = (float)x, | |
20364 | Y = (float)y, | |
20365 | Z = (float)z; | |
20366 | switch (interpolation) { | |
20367 | case 0: { | |
20368 | for (float l=0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) { | |
20369 | const int | |
20370 | cx = (int)(X+0.5f), | |
20371 | cy = (int)(Y+0.5f), | |
20372 | cz = (int)(Z+0.5f); | |
20373 | float | |
20374 | u = (float)W(cx,cy,cz,0), | |
20375 | v = (float)W(cx,cy,cz,1), | |
20376 | w = (float)W(cx,cy,cz,2); | |
20377 | if ((pu*u + pv*v + pw*w)<0) { u=-u; v=-v; w=-w; } | |
20378 | if (fast_approx) { for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(*this)(cx,cy,cz,k); ++S; } | |
20379 | else { | |
20380 | const float coef = (float)std::exp(-l*l/fsigma2); | |
20381 | for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(coef*(*this)(cx,cy,cz,k)); | |
20382 | S+=coef; | |
20383 | } | |
20384 | X+=(pu=u); Y+=(pv=v); Z+=(pw=w); | |
20385 | } | |
20386 | } break; | |
20387 | case 1: { | |
20388 | for (float l=0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) { | |
20389 | const int | |
20390 | cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1, | |
20391 | cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1, | |
20392 | cz = (int)Z, pz = (cz-1<0)?0:cz-1, nz = (cz+1>dz1)?dz1:cz+1; | |
20393 | const float | |
20394 | curru = (float)W(cx,cy,cz,0), | |
20395 | currv = (float)W(cx,cy,cz,1), | |
20396 | currw = (float)W(cx,cy,cz,2); | |
20397 | { ftype &u = W(px,py,pz,0), &v = W(px,py,pz,1), &w = W(px,py,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,py,pz,0), &v = W(cx,py,pz,1), &w = W(cx,py,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,py,pz,0), &v = W(nx,py,pz,1), &w = W(nx,py,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20398 | { ftype &u = W(px,cy,pz,0), &v = W(px,cy,pz,1), &w = W(px,cy,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,cy,pz,0), &v = W(cx,cy,pz,1), &w = W(cx,cy,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,cy,pz,0), &v = W(nx,cy,pz,1), &w = W(nx,cy,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20399 | { ftype &u = W(px,ny,pz,0), &v = W(px,ny,pz,1), &w = W(px,ny,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,ny,pz,0), &v = W(cx,ny,pz,1), &w = W(cx,ny,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,ny,pz,0), &v = W(nx,ny,pz,1), &w = W(nx,ny,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20400 | { ftype &u = W(px,py,cz,0), &v = W(px,py,cz,1), &w = W(px,py,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,py,cz,0), &v = W(cx,py,cz,1), &w = W(cx,py,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,py,cz,0), &v = W(nx,py,cz,1), &w = W(nx,py,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20401 | { ftype &u = W(px,cy,cz,0), &v = W(px,cy,cz,1), &w = W(px,cy,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,cy,cz,0), &v = W(nx,cy,cz,1), &w = W(nx,cy,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20402 | { ftype &u = W(px,ny,cz,0), &v = W(px,ny,cz,1), &w = W(px,ny,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,ny,cz,0), &v = W(cx,ny,cz,1), &w = W(cx,ny,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,ny,cz,0), &v = W(nx,ny,cz,1), &w = W(nx,ny,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20403 | { ftype &u = W(px,py,nz,0), &v = W(px,py,nz,1), &w = W(px,py,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,py,nz,0), &v = W(cx,py,nz,1), &w = W(cx,py,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,py,nz,0), &v = W(nx,py,nz,1), &w = W(nx,py,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20404 | { ftype &u = W(px,cy,nz,0), &v = W(px,cy,nz,1), &w = W(px,cy,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,cy,nz,0), &v = W(cx,cy,nz,1), &w = W(cx,cy,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,cy,nz,0), &v = W(nx,cy,nz,1), &w = W(nx,cy,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20405 | { ftype &u = W(px,ny,nz,0), &v = W(px,ny,nz,1), &w = W(px,ny,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,ny,nz,0), &v = W(cx,ny,nz,1), &w = W(cx,ny,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,ny,nz,0), &v = W(nx,ny,nz,1), &w = W(nx,ny,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20406 | float | |
20407 | u = (float)(W.linear_pix3d(X,Y,Z,0)), | |
20408 | v = (float)(W.linear_pix3d(X,Y,Z,1)), | |
20409 | w = (float)(W.linear_pix3d(X,Y,Z,2)); | |
20410 | if ((pu*u + pv*v + pw*w)<0) { u=-u; v=-v; w=-w; } | |
20411 | if (fast_approx) { for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)linear_pix3d(X,Y,Z,k); ++S; } | |
20412 | else { | |
20413 | const float coef = (float)std::exp(-l*l/fsigma2); | |
20414 | for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(coef*linear_pix3d(X,Y,Z,k)); | |
20415 | S+=coef; | |
20416 | } | |
20417 | X+=(pu=u); Y+=(pv=v); Z+=(pw=w); | |
20418 | } | |
20419 | } break; | |
20420 | default: { | |
20421 | for (float l=0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) { | |
20422 | const int | |
20423 | cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1, | |
20424 | cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1, | |
20425 | cz = (int)Z, pz = (cz-1<0)?0:cz-1, nz = (cz+1>dz1)?dz1:cz+1; | |
20426 | const float | |
20427 | curru = (float)W(cx,cy,cz,0), | |
20428 | currv = (float)W(cx,cy,cz,1), | |
20429 | currw = (float)W(cx,cy,cz,2); | |
20430 | { ftype &u = W(px,py,pz,0), &v = W(px,py,pz,1), &w = W(px,py,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,py,pz,0), &v = W(cx,py,pz,1), &w = W(cx,py,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,py,pz,0), &v = W(nx,py,pz,1), &w = W(nx,py,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20431 | { ftype &u = W(px,cy,pz,0), &v = W(px,cy,pz,1), &w = W(px,cy,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,cy,pz,0), &v = W(cx,cy,pz,1), &w = W(cx,cy,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,cy,pz,0), &v = W(nx,cy,pz,1), &w = W(nx,cy,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20432 | { ftype &u = W(px,ny,pz,0), &v = W(px,ny,pz,1), &w = W(px,ny,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,ny,pz,0), &v = W(cx,ny,pz,1), &w = W(cx,ny,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,ny,pz,0), &v = W(nx,ny,pz,1), &w = W(nx,ny,pz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20433 | { ftype &u = W(px,py,cz,0), &v = W(px,py,cz,1), &w = W(px,py,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,py,cz,0), &v = W(cx,py,cz,1), &w = W(cx,py,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,py,cz,0), &v = W(nx,py,cz,1), &w = W(nx,py,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20434 | { ftype &u = W(px,cy,cz,0), &v = W(px,cy,cz,1), &w = W(px,cy,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,cy,cz,0), &v = W(nx,cy,cz,1), &w = W(nx,cy,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20435 | { ftype &u = W(px,ny,cz,0), &v = W(px,ny,cz,1), &w = W(px,ny,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,ny,cz,0), &v = W(cx,ny,cz,1), &w = W(cx,ny,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,ny,cz,0), &v = W(nx,ny,cz,1), &w = W(nx,ny,cz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20436 | { ftype &u = W(px,py,nz,0), &v = W(px,py,nz,1), &w = W(px,py,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,py,nz,0), &v = W(cx,py,nz,1), &w = W(cx,py,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,py,nz,0), &v = W(nx,py,nz,1), &w = W(nx,py,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20437 | { ftype &u = W(px,cy,nz,0), &v = W(px,cy,nz,1), &w = W(px,cy,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,cy,nz,0), &v = W(cx,cy,nz,1), &w = W(cx,cy,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,cy,nz,0), &v = W(nx,cy,nz,1), &w = W(nx,cy,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20438 | { ftype &u = W(px,ny,nz,0), &v = W(px,ny,nz,1), &w = W(px,ny,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(cx,ny,nz,0), &v = W(cx,ny,nz,1), &w = W(cx,ny,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; { ftype &u = W(nx,ny,nz,0), &v = W(nx,ny,nz,1), &w = W(nx,ny,nz,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}; | |
20439 | const float | |
20440 | u0 = (float)(0.5f*W.linear_pix3d(X,Y,Z,0)), | |
20441 | v0 = (float)(0.5f*W.linear_pix3d(X,Y,Z,1)), | |
20442 | w0 = (float)(0.5f*W.linear_pix3d(X,Y,Z,2)); | |
20443 | float | |
20444 | u = (float)(W.linear_pix3d(X+u0,Y+v0,Z+w0,0)), | |
20445 | v = (float)(W.linear_pix3d(X+u0,Y+v0,Z+w0,1)), | |
20446 | w = (float)(W.linear_pix3d(X+u0,Y+v0,Z+w0,2)); | |
20447 | if ((pu*u + pv*v + pw*w)<0) { u=-u; v=-v; w=-w; } | |
20448 | if (fast_approx) { for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)linear_pix3d(X,Y,Z,k); ++S; } | |
20449 | else { | |
20450 | const float coef = (float)std::exp(-l*l/fsigma2); | |
20451 | for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(coef*linear_pix3d(X,Y,Z,k)); | |
20452 | S+=coef; | |
20453 | } | |
20454 | X+=(pu=u); Y+=(pv=v); Z+=(pw=w); | |
20455 | } | |
20456 | } break; | |
20457 | } | |
20458 | if (S>0) for (int k = 0; k<(int)((dest).dim); ++k) dest(x,y,z,k)+=tmp[k]/S; | |
20459 | else for (int k = 0; k<(int)((dest).dim); ++k) dest(x,y,z,k)+=(ftype)((*this)(x,y,z,k)); | |
20460 | if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; | |
20461 | } | |
20462 | } | |
20463 | } else | |
20464 | for (float theta=(360%(int)da)/2.0f; theta<360; (theta+=da),++N) { | |
20465 | const float | |
20466 | thetar = (float)(theta*cimg::valuePI/180), | |
20467 | vx = (float)(std::cos(thetar)), | |
20468 | vy = (float)(std::sin(thetar)); | |
20469 | const t | |
20470 | *pa = G.ptr(0,0,0,0), | |
20471 | *pb = G.ptr(0,0,0,1), | |
20472 | *pc = G.ptr(0,0,0,2); | |
20473 | ftype | |
20474 | *pd0 = W.ptr(0,0,0,0), | |
20475 | *pd1 = W.ptr(0,0,0,1), | |
20476 | *pd2 = W.ptr(0,0,0,2); | |
20477 | for (int yg = 0; yg<(int)((G).height); ++yg) for (int xg = 0; xg<(int)((G).width); ++xg) { | |
20478 | const t a = *(pa++), b = *(pb++), c = *(pc++); | |
20479 | const float | |
20480 | u = (float)(a*vx + b*vy), | |
20481 | v = (float)(b*vx + c*vy), | |
20482 | n = (float)std::sqrt(1e-5+u*u+v*v), | |
20483 | dln = dl/n; | |
20484 | *(pd0++) = (ftype)(u*dln); | |
20485 | *(pd1++) = (ftype)(v*dln); | |
20486 | *(pd2++) = (ftype)n; | |
20487 | } | |
20488 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20489 | tmp.fill(0); | |
20490 | const float | |
20491 | cu = (float)W(x,y,0,0), | |
20492 | cv = (float)W(x,y,0,1), | |
20493 | n = (float)W(x,y,0,2), | |
20494 | fsigma = (float)(n*sqrt2amplitude), | |
20495 | length = gauss_prec*fsigma, | |
20496 | fsigma2 = 2*fsigma*fsigma; | |
20497 | float | |
20498 | S = 0, | |
20499 | pu = cu, | |
20500 | pv = cv, | |
20501 | X = (float)x, | |
20502 | Y = (float)y; | |
20503 | switch (interpolation) { | |
20504 | case 0: { | |
20505 | for (float l=0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) { | |
20506 | const int | |
20507 | cx = (int)(X+0.5f), | |
20508 | cy = (int)(Y+0.5f); | |
20509 | float | |
20510 | u = (float)W(cx,cy,0,0), | |
20511 | v = (float)W(cx,cy,0,1); | |
20512 | if ((pu*u + pv*v)<0) { u=-u; v=-v; } | |
20513 | if (fast_approx) { for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(*this)(cx,cy,0,k); ++S; } | |
20514 | else { | |
20515 | const float coef = (float)std::exp(-l*l/fsigma2); | |
20516 | for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(coef*(*this)(cx,cy,0,k)); | |
20517 | S+=coef; | |
20518 | } | |
20519 | X+=(pu=u); Y+=(pv=v); | |
20520 | } | |
20521 | } break; | |
20522 | case 1: { | |
20523 | for (float l=0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) { | |
20524 | const int | |
20525 | cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1, | |
20526 | cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1; | |
20527 | const float | |
20528 | curru = (float)W(cx,cy,0,0), | |
20529 | currv = (float)W(cx,cy,0,1); | |
20530 | { ftype &u = W(px,py,0,0), &v = W(px,py,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(cx,py,0,0), &v = W(cx,py,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(nx,py,0,0), &v = W(nx,py,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; | |
20531 | { ftype &u = W(px,cy,0,0), &v = W(px,cy,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(nx,cy,0,0), &v = W(nx,cy,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; | |
20532 | { ftype &u = W(px,ny,0,0), &v = W(px,ny,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(cx,ny,0,0), &v = W(cx,ny,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(nx,ny,0,0), &v = W(nx,ny,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; | |
20533 | float | |
20534 | u = (float)(W.linear_pix2d(X,Y,0,0)), | |
20535 | v = (float)(W.linear_pix2d(X,Y,0,1)); | |
20536 | if ((pu*u + pv*v)<0) { u=-u; v=-v; } | |
20537 | if (fast_approx) { for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)linear_pix2d(X,Y,0,k); ++S; } | |
20538 | else { | |
20539 | const float coef = (float)std::exp(-l*l/fsigma2); | |
20540 | for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(coef*linear_pix2d(X,Y,0,k)); | |
20541 | S+=coef; | |
20542 | } | |
20543 | X+=(pu=u); Y+=(pv=v); | |
20544 | } | |
20545 | } break; | |
20546 | default: { | |
20547 | for (float l=0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) { | |
20548 | const int | |
20549 | cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1, | |
20550 | cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1; | |
20551 | const float | |
20552 | curru = (float)W(cx,cy,0,0), | |
20553 | currv = (float)W(cx,cy,0,1); | |
20554 | { ftype &u = W(px,py,0,0), &v = W(px,py,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(cx,py,0,0), &v = W(cx,py,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(nx,py,0,0), &v = W(nx,py,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; | |
20555 | { ftype &u = W(px,cy,0,0), &v = W(px,cy,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(nx,cy,0,0), &v = W(nx,cy,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; | |
20556 | { ftype &u = W(px,ny,0,0), &v = W(px,ny,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(cx,ny,0,0), &v = W(cx,ny,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; { ftype &u = W(nx,ny,0,0), &v = W(nx,ny,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}; | |
20557 | const float | |
20558 | u0 = (float)(0.5f*W.linear_pix2d(X,Y,0,0)), | |
20559 | v0 = (float)(0.5f*W.linear_pix2d(X,Y,0,1)); | |
20560 | float | |
20561 | u = (float)(W.linear_pix2d(X+u0,Y+v0,0,0)), | |
20562 | v = (float)(W.linear_pix2d(X+u0,Y+v0,0,1)); | |
20563 | if ((pu*u + pv*v)<0) { u=-u; v=-v; } | |
20564 | if (fast_approx) { for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)linear_pix2d(X,Y,0,k); ++S; } | |
20565 | else { | |
20566 | const float coef = (float)std::exp(-l*l/fsigma2); | |
20567 | for (int k = 0; k<(int)((*this).dim); ++k) tmp[k]+=(ftype)(coef*linear_pix2d(X,Y,0,k)); | |
20568 | S+=coef; | |
20569 | } | |
20570 | X+=(pu=u); Y+=(pv=v); | |
20571 | } | |
20572 | } break; | |
20573 | } | |
20574 | if (S>0) for (int k = 0; k<(int)((dest).dim); ++k) dest(x,y,0,k)+=tmp[k]/S; | |
20575 | else for (int k = 0; k<(int)((dest).dim); ++k) dest(x,y,0,k)+=(ftype)((*this)(x,y,0,k)); | |
20576 | if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; | |
20577 | } | |
20578 | } | |
20579 | const ftype *ptrs = dest.data+dest.size(); | |
20580 | const T m = cimg::type<T>::min(), M = cimg::type<T>::max(); | |
20581 | for (T *ptrd = (*this).data + (*this).size(); (ptrd--)>(*this).data; ) { const ftype val = *(--ptrs)/N; *ptrd = val<m?m:(val>M?M:(T)val); } | |
20582 | } | |
20583 | return *this; | |
20584 | } | |
20585 | template<typename tm> | |
20586 | CImg<T> get_blur_anisotropic(const CImg<tm>& mask, const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, | |
20587 | const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, | |
20588 | const float da=30.0f, const float gauss_prec=2.0f, const unsigned int interpolation=0, | |
20589 | const bool fast_approx=true, const float geom_factor=1.0f) const { | |
20590 | return (+*this).blur_anisotropic(mask,amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation,fast_approx,geom_factor); | |
20591 | } | |
20592 | template<typename tm> | |
20593 | CImg<T>& blur_anisotropic(const CImg<tm>& mask, const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, | |
20594 | const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, const float da=30.0f, | |
20595 | const float gauss_prec=2.0f, const unsigned int interpolation=0, const bool fast_approx=true, | |
20596 | const float geom_factor=1.0f) { | |
20597 | if (!is_empty() && amplitude>0) { | |
20598 | if (amplitude==0) return *this; | |
20599 | if (amplitude<0 || sharpness<0 || anisotropy<0 || anisotropy>1 || alpha<0 || sigma<0 || dl<0 || da<0 || gauss_prec<0) | |
20600 | throw CImgArgumentException("CImg<%s>::blur_anisotropic() : Given parameters are amplitude(%g), sharpness(%g), " | |
20601 | "anisotropy(%g), alpha(%g), sigma(%g), dl(%g), da(%g), gauss_prec(%g).\n" | |
20602 | "Admissible parameters are in the range : amplitude>0, sharpness>0, anisotropy in [0,1], " | |
20603 | "alpha>0, sigma>0, dl>0, da>0, gauss_prec>0.", | |
20604 | pixel_type(),amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec); | |
20605 | const bool threed = (depth>1), no_mask = mask.is_empty(); | |
20606 | const float nsharpness = cimg::max(sharpness,1e-5f), power1 = 0.5f*nsharpness, power2 = power1/(1e-7f+1.0f-anisotropy); | |
20607 | CImg<float> blurred = CImg<float>(*this,false).blur(alpha); | |
20608 | if (geom_factor>0) blurred*=geom_factor; | |
20609 | else blurred.normalize(0,-geom_factor); | |
20610 | if (threed) { | |
20611 | greycstoration_mutex_lock(greycstoration_params[0]);; | |
20612 | CImg<float> val(3), vec(3,3), G(blurred.get_structure_tensorXYZ()); | |
20613 | if (sigma>0) G.blur(sigma); | |
20614 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20615 | if (no_mask || mask(x,y,z)) { | |
20616 | G.get_tensor_at(x,y,z).symmetric_eigen(val,vec); | |
20617 | const float l1 = val[2], l2 = val[1], l3 = val[0], | |
20618 | ux = vec(0,0), uy = vec(0,1), uz = vec(0,2), | |
20619 | vx = vec(1,0), vy = vec(1,1), vz = vec(1,2), | |
20620 | wx = vec(2,0), wy = vec(2,1), wz = vec(2,2), | |
20621 | n1 = (float)std::pow(1.0f+l1+l2+l3,-power1), | |
20622 | n2 = (float)std::pow(1.0f+l1+l2+l3,-power2); | |
20623 | G(x,y,z,0) = n1*(ux*ux + vx*vx) + n2*wx*wx; | |
20624 | G(x,y,z,1) = n1*(ux*uy + vx*vy) + n2*wx*wy; | |
20625 | G(x,y,z,2) = n1*(ux*uz + vx*vz) + n2*wx*wz; | |
20626 | G(x,y,z,3) = n1*(uy*uy + vy*vy) + n2*wy*wy; | |
20627 | G(x,y,z,4) = n1*(uy*uz + vy*vz) + n2*wy*wz; | |
20628 | G(x,y,z,5) = n1*(uz*uz + vz*vz) + n2*wz*wz; | |
20629 | } else G(x,y,z,0) = G(x,y,z,1) = G(x,y,z,2) = G(x,y,z,3) = G(x,y,z,4) = G(x,y,z,5) = 0; | |
20630 | if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; | |
20631 | } | |
20632 | greycstoration_mutex_unlock(greycstoration_params[0]);; | |
20633 | blur_anisotropic(G,amplitude,dl,da,gauss_prec,interpolation,fast_approx); | |
20634 | } else { | |
20635 | greycstoration_mutex_lock(greycstoration_params[0]);; | |
20636 | CImg<float> val(2), vec(2,2), G(blurred.get_structure_tensorXY()); | |
20637 | if (sigma>0) G.blur(sigma); | |
20638 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20639 | if (no_mask || mask(x,y)) { | |
20640 | G.get_tensor_at(x,y).symmetric_eigen(val,vec); | |
20641 | const float l1 = val[1], l2 = val[0], | |
20642 | ux = vec(1,0), uy = vec(1,1), | |
20643 | vx = vec(0,0), vy = vec(0,1), | |
20644 | n1 = (float)std::pow(1.0f+l1+l2,-power1), | |
20645 | n2 = (float)std::pow(1.0f+l1+l2,-power2); | |
20646 | G(x,y,0,0) = n1*ux*ux + n2*vx*vx; | |
20647 | G(x,y,0,1) = n1*ux*uy + n2*vx*vy; | |
20648 | G(x,y,0,2) = n1*uy*uy + n2*vy*vy; | |
20649 | } else G(x,y,0,0) = G(x,y,0,1) = G(x,y,0,2) = 0; | |
20650 | if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; | |
20651 | } | |
20652 | greycstoration_mutex_unlock(greycstoration_params[0]);; | |
20653 | blur_anisotropic(G,amplitude,dl,da,gauss_prec,interpolation,fast_approx); | |
20654 | } | |
20655 | } | |
20656 | return *this; | |
20657 | } | |
20658 | CImg<T> get_blur_anisotropic(const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, | |
20659 | const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, | |
20660 | const float da=30.0f, const float gauss_prec=2.0f, const unsigned int interpolation=0, | |
20661 | const bool fast_approx=true, const float geom_factor=1.0f) const { | |
20662 | return (+*this).blur_anisotropic(amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation,fast_approx,geom_factor); | |
20663 | } | |
20664 | CImg<T>& blur_anisotropic(const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, | |
20665 | const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, const float da=30.0f, | |
20666 | const float gauss_prec=2.0f, const unsigned int interpolation=0, const bool fast_approx=true, | |
20667 | const float geom_factor=1.0f) { | |
20668 | return blur_anisotropic(CImg<T>(),amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation,fast_approx,geom_factor); | |
20669 | } | |
20670 | CImg<T> get_blur_bilateral(const float sigmax, const float sigmay, const float sigmaz, const float sigmar, | |
20671 | const int bgridx, const int bgridy, const int bgridz, const int bgridr, | |
20672 | const bool interpolation=true) const { | |
20673 | return (+*this).blur_bilateral(sigmax,sigmay,sigmaz,sigmar,bgridx,bgridy,bgridz,bgridr,interpolation); | |
20674 | } | |
20675 | CImg<T>& blur_bilateral(const float sigmax, const float sigmay, const float sigmaz, const float sigmar, | |
20676 | const int bgridx, const int bgridy, const int bgridz, const int bgridr, | |
20677 | const bool interpolation=true) { | |
20678 | T m, M = maxmin(m); | |
20679 | const float range = (float)(1.0f+M-m); | |
20680 | const unsigned int | |
20681 | bx0 = bgridx>=0?bgridx:width*(-bgridx)/100, | |
20682 | by0 = bgridy>=0?bgridy:height*(-bgridy)/100, | |
20683 | bz0 = bgridz>=0?bgridz:depth*(-bgridz)/100, | |
20684 | br0 = bgridr>=0?bgridr:(int)(-range*bgridr/100), | |
20685 | bx = bx0>0?bx0:1, | |
20686 | by = by0>0?by0:1, | |
20687 | bz = bz0>0?bz0:1, | |
20688 | br = br0>0?br0:1; | |
20689 | const float | |
20690 | nsigmax = sigmax*bx/width, | |
20691 | nsigmay = sigmay*by/height, | |
20692 | nsigmaz = sigmaz*bz/depth, | |
20693 | nsigmar = sigmar*br/range; | |
20694 | if (nsigmax>0 || nsigmay>0 || nsigmaz>0 || nsigmar>0) { | |
20695 | const bool threed = depth>1; | |
20696 | if (threed) { | |
20697 | typedef typename cimg::last<T,float>::type ftype; | |
20698 | CImg<ftype> bgrid(bx,by,bz,br), bgridw(bx,by,bz,br); | |
20699 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
20700 | bgrid.fill(0); bgridw.fill(0); | |
20701 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20702 | const T val = (*this)(x,y,z,k); | |
20703 | const int X = x*bx/width, Y = y*by/height, Z = z*bz/depth, R = (int)((val-m)*br/range); | |
20704 | bgrid(X,Y,Z,R) = (float)val; | |
20705 | bgridw(X,Y,Z,R) = 1; | |
20706 | } | |
20707 | bgrid.blur(nsigmax,nsigmay,nsigmaz,true).deriche(nsigmar,0,'v',false); | |
20708 | bgridw.blur(nsigmax,nsigmay,nsigmaz,true).deriche(nsigmar,0,'v',false); | |
20709 | if (interpolation) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20710 | const T val = (*this)(x,y,z,k); | |
20711 | const float X = (float)x*bx/width, Y = (float)y*by/height, Z = (float)z*bz/depth, R = (val-m)*br/range, | |
20712 | bval0 = bgrid.linear_pix4d(X,Y,Z,R), bval1 = bgridw.linear_pix4d(X,Y,Z,R); | |
20713 | (*this)(x,y,z,k) = (T)(bval0/bval1); | |
20714 | } else for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20715 | const T val = (*this)(x,y,z,k); | |
20716 | const int X = x*bx/width, Y = y*by/height, Z = z*bz/depth, R = (int)((val-m)*br/range); | |
20717 | const float bval0 = bgrid(X,Y,Z,R), bval1 = bgridw(X,Y,Z,R); | |
20718 | (*this)(x,y,z,k) = (T)(bval0/bval1); | |
20719 | } | |
20720 | } | |
20721 | } else { | |
20722 | typedef typename cimg::last<T,float>::type ftype; | |
20723 | CImg<ftype> bgrid(bx,by,br,2); | |
20724 | for (int k = 0; k<(int)((*this).dim); ++k) { | |
20725 | bgrid.fill(0); | |
20726 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20727 | const T val = (*this)(x,y,k); | |
20728 | const int X = x*bx/width, Y = y*by/height, R = (int)((val-m)*br/range); | |
20729 | bgrid(X,Y,R,0) = (float)val; | |
20730 | bgrid(X,Y,R,1) = 1; | |
20731 | } | |
20732 | bgrid.blur(nsigmax,nsigmay,0,true).blur(0,0,nsigmar,false); | |
20733 | if (interpolation) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20734 | const T val = (*this)(x,y,k); | |
20735 | const float X = (float)x*bx/width, Y = (float)y*by/height, R = (val-m)*br/range, | |
20736 | bval0 = bgrid.linear_pix3d(X,Y,R,0), bval1 = bgrid.linear_pix3d(X,Y,R,1); | |
20737 | (*this)(x,y,k) = (T)(bval0/bval1); | |
20738 | } else for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20739 | const T val = (*this)(x,y,k); | |
20740 | const int X = x*bx/width, Y = y*by/height, R = (int)((val-m)*br/range); | |
20741 | const float bval0 = bgrid(X,Y,R,0), bval1 = bgrid(X,Y,R,1); | |
20742 | (*this)(x,y,k) = (T)(bval0/bval1); | |
20743 | } | |
20744 | } | |
20745 | } | |
20746 | } | |
20747 | return *this; | |
20748 | } | |
20749 | CImg<T> get_blur_bilateral(const float sigmas, const float sigmar, const int bgrids=-33, const int bgridr=32, | |
20750 | const bool interpolation=true) const { | |
20751 | return (+*this).blur_bilateral(sigmas,sigmas,sigmas,sigmar,bgrids,bgrids,bgrids,bgridr,interpolation); | |
20752 | } | |
20753 | CImg<T>& blur_bilateral(const float sigmas, const float sigmar, const int bgrids=-33, const int bgridr=32, | |
20754 | const bool interpolation=true) { | |
20755 | return blur_bilateral(sigmas,sigmas,sigmas,sigmar,bgrids,bgrids,bgrids,bgridr,interpolation); | |
20756 | } | |
20757 | CImg<T> get_blur_patch(const unsigned int patch_size=3, const float sigma_p=10.0f, const float sigma_s=10.0f, | |
20758 | const unsigned int lookup_size=4, const bool fast_approx=true) const { | |
20759 | return (+*this).blur_patch(patch_size,sigma_p,sigma_s,lookup_size,fast_approx); | |
20760 | } | |
20761 | CImg<T>& blur_patch(const unsigned int patch_size=3, const float sigma_p=10.0f, const float sigma_s=10.0f, | |
20762 | const unsigned int lookup_size=4, const bool fast_approx=true) { | |
20763 | typedef typename cimg::superset<T,float>::type ftype; | |
20764 | CImg<ftype> res(width,height,depth,dim,0); | |
20765 | CImg<T> P(patch_size*patch_size*dim), Q(P); | |
20766 | const float sigma_s2 = sigma_s*sigma_s, sigma_p2 = sigma_p*sigma_p, Pnorm = P.size()*sigma_p2; | |
20767 | const int rsize2 = (int)lookup_size/2, rsize1 = rsize2-1+(lookup_size%2); | |
20768 | if (depth>1) switch (patch_size) { | |
20769 | case 2: | |
20770 | if (fast_approx) { { const unsigned int N3 = 2*2*2; for (int z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; ++z, ++_n1z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; ++x, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N3*k)[0] = (*this)(x, y, z,k), P.ptr(N3*k)[1] = (*this)(_n1x, y, z,k), P.ptr(N3*k)[2] = (*this)(x,_n1y, z,k), P.ptr(N3*k)[3] = (*this)(_n1x,_n1y, z,k), P.ptr(N3*k)[4] = (*this)(x, y,_n1z,k), P.ptr(N3*k)[5] = (*this)(_n1x, y,_n1z,k), P.ptr(N3*k)[6] = (*this)(x,_n1y,_n1z,k), P.ptr(N3*k)[7] = (*this)(_n1x,_n1y,_n1z,k); const int x0 = x-rsize1, y0 = y-rsize1, z0 = z-rsize1, x1 = x+rsize2, y1 = y+rsize2, z1 = z+rsize2; float sum_weights = 0; for (int r = (int)(z0)<0?0:(int)(z0), _n1r = r+1>=(int)((*this).depth)?(int)((*this).depth)-1:r+1; r<=(int)(z1) && (_n1r<(int)((*this).depth) || r==--_n1r); ++r, ++_n1r) for (int q = (int)(y0)<0?0:(int)(y0), _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); ++q, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); ++p, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N3*k)[0] = (*this)(p, q, r,k), Q.ptr(N3*k)[1] = (*this)(_n1p, q, r,k), Q.ptr(N3*k)[2] = (*this)(p,_n1q, r,k), Q.ptr(N3*k)[3] = (*this)(_n1p,_n1q, r,k), Q.ptr(N3*k)[4] = (*this)(p, q,_n1r,k), Q.ptr(N3*k)[5] = (*this)(_n1p, q,_n1r,k), Q.ptr(N3*k)[6] = (*this)(p,_n1q,_n1r,k), Q.ptr(N3*k)[7] = (*this)(_n1p,_n1q,_n1r,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, dz = r-z, alldist = distance2 + (dx*dx+dy*dy+dz*dz)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k) = (*this)(x,y,z,k); }}; } | |
20771 | else { { const unsigned int N3 = 2*2*2; for (int z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; ++z, ++_n1z) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; ++x, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N3*k)[0] = (*this)(x, y, z,k), P.ptr(N3*k)[1] = (*this)(_n1x, y, z,k), P.ptr(N3*k)[2] = (*this)(x,_n1y, z,k), P.ptr(N3*k)[3] = (*this)(_n1x,_n1y, z,k), P.ptr(N3*k)[4] = (*this)(x, y,_n1z,k), P.ptr(N3*k)[5] = (*this)(_n1x, y,_n1z,k), P.ptr(N3*k)[6] = (*this)(x,_n1y,_n1z,k), P.ptr(N3*k)[7] = (*this)(_n1x,_n1y,_n1z,k); const int x0 = x-rsize1, y0 = y-rsize1, z0 = z-rsize1, x1 = x+rsize2, y1 = y+rsize2, z1 = z+rsize2; float sum_weights = 0; for (int r = (int)(z0)<0?0:(int)(z0), _n1r = r+1>=(int)((*this).depth)?(int)((*this).depth)-1:r+1; r<=(int)(z1) && (_n1r<(int)((*this).depth) || r==--_n1r); ++r, ++_n1r) for (int q = (int)(y0)<0?0:(int)(y0), _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); ++q, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); ++p, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N3*k)[0] = (*this)(p, q, r,k), Q.ptr(N3*k)[1] = (*this)(_n1p, q, r,k), Q.ptr(N3*k)[2] = (*this)(p,_n1q, r,k), Q.ptr(N3*k)[3] = (*this)(_n1p,_n1q, r,k), Q.ptr(N3*k)[4] = (*this)(p, q,_n1r,k), Q.ptr(N3*k)[5] = (*this)(_n1p, q,_n1r,k), Q.ptr(N3*k)[6] = (*this)(p,_n1q,_n1r,k), Q.ptr(N3*k)[7] = (*this)(_n1p,_n1q,_n1r,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, dz = r-z, alldist = distance2 + (dx*dx+dy*dy+dz*dz)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k) = (*this)(x,y,z,k); }}; } | |
20772 | break; | |
20773 | case 3: | |
20774 | if (fast_approx) { { const unsigned int N3 = 3*3*3; for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; _p1x = x++, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N3*k)[0] = (*this)(_p1x,_p1y,_p1z,k), P.ptr(N3*k)[1] = (*this)(x,_p1y,_p1z,k), P.ptr(N3*k)[2] = (*this)(_n1x,_p1y,_p1z,k), P.ptr(N3*k)[3] = (*this)(_p1x, y,_p1z,k), P.ptr(N3*k)[4] = (*this)(x, y,_p1z,k), P.ptr(N3*k)[5] = (*this)(_n1x, y,_p1z,k), P.ptr(N3*k)[6] = (*this)(_p1x,_n1y,_p1z,k), P.ptr(N3*k)[7] = (*this)(x,_n1y,_p1z,k), P.ptr(N3*k)[8] = (*this)(_n1x,_n1y,_p1z,k), P.ptr(N3*k)[9] = (*this)(_p1x,_p1y, z,k), P.ptr(N3*k)[10] = (*this)(x,_p1y, z,k), P.ptr(N3*k)[11] = (*this)(_n1x,_p1y, z,k), P.ptr(N3*k)[12] = (*this)(_p1x, y, z,k), P.ptr(N3*k)[13] = (*this)(x, y, z,k), P.ptr(N3*k)[14] = (*this)(_n1x, y, z,k), P.ptr(N3*k)[15] = (*this)(_p1x,_n1y, z,k), P.ptr(N3*k)[16] = (*this)(x,_n1y, z,k), P.ptr(N3*k)[17] = (*this)(_n1x,_n1y, z,k), P.ptr(N3*k)[18] = (*this)(_p1x,_p1y,_n1z,k), P.ptr(N3*k)[19] = (*this)(x,_p1y,_n1z,k), P.ptr(N3*k)[20] = (*this)(_n1x,_p1y,_n1z,k), P.ptr(N3*k)[21] = (*this)(_p1x, y,_n1z,k), P.ptr(N3*k)[22] = (*this)(x, y,_n1z,k), P.ptr(N3*k)[23] = (*this)(_n1x, y,_n1z,k), P.ptr(N3*k)[24] = (*this)(_p1x,_n1y,_n1z,k), P.ptr(N3*k)[25] = (*this)(x,_n1y,_n1z,k), P.ptr(N3*k)[26] = (*this)(_n1x,_n1y,_n1z,k); const int x0 = x-rsize1, y0 = y-rsize1, z0 = z-rsize1, x1 = x+rsize2, y1 = y+rsize2, z1 = z+rsize2; float sum_weights = 0; for (int r = (int)(z0)<0?0:(int)(z0), _p1r = r-1<0?0:r-1, _n1r = r+1>=(int)((*this).depth)?(int)((*this).depth)-1:r+1; r<=(int)(z1) && (_n1r<(int)((*this).depth) || r==--_n1r); _p1r = r++, ++_n1r) for (int q = (int)(y0)<0?0:(int)(y0), _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); _p1q = q++, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); _p1p = p++, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N3*k)[0] = (*this)(_p1p,_p1q,_p1r,k), Q.ptr(N3*k)[1] = (*this)(p,_p1q,_p1r,k), Q.ptr(N3*k)[2] = (*this)(_n1p,_p1q,_p1r,k), Q.ptr(N3*k)[3] = (*this)(_p1p, q,_p1r,k), Q.ptr(N3*k)[4] = (*this)(p, q,_p1r,k), Q.ptr(N3*k)[5] = (*this)(_n1p, q,_p1r,k), Q.ptr(N3*k)[6] = (*this)(_p1p,_n1q,_p1r,k), Q.ptr(N3*k)[7] = (*this)(p,_n1q,_p1r,k), Q.ptr(N3*k)[8] = (*this)(_n1p,_n1q,_p1r,k), Q.ptr(N3*k)[9] = (*this)(_p1p,_p1q, r,k), Q.ptr(N3*k)[10] = (*this)(p,_p1q, r,k), Q.ptr(N3*k)[11] = (*this)(_n1p,_p1q, r,k), Q.ptr(N3*k)[12] = (*this)(_p1p, q, r,k), Q.ptr(N3*k)[13] = (*this)(p, q, r,k), Q.ptr(N3*k)[14] = (*this)(_n1p, q, r,k), Q.ptr(N3*k)[15] = (*this)(_p1p,_n1q, r,k), Q.ptr(N3*k)[16] = (*this)(p,_n1q, r,k), Q.ptr(N3*k)[17] = (*this)(_n1p,_n1q, r,k), Q.ptr(N3*k)[18] = (*this)(_p1p,_p1q,_n1r,k), Q.ptr(N3*k)[19] = (*this)(p,_p1q,_n1r,k), Q.ptr(N3*k)[20] = (*this)(_n1p,_p1q,_n1r,k), Q.ptr(N3*k)[21] = (*this)(_p1p, q,_n1r,k), Q.ptr(N3*k)[22] = (*this)(p, q,_n1r,k), Q.ptr(N3*k)[23] = (*this)(_n1p, q,_n1r,k), Q.ptr(N3*k)[24] = (*this)(_p1p,_n1q,_n1r,k), Q.ptr(N3*k)[25] = (*this)(p,_n1q,_n1r,k), Q.ptr(N3*k)[26] = (*this)(_n1p,_n1q,_n1r,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, dz = r-z, alldist = distance2 + (dx*dx+dy*dy+dz*dz)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k) = (*this)(x,y,z,k); }}; } | |
20775 | else { { const unsigned int N3 = 3*3*3; for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; _p1x = x++, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N3*k)[0] = (*this)(_p1x,_p1y,_p1z,k), P.ptr(N3*k)[1] = (*this)(x,_p1y,_p1z,k), P.ptr(N3*k)[2] = (*this)(_n1x,_p1y,_p1z,k), P.ptr(N3*k)[3] = (*this)(_p1x, y,_p1z,k), P.ptr(N3*k)[4] = (*this)(x, y,_p1z,k), P.ptr(N3*k)[5] = (*this)(_n1x, y,_p1z,k), P.ptr(N3*k)[6] = (*this)(_p1x,_n1y,_p1z,k), P.ptr(N3*k)[7] = (*this)(x,_n1y,_p1z,k), P.ptr(N3*k)[8] = (*this)(_n1x,_n1y,_p1z,k), P.ptr(N3*k)[9] = (*this)(_p1x,_p1y, z,k), P.ptr(N3*k)[10] = (*this)(x,_p1y, z,k), P.ptr(N3*k)[11] = (*this)(_n1x,_p1y, z,k), P.ptr(N3*k)[12] = (*this)(_p1x, y, z,k), P.ptr(N3*k)[13] = (*this)(x, y, z,k), P.ptr(N3*k)[14] = (*this)(_n1x, y, z,k), P.ptr(N3*k)[15] = (*this)(_p1x,_n1y, z,k), P.ptr(N3*k)[16] = (*this)(x,_n1y, z,k), P.ptr(N3*k)[17] = (*this)(_n1x,_n1y, z,k), P.ptr(N3*k)[18] = (*this)(_p1x,_p1y,_n1z,k), P.ptr(N3*k)[19] = (*this)(x,_p1y,_n1z,k), P.ptr(N3*k)[20] = (*this)(_n1x,_p1y,_n1z,k), P.ptr(N3*k)[21] = (*this)(_p1x, y,_n1z,k), P.ptr(N3*k)[22] = (*this)(x, y,_n1z,k), P.ptr(N3*k)[23] = (*this)(_n1x, y,_n1z,k), P.ptr(N3*k)[24] = (*this)(_p1x,_n1y,_n1z,k), P.ptr(N3*k)[25] = (*this)(x,_n1y,_n1z,k), P.ptr(N3*k)[26] = (*this)(_n1x,_n1y,_n1z,k); const int x0 = x-rsize1, y0 = y-rsize1, z0 = z-rsize1, x1 = x+rsize2, y1 = y+rsize2, z1 = z+rsize2; float sum_weights = 0; for (int r = (int)(z0)<0?0:(int)(z0), _p1r = r-1<0?0:r-1, _n1r = r+1>=(int)((*this).depth)?(int)((*this).depth)-1:r+1; r<=(int)(z1) && (_n1r<(int)((*this).depth) || r==--_n1r); _p1r = r++, ++_n1r) for (int q = (int)(y0)<0?0:(int)(y0), _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); _p1q = q++, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); _p1p = p++, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N3*k)[0] = (*this)(_p1p,_p1q,_p1r,k), Q.ptr(N3*k)[1] = (*this)(p,_p1q,_p1r,k), Q.ptr(N3*k)[2] = (*this)(_n1p,_p1q,_p1r,k), Q.ptr(N3*k)[3] = (*this)(_p1p, q,_p1r,k), Q.ptr(N3*k)[4] = (*this)(p, q,_p1r,k), Q.ptr(N3*k)[5] = (*this)(_n1p, q,_p1r,k), Q.ptr(N3*k)[6] = (*this)(_p1p,_n1q,_p1r,k), Q.ptr(N3*k)[7] = (*this)(p,_n1q,_p1r,k), Q.ptr(N3*k)[8] = (*this)(_n1p,_n1q,_p1r,k), Q.ptr(N3*k)[9] = (*this)(_p1p,_p1q, r,k), Q.ptr(N3*k)[10] = (*this)(p,_p1q, r,k), Q.ptr(N3*k)[11] = (*this)(_n1p,_p1q, r,k), Q.ptr(N3*k)[12] = (*this)(_p1p, q, r,k), Q.ptr(N3*k)[13] = (*this)(p, q, r,k), Q.ptr(N3*k)[14] = (*this)(_n1p, q, r,k), Q.ptr(N3*k)[15] = (*this)(_p1p,_n1q, r,k), Q.ptr(N3*k)[16] = (*this)(p,_n1q, r,k), Q.ptr(N3*k)[17] = (*this)(_n1p,_n1q, r,k), Q.ptr(N3*k)[18] = (*this)(_p1p,_p1q,_n1r,k), Q.ptr(N3*k)[19] = (*this)(p,_p1q,_n1r,k), Q.ptr(N3*k)[20] = (*this)(_n1p,_p1q,_n1r,k), Q.ptr(N3*k)[21] = (*this)(_p1p, q,_n1r,k), Q.ptr(N3*k)[22] = (*this)(p, q,_n1r,k), Q.ptr(N3*k)[23] = (*this)(_n1p, q,_n1r,k), Q.ptr(N3*k)[24] = (*this)(_p1p,_n1q,_n1r,k), Q.ptr(N3*k)[25] = (*this)(p,_n1q,_n1r,k), Q.ptr(N3*k)[26] = (*this)(_n1p,_n1q,_n1r,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, dz = r-z, alldist = distance2 + (dx*dx+dy*dy+dz*dz)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k) = (*this)(x,y,z,k); }}; } | |
20776 | break; | |
20777 | default: { | |
20778 | const int psize1 = (int)patch_size/2, psize0 = psize1-1+(patch_size%2); | |
20779 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20780 | if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; | |
20781 | P = get_crop(x-psize0,y-psize0,z-psize0,x+psize1,y+psize1,z+psize1,true); | |
20782 | const int x0 = x-rsize1, y0 = y-rsize1, z0 = z-rsize1, x1 = x+rsize2, y1 = y+rsize2, z1 = z+rsize2; | |
20783 | float sum_weights = 0; | |
20784 | for (int r = (int)(z0)<0?0:(int)(z0), _maxr = (int)(z1)<(int)((*this).depth)?(int)(z1):(int)((*this).depth)-1; r<=_maxr; ++r) for (int q = (int)(y0)<0?0:(int)(y0), _maxq = (int)(y1)<(int)((*this).height)?(int)(y1):(int)((*this).height)-1; q<=_maxq; ++q) for (int p = (int)(x0)<0?0:(int)(x0), _maxp = (int)(x1)<(int)((*this).width)?(int)(x1):(int)((*this).width)-1; p<=_maxp; ++p) { | |
20785 | (Q = get_crop(p-psize0,q-psize0,r-psize0,p+psize1,q+psize1,r+psize1,true))-=P; | |
20786 | const float | |
20787 | dx = x-p, dy = y-q, dz = z-r, | |
20788 | distance2 = Q.pow(2).sum()/Pnorm + (dx*dx + dy*dy + dz*dz)/sigma_s2, | |
20789 | weight = std::exp(-distance2); | |
20790 | sum_weights+=weight; | |
20791 | for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); | |
20792 | } | |
20793 | if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,z,k) = (*this)(x,y,z,k); | |
20794 | } | |
20795 | } break; | |
20796 | } else switch (patch_size) { | |
20797 | case 2: | |
20798 | if (fast_approx) { { const unsigned int N2 = 2*2; for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; ++x, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(x, y,0,k), P.ptr(N2*k)[1] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[2] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[3] = (*this)(_n1x,_n1y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); ++q, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); ++p, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(p, q,0,k), Q.ptr(N2*k)[1] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[2] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[3] = (*this)(_n1p,_n1q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20799 | else { { const unsigned int N2 = 2*2; for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; ++x, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(x, y,0,k), P.ptr(N2*k)[1] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[2] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[3] = (*this)(_n1x,_n1y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); ++q, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); ++p, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(p, q,0,k), Q.ptr(N2*k)[1] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[2] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[3] = (*this)(_n1p,_n1q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20800 | break; | |
20801 | case 3: | |
20802 | if (fast_approx) { { const unsigned int N2 = 3*3; for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; _p1x = x++, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[1] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[2] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[3] = (*this)(_p1x, y,0,k), P.ptr(N2*k)[4] = (*this)(x, y,0,k), P.ptr(N2*k)[5] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[6] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[7] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[8] = (*this)(_n1x,_n1y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); _p1q = q++, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); _p1p = p++, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[1] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[2] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[3] = (*this)(_p1p, q,0,k), Q.ptr(N2*k)[4] = (*this)(p, q,0,k), Q.ptr(N2*k)[5] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[6] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[7] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[8] = (*this)(_n1p,_n1q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20803 | else { { const unsigned int N2 = 3*3; for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1; _n1x<(int)((*this).width) || x==--_n1x; _p1x = x++, ++_n1x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[1] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[2] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[3] = (*this)(_p1x, y,0,k), P.ptr(N2*k)[4] = (*this)(x, y,0,k), P.ptr(N2*k)[5] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[6] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[7] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[8] = (*this)(_n1x,_n1y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1; q<=(int)(y1) && (_n1q<(int)((*this).height) || q==--_n1q); _p1q = q++, ++_n1q) for (int p = (int)(x0)<0?0:(int)(x0), _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1; p<=(int)(x1) && (_n1p<(int)((*this).width) || p==--_n1p); _p1p = p++, ++_n1p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[1] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[2] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[3] = (*this)(_p1p, q,0,k), Q.ptr(N2*k)[4] = (*this)(p, q,0,k), Q.ptr(N2*k)[5] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[6] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[7] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[8] = (*this)(_n1p,_n1q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20804 | break; | |
20805 | case 4: | |
20806 | if (fast_approx) { { const unsigned int N2 = 4*4; for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2; _n2x<(int)((*this).width) || _n1x==--_n2x || x==(_n2x = --_n1x); _p1x = x++, ++_n1x, ++_n2x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[1] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[2] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[3] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[4] = (*this)(_p1x, y,0,k), P.ptr(N2*k)[5] = (*this)(x, y,0,k), P.ptr(N2*k)[6] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[7] = (*this)(_n2x, y,0,k), P.ptr(N2*k)[8] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[9] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[10] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[11] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[12] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[13] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[14] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[15] = (*this)(_n2x,_n2y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2; q<=(int)(y1) && (_n2q<(int)((*this).height) || _n1q==--_n2q || q==(_n2q = --_n1q)); _p1q = q++, ++_n1q, ++_n2q) for (int p = (int)(x0)<0?0:(int)(x0), _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2; p<=(int)(x1) && (_n2p<(int)((*this).width) || _n1p==--_n2p || p==(_n2p = --_n1p)); _p1p = p++, ++_n1p, ++_n2p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[1] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[2] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[3] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[4] = (*this)(_p1p, q,0,k), Q.ptr(N2*k)[5] = (*this)(p, q,0,k), Q.ptr(N2*k)[6] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[7] = (*this)(_n2p, q,0,k), Q.ptr(N2*k)[8] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[9] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[10] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[11] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[12] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[13] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[14] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[15] = (*this)(_n2p,_n2q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20807 | else { { const unsigned int N2 = 4*4; for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2; _n2x<(int)((*this).width) || _n1x==--_n2x || x==(_n2x = --_n1x); _p1x = x++, ++_n1x, ++_n2x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[1] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[2] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[3] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[4] = (*this)(_p1x, y,0,k), P.ptr(N2*k)[5] = (*this)(x, y,0,k), P.ptr(N2*k)[6] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[7] = (*this)(_n2x, y,0,k), P.ptr(N2*k)[8] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[9] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[10] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[11] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[12] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[13] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[14] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[15] = (*this)(_n2x,_n2y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2; q<=(int)(y1) && (_n2q<(int)((*this).height) || _n1q==--_n2q || q==(_n2q = --_n1q)); _p1q = q++, ++_n1q, ++_n2q) for (int p = (int)(x0)<0?0:(int)(x0), _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2; p<=(int)(x1) && (_n2p<(int)((*this).width) || _n1p==--_n2p || p==(_n2p = --_n1p)); _p1p = p++, ++_n1p, ++_n2p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[1] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[2] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[3] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[4] = (*this)(_p1p, q,0,k), Q.ptr(N2*k)[5] = (*this)(p, q,0,k), Q.ptr(N2*k)[6] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[7] = (*this)(_n2p, q,0,k), Q.ptr(N2*k)[8] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[9] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[10] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[11] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[12] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[13] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[14] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[15] = (*this)(_n2p,_n2q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20808 | break; | |
20809 | case 5: | |
20810 | if (fast_approx) { { const unsigned int N2 = 5*5; for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2; _n2x<(int)((*this).width) || _n1x==--_n2x || x==(_n2x = --_n1x); _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[1] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[2] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[3] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[4] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[5] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[6] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[7] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[8] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[9] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[10] = (*this)(_p2x, y,0,k), P.ptr(N2*k)[11] = (*this)(_p1x, y,0,k), P.ptr(N2*k)[12] = (*this)(x, y,0,k), P.ptr(N2*k)[13] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[14] = (*this)(_n2x, y,0,k), P.ptr(N2*k)[15] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[16] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[17] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[18] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[19] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[20] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[21] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[22] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[23] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[24] = (*this)(_n2x,_n2y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2; q<=(int)(y1) && (_n2q<(int)((*this).height) || _n1q==--_n2q || q==(_n2q = --_n1q)); _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q) for (int p = (int)(x0)<0?0:(int)(x0), _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2; p<=(int)(x1) && (_n2p<(int)((*this).width) || _n1p==--_n2p || p==(_n2p = --_n1p)); _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[1] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[2] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[3] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[4] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[5] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[6] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[7] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[8] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[9] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[10] = (*this)(_p2p, q,0,k), Q.ptr(N2*k)[11] = (*this)(_p1p, q,0,k), Q.ptr(N2*k)[12] = (*this)(p, q,0,k), Q.ptr(N2*k)[13] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[14] = (*this)(_n2p, q,0,k), Q.ptr(N2*k)[15] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[16] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[17] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[18] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[19] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[20] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[21] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[22] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[23] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[24] = (*this)(_n2p,_n2q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20811 | else { { const unsigned int N2 = 5*5; for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2; _n2x<(int)((*this).width) || _n1x==--_n2x || x==(_n2x = --_n1x); _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[1] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[2] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[3] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[4] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[5] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[6] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[7] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[8] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[9] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[10] = (*this)(_p2x, y,0,k), P.ptr(N2*k)[11] = (*this)(_p1x, y,0,k), P.ptr(N2*k)[12] = (*this)(x, y,0,k), P.ptr(N2*k)[13] = (*this)(_n1x, y,0,k), P.ptr(N2*k)[14] = (*this)(_n2x, y,0,k), P.ptr(N2*k)[15] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[16] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[17] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[18] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[19] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[20] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[21] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[22] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[23] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[24] = (*this)(_n2x,_n2y,0,k); const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2; q<=(int)(y1) && (_n2q<(int)((*this).height) || _n1q==--_n2q || q==(_n2q = --_n1q)); _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q) for (int p = (int)(x0)<0?0:(int)(x0), _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2; p<=(int)(x1) && (_n2p<(int)((*this).width) || _n1p==--_n2p || p==(_n2p = --_n1p)); _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[1] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[2] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[3] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[4] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[5] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[6] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[7] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[8] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[9] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[10] = (*this)(_p2p, q,0,k), Q.ptr(N2*k)[11] = (*this)(_p1p, q,0,k), Q.ptr(N2*k)[12] = (*this)(p, q,0,k), Q.ptr(N2*k)[13] = (*this)(_n1p, q,0,k), Q.ptr(N2*k)[14] = (*this)(_n2p, q,0,k), Q.ptr(N2*k)[15] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[16] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[17] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[18] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[19] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[20] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[21] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[22] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[23] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[24] = (*this)(_n2p,_n2q,0,k); float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20812 | break; | |
20813 | case 6: | |
20814 | if (fast_approx) { { const unsigned int N2 = 6*6; for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3; _n3y<(int)((*this).height) || _n2y==--_n3y || _n1y==--_n2y || y==(_n3y = _n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=((*this).width)?(int)((*this).width)-1:3; _n3x<(int)((*this).width) || _n2x==--_n3x || _n1x==--_n2x || x==(_n3x = _n2x = --_n1x); _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[1] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[2] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[3] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[4] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[5] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[6] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[7] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[8] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[9] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[10] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[11] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[12] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[13] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[14] = (*this)(x,y,0,k), P.ptr(N2*k)[15] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[16] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[17] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[18] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[19] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[20] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[21] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[22] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[23] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[24] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[25] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[26] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[27] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[28] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[29] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[30] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[31] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[32] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[33] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[34] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[35] = (*this)(_n3x,_n3y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3; q<=(int)(y1) && (_n3q<(int)((*this).height) || _n2q==--_n3q || _n1q==--_n2q || q==(_n3q = _n2q = --_n1q)); _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q) for (int p = (int)(x0)<0?0:(int)(x0), _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3; p<=(int)(x1) && (_n3p<(int)((*this).width) || _n2p==--_n3p || _n1p==--_n2p || p==(_n3p = _n2p = --_n1p)); _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[1] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[2] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[3] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[4] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[5] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[6] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[7] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[8] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[9] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[10] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[11] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[12] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[13] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[14] = (*this)(p,q,0,k), Q.ptr(N2*k)[15] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[16] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[17] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[18] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[19] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[20] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[21] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[22] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[23] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[24] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[25] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[26] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[27] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[28] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[29] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[30] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[31] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[32] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[33] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[34] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[35] = (*this)(_n3p,_n3q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20815 | else { { const unsigned int N2 = 6*6; for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3; _n3y<(int)((*this).height) || _n2y==--_n3y || _n1y==--_n2y || y==(_n3y = _n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=((*this).width)?(int)((*this).width)-1:3; _n3x<(int)((*this).width) || _n2x==--_n3x || _n1x==--_n2x || x==(_n3x = _n2x = --_n1x); _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[1] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[2] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[3] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[4] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[5] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[6] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[7] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[8] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[9] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[10] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[11] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[12] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[13] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[14] = (*this)(x,y,0,k), P.ptr(N2*k)[15] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[16] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[17] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[18] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[19] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[20] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[21] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[22] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[23] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[24] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[25] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[26] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[27] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[28] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[29] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[30] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[31] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[32] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[33] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[34] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[35] = (*this)(_n3x,_n3y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3; q<=(int)(y1) && (_n3q<(int)((*this).height) || _n2q==--_n3q || _n1q==--_n2q || q==(_n3q = _n2q = --_n1q)); _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q) for (int p = (int)(x0)<0?0:(int)(x0), _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3; p<=(int)(x1) && (_n3p<(int)((*this).width) || _n2p==--_n3p || _n1p==--_n2p || p==(_n3p = _n2p = --_n1p)); _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[1] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[2] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[3] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[4] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[5] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[6] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[7] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[8] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[9] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[10] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[11] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[12] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[13] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[14] = (*this)(p,q,0,k), Q.ptr(N2*k)[15] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[16] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[17] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[18] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[19] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[20] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[21] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[22] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[23] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[24] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[25] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[26] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[27] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[28] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[29] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[30] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[31] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[32] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[33] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[34] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[35] = (*this)(_n3p,_n3q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20816 | break; | |
20817 | case 7: | |
20818 | if (fast_approx) { { const unsigned int N2 = 7*7; for (int y = 0, _p3y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3; _n3y<(int)((*this).height) || _n2y==--_n3y || _n1y==--_n2y || y==(_n3y = _n2y = --_n1y); _p3y = _p2y, _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y) for (int x = 0, _p3x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=((*this).width)?(int)((*this).width)-1:3; _n3x<(int)((*this).width) || _n2x==--_n3x || _n1x==--_n2x || x==(_n3x = _n2x = --_n1x); _p3x = _p2x, _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p3x,_p3y,0,k), P.ptr(N2*k)[1] = (*this)(_p2x,_p3y,0,k), P.ptr(N2*k)[2] = (*this)(_p1x,_p3y,0,k), P.ptr(N2*k)[3] = (*this)(x,_p3y,0,k), P.ptr(N2*k)[4] = (*this)(_n1x,_p3y,0,k), P.ptr(N2*k)[5] = (*this)(_n2x,_p3y,0,k), P.ptr(N2*k)[6] = (*this)(_n3x,_p3y,0,k), P.ptr(N2*k)[7] = (*this)(_p3x,_p2y,0,k), P.ptr(N2*k)[8] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[9] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[10] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[11] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[12] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[13] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[14] = (*this)(_p3x,_p1y,0,k), P.ptr(N2*k)[15] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[16] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[17] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[18] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[19] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[20] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[21] = (*this)(_p3x,y,0,k), P.ptr(N2*k)[22] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[23] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[24] = (*this)(x,y,0,k), P.ptr(N2*k)[25] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[26] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[27] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[28] = (*this)(_p3x,_n1y,0,k), P.ptr(N2*k)[29] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[30] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[31] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[32] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[33] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[34] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[35] = (*this)(_p3x,_n2y,0,k), P.ptr(N2*k)[36] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[37] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[38] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[39] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[40] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[41] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[42] = (*this)(_p3x,_n3y,0,k), P.ptr(N2*k)[43] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[44] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[45] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[46] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[47] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[48] = (*this)(_n3x,_n3y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p3q = q-3<0?0:q-3, _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3; q<=(int)(y1) && (_n3q<(int)((*this).height) || _n2q==--_n3q || _n1q==--_n2q || q==(_n3q = _n2q = --_n1q)); _p3q = _p2q, _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q) for (int p = (int)(x0)<0?0:(int)(x0), _p3p = p-3<0?0:p-3, _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3; p<=(int)(x1) && (_n3p<(int)((*this).width) || _n2p==--_n3p || _n1p==--_n2p || p==(_n3p = _n2p = --_n1p)); _p3p = _p2p, _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p3p,_p3q,0,k), Q.ptr(N2*k)[1] = (*this)(_p2p,_p3q,0,k), Q.ptr(N2*k)[2] = (*this)(_p1p,_p3q,0,k), Q.ptr(N2*k)[3] = (*this)(p,_p3q,0,k), Q.ptr(N2*k)[4] = (*this)(_n1p,_p3q,0,k), Q.ptr(N2*k)[5] = (*this)(_n2p,_p3q,0,k), Q.ptr(N2*k)[6] = (*this)(_n3p,_p3q,0,k), Q.ptr(N2*k)[7] = (*this)(_p3p,_p2q,0,k), Q.ptr(N2*k)[8] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[9] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[10] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[11] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[12] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[13] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[14] = (*this)(_p3p,_p1q,0,k), Q.ptr(N2*k)[15] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[16] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[17] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[18] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[19] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[20] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[21] = (*this)(_p3p,q,0,k), Q.ptr(N2*k)[22] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[23] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[24] = (*this)(p,q,0,k), Q.ptr(N2*k)[25] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[26] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[27] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[28] = (*this)(_p3p,_n1q,0,k), Q.ptr(N2*k)[29] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[30] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[31] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[32] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[33] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[34] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[35] = (*this)(_p3p,_n2q,0,k), Q.ptr(N2*k)[36] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[37] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[38] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[39] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[40] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[41] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[42] = (*this)(_p3p,_n3q,0,k), Q.ptr(N2*k)[43] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[44] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[45] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[46] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[47] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[48] = (*this)(_n3p,_n3q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20819 | else { { const unsigned int N2 = 7*7; for (int y = 0, _p3y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3; _n3y<(int)((*this).height) || _n2y==--_n3y || _n1y==--_n2y || y==(_n3y = _n2y = --_n1y); _p3y = _p2y, _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y) for (int x = 0, _p3x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=((*this).width)?(int)((*this).width)-1:3; _n3x<(int)((*this).width) || _n2x==--_n3x || _n1x==--_n2x || x==(_n3x = _n2x = --_n1x); _p3x = _p2x, _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p3x,_p3y,0,k), P.ptr(N2*k)[1] = (*this)(_p2x,_p3y,0,k), P.ptr(N2*k)[2] = (*this)(_p1x,_p3y,0,k), P.ptr(N2*k)[3] = (*this)(x,_p3y,0,k), P.ptr(N2*k)[4] = (*this)(_n1x,_p3y,0,k), P.ptr(N2*k)[5] = (*this)(_n2x,_p3y,0,k), P.ptr(N2*k)[6] = (*this)(_n3x,_p3y,0,k), P.ptr(N2*k)[7] = (*this)(_p3x,_p2y,0,k), P.ptr(N2*k)[8] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[9] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[10] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[11] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[12] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[13] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[14] = (*this)(_p3x,_p1y,0,k), P.ptr(N2*k)[15] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[16] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[17] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[18] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[19] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[20] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[21] = (*this)(_p3x,y,0,k), P.ptr(N2*k)[22] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[23] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[24] = (*this)(x,y,0,k), P.ptr(N2*k)[25] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[26] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[27] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[28] = (*this)(_p3x,_n1y,0,k), P.ptr(N2*k)[29] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[30] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[31] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[32] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[33] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[34] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[35] = (*this)(_p3x,_n2y,0,k), P.ptr(N2*k)[36] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[37] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[38] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[39] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[40] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[41] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[42] = (*this)(_p3x,_n3y,0,k), P.ptr(N2*k)[43] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[44] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[45] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[46] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[47] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[48] = (*this)(_n3x,_n3y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p3q = q-3<0?0:q-3, _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3; q<=(int)(y1) && (_n3q<(int)((*this).height) || _n2q==--_n3q || _n1q==--_n2q || q==(_n3q = _n2q = --_n1q)); _p3q = _p2q, _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q) for (int p = (int)(x0)<0?0:(int)(x0), _p3p = p-3<0?0:p-3, _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3; p<=(int)(x1) && (_n3p<(int)((*this).width) || _n2p==--_n3p || _n1p==--_n2p || p==(_n3p = _n2p = --_n1p)); _p3p = _p2p, _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p3p,_p3q,0,k), Q.ptr(N2*k)[1] = (*this)(_p2p,_p3q,0,k), Q.ptr(N2*k)[2] = (*this)(_p1p,_p3q,0,k), Q.ptr(N2*k)[3] = (*this)(p,_p3q,0,k), Q.ptr(N2*k)[4] = (*this)(_n1p,_p3q,0,k), Q.ptr(N2*k)[5] = (*this)(_n2p,_p3q,0,k), Q.ptr(N2*k)[6] = (*this)(_n3p,_p3q,0,k), Q.ptr(N2*k)[7] = (*this)(_p3p,_p2q,0,k), Q.ptr(N2*k)[8] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[9] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[10] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[11] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[12] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[13] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[14] = (*this)(_p3p,_p1q,0,k), Q.ptr(N2*k)[15] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[16] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[17] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[18] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[19] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[20] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[21] = (*this)(_p3p,q,0,k), Q.ptr(N2*k)[22] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[23] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[24] = (*this)(p,q,0,k), Q.ptr(N2*k)[25] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[26] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[27] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[28] = (*this)(_p3p,_n1q,0,k), Q.ptr(N2*k)[29] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[30] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[31] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[32] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[33] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[34] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[35] = (*this)(_p3p,_n2q,0,k), Q.ptr(N2*k)[36] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[37] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[38] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[39] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[40] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[41] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[42] = (*this)(_p3p,_n3q,0,k), Q.ptr(N2*k)[43] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[44] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[45] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[46] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[47] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[48] = (*this)(_n3p,_n3q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20820 | break; | |
20821 | case 8: | |
20822 | if (fast_approx) { { const unsigned int N2 = 8*8; for (int y = 0, _p3y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3, _n4y = 4>=((*this).height)?(int)((*this).height)-1:4; _n4y<(int)((*this).height) || _n3y==--_n4y || _n2y==--_n3y || _n1y==--_n2y || y==(_n4y = _n3y = _n2y = --_n1y); _p3y = _p2y, _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y, ++_n4y) for (int x = 0, _p3x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=((*this).width)?(int)((*this).width)-1:3, _n4x = 4>=((*this).width)?(int)((*this).width)-1:4; _n4x<(int)((*this).width) || _n3x==--_n4x || _n2x==--_n3x || _n1x==--_n2x || x==(_n4x = _n3x = _n2x = --_n1x); _p3x = _p2x, _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x, ++_n4x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p3x,_p3y,0,k), P.ptr(N2*k)[1] = (*this)(_p2x,_p3y,0,k), P.ptr(N2*k)[2] = (*this)(_p1x,_p3y,0,k), P.ptr(N2*k)[3] = (*this)(x,_p3y,0,k), P.ptr(N2*k)[4] = (*this)(_n1x,_p3y,0,k), P.ptr(N2*k)[5] = (*this)(_n2x,_p3y,0,k), P.ptr(N2*k)[6] = (*this)(_n3x,_p3y,0,k), P.ptr(N2*k)[7] = (*this)(_n4x,_p3y,0,k), P.ptr(N2*k)[8] = (*this)(_p3x,_p2y,0,k), P.ptr(N2*k)[9] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[10] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[11] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[12] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[13] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[14] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[15] = (*this)(_n4x,_p2y,0,k), P.ptr(N2*k)[16] = (*this)(_p3x,_p1y,0,k), P.ptr(N2*k)[17] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[18] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[19] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[20] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[21] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[22] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[23] = (*this)(_n4x,_p1y,0,k), P.ptr(N2*k)[24] = (*this)(_p3x,y,0,k), P.ptr(N2*k)[25] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[26] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[27] = (*this)(x,y,0,k), P.ptr(N2*k)[28] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[29] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[30] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[31] = (*this)(_n4x,y,0,k), P.ptr(N2*k)[32] = (*this)(_p3x,_n1y,0,k), P.ptr(N2*k)[33] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[34] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[35] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[36] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[37] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[38] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[39] = (*this)(_n4x,_n1y,0,k), P.ptr(N2*k)[40] = (*this)(_p3x,_n2y,0,k), P.ptr(N2*k)[41] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[42] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[43] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[44] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[45] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[46] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[47] = (*this)(_n4x,_n2y,0,k), P.ptr(N2*k)[48] = (*this)(_p3x,_n3y,0,k), P.ptr(N2*k)[49] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[50] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[51] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[52] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[53] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[54] = (*this)(_n3x,_n3y,0,k), P.ptr(N2*k)[55] = (*this)(_n4x,_n3y,0,k), P.ptr(N2*k)[56] = (*this)(_p3x,_n4y,0,k), P.ptr(N2*k)[57] = (*this)(_p2x,_n4y,0,k), P.ptr(N2*k)[58] = (*this)(_p1x,_n4y,0,k), P.ptr(N2*k)[59] = (*this)(x,_n4y,0,k), P.ptr(N2*k)[60] = (*this)(_n1x,_n4y,0,k), P.ptr(N2*k)[61] = (*this)(_n2x,_n4y,0,k), P.ptr(N2*k)[62] = (*this)(_n3x,_n4y,0,k), P.ptr(N2*k)[63] = (*this)(_n4x,_n4y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p3q = q-3<0?0:q-3, _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3, _n4q = q+4>=(int)((*this).height)?(int)((*this).height)-1:q+4; q<=(int)(y1) && (_n4q<(int)((*this).height) || _n3q==--_n4q || _n2q==--_n3q || _n1q==--_n2q || q==(_n4q = _n3q = _n2q = --_n1q)); _p3q = _p2q, _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q, ++_n4q) for (int p = (int)(x0)<0?0:(int)(x0), _p3p = p-3<0?0:p-3, _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3, _n4p = p+4>=(int)((*this).width)?(int)((*this).width)-1:p+4; p<=(int)(x1) && (_n4p<(int)((*this).width) || _n3p==--_n4p || _n2p==--_n3p || _n1p==--_n2p || p==(_n4p = _n3p = _n2p = --_n1p)); _p3p = _p2p, _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p, ++_n4p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p3p,_p3q,0,k), Q.ptr(N2*k)[1] = (*this)(_p2p,_p3q,0,k), Q.ptr(N2*k)[2] = (*this)(_p1p,_p3q,0,k), Q.ptr(N2*k)[3] = (*this)(p,_p3q,0,k), Q.ptr(N2*k)[4] = (*this)(_n1p,_p3q,0,k), Q.ptr(N2*k)[5] = (*this)(_n2p,_p3q,0,k), Q.ptr(N2*k)[6] = (*this)(_n3p,_p3q,0,k), Q.ptr(N2*k)[7] = (*this)(_n4p,_p3q,0,k), Q.ptr(N2*k)[8] = (*this)(_p3p,_p2q,0,k), Q.ptr(N2*k)[9] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[10] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[11] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[12] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[13] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[14] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[15] = (*this)(_n4p,_p2q,0,k), Q.ptr(N2*k)[16] = (*this)(_p3p,_p1q,0,k), Q.ptr(N2*k)[17] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[18] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[19] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[20] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[21] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[22] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[23] = (*this)(_n4p,_p1q,0,k), Q.ptr(N2*k)[24] = (*this)(_p3p,q,0,k), Q.ptr(N2*k)[25] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[26] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[27] = (*this)(p,q,0,k), Q.ptr(N2*k)[28] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[29] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[30] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[31] = (*this)(_n4p,q,0,k), Q.ptr(N2*k)[32] = (*this)(_p3p,_n1q,0,k), Q.ptr(N2*k)[33] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[34] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[35] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[36] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[37] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[38] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[39] = (*this)(_n4p,_n1q,0,k), Q.ptr(N2*k)[40] = (*this)(_p3p,_n2q,0,k), Q.ptr(N2*k)[41] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[42] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[43] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[44] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[45] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[46] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[47] = (*this)(_n4p,_n2q,0,k), Q.ptr(N2*k)[48] = (*this)(_p3p,_n3q,0,k), Q.ptr(N2*k)[49] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[50] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[51] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[52] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[53] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[54] = (*this)(_n3p,_n3q,0,k), Q.ptr(N2*k)[55] = (*this)(_n4p,_n3q,0,k), Q.ptr(N2*k)[56] = (*this)(_p3p,_n4q,0,k), Q.ptr(N2*k)[57] = (*this)(_p2p,_n4q,0,k), Q.ptr(N2*k)[58] = (*this)(_p1p,_n4q,0,k), Q.ptr(N2*k)[59] = (*this)(p,_n4q,0,k), Q.ptr(N2*k)[60] = (*this)(_n1p,_n4q,0,k), Q.ptr(N2*k)[61] = (*this)(_n2p,_n4q,0,k), Q.ptr(N2*k)[62] = (*this)(_n3p,_n4q,0,k), Q.ptr(N2*k)[63] = (*this)(_n4p,_n4q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20823 | else { { const unsigned int N2 = 8*8; for (int y = 0, _p3y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=((*this).height)?(int)((*this).height)-1:3, _n4y = 4>=((*this).height)?(int)((*this).height)-1:4; _n4y<(int)((*this).height) || _n3y==--_n4y || _n2y==--_n3y || _n1y==--_n2y || y==(_n4y = _n3y = _n2y = --_n1y); _p3y = _p2y, _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y, ++_n4y) for (int x = 0, _p3x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=((*this).width)?(int)((*this).width)-1:3, _n4x = 4>=((*this).width)?(int)((*this).width)-1:4; _n4x<(int)((*this).width) || _n3x==--_n4x || _n2x==--_n3x || _n1x==--_n2x || x==(_n4x = _n3x = _n2x = --_n1x); _p3x = _p2x, _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x, ++_n4x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p3x,_p3y,0,k), P.ptr(N2*k)[1] = (*this)(_p2x,_p3y,0,k), P.ptr(N2*k)[2] = (*this)(_p1x,_p3y,0,k), P.ptr(N2*k)[3] = (*this)(x,_p3y,0,k), P.ptr(N2*k)[4] = (*this)(_n1x,_p3y,0,k), P.ptr(N2*k)[5] = (*this)(_n2x,_p3y,0,k), P.ptr(N2*k)[6] = (*this)(_n3x,_p3y,0,k), P.ptr(N2*k)[7] = (*this)(_n4x,_p3y,0,k), P.ptr(N2*k)[8] = (*this)(_p3x,_p2y,0,k), P.ptr(N2*k)[9] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[10] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[11] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[12] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[13] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[14] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[15] = (*this)(_n4x,_p2y,0,k), P.ptr(N2*k)[16] = (*this)(_p3x,_p1y,0,k), P.ptr(N2*k)[17] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[18] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[19] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[20] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[21] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[22] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[23] = (*this)(_n4x,_p1y,0,k), P.ptr(N2*k)[24] = (*this)(_p3x,y,0,k), P.ptr(N2*k)[25] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[26] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[27] = (*this)(x,y,0,k), P.ptr(N2*k)[28] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[29] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[30] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[31] = (*this)(_n4x,y,0,k), P.ptr(N2*k)[32] = (*this)(_p3x,_n1y,0,k), P.ptr(N2*k)[33] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[34] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[35] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[36] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[37] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[38] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[39] = (*this)(_n4x,_n1y,0,k), P.ptr(N2*k)[40] = (*this)(_p3x,_n2y,0,k), P.ptr(N2*k)[41] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[42] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[43] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[44] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[45] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[46] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[47] = (*this)(_n4x,_n2y,0,k), P.ptr(N2*k)[48] = (*this)(_p3x,_n3y,0,k), P.ptr(N2*k)[49] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[50] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[51] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[52] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[53] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[54] = (*this)(_n3x,_n3y,0,k), P.ptr(N2*k)[55] = (*this)(_n4x,_n3y,0,k), P.ptr(N2*k)[56] = (*this)(_p3x,_n4y,0,k), P.ptr(N2*k)[57] = (*this)(_p2x,_n4y,0,k), P.ptr(N2*k)[58] = (*this)(_p1x,_n4y,0,k), P.ptr(N2*k)[59] = (*this)(x,_n4y,0,k), P.ptr(N2*k)[60] = (*this)(_n1x,_n4y,0,k), P.ptr(N2*k)[61] = (*this)(_n2x,_n4y,0,k), P.ptr(N2*k)[62] = (*this)(_n3x,_n4y,0,k), P.ptr(N2*k)[63] = (*this)(_n4x,_n4y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p3q = q-3<0?0:q-3, _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3, _n4q = q+4>=(int)((*this).height)?(int)((*this).height)-1:q+4; q<=(int)(y1) && (_n4q<(int)((*this).height) || _n3q==--_n4q || _n2q==--_n3q || _n1q==--_n2q || q==(_n4q = _n3q = _n2q = --_n1q)); _p3q = _p2q, _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q, ++_n4q) for (int p = (int)(x0)<0?0:(int)(x0), _p3p = p-3<0?0:p-3, _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3, _n4p = p+4>=(int)((*this).width)?(int)((*this).width)-1:p+4; p<=(int)(x1) && (_n4p<(int)((*this).width) || _n3p==--_n4p || _n2p==--_n3p || _n1p==--_n2p || p==(_n4p = _n3p = _n2p = --_n1p)); _p3p = _p2p, _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p, ++_n4p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p3p,_p3q,0,k), Q.ptr(N2*k)[1] = (*this)(_p2p,_p3q,0,k), Q.ptr(N2*k)[2] = (*this)(_p1p,_p3q,0,k), Q.ptr(N2*k)[3] = (*this)(p,_p3q,0,k), Q.ptr(N2*k)[4] = (*this)(_n1p,_p3q,0,k), Q.ptr(N2*k)[5] = (*this)(_n2p,_p3q,0,k), Q.ptr(N2*k)[6] = (*this)(_n3p,_p3q,0,k), Q.ptr(N2*k)[7] = (*this)(_n4p,_p3q,0,k), Q.ptr(N2*k)[8] = (*this)(_p3p,_p2q,0,k), Q.ptr(N2*k)[9] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[10] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[11] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[12] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[13] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[14] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[15] = (*this)(_n4p,_p2q,0,k), Q.ptr(N2*k)[16] = (*this)(_p3p,_p1q,0,k), Q.ptr(N2*k)[17] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[18] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[19] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[20] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[21] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[22] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[23] = (*this)(_n4p,_p1q,0,k), Q.ptr(N2*k)[24] = (*this)(_p3p,q,0,k), Q.ptr(N2*k)[25] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[26] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[27] = (*this)(p,q,0,k), Q.ptr(N2*k)[28] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[29] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[30] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[31] = (*this)(_n4p,q,0,k), Q.ptr(N2*k)[32] = (*this)(_p3p,_n1q,0,k), Q.ptr(N2*k)[33] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[34] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[35] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[36] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[37] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[38] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[39] = (*this)(_n4p,_n1q,0,k), Q.ptr(N2*k)[40] = (*this)(_p3p,_n2q,0,k), Q.ptr(N2*k)[41] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[42] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[43] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[44] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[45] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[46] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[47] = (*this)(_n4p,_n2q,0,k), Q.ptr(N2*k)[48] = (*this)(_p3p,_n3q,0,k), Q.ptr(N2*k)[49] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[50] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[51] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[52] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[53] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[54] = (*this)(_n3p,_n3q,0,k), Q.ptr(N2*k)[55] = (*this)(_n4p,_n3q,0,k), Q.ptr(N2*k)[56] = (*this)(_p3p,_n4q,0,k), Q.ptr(N2*k)[57] = (*this)(_p2p,_n4q,0,k), Q.ptr(N2*k)[58] = (*this)(_p1p,_n4q,0,k), Q.ptr(N2*k)[59] = (*this)(p,_n4q,0,k), Q.ptr(N2*k)[60] = (*this)(_n1p,_n4q,0,k), Q.ptr(N2*k)[61] = (*this)(_n2p,_n4q,0,k), Q.ptr(N2*k)[62] = (*this)(_n3p,_n4q,0,k), Q.ptr(N2*k)[63] = (*this)(_n4p,_n4q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20824 | break; | |
20825 | case 9: | |
20826 | if (fast_approx) { { const unsigned int N2 = 9*9; for (int y = 0, _p4y = 0, _p3y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=(int)((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=(int)((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=(int)((*this).height)?(int)((*this).height)-1:3, _n4y = 4>=(int)((*this).height)?(int)((*this).height)-1:4; _n4y<(int)((*this).height) || _n3y==--_n4y || _n2y==--_n3y || _n1y==--_n2y || y==(_n4y = _n3y = _n2y = --_n1y); _p4y = _p3y, _p3y = _p2y, _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y, ++_n4y) for (int x = 0, _p4x = 0, _p3x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(int)((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=(int)((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=(int)((*this).width)?(int)((*this).width)-1:3, _n4x = 4>=(int)((*this).width)?(int)((*this).width)-1:4; _n4x<(int)((*this).width) || _n3x==--_n4x || _n2x==--_n3x || _n1x==--_n2x || x==(_n4x = _n3x = _n2x = --_n1x); _p4x = _p3x, _p3x = _p2x, _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x, ++_n4x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p4x,_p4y,0,k), P.ptr(N2*k)[1] = (*this)(_p3x,_p4y,0,k), P.ptr(N2*k)[2] = (*this)(_p2x,_p4y,0,k), P.ptr(N2*k)[3] = (*this)(_p1x,_p4y,0,k), P.ptr(N2*k)[4] = (*this)(x,_p4y,0,k), P.ptr(N2*k)[5] = (*this)(_n1x,_p4y,0,k), P.ptr(N2*k)[6] = (*this)(_n2x,_p4y,0,k), P.ptr(N2*k)[7] = (*this)(_n3x,_p4y,0,k), P.ptr(N2*k)[8] = (*this)(_n4x,_p4y,0,k), P.ptr(N2*k)[9] = (*this)(_p4x,_p3y,0,k), P.ptr(N2*k)[10] = (*this)(_p3x,_p3y,0,k), P.ptr(N2*k)[11] = (*this)(_p2x,_p3y,0,k), P.ptr(N2*k)[12] = (*this)(_p1x,_p3y,0,k), P.ptr(N2*k)[13] = (*this)(x,_p3y,0,k), P.ptr(N2*k)[14] = (*this)(_n1x,_p3y,0,k), P.ptr(N2*k)[15] = (*this)(_n2x,_p3y,0,k), P.ptr(N2*k)[16] = (*this)(_n3x,_p3y,0,k), P.ptr(N2*k)[17] = (*this)(_n4x,_p3y,0,k), P.ptr(N2*k)[18] = (*this)(_p4x,_p2y,0,k), P.ptr(N2*k)[19] = (*this)(_p3x,_p2y,0,k), P.ptr(N2*k)[20] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[21] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[22] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[23] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[24] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[25] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[26] = (*this)(_n4x,_p2y,0,k), P.ptr(N2*k)[27] = (*this)(_p4x,_p1y,0,k), P.ptr(N2*k)[28] = (*this)(_p3x,_p1y,0,k), P.ptr(N2*k)[29] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[30] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[31] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[32] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[33] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[34] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[35] = (*this)(_n4x,_p1y,0,k), P.ptr(N2*k)[36] = (*this)(_p4x,y,0,k), P.ptr(N2*k)[37] = (*this)(_p3x,y,0,k), P.ptr(N2*k)[38] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[39] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[40] = (*this)(x,y,0,k), P.ptr(N2*k)[41] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[42] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[43] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[44] = (*this)(_n4x,y,0,k), P.ptr(N2*k)[45] = (*this)(_p4x,_n1y,0,k), P.ptr(N2*k)[46] = (*this)(_p3x,_n1y,0,k), P.ptr(N2*k)[47] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[48] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[49] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[50] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[51] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[52] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[53] = (*this)(_n4x,_n1y,0,k), P.ptr(N2*k)[54] = (*this)(_p4x,_n2y,0,k), P.ptr(N2*k)[55] = (*this)(_p3x,_n2y,0,k), P.ptr(N2*k)[56] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[57] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[58] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[59] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[60] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[61] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[62] = (*this)(_n4x,_n2y,0,k), P.ptr(N2*k)[63] = (*this)(_p4x,_n3y,0,k), P.ptr(N2*k)[64] = (*this)(_p3x,_n3y,0,k), P.ptr(N2*k)[65] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[66] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[67] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[68] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[69] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[70] = (*this)(_n3x,_n3y,0,k), P.ptr(N2*k)[71] = (*this)(_n4x,_n3y,0,k), P.ptr(N2*k)[72] = (*this)(_p4x,_n4y,0,k), P.ptr(N2*k)[73] = (*this)(_p3x,_n4y,0,k), P.ptr(N2*k)[74] = (*this)(_p2x,_n4y,0,k), P.ptr(N2*k)[75] = (*this)(_p1x,_n4y,0,k), P.ptr(N2*k)[76] = (*this)(x,_n4y,0,k), P.ptr(N2*k)[77] = (*this)(_n1x,_n4y,0,k), P.ptr(N2*k)[78] = (*this)(_n2x,_n4y,0,k), P.ptr(N2*k)[79] = (*this)(_n3x,_n4y,0,k), P.ptr(N2*k)[80] = (*this)(_n4x,_n4y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p4q = q-4<0?0:q-4, _p3q = q-3<0?0:q-3, _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3, _n4q = q+4>=(int)((*this).height)?(int)((*this).height)-1:q+4; q<=(int)(y1) && (_n4q<(int)((*this).height) || _n3q==--_n4q || _n2q==--_n3q || _n1q==--_n2q || q==(_n4q = _n3q = _n2q = --_n1q)); _p4q = _p3q, _p3q = _p2q, _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q, ++_n4q) for (int p = (int)(x0)<0?0:(int)(x0), _p4p = p-4<0?0:p-4, _p3p = p-3<0?0:p-3, _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3, _n4p = p+4>=(int)((*this).width)?(int)((*this).width)-1:p+4; p<=(int)(x1) && (_n4p<(int)((*this).width) || _n3p==--_n4p || _n2p==--_n3p || _n1p==--_n2p || p==(_n4p = _n3p = _n2p = --_n1p)); _p4p = _p3p, _p3p = _p2p, _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p, ++_n4p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p4p,_p4q,0,k), Q.ptr(N2*k)[1] = (*this)(_p3p,_p4q,0,k), Q.ptr(N2*k)[2] = (*this)(_p2p,_p4q,0,k), Q.ptr(N2*k)[3] = (*this)(_p1p,_p4q,0,k), Q.ptr(N2*k)[4] = (*this)(p,_p4q,0,k), Q.ptr(N2*k)[5] = (*this)(_n1p,_p4q,0,k), Q.ptr(N2*k)[6] = (*this)(_n2p,_p4q,0,k), Q.ptr(N2*k)[7] = (*this)(_n3p,_p4q,0,k), Q.ptr(N2*k)[8] = (*this)(_n4p,_p4q,0,k), Q.ptr(N2*k)[9] = (*this)(_p4p,_p3q,0,k), Q.ptr(N2*k)[10] = (*this)(_p3p,_p3q,0,k), Q.ptr(N2*k)[11] = (*this)(_p2p,_p3q,0,k), Q.ptr(N2*k)[12] = (*this)(_p1p,_p3q,0,k), Q.ptr(N2*k)[13] = (*this)(p,_p3q,0,k), Q.ptr(N2*k)[14] = (*this)(_n1p,_p3q,0,k), Q.ptr(N2*k)[15] = (*this)(_n2p,_p3q,0,k), Q.ptr(N2*k)[16] = (*this)(_n3p,_p3q,0,k), Q.ptr(N2*k)[17] = (*this)(_n4p,_p3q,0,k), Q.ptr(N2*k)[18] = (*this)(_p4p,_p2q,0,k), Q.ptr(N2*k)[19] = (*this)(_p3p,_p2q,0,k), Q.ptr(N2*k)[20] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[21] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[22] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[23] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[24] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[25] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[26] = (*this)(_n4p,_p2q,0,k), Q.ptr(N2*k)[27] = (*this)(_p4p,_p1q,0,k), Q.ptr(N2*k)[28] = (*this)(_p3p,_p1q,0,k), Q.ptr(N2*k)[29] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[30] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[31] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[32] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[33] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[34] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[35] = (*this)(_n4p,_p1q,0,k), Q.ptr(N2*k)[36] = (*this)(_p4p,q,0,k), Q.ptr(N2*k)[37] = (*this)(_p3p,q,0,k), Q.ptr(N2*k)[38] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[39] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[40] = (*this)(p,q,0,k), Q.ptr(N2*k)[41] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[42] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[43] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[44] = (*this)(_n4p,q,0,k), Q.ptr(N2*k)[45] = (*this)(_p4p,_n1q,0,k), Q.ptr(N2*k)[46] = (*this)(_p3p,_n1q,0,k), Q.ptr(N2*k)[47] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[48] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[49] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[50] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[51] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[52] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[53] = (*this)(_n4p,_n1q,0,k), Q.ptr(N2*k)[54] = (*this)(_p4p,_n2q,0,k), Q.ptr(N2*k)[55] = (*this)(_p3p,_n2q,0,k), Q.ptr(N2*k)[56] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[57] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[58] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[59] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[60] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[61] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[62] = (*this)(_n4p,_n2q,0,k), Q.ptr(N2*k)[63] = (*this)(_p4p,_n3q,0,k), Q.ptr(N2*k)[64] = (*this)(_p3p,_n3q,0,k), Q.ptr(N2*k)[65] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[66] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[67] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[68] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[69] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[70] = (*this)(_n3p,_n3q,0,k), Q.ptr(N2*k)[71] = (*this)(_n4p,_n3q,0,k), Q.ptr(N2*k)[72] = (*this)(_p4p,_n4q,0,k), Q.ptr(N2*k)[73] = (*this)(_p3p,_n4q,0,k), Q.ptr(N2*k)[74] = (*this)(_p2p,_n4q,0,k), Q.ptr(N2*k)[75] = (*this)(_p1p,_n4q,0,k), Q.ptr(N2*k)[76] = (*this)(p,_n4q,0,k), Q.ptr(N2*k)[77] = (*this)(_n1p,_n4q,0,k), Q.ptr(N2*k)[78] = (*this)(_n2p,_n4q,0,k), Q.ptr(N2*k)[79] = (*this)(_n3p,_n4q,0,k), Q.ptr(N2*k)[80] = (*this)(_n4p,_n4q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = ((alldist)>3?0:1); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20827 | else { { const unsigned int N2 = 9*9; for (int y = 0, _p4y = 0, _p3y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=(int)((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=(int)((*this).height)?(int)((*this).height)-1:2, _n3y = 3>=(int)((*this).height)?(int)((*this).height)-1:3, _n4y = 4>=(int)((*this).height)?(int)((*this).height)-1:4; _n4y<(int)((*this).height) || _n3y==--_n4y || _n2y==--_n3y || _n1y==--_n2y || y==(_n4y = _n3y = _n2y = --_n1y); _p4y = _p3y, _p3y = _p2y, _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y, ++_n3y, ++_n4y) for (int x = 0, _p4x = 0, _p3x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(int)((*this).width)?(int)((*this).width)-1:1, _n2x = 2>=(int)((*this).width)?(int)((*this).width)-1:2, _n3x = 3>=(int)((*this).width)?(int)((*this).width)-1:3, _n4x = 4>=(int)((*this).width)?(int)((*this).width)-1:4; _n4x<(int)((*this).width) || _n3x==--_n4x || _n2x==--_n3x || _n1x==--_n2x || x==(_n4x = _n3x = _n2x = --_n1x); _p4x = _p3x, _p3x = _p2x, _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x, ++_n3x, ++_n4x) { if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; for (int k = 0; k<(int)((*this).dim); ++k) P.ptr(N2*k)[0] = (*this)(_p4x,_p4y,0,k), P.ptr(N2*k)[1] = (*this)(_p3x,_p4y,0,k), P.ptr(N2*k)[2] = (*this)(_p2x,_p4y,0,k), P.ptr(N2*k)[3] = (*this)(_p1x,_p4y,0,k), P.ptr(N2*k)[4] = (*this)(x,_p4y,0,k), P.ptr(N2*k)[5] = (*this)(_n1x,_p4y,0,k), P.ptr(N2*k)[6] = (*this)(_n2x,_p4y,0,k), P.ptr(N2*k)[7] = (*this)(_n3x,_p4y,0,k), P.ptr(N2*k)[8] = (*this)(_n4x,_p4y,0,k), P.ptr(N2*k)[9] = (*this)(_p4x,_p3y,0,k), P.ptr(N2*k)[10] = (*this)(_p3x,_p3y,0,k), P.ptr(N2*k)[11] = (*this)(_p2x,_p3y,0,k), P.ptr(N2*k)[12] = (*this)(_p1x,_p3y,0,k), P.ptr(N2*k)[13] = (*this)(x,_p3y,0,k), P.ptr(N2*k)[14] = (*this)(_n1x,_p3y,0,k), P.ptr(N2*k)[15] = (*this)(_n2x,_p3y,0,k), P.ptr(N2*k)[16] = (*this)(_n3x,_p3y,0,k), P.ptr(N2*k)[17] = (*this)(_n4x,_p3y,0,k), P.ptr(N2*k)[18] = (*this)(_p4x,_p2y,0,k), P.ptr(N2*k)[19] = (*this)(_p3x,_p2y,0,k), P.ptr(N2*k)[20] = (*this)(_p2x,_p2y,0,k), P.ptr(N2*k)[21] = (*this)(_p1x,_p2y,0,k), P.ptr(N2*k)[22] = (*this)(x,_p2y,0,k), P.ptr(N2*k)[23] = (*this)(_n1x,_p2y,0,k), P.ptr(N2*k)[24] = (*this)(_n2x,_p2y,0,k), P.ptr(N2*k)[25] = (*this)(_n3x,_p2y,0,k), P.ptr(N2*k)[26] = (*this)(_n4x,_p2y,0,k), P.ptr(N2*k)[27] = (*this)(_p4x,_p1y,0,k), P.ptr(N2*k)[28] = (*this)(_p3x,_p1y,0,k), P.ptr(N2*k)[29] = (*this)(_p2x,_p1y,0,k), P.ptr(N2*k)[30] = (*this)(_p1x,_p1y,0,k), P.ptr(N2*k)[31] = (*this)(x,_p1y,0,k), P.ptr(N2*k)[32] = (*this)(_n1x,_p1y,0,k), P.ptr(N2*k)[33] = (*this)(_n2x,_p1y,0,k), P.ptr(N2*k)[34] = (*this)(_n3x,_p1y,0,k), P.ptr(N2*k)[35] = (*this)(_n4x,_p1y,0,k), P.ptr(N2*k)[36] = (*this)(_p4x,y,0,k), P.ptr(N2*k)[37] = (*this)(_p3x,y,0,k), P.ptr(N2*k)[38] = (*this)(_p2x,y,0,k), P.ptr(N2*k)[39] = (*this)(_p1x,y,0,k), P.ptr(N2*k)[40] = (*this)(x,y,0,k), P.ptr(N2*k)[41] = (*this)(_n1x,y,0,k), P.ptr(N2*k)[42] = (*this)(_n2x,y,0,k), P.ptr(N2*k)[43] = (*this)(_n3x,y,0,k), P.ptr(N2*k)[44] = (*this)(_n4x,y,0,k), P.ptr(N2*k)[45] = (*this)(_p4x,_n1y,0,k), P.ptr(N2*k)[46] = (*this)(_p3x,_n1y,0,k), P.ptr(N2*k)[47] = (*this)(_p2x,_n1y,0,k), P.ptr(N2*k)[48] = (*this)(_p1x,_n1y,0,k), P.ptr(N2*k)[49] = (*this)(x,_n1y,0,k), P.ptr(N2*k)[50] = (*this)(_n1x,_n1y,0,k), P.ptr(N2*k)[51] = (*this)(_n2x,_n1y,0,k), P.ptr(N2*k)[52] = (*this)(_n3x,_n1y,0,k), P.ptr(N2*k)[53] = (*this)(_n4x,_n1y,0,k), P.ptr(N2*k)[54] = (*this)(_p4x,_n2y,0,k), P.ptr(N2*k)[55] = (*this)(_p3x,_n2y,0,k), P.ptr(N2*k)[56] = (*this)(_p2x,_n2y,0,k), P.ptr(N2*k)[57] = (*this)(_p1x,_n2y,0,k), P.ptr(N2*k)[58] = (*this)(x,_n2y,0,k), P.ptr(N2*k)[59] = (*this)(_n1x,_n2y,0,k), P.ptr(N2*k)[60] = (*this)(_n2x,_n2y,0,k), P.ptr(N2*k)[61] = (*this)(_n3x,_n2y,0,k), P.ptr(N2*k)[62] = (*this)(_n4x,_n2y,0,k), P.ptr(N2*k)[63] = (*this)(_p4x,_n3y,0,k), P.ptr(N2*k)[64] = (*this)(_p3x,_n3y,0,k), P.ptr(N2*k)[65] = (*this)(_p2x,_n3y,0,k), P.ptr(N2*k)[66] = (*this)(_p1x,_n3y,0,k), P.ptr(N2*k)[67] = (*this)(x,_n3y,0,k), P.ptr(N2*k)[68] = (*this)(_n1x,_n3y,0,k), P.ptr(N2*k)[69] = (*this)(_n2x,_n3y,0,k), P.ptr(N2*k)[70] = (*this)(_n3x,_n3y,0,k), P.ptr(N2*k)[71] = (*this)(_n4x,_n3y,0,k), P.ptr(N2*k)[72] = (*this)(_p4x,_n4y,0,k), P.ptr(N2*k)[73] = (*this)(_p3x,_n4y,0,k), P.ptr(N2*k)[74] = (*this)(_p2x,_n4y,0,k), P.ptr(N2*k)[75] = (*this)(_p1x,_n4y,0,k), P.ptr(N2*k)[76] = (*this)(x,_n4y,0,k), P.ptr(N2*k)[77] = (*this)(_n1x,_n4y,0,k), P.ptr(N2*k)[78] = (*this)(_n2x,_n4y,0,k), P.ptr(N2*k)[79] = (*this)(_n3x,_n4y,0,k), P.ptr(N2*k)[80] = (*this)(_n4x,_n4y,0,k);; const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; float sum_weights = 0; for (int q = (int)(y0)<0?0:(int)(y0), _p4q = q-4<0?0:q-4, _p3q = q-3<0?0:q-3, _p2q = q-2<0?0:q-2, _p1q = q-1<0?0:q-1, _n1q = q+1>=(int)((*this).height)?(int)((*this).height)-1:q+1, _n2q = q+2>=(int)((*this).height)?(int)((*this).height)-1:q+2, _n3q = q+3>=(int)((*this).height)?(int)((*this).height)-1:q+3, _n4q = q+4>=(int)((*this).height)?(int)((*this).height)-1:q+4; q<=(int)(y1) && (_n4q<(int)((*this).height) || _n3q==--_n4q || _n2q==--_n3q || _n1q==--_n2q || q==(_n4q = _n3q = _n2q = --_n1q)); _p4q = _p3q, _p3q = _p2q, _p2q = _p1q, _p1q = q++, ++_n1q, ++_n2q, ++_n3q, ++_n4q) for (int p = (int)(x0)<0?0:(int)(x0), _p4p = p-4<0?0:p-4, _p3p = p-3<0?0:p-3, _p2p = p-2<0?0:p-2, _p1p = p-1<0?0:p-1, _n1p = p+1>=(int)((*this).width)?(int)((*this).width)-1:p+1, _n2p = p+2>=(int)((*this).width)?(int)((*this).width)-1:p+2, _n3p = p+3>=(int)((*this).width)?(int)((*this).width)-1:p+3, _n4p = p+4>=(int)((*this).width)?(int)((*this).width)-1:p+4; p<=(int)(x1) && (_n4p<(int)((*this).width) || _n3p==--_n4p || _n2p==--_n3p || _n1p==--_n2p || p==(_n4p = _n3p = _n2p = --_n1p)); _p4p = _p3p, _p3p = _p2p, _p2p = _p1p, _p1p = p++, ++_n1p, ++_n2p, ++_n3p, ++_n4p) { for (int k = 0; k<(int)((*this).dim); ++k) Q.ptr(N2*k)[0] = (*this)(_p4p,_p4q,0,k), Q.ptr(N2*k)[1] = (*this)(_p3p,_p4q,0,k), Q.ptr(N2*k)[2] = (*this)(_p2p,_p4q,0,k), Q.ptr(N2*k)[3] = (*this)(_p1p,_p4q,0,k), Q.ptr(N2*k)[4] = (*this)(p,_p4q,0,k), Q.ptr(N2*k)[5] = (*this)(_n1p,_p4q,0,k), Q.ptr(N2*k)[6] = (*this)(_n2p,_p4q,0,k), Q.ptr(N2*k)[7] = (*this)(_n3p,_p4q,0,k), Q.ptr(N2*k)[8] = (*this)(_n4p,_p4q,0,k), Q.ptr(N2*k)[9] = (*this)(_p4p,_p3q,0,k), Q.ptr(N2*k)[10] = (*this)(_p3p,_p3q,0,k), Q.ptr(N2*k)[11] = (*this)(_p2p,_p3q,0,k), Q.ptr(N2*k)[12] = (*this)(_p1p,_p3q,0,k), Q.ptr(N2*k)[13] = (*this)(p,_p3q,0,k), Q.ptr(N2*k)[14] = (*this)(_n1p,_p3q,0,k), Q.ptr(N2*k)[15] = (*this)(_n2p,_p3q,0,k), Q.ptr(N2*k)[16] = (*this)(_n3p,_p3q,0,k), Q.ptr(N2*k)[17] = (*this)(_n4p,_p3q,0,k), Q.ptr(N2*k)[18] = (*this)(_p4p,_p2q,0,k), Q.ptr(N2*k)[19] = (*this)(_p3p,_p2q,0,k), Q.ptr(N2*k)[20] = (*this)(_p2p,_p2q,0,k), Q.ptr(N2*k)[21] = (*this)(_p1p,_p2q,0,k), Q.ptr(N2*k)[22] = (*this)(p,_p2q,0,k), Q.ptr(N2*k)[23] = (*this)(_n1p,_p2q,0,k), Q.ptr(N2*k)[24] = (*this)(_n2p,_p2q,0,k), Q.ptr(N2*k)[25] = (*this)(_n3p,_p2q,0,k), Q.ptr(N2*k)[26] = (*this)(_n4p,_p2q,0,k), Q.ptr(N2*k)[27] = (*this)(_p4p,_p1q,0,k), Q.ptr(N2*k)[28] = (*this)(_p3p,_p1q,0,k), Q.ptr(N2*k)[29] = (*this)(_p2p,_p1q,0,k), Q.ptr(N2*k)[30] = (*this)(_p1p,_p1q,0,k), Q.ptr(N2*k)[31] = (*this)(p,_p1q,0,k), Q.ptr(N2*k)[32] = (*this)(_n1p,_p1q,0,k), Q.ptr(N2*k)[33] = (*this)(_n2p,_p1q,0,k), Q.ptr(N2*k)[34] = (*this)(_n3p,_p1q,0,k), Q.ptr(N2*k)[35] = (*this)(_n4p,_p1q,0,k), Q.ptr(N2*k)[36] = (*this)(_p4p,q,0,k), Q.ptr(N2*k)[37] = (*this)(_p3p,q,0,k), Q.ptr(N2*k)[38] = (*this)(_p2p,q,0,k), Q.ptr(N2*k)[39] = (*this)(_p1p,q,0,k), Q.ptr(N2*k)[40] = (*this)(p,q,0,k), Q.ptr(N2*k)[41] = (*this)(_n1p,q,0,k), Q.ptr(N2*k)[42] = (*this)(_n2p,q,0,k), Q.ptr(N2*k)[43] = (*this)(_n3p,q,0,k), Q.ptr(N2*k)[44] = (*this)(_n4p,q,0,k), Q.ptr(N2*k)[45] = (*this)(_p4p,_n1q,0,k), Q.ptr(N2*k)[46] = (*this)(_p3p,_n1q,0,k), Q.ptr(N2*k)[47] = (*this)(_p2p,_n1q,0,k), Q.ptr(N2*k)[48] = (*this)(_p1p,_n1q,0,k), Q.ptr(N2*k)[49] = (*this)(p,_n1q,0,k), Q.ptr(N2*k)[50] = (*this)(_n1p,_n1q,0,k), Q.ptr(N2*k)[51] = (*this)(_n2p,_n1q,0,k), Q.ptr(N2*k)[52] = (*this)(_n3p,_n1q,0,k), Q.ptr(N2*k)[53] = (*this)(_n4p,_n1q,0,k), Q.ptr(N2*k)[54] = (*this)(_p4p,_n2q,0,k), Q.ptr(N2*k)[55] = (*this)(_p3p,_n2q,0,k), Q.ptr(N2*k)[56] = (*this)(_p2p,_n2q,0,k), Q.ptr(N2*k)[57] = (*this)(_p1p,_n2q,0,k), Q.ptr(N2*k)[58] = (*this)(p,_n2q,0,k), Q.ptr(N2*k)[59] = (*this)(_n1p,_n2q,0,k), Q.ptr(N2*k)[60] = (*this)(_n2p,_n2q,0,k), Q.ptr(N2*k)[61] = (*this)(_n3p,_n2q,0,k), Q.ptr(N2*k)[62] = (*this)(_n4p,_n2q,0,k), Q.ptr(N2*k)[63] = (*this)(_p4p,_n3q,0,k), Q.ptr(N2*k)[64] = (*this)(_p3p,_n3q,0,k), Q.ptr(N2*k)[65] = (*this)(_p2p,_n3q,0,k), Q.ptr(N2*k)[66] = (*this)(_p1p,_n3q,0,k), Q.ptr(N2*k)[67] = (*this)(p,_n3q,0,k), Q.ptr(N2*k)[68] = (*this)(_n1p,_n3q,0,k), Q.ptr(N2*k)[69] = (*this)(_n2p,_n3q,0,k), Q.ptr(N2*k)[70] = (*this)(_n3p,_n3q,0,k), Q.ptr(N2*k)[71] = (*this)(_n4p,_n3q,0,k), Q.ptr(N2*k)[72] = (*this)(_p4p,_n4q,0,k), Q.ptr(N2*k)[73] = (*this)(_p3p,_n4q,0,k), Q.ptr(N2*k)[74] = (*this)(_p2p,_n4q,0,k), Q.ptr(N2*k)[75] = (*this)(_p1p,_n4q,0,k), Q.ptr(N2*k)[76] = (*this)(p,_n4q,0,k), Q.ptr(N2*k)[77] = (*this)(_n1p,_n4q,0,k), Q.ptr(N2*k)[78] = (*this)(_n2p,_n4q,0,k), Q.ptr(N2*k)[79] = (*this)(_n3p,_n4q,0,k), Q.ptr(N2*k)[80] = (*this)(_n4p,_n4q,0,k);; float distance2 = 0; const T *pQ = Q.end(); for (T *pP = (P).data + (P).size(); (pP--)>(P).data; ) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } distance2/=Pnorm; const float dx = p-x, dy = q-y, alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = std::exp(-(alldist)); sum_weights+=weight; { for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)+=weight*(*this)(p,q,k); } } if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,k) = (*this)(x,y,k); }}; } | |
20828 | break; | |
20829 | default: { | |
20830 | const int psize1 = (int)patch_size/2, psize0 = psize1-1+(patch_size%2); | |
20831 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20832 | if (!*(greycstoration_params->stop_request)) ++(*greycstoration_params->counter); else return *this;; | |
20833 | P = get_crop(x-psize0,y-psize0,x+psize1,y+psize1,true); | |
20834 | const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; | |
20835 | float sum_weights = 0; | |
20836 | for (int q = (int)(y0)<0?0:(int)(y0), _maxq = (int)(y1)<(int)((*this).height)?(int)(y1):(int)((*this).height)-1; q<=_maxq; ++q) for (int p = (int)(x0)<0?0:(int)(x0), _maxp = (int)(x1)<(int)((*this).width)?(int)(x1):(int)((*this).width)-1; p<=_maxp; ++p) { | |
20837 | (Q = get_crop(p-psize0,q-psize0,p+psize1,q+psize1,true))-=P; | |
20838 | const float | |
20839 | dx = x-p, dy = y-q, | |
20840 | distance2 = Q.pow(2).sum()/Pnorm + (dx*dx + dy*dy)/sigma_s2, | |
20841 | weight = std::exp(-distance2); | |
20842 | sum_weights+=weight; | |
20843 | for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,0,k)+=weight*(*this)(p,q,0,k); | |
20844 | } | |
20845 | if (sum_weights>0) for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,0,k)/=sum_weights; else for (int k = 0; k<(int)((*this).dim); ++k) res(x,y,0,k) = (*this)(x,y,0,k); | |
20846 | } | |
20847 | } break; | |
20848 | } | |
20849 | return res.transfer_to(*this); | |
20850 | } | |
20851 | CImgList<typename cimg::superset<T,float>::type> get_FFT(const char axe, const bool invert=false) const { | |
20852 | typedef typename cimg::superset<T,float>::type restype; | |
20853 | return CImgList<restype>(*this).FFT(axe,invert); | |
20854 | } | |
20855 | CImgList<typename cimg::superset<T,float>::type> get_FFT(const bool invert=false) const { | |
20856 | typedef typename cimg::superset<T,float>::type restype; | |
20857 | return CImgList<restype>(*this).FFT(invert); | |
20858 | } | |
20859 | CImg<T> get_blur_median(const unsigned int n=3) { | |
20860 | CImg<T> res(width,height,depth,dim); | |
20861 | if (!n || n==1) return *this; | |
20862 | const int hl=n/2, hr=hl-1+n%2; | |
20863 | if (res.depth!=1) { | |
20864 | CImg<T> vois; | |
20865 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20866 | const int | |
20867 | x0 = x - hl, y0 = y - hl, z0 = z-hl, x1 = x + hr, y1 = y + hr, z1 = z+hr, | |
20868 | nx0 = x0<0?0:x0, ny0 = y0<0?0:y0, nz0 = z0<0?0:z0, | |
20869 | nx1 = x1>=dimx()?dimx()-1:x1, ny1 = y1>=dimy()?dimy()-1:y1, nz1 = z1>=dimz()?dimz()-1:z1; | |
20870 | vois = get_crop(nx0,ny0,nz0,k,nx1,ny1,nz1,k); | |
20871 | res(x,y,z,k) = vois.median(); | |
20872 | } | |
20873 | } else { | |
20874 | if (res.height!=1) switch (n) { | |
20875 | case 3: { | |
20876 | T I[9] = { 0 }; | |
20877 | T J[9]; T& Jpp = J[0]; T& Jcp = J[1]; T& Jnp = J[2]; T& Jpc = J[3]; T& Jcc = J[4]; T& Jnc = J[5]; T& Jpn = J[6]; T& Jcn = J[7]; T& Jnn = J[8]; Jpp = Jcp = Jnp = Jpc = Jcc = Jnc = Jpn = Jcn = Jnn = 0; | |
20878 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,0,k)), (I[3] = I[4] = (*this)(0,y,0,k)), (I[6] = I[7] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,0,k)), (I[5] = (*this)(_n1x,y,0,k)), (I[8] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
20879 | std::memcpy(J,I,9*sizeof(T)); | |
20880 | if ((Jcp)>(Jnp)) cimg::swap(Jcp,Jnp); if ((Jcc)>(Jnc)) cimg::swap(Jcc,Jnc); if ((Jcn)>(Jnn)) cimg::swap(Jcn,Jnn); | |
20881 | if ((Jpp)>(Jcp)) cimg::swap(Jpp,Jcp); if ((Jpc)>(Jcc)) cimg::swap(Jpc,Jcc); if ((Jpn)>(Jcn)) cimg::swap(Jpn,Jcn); | |
20882 | if ((Jcp)>(Jnp)) cimg::swap(Jcp,Jnp); if ((Jcc)>(Jnc)) cimg::swap(Jcc,Jnc); if ((Jcn)>(Jnn)) cimg::swap(Jcn,Jnn); | |
20883 | if ((Jpp)>(Jpc)) cimg::swap(Jpp,Jpc); if ((Jnc)>(Jnn)) cimg::swap(Jnc,Jnn); if ((Jcc)>(Jcn)) cimg::swap(Jcc,Jcn); | |
20884 | if ((Jpc)>(Jpn)) cimg::swap(Jpc,Jpn); if ((Jcp)>(Jcc)) cimg::swap(Jcp,Jcc); if ((Jnp)>(Jnc)) cimg::swap(Jnp,Jnc); | |
20885 | if ((Jcc)>(Jcn)) cimg::swap(Jcc,Jcn); if ((Jcc)>(Jnp)) cimg::swap(Jcc,Jnp); if ((Jpn)>(Jcc)) cimg::swap(Jpn,Jcc); | |
20886 | if ((Jcc)>(Jnp)) cimg::swap(Jcc,Jnp); | |
20887 | res(x,y,0,k) = Jcc; | |
20888 | } | |
20889 | } break; | |
20890 | case 5: { | |
20891 | T I[25] = { 0 }; | |
20892 | T J[25]; T& Jbb = J[0]; T& Jpb = J[1]; T& Jcb = J[2]; T& Jnb = J[3]; T& Jab = J[4]; T& Jbp = J[5]; T& Jpp = J[6]; T& Jcp = J[7]; T& Jnp = J[8]; T& Jap = J[9]; T& Jbc = J[10]; T& Jpc = J[11]; T& Jcc = J[12]; T& Jnc = J[13]; T& Jac = J[14]; T& Jbn = J[15]; T& Jpn = J[16]; T& Jcn = J[17]; T& Jnn = J[18]; T& Jan = J[19]; T& Jba = J[20]; T& Jpa = J[21]; T& Jca = J[22]; T& Jna = J[23]; T& Jaa = J[24]; Jbb = Jpb = Jcb = Jnb = Jab = Jbp = Jpp = Jcp = Jnp = Jap = Jbc = Jpc = Jcc = Jnc = Jac = Jbn = Jpn = Jcn = Jnn = Jan = Jba = Jpa = Jca = Jna = Jaa = 0; | |
20893 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0, _p2y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1, _n2y = 2>=((*this).height)?(int)((*this).height)-1:2; _n2y<(int)((*this).height) || _n1y==--_n2y || y==(_n2y = --_n1y); _p2y = _p1y, _p1y = y++, ++_n1y, ++_n2y) for (int x = 0, _p2x = 0, _p1x = 0, _n1x = 1>=(*this).width?(int)((*this).width)-1:1, _n2x = (int)( (I[0] = I[1] = I[2] = (*this)(0,_p2y,0,k)), (I[5] = I[6] = I[7] = (*this)(0,_p1y,0,k)), (I[10] = I[11] = I[12] = (*this)(0,y,0,k)), (I[15] = I[16] = I[17] = (*this)(0,_n1y,0,k)), (I[20] = I[21] = I[22] = (*this)(0,_n2y,0,k)), (I[3] = (*this)(_n1x,_p2y,0,k)), (I[8] = (*this)(_n1x,_p1y,0,k)), (I[13] = (*this)(_n1x,y,0,k)), (I[18] = (*this)(_n1x,_n1y,0,k)), (I[23] = (*this)(_n1x,_n2y,0,k)), 2>=(*this).width?(int)((*this).width)-1:2); (_n2x<(int)((*this).width) && ( (I[4] = (*this)(_n2x,_p2y,0,k)), (I[9] = (*this)(_n2x,_p1y,0,k)), (I[14] = (*this)(_n2x,y,0,k)), (I[19] = (*this)(_n2x,_n1y,0,k)), (I[24] = (*this)(_n2x,_n2y,0,k)),1)) || _n1x==--_n2x || x==(_n2x = --_n1x); I[0] = I[1], I[1] = I[2], I[2] = I[3], I[3] = I[4], I[5] = I[6], I[6] = I[7], I[7] = I[8], I[8] = I[9], I[10] = I[11], I[11] = I[12], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[17] = I[18], I[18] = I[19], I[20] = I[21], I[21] = I[22], I[22] = I[23], I[23] = I[24], _p2x = _p1x, _p1x = x++, ++_n1x, ++_n2x) { | |
20894 | std::memcpy(J,I,25*sizeof(T)); | |
20895 | if ((Jbb)>(Jpb)) cimg::swap(Jbb,Jpb); if ((Jnb)>(Jab)) cimg::swap(Jnb,Jab); if ((Jcb)>(Jab)) cimg::swap(Jcb,Jab); if ((Jcb)>(Jnb)) cimg::swap(Jcb,Jnb); | |
20896 | if ((Jpp)>(Jcp)) cimg::swap(Jpp,Jcp); if ((Jbp)>(Jcp)) cimg::swap(Jbp,Jcp); if ((Jbp)>(Jpp)) cimg::swap(Jbp,Jpp); if ((Jap)>(Jbc)) cimg::swap(Jap,Jbc); | |
20897 | if ((Jnp)>(Jbc)) cimg::swap(Jnp,Jbc); if ((Jnp)>(Jap)) cimg::swap(Jnp,Jap); if ((Jcc)>(Jnc)) cimg::swap(Jcc,Jnc); if ((Jpc)>(Jnc)) cimg::swap(Jpc,Jnc); | |
20898 | if ((Jpc)>(Jcc)) cimg::swap(Jpc,Jcc); if ((Jbn)>(Jpn)) cimg::swap(Jbn,Jpn); if ((Jac)>(Jpn)) cimg::swap(Jac,Jpn); if ((Jac)>(Jbn)) cimg::swap(Jac,Jbn); | |
20899 | if ((Jnn)>(Jan)) cimg::swap(Jnn,Jan); if ((Jcn)>(Jan)) cimg::swap(Jcn,Jan); if ((Jcn)>(Jnn)) cimg::swap(Jcn,Jnn); if ((Jpa)>(Jca)) cimg::swap(Jpa,Jca); | |
20900 | if ((Jba)>(Jca)) cimg::swap(Jba,Jca); if ((Jba)>(Jpa)) cimg::swap(Jba,Jpa); if ((Jna)>(Jaa)) cimg::swap(Jna,Jaa); if ((Jcb)>(Jbp)) cimg::swap(Jcb,Jbp); | |
20901 | if ((Jnb)>(Jpp)) cimg::swap(Jnb,Jpp); if ((Jbb)>(Jpp)) cimg::swap(Jbb,Jpp); if ((Jbb)>(Jnb)) cimg::swap(Jbb,Jnb); if ((Jab)>(Jcp)) cimg::swap(Jab,Jcp); | |
20902 | if ((Jpb)>(Jcp)) cimg::swap(Jpb,Jcp); if ((Jpb)>(Jab)) cimg::swap(Jpb,Jab); if ((Jpc)>(Jac)) cimg::swap(Jpc,Jac); if ((Jnp)>(Jac)) cimg::swap(Jnp,Jac); | |
20903 | if ((Jnp)>(Jpc)) cimg::swap(Jnp,Jpc); if ((Jcc)>(Jbn)) cimg::swap(Jcc,Jbn); if ((Jap)>(Jbn)) cimg::swap(Jap,Jbn); if ((Jap)>(Jcc)) cimg::swap(Jap,Jcc); | |
20904 | if ((Jnc)>(Jpn)) cimg::swap(Jnc,Jpn); if ((Jbc)>(Jpn)) cimg::swap(Jbc,Jpn); if ((Jbc)>(Jnc)) cimg::swap(Jbc,Jnc); if ((Jba)>(Jna)) cimg::swap(Jba,Jna); | |
20905 | if ((Jcn)>(Jna)) cimg::swap(Jcn,Jna); if ((Jcn)>(Jba)) cimg::swap(Jcn,Jba); if ((Jpa)>(Jaa)) cimg::swap(Jpa,Jaa); if ((Jnn)>(Jaa)) cimg::swap(Jnn,Jaa); | |
20906 | if ((Jnn)>(Jpa)) cimg::swap(Jnn,Jpa); if ((Jan)>(Jca)) cimg::swap(Jan,Jca); if ((Jnp)>(Jcn)) cimg::swap(Jnp,Jcn); if ((Jap)>(Jnn)) cimg::swap(Jap,Jnn); | |
20907 | if ((Jbb)>(Jnn)) cimg::swap(Jbb,Jnn); if ((Jbb)>(Jap)) cimg::swap(Jbb,Jap); if ((Jbc)>(Jan)) cimg::swap(Jbc,Jan); if ((Jpb)>(Jan)) cimg::swap(Jpb,Jan); | |
20908 | if ((Jpb)>(Jbc)) cimg::swap(Jpb,Jbc); if ((Jpc)>(Jba)) cimg::swap(Jpc,Jba); if ((Jcb)>(Jba)) cimg::swap(Jcb,Jba); if ((Jcb)>(Jpc)) cimg::swap(Jcb,Jpc); | |
20909 | if ((Jcc)>(Jpa)) cimg::swap(Jcc,Jpa); if ((Jnb)>(Jpa)) cimg::swap(Jnb,Jpa); if ((Jnb)>(Jcc)) cimg::swap(Jnb,Jcc); if ((Jnc)>(Jca)) cimg::swap(Jnc,Jca); | |
20910 | if ((Jab)>(Jca)) cimg::swap(Jab,Jca); if ((Jab)>(Jnc)) cimg::swap(Jab,Jnc); if ((Jac)>(Jna)) cimg::swap(Jac,Jna); if ((Jbp)>(Jna)) cimg::swap(Jbp,Jna); | |
20911 | if ((Jbp)>(Jac)) cimg::swap(Jbp,Jac); if ((Jbn)>(Jaa)) cimg::swap(Jbn,Jaa); if ((Jpp)>(Jaa)) cimg::swap(Jpp,Jaa); if ((Jpp)>(Jbn)) cimg::swap(Jpp,Jbn); | |
20912 | if ((Jcp)>(Jpn)) cimg::swap(Jcp,Jpn); if ((Jcp)>(Jan)) cimg::swap(Jcp,Jan); if ((Jnc)>(Jpa)) cimg::swap(Jnc,Jpa); if ((Jbn)>(Jna)) cimg::swap(Jbn,Jna); | |
20913 | if ((Jcp)>(Jnc)) cimg::swap(Jcp,Jnc); if ((Jcp)>(Jbn)) cimg::swap(Jcp,Jbn); if ((Jpb)>(Jap)) cimg::swap(Jpb,Jap); if ((Jnb)>(Jpc)) cimg::swap(Jnb,Jpc); | |
20914 | if ((Jbp)>(Jcn)) cimg::swap(Jbp,Jcn); if ((Jpc)>(Jcn)) cimg::swap(Jpc,Jcn); if ((Jap)>(Jcn)) cimg::swap(Jap,Jcn); if ((Jab)>(Jbc)) cimg::swap(Jab,Jbc); | |
20915 | if ((Jpp)>(Jcc)) cimg::swap(Jpp,Jcc); if ((Jcp)>(Jac)) cimg::swap(Jcp,Jac); if ((Jab)>(Jpp)) cimg::swap(Jab,Jpp); if ((Jab)>(Jcp)) cimg::swap(Jab,Jcp); | |
20916 | if ((Jcc)>(Jac)) cimg::swap(Jcc,Jac); if ((Jbc)>(Jac)) cimg::swap(Jbc,Jac); if ((Jpp)>(Jcp)) cimg::swap(Jpp,Jcp); if ((Jbc)>(Jcc)) cimg::swap(Jbc,Jcc); | |
20917 | if ((Jpp)>(Jbc)) cimg::swap(Jpp,Jbc); if ((Jpp)>(Jcn)) cimg::swap(Jpp,Jcn); if ((Jcc)>(Jcn)) cimg::swap(Jcc,Jcn); if ((Jcp)>(Jcn)) cimg::swap(Jcp,Jcn); | |
20918 | if ((Jcp)>(Jbc)) cimg::swap(Jcp,Jbc); if ((Jcc)>(Jnn)) cimg::swap(Jcc,Jnn); if ((Jcp)>(Jcc)) cimg::swap(Jcp,Jcc); if ((Jbc)>(Jnn)) cimg::swap(Jbc,Jnn); | |
20919 | if ((Jcc)>(Jba)) cimg::swap(Jcc,Jba); if ((Jbc)>(Jba)) cimg::swap(Jbc,Jba); if ((Jbc)>(Jcc)) cimg::swap(Jbc,Jcc); | |
20920 | res(x,y,0,k) = Jcc; | |
20921 | } | |
20922 | } break; | |
20923 | default: { | |
20924 | CImg<T> vois; | |
20925 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
20926 | const int | |
20927 | x0 = x - hl, y0 = y - hl, x1 = x + hr, y1 = y + hr, | |
20928 | nx0 = x0<0?0:x0, ny0 = y0<0?0:y0, | |
20929 | nx1 = x1>=dimx()?dimx()-1:x1, ny1 = y1>=dimy()?dimy()-1:y1; | |
20930 | vois = get_crop(nx0,ny0,0,k,nx1,ny1,0,k); | |
20931 | res(x,y,0,k) = vois.median(); | |
20932 | } | |
20933 | } break; | |
20934 | } else switch (n) { | |
20935 | case 2: { | |
20936 | T I[4] = { 0 }; | |
20937 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; ++y, ++_n1y) for (int x = 0, _n1x = (int)( (I[0] = (*this)(0,y,0,k)), (I[2] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[1] = (*this)(_n1x,y,0,k)), (I[3] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[2] = I[3], ++x, ++_n1x) res(x,0,0,k) = (T)(0.5f*(I[0]+I[1])); | |
20938 | } break; | |
20939 | case 3: { | |
20940 | T I[9] = { 0 }; | |
20941 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,0,k)), (I[3] = I[4] = (*this)(0,y,0,k)), (I[6] = I[7] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,0,k)), (I[5] = (*this)(_n1x,y,0,k)), (I[8] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
20942 | res(x,0,0,k) = I[3]<I[4]? | |
20943 | (I[4]<I[5]?I[4]: | |
20944 | (I[3]<I[5]?I[5]:I[3])): | |
20945 | (I[3]<I[5]?I[3]: | |
20946 | (I[4]<I[5]?I[5]:I[4])); | |
20947 | } | |
20948 | } break; | |
20949 | default: { | |
20950 | CImg<T> vois; | |
20951 | for (int k = 0; k<(int)((*this).dim); ++k) for (int x = 0; x<(int)((*this).width); ++x) { | |
20952 | const int | |
20953 | x0 = x - hl, x1 = x + hr, | |
20954 | nx0 = x0<0?0:x0, nx1 = x1>=dimx()?dimx()-1:x1; | |
20955 | vois = get_crop(nx0,0,0,k,nx1,0,0,k); | |
20956 | res(x,0,0,k) = vois.median(); | |
20957 | } | |
20958 | } break; | |
20959 | } | |
20960 | } | |
20961 | return res; | |
20962 | } | |
20963 | CImg<T>& blur_median(const unsigned int n=3) { | |
20964 | return get_blur_median(n).transfer_to(*this); | |
20965 | } | |
20966 | CImg<T> get_sharpen(const float amplitude=50.0f, const float edge=1.0f, const float alpha=0.0f, const float sigma=0.0f) const { | |
20967 | return (+*this).sharpen(amplitude,edge,alpha,sigma); | |
20968 | } | |
20969 | CImg<T>& sharpen(const float amplitude=50.0f, const float edge=1.0f, const float alpha=0.0f, const float sigma=0.0f) { | |
20970 | if (is_empty()) return *this; | |
20971 | const bool threed = (depth>1); | |
20972 | const float nedge = 0.5f*edge; | |
20973 | typedef typename cimg::superset<T,float>::type ftype; | |
20974 | CImg<ftype> val, vec, veloc(width,height,depth,dim); | |
20975 | if (threed) { | |
20976 | CImg<ftype> G = (alpha>0?get_blur(alpha).get_structure_tensorXYZ():get_structure_tensorXYZ()); | |
20977 | if (sigma>0) G.blur(sigma); | |
20978 | float I[27]; float& Ippp = I[0]; float& Icpp = I[1]; float& Inpp = I[2]; float& Ipcp = I[3]; float& Iccp = I[4]; float& Incp = I[5]; float& Ipnp = I[6]; float& Icnp = I[7]; float& Innp = I[8]; float& Ippc = I[9]; float& Icpc = I[10]; float& Inpc = I[11]; float& Ipcc = I[12]; float& Iccc = I[13]; float& Incc = I[14]; float& Ipnc = I[15]; float& Icnc = I[16]; float& Innc = I[17]; float& Ippn = I[18]; float& Icpn = I[19]; float& Inpn = I[20]; float& Ipcn = I[21]; float& Iccn = I[22]; float& Incn = I[23]; float& Ipnn = I[24]; float& Icnn = I[25]; float& Innn = I[26]; Ippp = Icpp = Inpp = Ipcp = Iccp = Incp = Ipnp = Icnp = Innp = Ippc = Icpc = Inpc = Ipcc = Iccc = Incc = Ipnc = Icnc = Innc = Ippn = Icpn = Inpn = Ipcn = Iccn = Incn = Ipnn = Icnn = Innn = 0; | |
20979 | for (int z = 0; z<(int)((G).depth); ++z) for (int y = 0; y<(int)((G).height); ++y) for (int x = 0; x<(int)((G).width); ++x) { | |
20980 | G.get_tensor_at(x,y,z).symmetric_eigen(val,vec); | |
20981 | G(x,y,z,0) = vec(0,0); | |
20982 | G(x,y,z,1) = vec(0,1); | |
20983 | G(x,y,z,2) = vec(0,2); | |
20984 | G(x,y,z,3) = 1.0f-(float)std::pow((float)(1+val[0]+val[1]+val[2]),-nedge); | |
20985 | } | |
20986 | for (int k = 0; k<(int)((*this).dim); ++k) for (int z = 0, _p1z = 0, _n1z = 1>=((*this).depth)?(int)((*this).depth)-1:1; _n1z<(int)((*this).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,_p1z,k)), (I[3] = I[4] = (*this)(0,y,_p1z,k)), (I[6] = I[7] = (*this)(0,_n1y,_p1z,k)), (I[9] = I[10] = (*this)(0,_p1y,z,k)), (I[12] = I[13] = (*this)(0,y,z,k)), (I[15] = I[16] = (*this)(0,_n1y,z,k)), (I[18] = I[19] = (*this)(0,_p1y,_n1z,k)), (I[21] = I[22] = (*this)(0,y,_n1z,k)), (I[24] = I[25] = (*this)(0,_n1y,_n1z,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,_p1z,k)), (I[5] = (*this)(_n1x,y,_p1z,k)), (I[8] = (*this)(_n1x,_n1y,_p1z,k)), (I[11] = (*this)(_n1x,_p1y,z,k)), (I[14] = (*this)(_n1x,y,z,k)), (I[17] = (*this)(_n1x,_n1y,z,k)), (I[20] = (*this)(_n1x,_p1y,_n1z,k)), (I[23] = (*this)(_n1x,y,_n1z,k)), (I[26] = (*this)(_n1x,_n1y,_n1z,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], I[9] = I[10], I[10] = I[11], I[12] = I[13], I[13] = I[14], I[15] = I[16], I[16] = I[17], I[18] = I[19], I[19] = I[20], I[21] = I[22], I[22] = I[23], I[24] = I[25], I[25] = I[26], _p1x = x++, ++_n1x) { | |
20987 | const float | |
20988 | u = G(x,y,z,0), | |
20989 | v = G(x,y,z,1), | |
20990 | w = G(x,y,z,2), | |
20991 | amp = G(x,y,z,3), | |
20992 | ixx = Incc+Ipcc-2*Iccc, | |
20993 | ixy = 0.25f*(Innc+Ippc-Inpc-Ipnc), | |
20994 | ixz = 0.25f*(Incn+Ipcp-Incp-Ipcn), | |
20995 | iyy = Icnc+Icpc-2*Iccc, | |
20996 | iyz = 0.25f*(Icnn+Icpp-Icnp-Icpn), | |
20997 | izz = Iccn+Iccp-2*Iccc, | |
20998 | ixf = Incc-Iccc, | |
20999 | ixb = Iccc-Ipcc, | |
21000 | iyf = Icnc-Iccc, | |
21001 | iyb = Iccc-Icpc, | |
21002 | izf = Iccn-Iccc, | |
21003 | izb = Iccc-Iccp, | |
21004 | itt = u*u*ixx + v*v*iyy + w*w*izz + 2*u*v*ixy + 2*u*w*ixz + 2*v*w*iyz, | |
21005 | it = u*cimg::minmod(ixf,ixb) + v*cimg::minmod(iyf,iyb) + w*cimg::minmod(izf,izb); | |
21006 | veloc(x,y,z,k) = -amp*cimg::sign(itt)*cimg::abs(it); | |
21007 | } | |
21008 | } else { | |
21009 | CImg<ftype> G = (alpha>0?get_blur(alpha).get_structure_tensorXY():get_structure_tensorXY()); | |
21010 | if (sigma>0) G.blur(sigma); | |
21011 | float I[9]; float& Ipp = I[0]; float& Icp = I[1]; float& Inp = I[2]; float& Ipc = I[3]; float& Icc = I[4]; float& Inc = I[5]; float& Ipn = I[6]; float& Icn = I[7]; float& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
21012 | for (int y = 0; y<(int)((G).height); ++y) for (int x = 0; x<(int)((G).width); ++x) { | |
21013 | G.get_tensor_at(x,y).symmetric_eigen(val,vec); | |
21014 | G(x,y,0) = vec(0,0); | |
21015 | G(x,y,1) = vec(0,1); | |
21016 | G(x,y,2) = 1.0f-(float)std::pow((float)(1+val[0]+val[1]),-nedge); | |
21017 | } | |
21018 | for (int k = 0; k<(int)((*this).dim); ++k) for (int y = 0, _p1y = 0, _n1y = 1>=((*this).height)?(int)((*this).height)-1:1; _n1y<(int)((*this).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (I[0] = I[1] = (*this)(0,_p1y,0,k)), (I[3] = I[4] = (*this)(0,y,0,k)), (I[6] = I[7] = (*this)(0,_n1y,0,k)), 1>=(*this).width?(int)((*this).width)-1:1); (_n1x<(int)((*this).width) && ( (I[2] = (*this)(_n1x,_p1y,0,k)), (I[5] = (*this)(_n1x,y,0,k)), (I[8] = (*this)(_n1x,_n1y,0,k)),1)) || x==--_n1x; I[0] = I[1], I[1] = I[2], I[3] = I[4], I[4] = I[5], I[6] = I[7], I[7] = I[8], _p1x = x++, ++_n1x) { | |
21019 | const float | |
21020 | u = G(x,y,0), | |
21021 | v = G(x,y,1), | |
21022 | amp = G(x,y,2), | |
21023 | ixx = Inc+Ipc-2*Icc, | |
21024 | ixy = 0.25f*(Inn+Ipp-Inp-Ipn), | |
21025 | iyy = Icn+Icp-2*Icc, | |
21026 | ixf = Inc-Icc, | |
21027 | ixb = Icc-Ipc, | |
21028 | iyf = Icn-Icc, | |
21029 | iyb = Icc-Icp, | |
21030 | itt = u*u*ixx + v*v*iyy + 2*u*v*ixy, | |
21031 | it = u*cimg::minmod(ixf,ixb) + v*cimg::minmod(iyf,iyb); | |
21032 | veloc(x,y,k) = -amp*cimg::sign(itt)*cimg::abs(it); | |
21033 | } | |
21034 | } | |
21035 | float m, M = (float)veloc.maxmin(m); | |
21036 | const float vmax = (float)cimg::max(cimg::abs(m),cimg::abs(M)); | |
21037 | if (vmax!=0) { veloc*=amplitude/vmax; (*this)+=veloc; } | |
21038 | return *this; | |
21039 | } | |
21040 | CImg<typename cimg::superset<T,float>::type> get_haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) const { | |
21041 | if (is_empty() || !nb_scales) return *this; | |
21042 | typedef typename cimg::superset<T,float>::type ftype; | |
21043 | CImg<ftype> res; | |
21044 | if (nb_scales==1) { | |
21045 | switch (cimg::uncase(axis)) { | |
21046 | case 'x': { | |
21047 | const unsigned int w = width/2; | |
21048 | if (w) { | |
21049 | if (w%2) throw CImgInstanceException("CImg<%s>::haar() : Sub-image width = %u is not even at a particular scale (=%u).",pixel_type(),w); | |
21050 | res.assign(width,height,depth,dim); | |
21051 | if (invert) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
21052 | for (unsigned int x=0, xw=w, x2=0; x<w; ++x, ++xw) { | |
21053 | const ftype val0 = (ftype)(*this)(x,y,z,v), val1 = (ftype)(*this)(xw,y,z,v); | |
21054 | res(x2++,y,z,v) = val0 - val1; | |
21055 | res(x2++,y,z,v) = val0 + val1; | |
21056 | } | |
21057 | } else for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
21058 | for (unsigned int x=0, xw=w, x2=0; x<w; ++x, ++xw) { | |
21059 | const ftype val0 = (ftype)(*this)(x2++,y,z,v), val1 = (ftype)(*this)(x2++,y,z,v); | |
21060 | res(x,y,z,v) = (val0 + val1)/2; | |
21061 | res(xw,y,z,v) = (val1 - val0)/2; | |
21062 | } | |
21063 | } | |
21064 | } else return *this; | |
21065 | } break; | |
21066 | case 'y': { | |
21067 | const unsigned int h = height/2; | |
21068 | if (h) { | |
21069 | if (h%2) throw CImgInstanceException("CImg<%s>::haar() : Sub-image height = %u is not even at a particular scale.",pixel_type(),h); | |
21070 | res.assign(width,height,depth,dim); | |
21071 | if (invert) for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int x = 0; x<(int)((*this).width); ++x) { | |
21072 | for (unsigned int y=0, yh=h, y2=0; y<h; ++y, ++yh) { | |
21073 | const ftype val0 = (ftype)(*this)(x,y,z,v), val1 = (ftype)(*this)(x,yh,z,v); | |
21074 | res(x,y2++,z,v) = val0 - val1; | |
21075 | res(x,y2++,z,v) = val0 + val1; | |
21076 | } | |
21077 | } else for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int x = 0; x<(int)((*this).width); ++x) { | |
21078 | for (unsigned int y=0, yh=h, y2=0; y<h; ++y, ++yh) { | |
21079 | const ftype val0 = (ftype)(*this)(x,y2++,z,v), val1 = (ftype)(*this)(x,y2++,z,v); | |
21080 | res(x,y,z,v) = (val0 + val1)/2; | |
21081 | res(x,yh,z,v) = (val1 - val0)/2; | |
21082 | } | |
21083 | } | |
21084 | } else return *this; | |
21085 | } break; | |
21086 | case 'z': { | |
21087 | const unsigned int d = depth/2; | |
21088 | if (d) { | |
21089 | if (d%2) throw CImgInstanceException("CImg<%s>::haar() : Sub-image depth = %u is not even at a particular scale.",pixel_type(),d); | |
21090 | res.assign(width,height,depth,dim); | |
21091 | if (invert) for (int v = 0; v<(int)((*this).dim); ++v) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
21092 | for (unsigned int z=0, zd=d, z2=0; z<d; ++z, ++zd) { | |
21093 | const ftype val0 = (ftype)(*this)(x,y,z,v), val1 = (ftype)(*this)(x,y,zd,v); | |
21094 | res(x,y,z2++,v) = val0 - val1; | |
21095 | res(x,y,z2++,v) = val0 + val1; | |
21096 | } | |
21097 | } else for (int v = 0; v<(int)((*this).dim); ++v) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
21098 | for (unsigned int z=0, zd=d, z2=0; z<d; ++z, ++zd) { | |
21099 | const ftype val0 = (ftype)(*this)(x,y,z2++,v), val1 = (ftype)(*this)(x,y,z2++,v); | |
21100 | res(x,y,z,v) = (val0 + val1)/2; | |
21101 | res(x,y,zd,v) = (val1 - val0)/2; | |
21102 | } | |
21103 | } | |
21104 | } else return *this; | |
21105 | } break; | |
21106 | default: throw CImgArgumentException("CImg<%s>::haar() : Unknown axis '%c'.",pixel_type(),axis); break; | |
21107 | } | |
21108 | } else { | |
21109 | if (invert) { | |
21110 | res.assign(*this); | |
21111 | switch (cimg::uncase(axis)) { | |
21112 | case 'x': { | |
21113 | unsigned int w = width; | |
21114 | for (unsigned int s=1; w && s<nb_scales; ++s) w/=2; | |
21115 | for (w=w?w:1; w<=width; w*=2) res.draw_image(res.get_crop(0,w-1).get_haar('x',true,1),0); | |
21116 | } break; | |
21117 | case 'y': { | |
21118 | unsigned int h = width; | |
21119 | for (unsigned int s=1; h && s<nb_scales; ++s) h/=2; | |
21120 | for (h=h?h:1; h<=height; h*=2) res.draw_image(res.get_crop(0,0,width-1,h-1).get_haar('y',true,1),0); | |
21121 | } break; | |
21122 | case 'z': { | |
21123 | unsigned int d = depth; | |
21124 | for (unsigned int s=1; d && s<nb_scales; ++s) d/=2; | |
21125 | for (d=d?d:1; d<=depth; d*=2) res.draw_image(res.get_crop(0,0,0,width-1,height-1,d-1).get_haar('z',true,1),0); | |
21126 | } break; | |
21127 | default: throw CImgArgumentException("CImg<%s>::haar() : Unknown axis '%c'.",pixel_type(),axis); break; | |
21128 | } | |
21129 | } else { | |
21130 | res = get_haar(axis,false,1); | |
21131 | switch (cimg::uncase(axis)) { | |
21132 | case 'x': { | |
21133 | for (unsigned int s=1, w=width/2; w && s<nb_scales; ++s, w/=2) res.draw_image(res.get_crop(0,w-1).get_haar('x',false,1),0); | |
21134 | } break; | |
21135 | case 'y': { | |
21136 | for (unsigned int s=1, h=height/2; h && s<nb_scales; ++s, h/=2) res.draw_image(res.get_crop(0,0,width-1,h-1).get_haar('y',false,1),0); | |
21137 | } break; | |
21138 | case 'z': { | |
21139 | for (unsigned int s=1, d=depth/2; d && s<nb_scales; ++s, d/=2) res.draw_image(res.get_crop(0,0,0,width-1,height-1,d-1).get_haar('z',false,1),0); | |
21140 | } break; | |
21141 | default: throw CImgArgumentException("CImg<%s>::haar() : Unknown axis '%c'.",pixel_type(),axis); break; | |
21142 | } | |
21143 | } | |
21144 | } | |
21145 | return res; | |
21146 | } | |
21147 | CImg<T>& haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) { | |
21148 | return get_haar(axis,invert,nb_scales).transfer_to(*this); | |
21149 | } | |
21150 | CImg<typename cimg::superset<T,float>::type> get_haar(const bool invert=false, const unsigned int nb_scales=1) const { | |
21151 | typedef typename cimg::superset<T,float>::type ftype; | |
21152 | CImg<ftype> res; | |
21153 | if (nb_scales==1) { | |
21154 | if (width>1) get_haar('x',invert,1).transfer_to(res); | |
21155 | if (height>1) { if (res) res.get_haar('y',invert,1).transfer_to(res); else get_haar('y',invert,1).transfer_to(res); } | |
21156 | if (depth>1) { if (res) res.get_haar('z',invert,1).transfer_to(res); else get_haar('z',invert,1).transfer_to(res); } | |
21157 | if (res) return res; | |
21158 | } else { | |
21159 | if (invert) { | |
21160 | res.assign(*this); | |
21161 | if (width>1) { | |
21162 | if (height>1) { | |
21163 | if (depth>1) { | |
21164 | unsigned int w = width, h = height, d = depth; for (unsigned int s=1; w && h && d && s<nb_scales; ++s) { w/=2; h/=2; d/=2; } | |
21165 | for (w=w?w:1, h=h?h:1, d=d?d:1; w<=width && h<=height && d<=depth; w*=2, h*=2, d*=2) | |
21166 | res.draw_image(res.get_crop(0,0,0,w-1,h-1,d-1).get_haar(true,1),0,0,0); | |
21167 | } else { | |
21168 | unsigned int w = width, h = height; for (unsigned int s=1; w && h && s<nb_scales; ++s) { w/=2; h/=2; } | |
21169 | for (w=w?w:1, h=h?h:1; w<=width && h<=height; w*=2, h*=2) | |
21170 | res.draw_image(res.get_crop(0,0,0,w-1,h-1,0).get_haar(true,1),0,0,0); | |
21171 | } | |
21172 | } else { | |
21173 | if (depth>1) { | |
21174 | unsigned int w = width, d = depth; for (unsigned int s=1; w && d && s<nb_scales; ++s) { w/=2; d/=2; } | |
21175 | for (w=w?w:1, d=d?d:1; w<=width && d<=depth; w*=2, d*=2) | |
21176 | res.draw_image(res.get_crop(0,0,0,w-1,0,d-1).get_haar(true,1),0,0,0); | |
21177 | } else { | |
21178 | unsigned int w = width; for (unsigned int s=1; w && s<nb_scales; ++s) w/=2; | |
21179 | for (w=w?w:1; w<=width; w*=2) | |
21180 | res.draw_image(res.get_crop(0,0,0,w-1,0,0).get_haar(true,1),0,0,0); | |
21181 | } | |
21182 | } | |
21183 | } else { | |
21184 | if (height>1) { | |
21185 | if (depth>1) { | |
21186 | unsigned int h = height, d = depth; for (unsigned int s=1; h && d && s<nb_scales; ++s) { h/=2; d/=2; } | |
21187 | for (h=h?h:1, d=d?d:1; h<=height && d<=depth; h*=2, d*=2) | |
21188 | res.draw_image(res.get_crop(0,0,0,0,h-1,d-1).get_haar(true,1),0,0,0); | |
21189 | } else { | |
21190 | unsigned int h = height; for (unsigned int s=1; h && s<nb_scales; ++s) h/=2; | |
21191 | for (h=h?h:1; h<=height; h*=2) | |
21192 | res.draw_image(res.get_crop(0,0,0,0,h-1,0).get_haar(true,1),0,0,0); | |
21193 | } | |
21194 | } else { | |
21195 | if (depth>1) { | |
21196 | unsigned int d = depth; for (unsigned int s=1; d && s<nb_scales; ++s) d/=2; | |
21197 | for (d=d?d:1; d<=depth; d*=2) | |
21198 | res.draw_image(res.get_crop(0,0,0,0,0,d-1).get_haar(true,1),0,0,0); | |
21199 | } else return *this; | |
21200 | } | |
21201 | } | |
21202 | } else { | |
21203 | res = get_haar(false,1); | |
21204 | if (width>1) { | |
21205 | if (height>1) { | |
21206 | if (depth>1) for (unsigned int s=1, w=width/2, h=height/2, d=depth/2; w && h && d && s<nb_scales; ++s, w/=2, h/=2, d/=2) | |
21207 | res.draw_image(res.get_crop(0,0,0,w-1,h-1,d-1).haar(false,1),0,0,0); | |
21208 | else for (unsigned int s=1, w=width/2, h=height/2; w && h && s<nb_scales; ++s, w/=2, h/=2) | |
21209 | res.draw_image(res.get_crop(0,0,0,w-1,h-1,0).haar(false,1),0,0,0); | |
21210 | } else { | |
21211 | if (depth>1) for (unsigned int s=1, w=width/2, d=depth/2; w && d && s<nb_scales; ++s, w/=2, d/=2) | |
21212 | res.draw_image(res.get_crop(0,0,0,w-1,0,d-1).haar(false,1),0,0,0); | |
21213 | else for (unsigned int s=1, w=width/2; w && s<nb_scales; ++s, w/=2) | |
21214 | res.draw_image(res.get_crop(0,0,0,w-1,0,0).haar(false,1),0,0,0); | |
21215 | } | |
21216 | } else { | |
21217 | if (height>1) { | |
21218 | if (depth>1) for (unsigned int s=1, h=height/2, d=depth/2; h && d && s<nb_scales; ++s, h/=2, d/=2) | |
21219 | res.draw_image(res.get_crop(0,0,0,0,h-1,d-1).haar(false,1),0,0,0); | |
21220 | else for (unsigned int s=1, h=height/2; h && s<nb_scales; ++s, h/=2) | |
21221 | res.draw_image(res.get_crop(0,0,0,0,h-1,0).haar(false,1),0,0,0); | |
21222 | } else { | |
21223 | if (depth>1) for (unsigned int s=1, d=depth/2; d && s<nb_scales; ++s, d/=2) | |
21224 | res.draw_image(res.get_crop(0,0,0,0,0,d-1).haar(false,1),0,0,0); | |
21225 | else return *this; | |
21226 | } | |
21227 | } | |
21228 | } | |
21229 | return res; | |
21230 | } | |
21231 | return *this; | |
21232 | } | |
21233 | CImg<T>& haar(const bool invert=false, const unsigned int nb_scales=1) { | |
21234 | return get_haar(invert,nb_scales).transfer_to(*this); | |
21235 | } | |
21236 | CImg<typename cimg::superset<T,float>::type> | |
21237 | get_displacement_field(const CImg<T>& target, | |
21238 | const float smoothness=0.1f, const float precision=0.1f, | |
21239 | const unsigned int nb_scales=0, const unsigned int itermax=10000) const { | |
21240 | typedef typename cimg::superset<T,float>::type ftype; | |
21241 | if (is_empty() || !target) return *this; | |
21242 | if (!is_sameXYZV(target)) | |
21243 | throw CImgArgumentException("CImg<%s>::displacement_field() : Instance image (%u,%u,%u,%u,%p) and target image (%u,%u,%u,%u,%p) " | |
21244 | "have different size.",pixel_type(),width,height,depth,dim,data, | |
21245 | target.width,target.height,target.depth,target.dim,target.data); | |
21246 | if (smoothness<0) | |
21247 | throw CImgArgumentException("CImg<%s>::displacement_field() : Smoothness parameter %g is negative.",pixel_type(),smoothness); | |
21248 | if (precision<0) | |
21249 | throw CImgArgumentException("CImg<%s>::displacement_field() : Precision parameter %g is negative.",pixel_type(),precision); | |
21250 | const unsigned int nscales = nb_scales>0?nb_scales:(unsigned int)(2*std::log((double)(cimg::max(width,height,depth)))); | |
21251 | ftype m1, M1 = maxmin(m1), m2, M2 = target.maxmin(m2); | |
21252 | const ftype factor = cimg::max(cimg::abs(m1),cimg::abs(M1),cimg::abs(m2),cimg::abs(M2)); | |
21253 | CImg<ftype> U0; | |
21254 | const bool threed = (depth>1); | |
21255 | for (int scale=(int)nscales-1; scale>=0; --scale) { | |
21256 | const float sfactor = (float)std::pow(1.5f,(float)scale), sprecision = (float)(precision/std::pow(2.25,1+scale)); | |
21257 | const int | |
21258 | sw = (int)(width/sfactor), sh = (int)(height/sfactor), sd = (int)(depth/sfactor), | |
21259 | swidth = sw?sw:1, sheight = sh?sh:1, sdepth = sd?sd:1; | |
21260 | CImg<ftype> | |
21261 | I1 = get_resize(swidth,sheight,sdepth,-100,2), | |
21262 | I2 = target.get_resize(swidth,sheight,sdepth,-100,2); | |
21263 | I1/=factor; I2/=factor; | |
21264 | CImg<ftype> U; | |
21265 | if (U0) U = (U0*=1.5f).get_resize(I1.dimx(),I1.dimy(),I1.dimz(),-100,3); | |
21266 | else U.assign(I1.dimx(),I1.dimy(),I1.dimz(),threed?3:2,0); | |
21267 | CImg<ftype> veloc(U); | |
21268 | float dt = 2.0f, Energy = cimg::type<float>::max(); | |
21269 | const CImgList<ftype> dI = threed?I2.get_gradientXYZ():I2.get_gradientXY(); | |
21270 | for (unsigned int iter=0; iter<itermax; iter++) { | |
21271 | veloc.fill(0); | |
21272 | float nEnergy = 0; | |
21273 | if (threed) { | |
21274 | ftype I[27]; ftype& Ippp = I[0]; ftype& Icpp = I[1]; ftype& Inpp = I[2]; ftype& Ipcp = I[3]; ftype& Iccp = I[4]; ftype& Incp = I[5]; ftype& Ipnp = I[6]; ftype& Icnp = I[7]; ftype& Innp = I[8]; ftype& Ippc = I[9]; ftype& Icpc = I[10]; ftype& Inpc = I[11]; ftype& Ipcc = I[12]; ftype& Iccc = I[13]; ftype& Incc = I[14]; ftype& Ipnc = I[15]; ftype& Icnc = I[16]; ftype& Innc = I[17]; ftype& Ippn = I[18]; ftype& Icpn = I[19]; ftype& Inpn = I[20]; ftype& Ipcn = I[21]; ftype& Iccn = I[22]; ftype& Incn = I[23]; ftype& Ipnn = I[24]; ftype& Icnn = I[25]; ftype& Innn = I[26]; Ippp = Icpp = Inpp = Ipcp = Iccp = Incp = Ipnp = Icnp = Innp = Ippc = Icpc = Inpc = Ipcc = Iccc = Incc = Ipnc = Icnc = Innc = Ippn = Icpn = Inpn = Ipcn = Iccn = Incn = Ipnn = Icnn = Innn = 0; | |
21275 | for (int z = 0, _p1z = 0, _n1z = 1>=((U).depth)?(int)((U).depth)-1:1; _n1z<(int)((U).depth) || z==--_n1z; _p1z = z++, ++_n1z) for (int y = 0, _p1y = 0, _n1y = 1>=((U).height)?(int)((U).height)-1:1; _n1y<(int)((U).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = 1>=((U).width)?(int)((U).width)-1:1; _n1x<(int)((U).width) || x==--_n1x; _p1x = x++, ++_n1x) { | |
21276 | const float X = x + U(x,y,z,0), Y = y + U(x,y,z,1), Z = z + U(x,y,z,2); | |
21277 | for (int k = 0; k<(int)((U).dim); ++k) { | |
21278 | const float | |
21279 | Ux = 0.5f*(U(_n1x,y,z,k) - U(_p1x,y,z,k)), | |
21280 | Uy = 0.5f*(U(x,_n1y,z,k) - U(x,_p1y,z,k)), | |
21281 | Uz = 0.5f*(U(x,y,_n1z,k) - U(x,y,_p1z,k)), | |
21282 | Uxx = U(_n1x,y,z,k) + U(_p1x,y,z,k) - 2*U(x,y,z,k), | |
21283 | Uyy = U(x,_n1y,z,k) + U(x,_p1y,z,k) - 2*U(x,y,z,k), | |
21284 | Uzz = U(x,y,_n1z,k) + U(x,y,_n1z,k) - 2*U(x,y,z,k); | |
21285 | nEnergy += smoothness*(Ux*Ux + Uy*Uy + Uz*Uz); | |
21286 | float deltaIgrad = 0; | |
21287 | for (int i = 0; i<(int)((I1).dim); ++i) { | |
21288 | const float deltaIi = (float)(I2.linear_pix3d(X,Y,Z,i) - I1(x,y,z,i)); | |
21289 | nEnergy += deltaIi*deltaIi/2; | |
21290 | deltaIgrad+=-deltaIi*dI[k].linear_pix3d(X,Y,Z,i); | |
21291 | } | |
21292 | veloc(x,y,z,k) = deltaIgrad + smoothness*(Uxx + Uyy + Uzz); | |
21293 | } | |
21294 | } | |
21295 | } else { | |
21296 | ftype I[9]; ftype& Ipp = I[0]; ftype& Icp = I[1]; ftype& Inp = I[2]; ftype& Ipc = I[3]; ftype& Icc = I[4]; ftype& Inc = I[5]; ftype& Ipn = I[6]; ftype& Icn = I[7]; ftype& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; | |
21297 | for (int y = 0, _p1y = 0, _n1y = 1>=((U).height)?(int)((U).height)-1:1; _n1y<(int)((U).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = 1>=((U).width)?(int)((U).width)-1:1; _n1x<(int)((U).width) || x==--_n1x; _p1x = x++, ++_n1x) { | |
21298 | const float X = x + U(x,y,0), Y = y + U(x,y,1); | |
21299 | for (int k = 0; k<(int)((U).dim); ++k) { | |
21300 | const float | |
21301 | Ux = 0.5f*(U(_n1x,y,k) - U(_p1x,y,k)), | |
21302 | Uy = 0.5f*(U(x,_n1y,k) - U(x,_p1y,k)), | |
21303 | Uxx = U(_n1x,y,k) + U(_p1x,y,k) - 2*U(x,y,k), | |
21304 | Uyy = U(x,_n1y,k) + U(x,_p1y,k) - 2*U(x,y,k); | |
21305 | nEnergy += smoothness*(Ux*Ux + Uy*Uy); | |
21306 | float deltaIgrad = 0; | |
21307 | for (int i = 0; i<(int)((I1).dim); ++i) { | |
21308 | const float deltaIi = (float)(I2.linear_pix2d(X,Y,i) - I1(x,y,i)); | |
21309 | nEnergy += deltaIi*deltaIi/2; | |
21310 | deltaIgrad+=-deltaIi*dI[k].linear_pix2d(X,Y,i); | |
21311 | } | |
21312 | veloc(x,y,k) = deltaIgrad + smoothness*(Uxx + Uyy); | |
21313 | } | |
21314 | } | |
21315 | } | |
21316 | const float vmax = cimg::max(cimg::abs(veloc.min()), cimg::abs(veloc.max())); | |
21317 | U+=(veloc*=dt/vmax); | |
21318 | if (cimg::abs(nEnergy-Energy)<sprecision) break; | |
21319 | if (nEnergy<Energy) dt*=0.5f; | |
21320 | Energy = nEnergy; | |
21321 | } | |
21322 | U.transfer_to(U0); | |
21323 | } | |
21324 | return U0; | |
21325 | } | |
21326 | CImg<T>& displacement_field(const CImg<T>& target, const float smooth=0.1f, const float precision=0.1f, | |
21327 | const unsigned int nb_scales=0, const unsigned int itermax=10000) { | |
21328 | return get_displacement_field(target,smooth,precision,nb_scales,itermax).transfer_to(*this); | |
21329 | } | |
21330 | static CImg<T> vector(const T a0) { | |
21331 | static CImg<T> r(1,1); r[0] = a0; | |
21332 | return r; | |
21333 | } | |
21334 | static CImg<T> vector(const T a0, const T a1) { | |
21335 | static CImg<T> r(1,2); T *ptr = r.data; | |
21336 | *(ptr++) = a0; *(ptr++) = a1; | |
21337 | return r; | |
21338 | } | |
21339 | static CImg<T> vector(const T a0, const T a1, const T a2) { | |
21340 | static CImg<T> r(1,3); T *ptr = r.data; | |
21341 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; | |
21342 | return r; | |
21343 | } | |
21344 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3) { | |
21345 | static CImg<T> r(1,4); T *ptr = r.data; | |
21346 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; | |
21347 | return r; | |
21348 | } | |
21349 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, const T a4) { | |
21350 | static CImg<T> r(1,5); T *ptr = r.data; | |
21351 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; | |
21352 | return r; | |
21353 | } | |
21354 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, const T a4, const T a5) { | |
21355 | static CImg<T> r(1,6); T *ptr = r.data; | |
21356 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; | |
21357 | return r; | |
21358 | } | |
21359 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21360 | const T a4, const T a5, const T a6) { | |
21361 | static CImg<T> r(1,7); T *ptr = r.data; | |
21362 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; | |
21363 | return r; | |
21364 | } | |
21365 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21366 | const T a4, const T a5, const T a6, const T a7) { | |
21367 | static CImg<T> r(1,8); T *ptr = r.data; | |
21368 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21369 | return r; | |
21370 | } | |
21371 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21372 | const T a4, const T a5, const T a6, const T a7, const T a8) { | |
21373 | static CImg<T> r(1,9); T *ptr = r.data; | |
21374 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21375 | *(ptr++) = a8; | |
21376 | return r; | |
21377 | } | |
21378 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21379 | const T a4, const T a5, const T a6, const T a7, | |
21380 | const T a8, const T a9) { | |
21381 | static CImg<T> r(1,10); T *ptr = r.data; | |
21382 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21383 | *(ptr++) = a8; *(ptr++) = a9; | |
21384 | return r; | |
21385 | } | |
21386 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21387 | const T a4, const T a5, const T a6, const T a7, | |
21388 | const T a8, const T a9, const T a10) { | |
21389 | static CImg<T> r(1,11); T *ptr = r.data; | |
21390 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21391 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; | |
21392 | return r; | |
21393 | } | |
21394 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21395 | const T a4, const T a5, const T a6, const T a7, | |
21396 | const T a8, const T a9, const T a10, const T a11) { | |
21397 | static CImg<T> r(1,12); T *ptr = r.data; | |
21398 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21399 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11; | |
21400 | return r; | |
21401 | } | |
21402 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21403 | const T a4, const T a5, const T a6, const T a7, | |
21404 | const T a8, const T a9, const T a10, const T a11, | |
21405 | const T a12) { | |
21406 | static CImg<T> r(1,13); T *ptr = r.data; | |
21407 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21408 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; | |
21409 | return r; | |
21410 | } | |
21411 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21412 | const T a4, const T a5, const T a6, const T a7, | |
21413 | const T a8, const T a9, const T a10, const T a11, | |
21414 | const T a12, const T a13) { | |
21415 | static CImg<T> r(1,14); T *ptr = r.data; | |
21416 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21417 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; *(ptr++) = a13; | |
21418 | return r; | |
21419 | } | |
21420 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21421 | const T a4, const T a5, const T a6, const T a7, | |
21422 | const T a8, const T a9, const T a10, const T a11, | |
21423 | const T a12, const T a13, const T a14) { | |
21424 | static CImg<T> r(1,15); T *ptr = r.data; | |
21425 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21426 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; | |
21427 | return r; | |
21428 | } | |
21429 | static CImg<T> vector(const T a0, const T a1, const T a2, const T a3, | |
21430 | const T a4, const T a5, const T a6, const T a7, | |
21431 | const T a8, const T a9, const T a10, const T a11, | |
21432 | const T a12, const T a13, const T a14, const T a15) { | |
21433 | static CImg<T> r(1,16); T *ptr = r.data; | |
21434 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21435 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; *(ptr++) = a15; | |
21436 | return r; | |
21437 | } | |
21438 | template<int N> static CImg<T> vector(const int a0, const int a1, ...) { | |
21439 | CImg<T> res(1,N); | |
21440 | { unsigned int _siz = (unsigned int)N; if (_siz--) { va_list ap; __builtin_va_start(ap,a1); T *ptrd = (res).data; *(ptrd++) = (T)a0; if (_siz--) { *(ptrd++) = (T)a1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }}; | |
21441 | return res; | |
21442 | } | |
21443 | template<int N> static CImg<T> vector(const double a0, const double a1, ...) { | |
21444 | CImg<T> res(1,N); | |
21445 | { unsigned int _siz = (unsigned int)N; if (_siz--) { va_list ap; __builtin_va_start(ap,a1); T *ptrd = (res).data; *(ptrd++) = (T)a0; if (_siz--) { *(ptrd++) = (T)a1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }}; | |
21446 | return res; | |
21447 | } | |
21448 | static CImg<T> matrix(const T a0) { | |
21449 | return vector(a0); | |
21450 | } | |
21451 | static CImg<T> matrix(const T a0, const T a1, | |
21452 | const T a2, const T a3) { | |
21453 | static CImg<T> r(2,2); T *ptr = r.data; | |
21454 | *(ptr++) = a0; *(ptr++) = a1; | |
21455 | *(ptr++) = a2; *(ptr++) = a3; | |
21456 | return r; | |
21457 | } | |
21458 | static CImg<T> matrix(const T a0, const T a1, const T a2, | |
21459 | const T a3, const T a4, const T a5, | |
21460 | const T a6, const T a7, const T a8) { | |
21461 | static CImg<T> r(3,3); T *ptr = r.data; | |
21462 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; | |
21463 | *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5; | |
21464 | *(ptr++) = a6; *(ptr++) = a7; *(ptr++) = a8; | |
21465 | return r; | |
21466 | } | |
21467 | static CImg<T> matrix(const T a0, const T a1, const T a2, const T a3, | |
21468 | const T a4, const T a5, const T a6, const T a7, | |
21469 | const T a8, const T a9, const T a10, const T a11, | |
21470 | const T a12, const T a13, const T a14, const T a15) { | |
21471 | static CImg<T> r(4,4); T *ptr = r.data; | |
21472 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; | |
21473 | *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; | |
21474 | *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11; | |
21475 | *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; *(ptr++) = a15; | |
21476 | return r; | |
21477 | } | |
21478 | static CImg<T> matrix(const T a0, const T a1, const T a2, const T a3, const T a4, | |
21479 | const T a5, const T a6, const T a7, const T a8, const T a9, | |
21480 | const T a10, const T a11, const T a12, const T a13, const T a14, | |
21481 | const T a15, const T a16, const T a17, const T a18, const T a19, | |
21482 | const T a20, const T a21, const T a22, const T a23, const T a24) { | |
21483 | static CImg<T> r(5,5); T *ptr = r.data; | |
21484 | *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; | |
21485 | *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; *(ptr++) = a8; *(ptr++) = a9; | |
21486 | *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; | |
21487 | *(ptr++) = a15; *(ptr++) = a16; *(ptr++) = a17; *(ptr++) = a18; *(ptr++) = a19; | |
21488 | *(ptr++) = a20; *(ptr++) = a21; *(ptr++) = a22; *(ptr++) = a23; *(ptr++) = a24; | |
21489 | return r; | |
21490 | } | |
21491 | template<int M,int N> static CImg<T> matrix(const int a0, const int a1, ...) { | |
21492 | CImg<T> res(M,N); | |
21493 | { unsigned int _siz = (unsigned int)M*N; if (_siz--) { va_list ap; __builtin_va_start(ap,a1); T *ptrd = (res).data; *(ptrd++) = (T)a0; if (_siz--) { *(ptrd++) = (T)a1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,int); } __builtin_va_end(ap); }}; | |
21494 | return res; | |
21495 | } | |
21496 | template<int M,int N> static CImg<T> matrix(const double a0, const double a1, ...) { | |
21497 | CImg<T> res(M,N); | |
21498 | { unsigned int _siz = (unsigned int)M*N; if (_siz--) { va_list ap; __builtin_va_start(ap,a1); T *ptrd = (res).data; *(ptrd++) = (T)a0; if (_siz--) { *(ptrd++) = (T)a1; for (; _siz; --_siz) *(ptrd++) = (T)__builtin_va_arg(ap,double); } __builtin_va_end(ap); }}; | |
21499 | return res; | |
21500 | } | |
21501 | static CImg<T> tensor(const T a1) { | |
21502 | return matrix(a1); | |
21503 | } | |
21504 | static CImg<T> tensor(const T a1, const T a2, const T a3) { | |
21505 | return matrix(a1,a2,a2,a3); | |
21506 | } | |
21507 | static CImg<T> tensor(const T a1, const T a2, const T a3, const T a4, const T a5, const T a6) { | |
21508 | return matrix(a1,a2,a3,a2,a4,a5,a3,a5,a6); | |
21509 | } | |
21510 | static CImg<T> diagonal(const T a0) { | |
21511 | return matrix(a0); | |
21512 | } | |
21513 | static CImg<T> diagonal(const T a0, const T a1) { | |
21514 | return matrix(a0,0,0,a1); | |
21515 | } | |
21516 | static CImg<T> diagonal(const T a0, const T a1, const T a2) { | |
21517 | return matrix(a0,0,0,0,a1,0,0,0,a2); | |
21518 | } | |
21519 | static CImg<T> diagonal(const T a0, const T a1, const T a2, const T a3) { | |
21520 | return matrix(a0,0,0,0,0,a1,0,0,0,0,a2,0,0,0,0,a3); | |
21521 | } | |
21522 | static CImg<T> diagonal(const T a0, const T a1, const T a2, const T a3, const T a4) { | |
21523 | return matrix(a0,0,0,0,0,0,a1,0,0,0,0,0,a2,0,0,0,0,0,a3,0,0,0,0,0,a4); | |
21524 | } | |
21525 | template<int N> static CImg<T> diagonal(const int a0, ...) { | |
21526 | CImg<T> res; | |
21527 | if (N>0) { | |
21528 | res.assign(N,N,1,1,0); | |
21529 | va_list ap; | |
21530 | __builtin_va_start(ap,a0); | |
21531 | res[0] = (T)a0; | |
21532 | for (int i=1; i<N; ++i) res(i,i) = (T)__builtin_va_arg(ap,int); | |
21533 | __builtin_va_end(ap); | |
21534 | } | |
21535 | return res; | |
21536 | } | |
21537 | template<int N> static CImg<T> diagonal(const double a0, ...) { | |
21538 | CImg<T> res; | |
21539 | if (N>0) { | |
21540 | res.assign(N,N,1,1,0); | |
21541 | va_list ap; | |
21542 | __builtin_va_start(ap,a0); | |
21543 | res[0] = (T)a0; | |
21544 | for (int i=1; i<N; ++i) res(i,i) = (T)__builtin_va_arg(ap,double); | |
21545 | __builtin_va_end(ap); | |
21546 | } | |
21547 | return res; | |
21548 | } | |
21549 | static CImg<T> identity_matrix(const unsigned int N) { | |
21550 | CImg<T> res(N,N,1,1,0); | |
21551 | for (int x = 0; x<(int)((res).width); ++x) res(x,x) = 1; | |
21552 | return res; | |
21553 | } | |
21554 | static CImg<T> sequence(const unsigned int N, const T a0, const T a1) { | |
21555 | if (N) return CImg<T>(1,N).sequence(a0,a1); | |
21556 | return CImg<T>(); | |
21557 | } | |
21558 | static CImg<T> rotation_matrix(const float x, const float y, const float z, const float w, const bool quaternion_data=false) { | |
21559 | float X,Y,Z,W; | |
21560 | if (!quaternion_data) { | |
21561 | const float norm = (float)std::sqrt(x*x + y*y + z*z), | |
21562 | nx = norm>0?x/norm:0, | |
21563 | ny = norm>0?y/norm:0, | |
21564 | nz = norm>0?z/norm:1, | |
21565 | nw = norm>0?w:0, | |
21566 | sina = (float)std::sin(nw/2), | |
21567 | cosa = (float)std::cos(nw/2); | |
21568 | X = nx*sina; | |
21569 | Y = ny*sina; | |
21570 | Z = nz*sina; | |
21571 | W = cosa; | |
21572 | } else { | |
21573 | const float norm = (float)std::sqrt(x*x + y*y + z*z + w*w); | |
21574 | if (norm>0) { X = x/norm; Y = y/norm; Z = z/norm; W = w/norm; } | |
21575 | else { X = Y = Z = 0; W = 1; } | |
21576 | } | |
21577 | const float xx = X*X, xy = X*Y, xz = X*Z, xw = X*W, yy = Y*Y, yz = Y*Z, yw = Y*W, zz = Z*Z, zw = Z*W; | |
21578 | return CImg<T>::matrix((T)(1-2*(yy+zz)), (T)(2*(xy+zw)), (T)(2*(xz-yw)), | |
21579 | (T)(2*(xy-zw)), (T)(1-2*(xx+zz)), (T)(2*(yz+xw)), | |
21580 | (T)(2*(xz+yw)), (T)(2*(yz-xw)), (T)(1-2*(xx+yy))); | |
21581 | } | |
21582 | CImg<T> get_vector_at(const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) const { | |
21583 | static CImg<T> dest; | |
21584 | if (dest.height!=dim) dest.assign(1,dim); | |
21585 | const unsigned int whz = width*height*depth; | |
21586 | const T *ptrs = ptr(x,y,z); | |
21587 | T *ptrd = dest.data; | |
21588 | for (int k = 0; k<(int)((*this).dim); ++k) { *(ptrd++) = *ptrs; ptrs+=whz; } | |
21589 | return dest; | |
21590 | } | |
21591 | template<typename t> CImg<T>& set_vector_at(const CImg<t>& vec, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) { | |
21592 | if (x<width && y<height && z<depth) { | |
21593 | const unsigned int whz = width*height*depth; | |
21594 | const t *ptrs = vec.data; | |
21595 | T *ptrd = ptr(x,y,z); | |
21596 | for (unsigned int k=cimg::min((unsigned int)vec.size(),dim); k; --k) { *ptrd = (T)*(ptrs++); ptrd+=whz; } | |
21597 | } | |
21598 | return *this; | |
21599 | } | |
21600 | CImg<T> get_matrix_at(const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) const { | |
21601 | const int n = (int)std::sqrt((double)dim); | |
21602 | CImg<T> dest(n,n); | |
21603 | for (int k = 0; k<(int)((*this).dim); ++k) dest[k]=(*this)(x,y,z,k); | |
21604 | return dest; | |
21605 | } | |
21606 | template<typename t> CImg<T>& set_matrix_at(const CImg<t>& mat, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) { | |
21607 | return set_vector_at(mat,x,y,z); | |
21608 | } | |
21609 | CImg<T> get_tensor_at(const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) const { | |
21610 | if (dim==6) return tensor((*this)(x,y,z,0),(*this)(x,y,z,1),(*this)(x,y,z,2), | |
21611 | (*this)(x,y,z,3),(*this)(x,y,z,4),(*this)(x,y,z,5)); | |
21612 | if (dim==3) return tensor((*this)(x,y,z,0),(*this)(x,y,z,1),(*this)(x,y,z,2)); | |
21613 | return tensor((*this)(x,y,z,0)); | |
21614 | } | |
21615 | template<typename t> CImg<T>& set_tensor_at(const CImg<t>& ten, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) { | |
21616 | if (ten.height==2) { | |
21617 | (*this)(x,y,z,0) = (T)ten[0]; | |
21618 | (*this)(x,y,z,1) = (T)ten[1]; | |
21619 | (*this)(x,y,z,2) = (T)ten[3]; | |
21620 | } | |
21621 | else { | |
21622 | (*this)(x,y,z,0) = (T)ten[0]; | |
21623 | (*this)(x,y,z,1) = (T)ten[1]; | |
21624 | (*this)(x,y,z,2) = (T)ten[2]; | |
21625 | (*this)(x,y,z,3) = (T)ten[4]; | |
21626 | (*this)(x,y,z,4) = (T)ten[5]; | |
21627 | (*this)(x,y,z,5) = (T)ten[8]; | |
21628 | } | |
21629 | return *this; | |
21630 | } | |
21631 | CImg<T> get_vector() const { | |
21632 | return get_unroll('y'); | |
21633 | } | |
21634 | CImg<T>& vector() { | |
21635 | return unroll('y'); | |
21636 | } | |
21637 | CImg<T> get_matrix() const { | |
21638 | return (+*this).matrix(); | |
21639 | } | |
21640 | CImg<T>& matrix() { | |
21641 | const unsigned int siz = size(); | |
21642 | switch (siz) { | |
21643 | case 1: break; | |
21644 | case 4: width = height = 2; break; | |
21645 | case 9: width = height = 3; break; | |
21646 | case 16: width = height = 4; break; | |
21647 | case 25: width = height = 5; break; | |
21648 | case 36: width = height = 6; break; | |
21649 | case 49: width = height = 7; break; | |
21650 | case 64: width = height = 8; break; | |
21651 | case 81: width = height = 9; break; | |
21652 | case 100: width = height = 10; break; | |
21653 | default: { | |
21654 | unsigned int i = 11, i2 = i*i; | |
21655 | while (i2<siz) { i2+=2*i+1; ++i; } | |
21656 | if (i2==siz) width = height = i; | |
21657 | else throw CImgInstanceException("CImg<%s>::matrix() : Image size = %u is not a square number",pixel_type(),siz); | |
21658 | } break; | |
21659 | } | |
21660 | return *this; | |
21661 | } | |
21662 | CImg<T> get_tensor() const { | |
21663 | CImg<T> res; | |
21664 | const unsigned int siz = size(); | |
21665 | switch (siz) { | |
21666 | case 1: break; | |
21667 | case 3: | |
21668 | res.assign(2,2); | |
21669 | res(0,0) = (*this)(0); | |
21670 | res(1,0) = res(0,1) = (*this)(1); | |
21671 | res(1,1) = (*this)(2); | |
21672 | break; | |
21673 | case 6: | |
21674 | res.assign(3,3); | |
21675 | res(0,0) = (*this)(0); | |
21676 | res(1,0) = res(0,1) = (*this)(1); | |
21677 | res(2,0) = res(0,2) = (*this)(2); | |
21678 | res(1,1) = (*this)(3); | |
21679 | res(2,1) = res(1,2) = (*this)(4); | |
21680 | res(2,2) = (*this)(5); | |
21681 | break; | |
21682 | default: | |
21683 | throw CImgInstanceException("CImg<%s>::tensor() : Wrong vector dimension = %u in instance image.", | |
21684 | pixel_type(), dim); | |
21685 | break; | |
21686 | } | |
21687 | return res; | |
21688 | } | |
21689 | CImg<T>& tensor() { | |
21690 | return get_tensor().transfer_to(*this); | |
21691 | } | |
21692 | CImg<T> get_unroll(const char axe='x') const { | |
21693 | return (+*this).unroll(axe); | |
21694 | } | |
21695 | CImg<T>& unroll(const char axe='x') { | |
21696 | const unsigned int siz = size(); | |
21697 | if (siz) switch (axe) { | |
21698 | case 'x': width = siz; height=depth=dim=1; break; | |
21699 | case 'y': height = siz; width=depth=dim=1; break; | |
21700 | case 'z': depth = siz; width=height=dim=1; break; | |
21701 | case 'v': dim = siz; width=height=depth=1; break; | |
21702 | default: throw CImgArgumentException("CImg<%s>::unroll() : Given axe is '%c' which is not 'x','y','z' or 'v'", | |
21703 | pixel_type(),axe); | |
21704 | } | |
21705 | return *this; | |
21706 | } | |
21707 | CImg<T> get_diagonal() const { | |
21708 | if (is_empty()) return CImg<T>(); | |
21709 | CImg<T> res(size(),size(),1,1,0); | |
21710 | for (unsigned int off = 0; off<(*this).size(); ++off) res(off,off) = (*this)(off); | |
21711 | return res; | |
21712 | } | |
21713 | CImg<T>& diagonal() { | |
21714 | return get_diagonal().transfer_to(*this); | |
21715 | } | |
21716 | CImg<T> get_identity_matrix() const { | |
21717 | return identity_matrix(cimg::max(width,height)); | |
21718 | } | |
21719 | CImg<T>& identity_matrix() { | |
21720 | return identity_matrix(cimg::max(width,height)).transfer_to(*this); | |
21721 | } | |
21722 | CImg<T> get_sequence(const T a0, const T a1) const { | |
21723 | return (+*this).sequence(a0,a1); | |
21724 | } | |
21725 | CImg<T>& sequence(const T a0, const T a1) { | |
21726 | if (!is_empty()) { | |
21727 | const unsigned int siz = size()-1; | |
21728 | const float delta = (float)((float)a1-a0); | |
21729 | T* ptr = data; | |
21730 | for (unsigned int l = 0; l<(*this).size(); ++l) *(ptr++) = (T)(a0 + delta*l/siz); | |
21731 | } | |
21732 | return *this; | |
21733 | } | |
21734 | CImg<T> get_transpose() const { | |
21735 | return get_permute_axes("yxzv"); | |
21736 | } | |
21737 | CImg<T>& transpose() { | |
21738 | if (width==1) { width=height; height=1; return *this; } | |
21739 | if (height==1) { height=width; width=1; return *this; } | |
21740 | if (width==height) { | |
21741 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x=y; x<dimx(); ++x) cimg::swap((*this)(x,y,z,v),(*this)(y,x,z,v)); | |
21742 | return *this; | |
21743 | } | |
21744 | return get_transpose().transfer_to(*this); | |
21745 | } | |
21746 | CImg<typename cimg::superset<T,float>::type> get_invert(const bool use_LU=true) const { | |
21747 | typedef typename cimg::superset<T,float>::type restype; | |
21748 | return CImg<restype>(*this,false).invert(use_LU); | |
21749 | } | |
21750 | CImg<T>& invert(const bool use_LU=true) { | |
21751 | if (!is_empty()) { | |
21752 | if (width!=height || depth!=1 || dim!=1) | |
21753 | throw CImgInstanceException("CImg<%s>::invert() : Instance matrix (%u,%u,%u,%u,%p) is not square.", | |
21754 | pixel_type(),width,height,depth,dim,data); | |
21755 | const double dete = width>3?-1.0:det(); | |
21756 | if (dete!=0.0 && width==2) { | |
21757 | const double | |
21758 | a = data[0], c = data[1], | |
21759 | b = data[2], d = data[3]; | |
21760 | data[0] = (T)(d/dete); data[1] = (T)(-c/dete); | |
21761 | data[2] = (T)(-b/dete); data[3] = (T)(a/dete); | |
21762 | } else if (dete!=0.0 && width==3) { | |
21763 | const double | |
21764 | a = data[0], d = data[1], g = data[2], | |
21765 | b = data[3], e = data[4], h = data[5], | |
21766 | c = data[6], f = data[7], i = data[8]; | |
21767 | data[0] = (T)((i*e-f*h)/dete), data[1] = (T)((g*f-i*d)/dete), data[2] = (T)((d*h-g*e)/dete); | |
21768 | data[3] = (T)((h*c-i*b)/dete), data[4] = (T)((i*a-c*g)/dete), data[5] = (T)((g*b-a*h)/dete); | |
21769 | data[6] = (T)((b*f-e*c)/dete), data[7] = (T)((d*c-a*f)/dete), data[8] = (T)((a*e-d*b)/dete); | |
21770 | } else { | |
21771 | typedef typename cimg::superset<float,T>::type ftype; | |
21772 | if (use_LU) { | |
21773 | CImg<ftype> A(*this), indx, col(1,width); | |
21774 | bool d; | |
21775 | A._LU(indx,d); | |
21776 | for (int j = 0; j<(int)((*this).width); ++j) { | |
21777 | col.fill(0); | |
21778 | col(j) = 1; | |
21779 | col._solve(A,indx); | |
21780 | for (int i = 0; i<(int)((*this).width); ++i) (*this)(j,i) = (T)col(i); | |
21781 | } | |
21782 | } else { | |
21783 | CImg<ftype> U(width,width), S(1,width), V(width,width); | |
21784 | SVD(U,S,V,false); | |
21785 | U.transpose(); | |
21786 | for (int k = 0; k<(int)((S).height); ++k) if (S[k]!=0) S[k]=1/S[k]; | |
21787 | S.diagonal(); | |
21788 | *this = V*S*U; | |
21789 | } | |
21790 | } | |
21791 | } | |
21792 | return *this; | |
21793 | } | |
21794 | CImg<typename cimg::superset<T,float>::type> get_pseudoinvert() const { | |
21795 | typedef typename cimg::superset<T,float>::type restype; | |
21796 | CImg<restype> U, S, V; | |
21797 | SVD(U,S,V); | |
21798 | for (int x = 0; x<(int)((V).width); ++x) { | |
21799 | const float s = S(x), invs = s!=0.0f?1.0f/s:0.0f; | |
21800 | for (int y = 0; y<(int)((V).height); ++y) V(x,y)*=invs; | |
21801 | } | |
21802 | return V*U.transpose(); | |
21803 | } | |
21804 | CImg<T>& pseudoinvert() { | |
21805 | return get_pseudoinvert().transfer_to(*this); | |
21806 | } | |
21807 | template<typename t> CImg<typename cimg::superset<T,t>::type> get_cross(const CImg<t>& img) const { | |
21808 | typedef typename cimg::superset<T,t>::type restype; | |
21809 | return CImg<restype>(*this).cross(img); | |
21810 | } | |
21811 | template<typename t> CImg<T>& cross(const CImg<t>& img) { | |
21812 | if (width!=1 || height<3 || img.width!=1 || img.height<3) | |
21813 | throw CImgInstanceException("CImg<%s>::cross() : Arguments (%u,%u,%u,%u,%p) and (%u,%u,%u,%u,%p) must be both 3d vectors.", | |
21814 | pixel_type(),width,height,depth,dim,data,img.width,img.height,img.depth,img.dim,img.data); | |
21815 | const T x = (*this)[0], y = (*this)[1], z = (*this)[2]; | |
21816 | (*this)[0] = (T)(y*img[2]-z*img[1]); | |
21817 | (*this)[1] = (T)(z*img[0]-x*img[2]); | |
21818 | (*this)[2] = (T)(x*img[1]-y*img[0]); | |
21819 | return *this; | |
21820 | } | |
21821 | template<typename t> CImg<typename cimg::superset2<T,t,float>::type> get_solve(const CImg<t>& A) const { | |
21822 | typedef typename cimg::superset2<T,t,float>::type restype; | |
21823 | return CImg<restype>(*this,false).solve(A); | |
21824 | } | |
21825 | template<typename t> CImg<T>& solve(const CImg<t>& A) { | |
21826 | if (width!=1 || depth!=1 || dim!=1 || height!=A.height || A.depth!=1 || A.dim!=1) | |
21827 | throw CImgArgumentException("CImg<%s>::solve() : Instance matrix size is (%u,%u,%u,%u) while " | |
21828 | "size of given matrix A is (%u,%u,%u,%u).", | |
21829 | pixel_type(),width,height,depth,dim,A.width,A.height,A.depth,A.dim); | |
21830 | typedef typename cimg::superset2<T,t,float>::type ftype; | |
21831 | if (A.width==A.height) { | |
21832 | CImg<ftype> lu(A); | |
21833 | CImg<ftype> indx; | |
21834 | bool d; | |
21835 | lu._LU(indx,d); | |
21836 | _solve(lu,indx); | |
21837 | } else assign(A.get_pseudoinvert()*(*this)); | |
21838 | return *this; | |
21839 | } | |
21840 | template<typename t, typename ti> CImg<T>& _solve(const CImg<t>& A, const CImg<ti>& indx) { | |
21841 | typedef typename cimg::superset2<T,t,float>::type ftype; | |
21842 | const int N = size(); | |
21843 | int ii = -1; | |
21844 | ftype sum; | |
21845 | for (int i=0; i<N; ++i) { | |
21846 | const int ip = (int)indx[i]; | |
21847 | ftype sum = (*this)(ip); | |
21848 | (*this)(ip) = (*this)(i); | |
21849 | if (ii>=0) for (int j=ii; j<=i-1; ++j) sum-=A(j,i)*(*this)(j); | |
21850 | else if (sum!=0) ii=i; | |
21851 | (*this)(i) = (T)sum; | |
21852 | } | |
21853 | { for (int i=N-1; i>=0; --i) { | |
21854 | sum = (*this)(i); | |
21855 | for (int j=i+1; j<N; ++j) sum-=A(j,i)*(*this)(j); | |
21856 | (*this)(i) = (T)(sum/A(i,i)); | |
21857 | }} | |
21858 | return *this; | |
21859 | } | |
21860 | template<typename t> CImg<T> get_sort(CImg<t>& permutations, const bool increasing=true) const { | |
21861 | return (+*this).sort(permutations,increasing); | |
21862 | } | |
21863 | template<typename t> | |
21864 | CImg<T>& sort(CImg<t>& permutations, const bool increasing=true) { | |
21865 | if (is_empty()) permutations.assign(); | |
21866 | else { | |
21867 | if (permutations.size()!=size()) permutations.assign(size()); | |
21868 | for (unsigned int off = 0; off<(permutations).size(); ++off) permutations[off] = (t)off; | |
21869 | _quicksort(0,size()-1,permutations,increasing); | |
21870 | } | |
21871 | return *this; | |
21872 | } | |
21873 | CImg<T> get_sort(const bool increasing=true) const { | |
21874 | return (+*this).sort(increasing); | |
21875 | } | |
21876 | CImg<T>& sort(const bool increasing=true) { | |
21877 | CImg<T> foo; | |
21878 | return sort(foo,increasing); | |
21879 | } | |
21880 | template<typename t> CImg<T>& _quicksort(const int min, const int max, CImg<t>& permutations, const bool increasing) { | |
21881 | if (min<max) { | |
21882 | const int mid = (min+max)/2; | |
21883 | if (increasing) { | |
21884 | if ((*this)[min]>(*this)[mid]) { | |
21885 | cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); } | |
21886 | if ((*this)[mid]>(*this)[max]) { | |
21887 | cimg::swap((*this)[max],(*this)[mid]); cimg::swap(permutations[max],permutations[mid]); } | |
21888 | if ((*this)[min]>(*this)[mid]) { | |
21889 | cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); } | |
21890 | } else { | |
21891 | if ((*this)[min]<(*this)[mid]) { | |
21892 | cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); } | |
21893 | if ((*this)[mid]<(*this)[max]) { | |
21894 | cimg::swap((*this)[max],(*this)[mid]); cimg::swap(permutations[max],permutations[mid]); } | |
21895 | if ((*this)[min]<(*this)[mid]) { | |
21896 | cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); } | |
21897 | } | |
21898 | if (max-min>=3) { | |
21899 | const T pivot = (*this)[mid]; | |
21900 | int i = min, j = max; | |
21901 | if (increasing) { | |
21902 | do { | |
21903 | while ((*this)[i]<pivot) ++i; | |
21904 | while ((*this)[j]>pivot) --j; | |
21905 | if (i<=j) { | |
21906 | cimg::swap((*this)[i],(*this)[j]); | |
21907 | cimg::swap(permutations[i++],permutations[j--]); | |
21908 | } | |
21909 | } while (i<=j); | |
21910 | } else { | |
21911 | do { | |
21912 | while ((*this)[i]>pivot) ++i; | |
21913 | while ((*this)[j]<pivot) --j; | |
21914 | if (i<=j) { | |
21915 | cimg::swap((*this)[i],(*this)[j]); | |
21916 | cimg::swap(permutations[i++],permutations[j--]); | |
21917 | } | |
21918 | } while (i<=j); | |
21919 | } | |
21920 | if (min<j) _quicksort(min,j,permutations,increasing); | |
21921 | if (i<max) _quicksort(i,max,permutations,increasing); | |
21922 | } | |
21923 | } | |
21924 | return *this; | |
21925 | } | |
21926 | template<typename t> CImg<T> get_permute(const CImg<t>& permutation) const { | |
21927 | if (permutation.size()!=size()) | |
21928 | throw CImgArgumentException("CImg<%s>::permute() : Instance image (%u,%u,%u,%u,%p) and permutation (%u,%u,%u,%u,%p)" | |
21929 | "have different sizes.",pixel_type(), | |
21930 | width,height,depth,dim,data, | |
21931 | permutation.width,permutation.height,permutation.depth,permutation.dim,permutation.data); | |
21932 | CImg<T> res(width,height,depth,dim); | |
21933 | const t *p = permutation.ptr(permutation.size()); | |
21934 | for (T *ptr = (res).data + (res).size(); (ptr--)>(res).data; ) *ptr = (*this)[*(--p)]; | |
21935 | return res; | |
21936 | } | |
21937 | template<typename t> CImg<T>& permute(const CImg<t>& permutation) { | |
21938 | return get_permute(permutation).transfer_to(*this); | |
21939 | } | |
21940 | template<typename t> const CImg<T>& SVD(CImg<t>& U, CImg<t>& S, CImg<t>& V, | |
21941 | const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const { | |
21942 | if (is_empty()) { U.assign(); S.assign(); V.assign(); } | |
21943 | else { | |
21944 | U = *this; | |
21945 | if (lambda!=0.0f) { | |
21946 | const unsigned int delta = cimg::min(U.width,U.height); | |
21947 | for (unsigned int i=0; i<delta; ++i) U(i,i) = (t)(U(i,i) + lambda); | |
21948 | } | |
21949 | if (S.size()<width) S.assign(1,width); | |
21950 | if (V.width<width || V.height<height) V.assign(width,width); | |
21951 | CImg<t> rv1(width); | |
21952 | t anorm = 0, c, f, g = 0, h, s, scale = 0; | |
21953 | int l = 0, nm = 0; | |
21954 | for (int i = 0; i<(int)((U).width); ++i) { | |
21955 | l = i+1; rv1[i] = scale*g; g = s = scale = 0; | |
21956 | if (i<dimy()) { | |
21957 | for (int k=i; k<dimy(); ++k) scale+= cimg::abs(U(i,k)); | |
21958 | if (scale) { | |
21959 | for (int k=i; k<dimy(); ++k) { U(i,k)/=scale; s+= U(i,k)*U(i,k); } | |
21960 | f = U(i,i); g = (t)((f>=0?-1:1)*std::sqrt(s)); h=f*g-s; U(i,i) = f-g; | |
21961 | for (int j=l; j<dimx(); ++j) { | |
21962 | s = 0; for (int k=i; k<dimy(); ++k) s+= U(i,k)*U(j,k); | |
21963 | f = s/h; | |
21964 | { for (int k=i; k<dimy(); ++k) U(j,k)+= f*U(i,k); } | |
21965 | } | |
21966 | { for (int k=i; k<dimy(); ++k) U(i,k)*= scale; } | |
21967 | } | |
21968 | } | |
21969 | S[i]=scale*g; | |
21970 | g = s = scale = 0; | |
21971 | if (i<dimy() && i!=dimx()-1) { | |
21972 | for (int k=l; k<dimx(); ++k) scale += cimg::abs(U(k,i)); | |
21973 | if (scale) { | |
21974 | for (int k=l; k<dimx(); ++k) { U(k,i)/= scale; s+= U(k,i)*U(k,i); } | |
21975 | f = U(l,i); g = (t)((f>=0?-1:1)*std::sqrt(s)); h = f*g-s; U(l,i) = f-g; | |
21976 | { for (int k=l; k<dimx(); ++k) rv1[k]=U(k,i)/h; } | |
21977 | for (int j=l; j<dimy(); ++j) { | |
21978 | s = 0; for (int k=l; k<dimx(); ++k) s+= U(k,j)*U(k,i); | |
21979 | { for (int k=l; k<dimx(); ++k) U(k,j)+= s*rv1[k]; } | |
21980 | } | |
21981 | { for (int k=l; k<dimx(); ++k) U(k,i)*= scale; } | |
21982 | } | |
21983 | } | |
21984 | anorm = (t)cimg::max((float)anorm,(float)(cimg::abs(S[i])+cimg::abs(rv1[i]))); | |
21985 | } | |
21986 | { for (int i=dimx()-1; i>=0; --i) { | |
21987 | if (i<dimx()-1) { | |
21988 | if (g) { | |
21989 | { for (int j=l; j<dimx(); ++j) V(i,j) =(U(j,i)/U(l,i))/g; } | |
21990 | for (int j=l; j<dimx(); ++j) { | |
21991 | s = 0; for (int k=l; k<dimx(); ++k) s+= U(k,i)*V(j,k); | |
21992 | { for (int k=l; k<dimx(); ++k) V(j,k)+= s*V(i,k); } | |
21993 | } | |
21994 | } | |
21995 | for (int j=l; j<dimx(); ++j) V(j,i) = V(i,j) = (t)0.0; | |
21996 | } | |
21997 | V(i,i) = (t)1.0; g = rv1[i]; l = i; | |
21998 | } | |
21999 | } | |
22000 | { for (int i=cimg::min(dimx(),dimy())-1; i>=0; --i) { | |
22001 | l = i+1; g = S[i]; | |
22002 | for (int j=l; j<dimx(); ++j) U(j,i) = 0; | |
22003 | if (g) { | |
22004 | g = 1/g; | |
22005 | for (int j=l; j<dimx(); ++j) { | |
22006 | s = 0; for (int k=l; k<dimy(); ++k) s+= U(i,k)*U(j,k); | |
22007 | f = (s/U(i,i))*g; | |
22008 | { for (int k=i; k<dimy(); ++k) U(j,k)+= f*U(i,k); } | |
22009 | } | |
22010 | { for (int j=i; j<dimy(); ++j) U(i,j)*= g; } | |
22011 | } else for (int j=i; j<dimy(); ++j) U(i,j) = 0; | |
22012 | ++U(i,i); | |
22013 | } | |
22014 | } | |
22015 | for (int k=dimx()-1; k>=0; --k) { | |
22016 | for (unsigned int its=0; its<max_iter; ++its) { | |
22017 | bool flag = true; | |
22018 | for (l=k; l>=1; --l) { | |
22019 | nm = l-1; | |
22020 | if ((cimg::abs(rv1[l])+anorm)==anorm) { flag = false; break; } | |
22021 | if ((cimg::abs(S[nm])+anorm)==anorm) break; | |
22022 | } | |
22023 | if (flag) { | |
22024 | c = 0; s = 1; | |
22025 | for (int i=l; i<=k; ++i) { | |
22026 | f = s*rv1[i]; rv1[i] = c*rv1[i]; | |
22027 | if ((cimg::abs(f)+anorm)==anorm) break; | |
22028 | g = S[i]; h = (t)cimg::pythagore(f,g); S[i] = h; h = 1/h; c = g*h; s = -f*h; | |
22029 | for (int j = 0; j<(int)((U).height); ++j) { const t y = U(nm,j), z = U(i,j); U(nm,j) = y*c+z*s; U(i,j) = z*c-y*s; } | |
22030 | } | |
22031 | } | |
22032 | const t z = S[k]; | |
22033 | if (l==k) { if (z<0) { S[k] = -z; for (int j = 0; j<(int)((U).width); ++j) V(k,j) = -V(k,j); } break; } | |
22034 | nm = k-1; | |
22035 | t x = S[l], y = S[nm]; | |
22036 | g = rv1[nm]; h = rv1[k]; | |
22037 | f = ((y-z)*(y+z)+(g-h)*(g+h))/(2*h*y); | |
22038 | g = (t)cimg::pythagore(f,1.0); | |
22039 | f = ((x-z)*(x+z)+h*((y/(f+ (f>=0?g:-g)))-h))/x; | |
22040 | c = s = 1; | |
22041 | for (int j=l; j<=nm; ++j) { | |
22042 | const int i = j+1; | |
22043 | g = rv1[i]; h = s*g; g = c*g; | |
22044 | t y = S[i]; | |
22045 | t z = (t)cimg::pythagore(f,h); | |
22046 | rv1[j] = z; c = f/z; s = h/z; | |
22047 | f = x*c+g*s; g = g*c-x*s; h = y*s; y*=c; | |
22048 | for (int jj = 0; jj<(int)((U).width); ++jj) { const t x = V(j,jj), z = V(i,jj); V(j,jj) = x*c+z*s; V(i,jj) = z*c-x*s; } | |
22049 | z = (t)cimg::pythagore(f,h); S[j] = z; | |
22050 | if (z) { z = 1/z; c = f*z; s = h*z; } | |
22051 | f = c*g+s*y; x = c*y-s*g; | |
22052 | { for (int jj = 0; jj<(int)((U).height); ++jj) { const t y = U(j,jj); z = U(i,jj); U(j,jj) = y*c+z*s; U(i,jj) = z*c-y*s; }} | |
22053 | } | |
22054 | rv1[l] = 0; rv1[k]=f; S[k]=x; | |
22055 | } | |
22056 | } | |
22057 | if (sorting) { | |
22058 | CImg<int> permutations(width); | |
22059 | CImg<t> tmp(width); | |
22060 | S.sort(permutations,false); | |
22061 | for (int k = 0; k<(int)((U).height); ++k) { | |
22062 | for (int x = 0; x<(int)((permutations).width); ++x) tmp(x) = U(permutations(x),k); | |
22063 | std::memcpy(U.ptr(0,k),tmp.data,sizeof(t)*width); | |
22064 | } | |
22065 | { for (int k = 0; k<(int)((V).height); ++k) { | |
22066 | for (int x = 0; x<(int)((permutations).width); ++x) tmp(x) = V(permutations(x),k); | |
22067 | std::memcpy(V.ptr(0,k),tmp.data,sizeof(t)*width); | |
22068 | }} | |
22069 | } | |
22070 | } | |
22071 | return *this; | |
22072 | } | |
22073 | template<typename t> const CImg<T>& SVD(CImgList<t>& USV) const { | |
22074 | if (USV.size<3) USV.assign(3); | |
22075 | return SVD(USV[0],USV[1],USV[2]); | |
22076 | } | |
22077 | CImgList<typename cimg::superset<T,float>::type> get_SVD(const bool sorting=true) const { | |
22078 | typedef typename cimg::superset<T,float>::type restype; | |
22079 | CImgList<restype> res(3); | |
22080 | SVD(res[0],res[1],res[2],sorting); | |
22081 | return res; | |
22082 | } | |
22083 | template<typename t> CImg<T>& _LU(CImg<t>& indx, bool& d) { | |
22084 | typedef typename cimg::superset<T,float>::type ftype; | |
22085 | const int N = dimx(); | |
22086 | int imax = 0; | |
22087 | CImg<ftype> vv(N); | |
22088 | indx.assign(N); | |
22089 | d = true; | |
22090 | for (int i = 0; i<(int)((*this).width); ++i) { | |
22091 | ftype vmax = 0; | |
22092 | for (int j = 0; j<(int)((*this).width); ++j) { | |
22093 | const ftype tmp = cimg::abs((*this)(j,i)); | |
22094 | if (tmp>vmax) vmax = tmp; | |
22095 | } | |
22096 | if (vmax==0) { indx.fill(0); return fill(0); } | |
22097 | vv[i] = 1/vmax; | |
22098 | } | |
22099 | for (int j = 0; j<(int)((*this).width); ++j) { | |
22100 | for (int i=0; i<j; ++i) { | |
22101 | ftype sum=(*this)(j,i); | |
22102 | for (int k=0; k<i; ++k) sum-=(*this)(k,i)*(*this)(j,k); | |
22103 | (*this)(j,i) = (T)sum; | |
22104 | } | |
22105 | ftype vmax = 0; | |
22106 | { for (int i=j; i<dimx(); ++i) { | |
22107 | ftype sum=(*this)(j,i); | |
22108 | for (int k=0; k<j; ++k) sum-=(*this)(k,i)*(*this)(j,k); | |
22109 | (*this)(j,i) = (T)sum; | |
22110 | const ftype tmp = vv[i]*cimg::abs(sum); | |
22111 | if (tmp>=vmax) { vmax=tmp; imax=i; } | |
22112 | }} | |
22113 | if (j!=imax) { | |
22114 | for (int k = 0; k<(int)((*this).width); ++k) cimg::swap((*this)(k,imax),(*this)(k,j)); | |
22115 | d =!d; | |
22116 | vv[imax] = vv[j]; | |
22117 | } | |
22118 | indx[j] = (t)imax; | |
22119 | if ((*this)(j,j)==0) (*this)(j,j) = (T)1e-20; | |
22120 | if (j<N) { | |
22121 | const ftype tmp = 1/(ftype)(*this)(j,j); | |
22122 | for (int i=j+1; i<N; ++i) (*this)(j,i) = (T)((*this)(j,i)*tmp); | |
22123 | } | |
22124 | } | |
22125 | return *this; | |
22126 | } | |
22127 | CImgList<typename cimg::superset<T,float>::type> get_eigen() const { | |
22128 | typedef typename cimg::superset<T,float>::type restype; | |
22129 | CImgList<restype> res(2); | |
22130 | eigen(res[0],res[1]); | |
22131 | return res; | |
22132 | } | |
22133 | template<typename t> const CImg<T>& eigen(CImg<t>& val, CImg<t> &vec) const { | |
22134 | if (is_empty()) { val.assign(); vec.assign(); } | |
22135 | else { | |
22136 | if (width!=height || depth>1 || dim>1) | |
22137 | throw CImgInstanceException("CImg<%s>::eigen() : Instance object (%u,%u,%u,%u,%p) is empty.", | |
22138 | pixel_type(),width,height,depth,dim,data); | |
22139 | if (val.size()<width) val.assign(1,width); | |
22140 | if (vec.size()<width*width) vec.assign(width,width); | |
22141 | switch(width) { | |
22142 | case 1: { val[0]=(t)(*this)[0]; vec[0]=(t)1; } break; | |
22143 | case 2: { | |
22144 | const double a = (*this)[0], b = (*this)[1], c = (*this)[2], d = (*this)[3], e = a+d; | |
22145 | double f = e*e-4*(a*d-b*c); | |
22146 | if (f<0) cimg::warn("CImg<%s>::eigen() : Complex eigenvalues",pixel_type()); | |
22147 | f = std::sqrt(f); | |
22148 | const double l1 = 0.5*(e-f), l2 = 0.5*(e+f); | |
22149 | const double theta1 = std::atan2(l2-a,b), theta2 = std::atan2(l1-a,b); | |
22150 | val[0]=(t)l2; | |
22151 | val[1]=(t)l1; | |
22152 | vec(0,0) = (t)std::cos(theta1); | |
22153 | vec(0,1) = (t)std::sin(theta1); | |
22154 | vec(1,0) = (t)std::cos(theta2); | |
22155 | vec(1,1) = (t)std::sin(theta2); | |
22156 | } break; | |
22157 | default: | |
22158 | throw CImgInstanceException("CImg<%s>::eigen() : Eigenvalues computation of general matrices is limited" | |
22159 | "to 2x2 matrices (given is %ux%u)", pixel_type(),width,height); | |
22160 | } | |
22161 | } | |
22162 | return *this; | |
22163 | } | |
22164 | CImgList<typename cimg::superset<T,float>::type> get_symmetric_eigen() const { | |
22165 | typedef typename cimg::superset<T,float>::type restype; | |
22166 | CImgList<restype> res(2); | |
22167 | symmetric_eigen(res[0],res[1]); | |
22168 | return res; | |
22169 | } | |
22170 | template<typename t> const CImg<T>& symmetric_eigen(CImg<t>& val, CImg<t>& vec) const { | |
22171 | if (is_empty()) { val.assign(); vec.assign(); } | |
22172 | else { | |
22173 | if (width!=height || depth>1 || dim>1) | |
22174 | throw CImgInstanceException("CImg<%s>::eigen() : Instance object (%u,%u,%u,%u,%p) is empty.", | |
22175 | pixel_type(),width,height,depth,dim,data); | |
22176 | if (val.size()<width) val.assign(1,width); | |
22177 | if (vec.data && vec.size()<width*width) vec.assign(width,width); | |
22178 | if (width<3) return eigen(val,vec); | |
22179 | CImg<t> V(width,width); | |
22180 | SVD(vec,val,V,false); | |
22181 | bool ambiguous = false; | |
22182 | float eig = 0; | |
22183 | for (int p = 0; p<(int)((val).height); ++p) { | |
22184 | if (val[p]>eig) eig = (float)val[p]; | |
22185 | t scal = 0; | |
22186 | for (int y = 0; y<(int)((vec).height); ++y) scal+=vec(p,y)*V(p,y); | |
22187 | if (cimg::abs(scal)<0.9f) ambiguous = true; | |
22188 | if (scal<0) val[p] = -val[p]; | |
22189 | } | |
22190 | if (ambiguous) { | |
22191 | (eig*=2)++; | |
22192 | SVD(vec,val,V,false,40,eig); | |
22193 | val-=eig; | |
22194 | } | |
22195 | CImg<int> permutations(width); | |
22196 | CImg<t> tmp(width); | |
22197 | val.sort(permutations,false); | |
22198 | for (int k = 0; k<(int)((vec).height); ++k) { | |
22199 | for (int x = 0; x<(int)((permutations).width); ++x) tmp(x) = vec(permutations(x),k); | |
22200 | std::memcpy(vec.ptr(0,k),tmp.data,sizeof(t)*width); | |
22201 | } | |
22202 | } | |
22203 | return *this; | |
22204 | } | |
22205 | const CImg<T>& display(CImgDisplay& disp) const { | |
22206 | disp.display(*this); | |
22207 | return *this; | |
22208 | } | |
22209 | const CImg<T>& display(const char *const title, const int min_size=128, const int max_size=1024, | |
22210 | const int print_flag=1) const { | |
22211 | if (is_empty()) | |
22212 | throw CImgInstanceException("CImg<%s>::display() : Instance image (%u,%u,%u,%u,%p) is empty.", | |
22213 | pixel_type(),width,height,depth,dim,data); | |
22214 | CImgDisplay disp; | |
22215 | unsigned int w = width+(depth>1?depth:0), h = height+(depth>1?depth:0), XYZ[3]; | |
22216 | print(title,print_flag); | |
22217 | const unsigned int dmin = cimg::min(w,h), minsiz = min_size>=0?min_size:(-min_size)*dmin/100; | |
22218 | if (dmin<minsiz) { w=w*minsiz/dmin; w+=(w==0); h=h*minsiz/dmin; h+=(h==0); } | |
22219 | const unsigned int dmax = cimg::max(w,h), maxsiz = max_size>=0?max_size:(-max_size)*dmax/100; | |
22220 | if (dmax>maxsiz) { w=w*maxsiz/dmax; w+=(w==0); h=h*maxsiz/dmax; h+=(h==0); } | |
22221 | disp.assign(w,h,title,1,3); | |
22222 | XYZ[0] = width/2; XYZ[1] = height/2; XYZ[2] = depth/2; | |
22223 | while (!disp.is_closed && !disp.key) get_coordinates(1,disp,XYZ); | |
22224 | return *this; | |
22225 | } | |
22226 | const CImg<T>& display(const int min_size=128, const int max_size=1024, const int print_flag=1) const { | |
22227 | char title[256] = { 0 }; | |
22228 | std::sprintf(title,"CImg<%s>",pixel_type()); | |
22229 | return display(title,min_size,max_size,print_flag); | |
22230 | } | |
22231 | CImg<typename cimg::last<T,int>::type> get_coordinates(const int coords_type, CImgDisplay &disp, | |
22232 | unsigned int *const XYZ=0, const unsigned char *const color=0) const { | |
22233 | typedef typename cimg::last<T,unsigned char>::type uchar; | |
22234 | if (is_empty()) throw CImgInstanceException("CImg<%s>::get_coordinates() : Instance image (%u,%u,%u,%u,%p) is empty.", | |
22235 | pixel_type(),width,height,depth,dim,data); | |
22236 | const unsigned int | |
22237 | old_events = disp.events, | |
22238 | old_normalization = disp.normalization, | |
22239 | hatch = 0x55555555; | |
22240 | bool old_is_resized = disp.is_resized; | |
22241 | disp.events = 3; | |
22242 | disp.normalization = 0; | |
22243 | disp.show().key = 0; | |
22244 | unsigned char fgcolor[] = { 255,255,105 }, bgcolor[] = { 0,0,0 }; | |
22245 | if (color) std::memcpy(fgcolor,color,sizeof(unsigned char)*cimg::min(3,dimv())); | |
22246 | int area = 0, clicked_area = 0, phase = 0, | |
22247 | X0 = (int)((XYZ?XYZ[0]:width/2)%width), Y0 = (int)((XYZ?XYZ[1]:height/2)%height), Z0 = (int)((XYZ?XYZ[2]:depth/2)%depth), | |
22248 | X1 =-1, Y1 = -1, Z1 = -1, | |
22249 | X = -1, Y = -1, Z = -1, | |
22250 | oX = X, oY = Y, oZ = Z; | |
22251 | unsigned int old_button = 0, key = 0; | |
22252 | bool shape_selected = false, text_down = false; | |
22253 | CImg<uchar> visu, visu0; | |
22254 | char text[1024] = { 0 }; | |
22255 | while (!key && !disp.is_closed && !shape_selected) { | |
22256 | oX = X; oY = Y; oZ = Z; | |
22257 | int mx = disp.mouse_x, my = disp.mouse_y; | |
22258 | const int mX = mx*(width+(depth>1?depth:0))/disp.width, mY = my*(height+(depth>1?depth:0))/disp.height; | |
22259 | area = 0; | |
22260 | if (mX<dimx() && mY<dimy()) { area = 1; X = mX; Y = mY; Z = phase?Z1:Z0; } | |
22261 | if (mX<dimx() && mY>=dimy()) { area = 2; X = mX; Z = mY-height; Y = phase?Y1:Y0; } | |
22262 | if (mX>=dimx() && mY<dimy()) { area = 3; Y = mY; Z = mX-width; X = phase?X1:X0; } | |
22263 | key = disp.key; | |
22264 | if (key && key!=cimg::keyCTRLLEFT) { | |
22265 | if (disp.is_key(cimg::keyCTRLLEFT,true)) { | |
22266 | switch (key) { | |
22267 | case cimg::keyARROWLEFT: | |
22268 | case cimg::keyARROWDOWN: --disp.wheel; break; | |
22269 | case cimg::keyARROWRIGHT: | |
22270 | case cimg::keyARROWUP: ++disp.wheel; break; | |
22271 | case cimg::keyD: if (disp.is_fullscreen) disp.toggle_fullscreen(); disp.resize(-200,-200); disp.is_resized = true; break; | |
22272 | case cimg::keyC: if (disp.is_fullscreen) disp.toggle_fullscreen(); disp.resize(-50,-50); disp.is_resized = true; break; | |
22273 | case cimg::keyR: if (disp.is_fullscreen) disp.toggle_fullscreen(); disp.resize(*this); disp.is_resized = true; break; | |
22274 | case cimg::keyF: | |
22275 | disp.resize(disp.screen_dimx(),disp.screen_dimy()).toggle_fullscreen(); | |
22276 | disp.is_resized = true; | |
22277 | break; | |
22278 | case cimg::keyS: { | |
22279 | static unsigned int snap_number = 0; | |
22280 | char filename[32] = { 0 }; | |
22281 | std::FILE *file; | |
22282 | do { | |
22283 | std::sprintf(filename,"CImg_%.4u.bmp",snap_number++); | |
22284 | if ((file=std::fopen(filename,"r"))!=0) std::fclose(file); | |
22285 | } while (file); | |
22286 | if (visu0) { | |
22287 | visu.draw_text(2,2,fgcolor,bgcolor,11,0.8f,"Saving snapshot...").display(disp); | |
22288 | visu0.save(filename); | |
22289 | visu.draw_text(2,2,fgcolor,bgcolor,11,0.8f,"Snapshot '%s' saved.",filename).display(disp); | |
22290 | } | |
22291 | } break; | |
22292 | case cimg::keyO: { | |
22293 | static unsigned int snap_number = 0; | |
22294 | char filename[32] = { 0 }; | |
22295 | std::FILE *file; | |
22296 | do { | |
22297 | std::sprintf(filename,"CImg_%.4u.cimg",snap_number++); | |
22298 | if ((file=std::fopen(filename,"r"))!=0) std::fclose(file); | |
22299 | } while (file); | |
22300 | visu.draw_text(2,2,fgcolor,bgcolor,11,0.8f,"Saving instance...").display(disp); | |
22301 | save(filename); | |
22302 | visu.draw_text(2,2,fgcolor,bgcolor,11,0.8f,"Instance '%s' saved.",filename).display(disp); | |
22303 | } break; | |
22304 | default: break; | |
22305 | } | |
22306 | key = disp.key = 0; | |
22307 | } | |
22308 | } else key = 0; | |
22309 | if (!area) mx = my = X = Y = Z = -1; | |
22310 | else { | |
22311 | if (disp.button&1 && phase<2) { X1 = X; Y1 = Y; Z1 = Z; } | |
22312 | if (!(disp.button&1) && phase>=2) { | |
22313 | switch (clicked_area) { | |
22314 | case 1: Z1 = Z; break; | |
22315 | case 2: Y1 = Y; break; | |
22316 | case 3: X1 = X; break; | |
22317 | } | |
22318 | } | |
22319 | if (disp.button&2) { if (phase) { X1 = X; Y1 = Y; Z1 = Z; } else { X0 = X; Y0 = Y; Z0 = Z; } } | |
22320 | if (disp.button&4) { oX = X = X0; oY = Y = Y0; oZ = Z = Z0; phase = 0; visu.assign(); } | |
22321 | if (disp.wheel) { | |
22322 | switch (area) { | |
22323 | case 1: if (phase) Z = (Z1+=disp.wheel); else Z = (Z0+=disp.wheel); break; | |
22324 | case 2: if (phase) Y = (Y1+=disp.wheel); else Y = (Y0+=disp.wheel); break; | |
22325 | case 3: if (phase) X = (X1+=disp.wheel); else X = (X0+=disp.wheel); break; | |
22326 | default: break; | |
22327 | } | |
22328 | disp.wheel = 0; | |
22329 | } | |
22330 | if ((disp.button&1)!=old_button) { | |
22331 | switch (phase++) { | |
22332 | case 0: X0 = X1 = X; Y0 = Y1 = Y; Z0 = Z1 = Z; clicked_area = area; break; | |
22333 | case 1: X1 = X; Y1 = Y; Z1 = Z; break; | |
22334 | default: break; | |
22335 | } | |
22336 | old_button = disp.button&1; | |
22337 | } | |
22338 | if (depth>1 && (X!=oX || Y!=oY || Z!=oZ)) visu0.assign(); | |
22339 | } | |
22340 | if (phase) { | |
22341 | if (!coords_type) shape_selected = phase?true:false; | |
22342 | else { | |
22343 | if (depth>1) shape_selected = (phase==3)?true:false; | |
22344 | else shape_selected = (phase==2)?true:false; | |
22345 | } | |
22346 | } | |
22347 | if (X0<0) X0 = 0; if (X0>=dimx()) X0 = dimx()-1; if (Y0<0) Y0 = 0; if (Y0>=dimy()) Y0 = dimy()-1; | |
22348 | if (Z0<0) Z0 = 0; if (Z0>=dimz()) Z0 = dimz()-1; | |
22349 | if (X1<1) X1 = 0; if (X1>=dimx()) X1 = dimx()-1; if (Y1<0) Y1 = 0; if (Y1>=dimy()) Y1 = dimy()-1; | |
22350 | if (Z1<0) Z1 = 0; if (Z1>=dimz()) Z1 = dimz()-1; | |
22351 | if (oX!=X || oY!=Y || oZ!=Z || !visu0) { | |
22352 | if (!visu0) { | |
22353 | typedef typename cimg::superset<T,unsigned char>::type nT; | |
22354 | CImg<nT> tmp, tmp0; | |
22355 | if (depth!=1) { | |
22356 | tmp0 = (!phase)?get_projections2d(X0,Y0,Z0):get_projections2d(X1,Y1,Z1); | |
22357 | tmp = tmp0.get_channels(0,cimg::min(2U,dim-1)); | |
22358 | } else tmp = get_channels(0,cimg::min(2U,dim-1)); | |
22359 | switch (old_normalization) { | |
22360 | case 0: visu0 = tmp; break; | |
22361 | case 3: | |
22362 | if (cimg::type<T>::is_float()) visu0 = tmp.normalize(0,(T)255); | |
22363 | else { | |
22364 | const float m = (float)cimg::type<T>::min(), M = (float)cimg::type<T>::max(); | |
22365 | visu0.assign(tmp.width,tmp.height,1,tmp.dim); | |
22366 | unsigned char *ptrd = visu0.end(); | |
22367 | for (nT *ptrs = (tmp).data + (tmp).size(); (ptrs--)>(tmp).data; ) *(--ptrd) = (unsigned char)((*ptrs-m)*255.0f/(M-m)); | |
22368 | } break; | |
22369 | default: visu0 = tmp.normalize(0,255); break; | |
22370 | } | |
22371 | visu0.resize(disp); | |
22372 | } | |
22373 | visu = visu0; | |
22374 | if (!color) { | |
22375 | if (visu.mean()<200) { fgcolor[0] = fgcolor[1] = fgcolor[2] = 255; bgcolor[0] = bgcolor[1] = bgcolor[2] = 0; } | |
22376 | else { fgcolor[0] = fgcolor[1] = fgcolor[2] = 0; bgcolor[0] = bgcolor[1] = bgcolor[2] = 255; } | |
22377 | } | |
22378 | const int d = (depth>1)?depth:0; | |
22379 | if (phase) switch (coords_type) { | |
22380 | case 1: { | |
22381 | const int | |
22382 | x0 =(int)((X0+0.5f)*disp.width/(width+d)), y0 = (int)((Y0+0.5f)*disp.height/(height+d)), | |
22383 | x1 =(int)((X1+0.5f)*disp.width/(width+d)), y1 = (int)((Y1+0.5f)*disp.height/(height+d)); | |
22384 | visu.draw_arrow(x0,y0,x1,y1,fgcolor,30.0f,5.0f,1.0f,hatch); | |
22385 | if (d) { | |
22386 | const int | |
22387 | zx0 = (int)((width+Z0+0.5f)*disp.width/(width+d)), zx1 = (int)((width+Z1+0.5f)*disp.width/(width+d)), | |
22388 | zy0 = (int)((height+Z0+0.5f)*disp.height/(height+d)), zy1 = (int)((height+Z1+0.5f)*disp.height/(height+d)); | |
22389 | visu.draw_arrow(zx0,y0,zx1,y1,fgcolor,30.0f,5.0f,1.0f,hatch).draw_arrow(x0,zy0,x1,zy1,fgcolor,30.0f,5.0f,1.0f,hatch); | |
22390 | } | |
22391 | } break; | |
22392 | case 2: { | |
22393 | const int | |
22394 | x0=(X0<X1?X0:X1)*disp.width/(width+d), | |
22395 | y0=(Y0<Y1?Y0:Y1)*disp.height/(height+d), | |
22396 | x1=((X0<X1?X1:X0)+1)*disp.width/(width+d)-1, | |
22397 | y1=((Y0<Y1?Y1:Y0)+1)*disp.height/(height+d)-1; | |
22398 | visu.draw_rectangle(x0,y0,x1,y1,fgcolor,0.2f).draw_line(x0,y0,x1,y0,fgcolor,1.0f,hatch). | |
22399 | draw_line(x1,y0,x1,y1,fgcolor,1.0f,hatch).draw_line(x1,y1,x0,y1,fgcolor,1.0f,hatch). | |
22400 | draw_line(x0,y1,x0,y0,fgcolor,1.0f,hatch); | |
22401 | if (d) { | |
22402 | const int | |
22403 | zx0=(int)((width+(Z0<Z1?Z0:Z1))*disp.width/(width+d)), | |
22404 | zy0=(int)((height+(Z0<Z1?Z0:Z1))*disp.height/(height+d)), | |
22405 | zx1=(int)((width+(Z0<Z1?Z1:Z0)+1)*disp.width/(width+d))-1, | |
22406 | zy1=(int)((height+(Z0<Z1?Z1:Z0)+1)*disp.height/(height+d))-1; | |
22407 | visu.draw_rectangle(zx0,y0,zx1,y1,fgcolor,0.2f).draw_line(zx0,y0,zx1,y0,fgcolor,1.0f,hatch). | |
22408 | draw_line(zx1,y0,zx1,y1,fgcolor,1.0f,hatch).draw_line(zx1,y1,zx0,y1,fgcolor,1.0f,hatch). | |
22409 | draw_line(zx0,y1,zx0,y0,fgcolor,1.0f,hatch); | |
22410 | visu.draw_rectangle(x0,zy0,x1,zy1,fgcolor,0.2f).draw_line(x0,zy0,x1,zy0,fgcolor,1.0f,hatch). | |
22411 | draw_line(x1,zy0,x1,zy1,fgcolor,1.0f,hatch).draw_line(x1,zy1,x0,zy1,fgcolor,1.0f,hatch). | |
22412 | draw_line(x0,zy1,x0,zy0,fgcolor,1.0f,hatch); | |
22413 | } | |
22414 | } break; | |
22415 | case 3: { | |
22416 | const int | |
22417 | x0=X0*disp.width/(width+d), | |
22418 | y0=Y0*disp.height/(height+d), | |
22419 | x1=X1*disp.width/(width+d)-1, | |
22420 | y1=Y1*disp.height/(height+d)-1; | |
22421 | visu.draw_ellipse(x0,y0,(float)(x1-x0),(float)(y1-y0),1.0f,0.0f,fgcolor,0.2f). | |
22422 | draw_ellipse(x0,y0,(float)(x1-x0),(float)(y1-y0),1.0f,0.0f,fgcolor,1.0f,hatch); | |
22423 | if (d) { | |
22424 | const int | |
22425 | zx0=(int)((width+Z0)*disp.width/(width+d)), | |
22426 | zy0=(int)((height+Z0)*disp.height/(height+d)), | |
22427 | zx1=(int)((width+Z1+1)*disp.width/(width+d))-1, | |
22428 | zy1=(int)((height+Z1+1)*disp.height/(height+d))-1; | |
22429 | visu.draw_ellipse(zx0,y0,(float)(zx1-zx0),(float)(y1-y0),1.0f,0.0f,fgcolor,0.2f). | |
22430 | draw_ellipse(zx0,y0,(float)(zx1-zx0),(float)(y1-y0),1.0f,0.0f,fgcolor,1.0f,hatch). | |
22431 | draw_ellipse(x0,zy0,(float)(x1-x0),(float)(zy1-zy0),1.0f,0.0f,fgcolor,0.2f). | |
22432 | draw_ellipse(x0,zy0,(float)(x1-x0),(float)(zy1-zy0),1.0f,0.0f,fgcolor,1.0f,hatch); | |
22433 | } | |
22434 | } break; | |
22435 | } | |
22436 | if (my<12) text_down = true; | |
22437 | if (my>=visu.dimy()-11) text_down = false; | |
22438 | if (!coords_type || !phase) { | |
22439 | if (X>=0 && Y>=0 && Z>=0 && X<dimx() && Y<dimy() && Z<dimz()) { | |
22440 | if (depth>1) std::sprintf(text,"Point (%d,%d,%d)={ ",X,Y,Z); else std::sprintf(text,"Point (%d,%d)={ ",X,Y); | |
22441 | char *ctext = text + cimg::strlen(text), *const ltext = text + 512; | |
22442 | for (unsigned int k=0; k<dim && ctext<ltext; ++k) { | |
22443 | std::sprintf(ctext,cimg::type<T>::format(),cimg::type<T>::format((*this)(X,Y,Z,k))); | |
22444 | ctext = text + cimg::strlen(text); | |
22445 | *(ctext++) = ' '; *ctext = '\0'; | |
22446 | } | |
22447 | std::sprintf(text + cimg::strlen(text),"}"); | |
22448 | } | |
22449 | } else switch (coords_type) { | |
22450 | case 1: { | |
22451 | const double dX=(double)(X0-X1), dY=(double)(Y0-Y1), dZ=(double)(Z0-Z1), norm = std::sqrt(dX*dX+dY*dY+dZ*dZ); | |
22452 | if (depth>1) std::sprintf(text,"Vect (%d,%d,%d)-(%d,%d,%d), norm=%g",X0,Y0,Z0,X1,Y1,Z1,norm); | |
22453 | else std::sprintf(text,"Vect (%d,%d)-(%d,%d), norm=%g",X0,Y0,X1,Y1,norm); | |
22454 | } break; | |
22455 | case 2: | |
22456 | if (depth>1) std::sprintf(text,"Box (%d,%d,%d)-(%d,%d,%d), Size=(%d,%d,%d)", | |
22457 | X0<X1?X0:X1,Y0<Y1?Y0:Y1,Z0<Z1?Z0:Z1, | |
22458 | X0<X1?X1:X0,Y0<Y1?Y1:Y0,Z0<Z1?Z1:Z0, | |
22459 | 1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1),1+cimg::abs(Z0-Z1)); | |
22460 | else std::sprintf(text,"Box (%d,%d)-(%d,%d), Size=(%d,%d)", | |
22461 | X0<X1?X0:X1,Y0<Y1?Y0:Y1,X0<X1?X1:X0,Y0<Y1?Y1:Y0,1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1)); | |
22462 | break; | |
22463 | default: | |
22464 | if (depth>1) std::sprintf(text,"Ellipse (%d,%d,%d)-(%d,%d,%d), Radii=(%d,%d,%d)", | |
22465 | X0,Y0,Z0,X1,Y1,Z1,1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1),1+cimg::abs(Z0-Z1)); | |
22466 | else std::sprintf(text,"Ellipse (%d,%d)-(%d,%d), Radii=(%d,%d)", | |
22467 | X0,Y0,X1,Y1,1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1)); | |
22468 | break; | |
22469 | } | |
22470 | if (phase || (mx>=0 && my>=0)) visu.draw_text(text,0,text_down?visu.dimy()-11:0,fgcolor,bgcolor,11,0.7f); | |
22471 | disp.display(visu).wait(25); | |
22472 | } else if (!shape_selected) disp.wait(); | |
22473 | if (disp.is_resized) { disp.resize(false); old_is_resized = true; disp.is_resized = false; visu0.assign(); } | |
22474 | } | |
22475 | typedef typename cimg::last<T,int>::type restype; | |
22476 | CImg<restype> res(1,6,1,1,(restype)-1); | |
22477 | if (XYZ) { XYZ[0] = (unsigned int)X0; XYZ[1] = (unsigned int)Y0; XYZ[2] = (unsigned int)Z0; } | |
22478 | if (shape_selected) { | |
22479 | if (coords_type==2) { | |
22480 | if (X0>X1) cimg::swap(X0,X1); | |
22481 | if (Y0>Y1) cimg::swap(Y0,Y1); | |
22482 | if (Z0>Z1) cimg::swap(Z0,Z1); | |
22483 | } | |
22484 | if (X1<0 || Y1<0 || Z1<0) X0 = Y0 = Z0 = X1 = Y1 = Z1 = -1; | |
22485 | switch(coords_type) { | |
22486 | case 1: | |
22487 | case 2: res[3] = (restype)X1; res[4] = (restype)Y1; res[5] = (restype)Z1; | |
22488 | default: res[0] = (restype)X0; res[1] = (restype)Y0; res[2] = (restype)Z0; | |
22489 | } | |
22490 | } | |
22491 | disp.button = 0; | |
22492 | disp.events = old_events; | |
22493 | disp.normalization = old_normalization; | |
22494 | disp.is_resized = old_is_resized; | |
22495 | disp.key = key; | |
22496 | return res; | |
22497 | } | |
22498 | CImg<typename cimg::last<T,int>::type> get_coordinates(const int coords_type=0, | |
22499 | unsigned int *const XYZ=0, const unsigned char *const color=0) const { | |
22500 | unsigned int w = width + (depth>1?depth:0), h = height + (depth>1?depth:0); | |
22501 | const unsigned int dmin = cimg::min(w,h), minsiz = 256; | |
22502 | if (dmin<minsiz) { w=w*minsiz/dmin; h=h*minsiz/dmin; } | |
22503 | const unsigned int dmax = cimg::max(w,h), maxsiz = 1024; | |
22504 | if (dmax>maxsiz) { w=w*maxsiz/dmax; h=h*maxsiz/dmax; } | |
22505 | CImgDisplay disp(w,h," ",1,3); | |
22506 | return get_coordinates(coords_type,disp,XYZ,color); | |
22507 | } | |
22508 | CImg<T>& coordinates(const int coords_type=0,unsigned int *const XYZ=0, const unsigned char *const color=0) { | |
22509 | return get_coordinates(coords_type,XYZ,color).transfer_to(*this); | |
22510 | } | |
22511 | template<typename tp, typename tf, typename tc, typename to> | |
22512 | const CImg<T>& display_object3d(const CImg<tp>& points, const CImgList<tf>& primitives, | |
22513 | const CImgList<tc>& colors, const CImgList<to>& opacities, CImgDisplay& disp, | |
22514 | const bool centering=true, | |
22515 | const int render_static=4, const int render_motion=1, | |
22516 | const bool double_sided=false, const float focale=500.0f, | |
22517 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22518 | const bool display_axes=true, float *const pose_matrix=0) const { | |
22519 | if (!points || !primitives || !opacities) | |
22520 | throw CImgArgumentException("CImg<%s>::display_object3d() : Given points (%u), primitives (%u) or opacities (%u) are empty.", | |
22521 | pixel_type(),points.size()/3,primitives.size,opacities.size); | |
22522 | if (is_empty()) | |
22523 | return CImg<T>(disp.width,disp.height,1,colors[0].size(),0). | |
22524 | display_object3d(points,primitives,colors,opacities,disp,centering, | |
22525 | render_static,render_motion,double_sided,focale,specular_light,specular_shine, | |
22526 | display_axes,pose_matrix); | |
22527 | if (points.height<3) | |
22528 | return display_object3d(points.get_resize(-100,3,1,1,0),primitives,colors,opacities,disp, | |
22529 | centering,render_static,render_motion,double_sided,focale,specular_light,specular_shine, | |
22530 | display_axes,pose_matrix); | |
22531 | CImg<float> pose, rot_mat, | |
22532 | centered_points = centering?CImg<float>(points.width,3):CImg<float>(), | |
22533 | rotated_points(points.width,3), | |
22534 | bbox_points, rotated_bbox_points, | |
22535 | axes_points, rotated_axes_points; | |
22536 | CImgList<to> bbox_opacities, axes_opacities; | |
22537 | CImgList<T> bbox_colors, axes_colors; | |
22538 | CImgList<tf> bbox_primitives, axes_primitives; | |
22539 | float dx = 0, dy = 0, dz = 0, ratio = 1; | |
22540 | T minval = (T)0, maxval = (T)255; | |
22541 | if (disp.normalization) minval = colors.minmax(maxval); | |
22542 | const float meanval = (float)mean(); | |
22543 | bool color_model = true; | |
22544 | if (cimg::abs(meanval-minval)>cimg::abs(meanval-maxval)) color_model = false; | |
22545 | const CImg<T> | |
22546 | bgcolor(1,1,1,dim,color_model?minval:maxval), | |
22547 | fgcolor(1,1,1,dim,color_model?maxval:minval); | |
22548 | float | |
22549 | xm, xM = (float)points.get_shared_line(0).maxmin(xm), | |
22550 | ym, yM = (float)points.get_shared_line(1).maxmin(ym), | |
22551 | zm, zM = (float)points.get_shared_line(2).maxmin(zm), | |
22552 | delta = cimg::max(xM-xm,yM-ym,zM-zm); | |
22553 | if (display_axes) { | |
22554 | axes_points.assign(7,3); | |
22555 | rotated_axes_points.assign(7,3); | |
22556 | axes_opacities.assign(3,1,1,1,1,1.0f); | |
22557 | axes_colors.assign(3,dim,1,1,1,fgcolor[0]); | |
22558 | axes_points(0,0) = 0; axes_points(0,1) = 0; axes_points(0,2) = 0; | |
22559 | axes_points(1,0) = 20; axes_points(1,1) = 0; axes_points(1,2) = 0; | |
22560 | axes_points(2,0) = 0; axes_points(2,1) = 20; axes_points(2,2) = 0; | |
22561 | axes_points(3,0) = 0; axes_points(3,1) = 0; axes_points(3,2) = 20; | |
22562 | axes_points(4,0) = 22; axes_points(4,1) = -6; axes_points(4,2) = 0; | |
22563 | axes_points(5,0) = -6; axes_points(5,1) = 22; axes_points(5,2) = 0; | |
22564 | axes_points(6,0) = -6; axes_points(6,1) = -6; axes_points(6,2) = 22; | |
22565 | axes_primitives.insert(CImg<tf>::vector(0,1)); | |
22566 | axes_primitives.insert(CImg<tf>::vector(0,2)); | |
22567 | axes_primitives.insert(CImg<tf>::vector(0,3)); | |
22568 | } | |
22569 | CImg<T> visu0(*this), visu; | |
22570 | bool init = true, clicked = false, redraw = true; | |
22571 | unsigned int key = 0; | |
22572 | int x0 = 0, y0 = 0, x1 = 0, y1 = 0; | |
22573 | const unsigned int old_events = disp.events; | |
22574 | disp.show().button = disp.key = 0; | |
22575 | disp.events = 3; | |
22576 | while (!disp.is_closed && !key) { | |
22577 | if (init) { | |
22578 | ratio = delta>0?(2.0f*cimg::min(disp.width,disp.height)/(3.0f*delta)):0; | |
22579 | dx = 0.5f*(xM+xm); dy = 0.5f*(yM+ym); dz = 0.5f*(zM+zm); | |
22580 | if (centering) { | |
22581 | for (int l = 0; l<(int)((centered_points).width); ++l) { | |
22582 | centered_points(l,0) = (float)((points(l,0)-dx)*ratio); | |
22583 | centered_points(l,1) = (float)((points(l,1)-dy)*ratio); | |
22584 | centered_points(l,2) = (float)((points(l,2)-dz)*ratio); | |
22585 | } | |
22586 | } | |
22587 | if (render_static<0 || render_motion<0) { | |
22588 | bbox_colors.assign(12,dim,1,1,1,fgcolor[0]); | |
22589 | bbox_primitives.assign(12,1,2); | |
22590 | bbox_points.assign(8,3); | |
22591 | rotated_bbox_points.assign(8,3); | |
22592 | bbox_points(0,0) = xm; bbox_points(0,1) = ym; bbox_points(0,2) = zm; | |
22593 | bbox_points(1,0) = xM; bbox_points(1,1) = ym; bbox_points(1,2) = zm; | |
22594 | bbox_points(2,0) = xM; bbox_points(2,1) = yM; bbox_points(2,2) = zm; | |
22595 | bbox_points(3,0) = xm; bbox_points(3,1) = yM; bbox_points(3,2) = zm; | |
22596 | bbox_points(4,0) = xm; bbox_points(4,1) = ym; bbox_points(4,2) = zM; | |
22597 | bbox_points(5,0) = xM; bbox_points(5,1) = ym; bbox_points(5,2) = zM; | |
22598 | bbox_points(6,0) = xM; bbox_points(6,1) = yM; bbox_points(6,2) = zM; | |
22599 | bbox_points(7,0) = xm; bbox_points(7,1) = yM; bbox_points(7,2) = zM; | |
22600 | bbox_primitives[0].fill(0,1); bbox_primitives[1].fill(1,2); bbox_primitives[2].fill(2,3); bbox_primitives[3].fill(3,0); | |
22601 | bbox_primitives[4].fill(4,5); bbox_primitives[5].fill(5,6); bbox_primitives[6].fill(6,7); bbox_primitives[7].fill(7,4); | |
22602 | bbox_primitives[8].fill(0,4); bbox_primitives[9].fill(1,5); bbox_primitives[10].fill(2,6); bbox_primitives[11].fill(3,7); | |
22603 | bbox_opacities.assign(bbox_primitives.size,1,1,1,1,1.0f); | |
22604 | } | |
22605 | if (!pose) { | |
22606 | if (pose_matrix) pose = CImg<float>(pose_matrix,4,4,1,1,false); | |
22607 | else pose = CImg<float>::identity_matrix(4); | |
22608 | } | |
22609 | init = false; | |
22610 | redraw = true; | |
22611 | } | |
22612 | if (redraw) { | |
22613 | const float | |
22614 | r00 = pose(0,0), r10 = pose(1,0), r20 = pose(2,0), r30 = pose(3,0), | |
22615 | r01 = pose(0,1), r11 = pose(1,1), r21 = pose(2,1), r31 = pose(3,1), | |
22616 | r02 = pose(0,2), r12 = pose(1,2), r22 = pose(2,2), r32 = pose(3,2); | |
22617 | if ((clicked && render_motion>=0) || (!clicked && render_static>=0)) { | |
22618 | if (centering) for (int l = 0; l<(int)((centered_points).width); ++l) { | |
22619 | const float x = centered_points(l,0), y = centered_points(l,1), z = centered_points(l,2); | |
22620 | rotated_points(l,0) = r00*x + r10*y + r20*z + r30; | |
22621 | rotated_points(l,1) = r01*x + r11*y + r21*z + r31; | |
22622 | rotated_points(l,2) = r02*x + r12*y + r22*z + r32; | |
22623 | } else for (int l = 0; l<(int)((points).width); ++l) { | |
22624 | const float x = (float)points(l,0), y = (float)points(l,1), z = (float)points(l,2); | |
22625 | rotated_points(l,0) = r00*x + r10*y + r20*z + r30; | |
22626 | rotated_points(l,1) = r01*x + r11*y + r21*z + r31; | |
22627 | rotated_points(l,2) = r02*x + r12*y + r22*z + r32; | |
22628 | } | |
22629 | } else { | |
22630 | if (!centering) for (int l = 0; l<(int)((bbox_points).width); ++l) { | |
22631 | const float x = bbox_points(l,0), y = bbox_points(l,1), z = bbox_points(l,2); | |
22632 | rotated_bbox_points(l,0) = r00*x + r10*y + r20*z + r30; | |
22633 | rotated_bbox_points(l,1) = r01*x + r11*y + r21*z + r31; | |
22634 | rotated_bbox_points(l,2) = r02*x + r12*y + r22*z + r32; | |
22635 | } else for (int l = 0; l<(int)((bbox_points).width); ++l) { | |
22636 | const float x = (bbox_points(l,0)-dx)*ratio, y = (bbox_points(l,1)-dy)*ratio, z = (bbox_points(l,2)-dz)*ratio; | |
22637 | rotated_bbox_points(l,0) = r00*x + r10*y + r20*z + r30; | |
22638 | rotated_bbox_points(l,1) = r01*x + r11*y + r21*z + r31; | |
22639 | rotated_bbox_points(l,2) = r02*x + r12*y + r22*z + r32; | |
22640 | } | |
22641 | } | |
22642 | visu = visu0; | |
22643 | if ((clicked && render_motion<0) || (!clicked && render_static<0)) | |
22644 | visu.draw_object3d(visu.width/2.0f, visu.height/2.0f, 0, | |
22645 | rotated_bbox_points,bbox_primitives,bbox_colors,bbox_opacities,1, | |
22646 | false,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000.0f,specular_light,0.2f); | |
22647 | else visu.draw_object3d(visu.width/2.0f, visu.height/2.0f, 0, | |
22648 | rotated_points,primitives,colors,opacities,clicked?render_motion:render_static, | |
22649 | double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000.0f,specular_light,specular_shine); | |
22650 | if (display_axes) { | |
22651 | const float Xaxes = 25.0f, Yaxes = visu.height-35.0f; | |
22652 | for (int l = 0; l<(int)((axes_points).width); ++l) { | |
22653 | const float x = axes_points(l,0), y = axes_points(l,1), z = axes_points(l,2); | |
22654 | rotated_axes_points(l,0) = r00*x + r10*y + r20*z; | |
22655 | rotated_axes_points(l,1) = r01*x + r11*y + r21*z; | |
22656 | rotated_axes_points(l,2) = r02*x + r12*y + r22*z; | |
22657 | } | |
22658 | axes_opacities(0,0) = (rotated_axes_points(1,2)>0)?0.5f:1.0f; | |
22659 | axes_opacities(1,0) = (rotated_axes_points(2,2)>0)?0.5f:1.0f; | |
22660 | axes_opacities(2,0) = (rotated_axes_points(3,2)>0)?0.5f:1.0f; | |
22661 | visu.draw_object3d(Xaxes,Yaxes,0,rotated_axes_points,axes_primitives,axes_colors,axes_opacities,1,false,focale,0,0,0,0). | |
22662 | draw_text("X",(int)(Xaxes+rotated_axes_points(4,0)), (int)(Yaxes+rotated_axes_points(4,1)), axes_colors[0].data, (T*)0, 11, axes_opacities(0,0)). | |
22663 | draw_text("Y",(int)(Xaxes+rotated_axes_points(5,0)), (int)(Yaxes+rotated_axes_points(5,1)), axes_colors[1].data, (T*)0, 11, axes_opacities(1,0)). | |
22664 | draw_text("Z",(int)(Xaxes+rotated_axes_points(6,0)), (int)(Yaxes+rotated_axes_points(6,1)), axes_colors[2].data, (T*)0, 11, axes_opacities(2,0)); | |
22665 | } | |
22666 | visu.display(disp); | |
22667 | if (!clicked || render_motion==render_static) redraw = false; | |
22668 | } | |
22669 | disp.wait(); | |
22670 | if ((disp.button || disp.wheel) && disp.mouse_x>=0 && disp.mouse_y>=0) { | |
22671 | redraw = true; | |
22672 | if (!clicked) { x0 = x1 = disp.mouse_x; y0 = y1 = disp.mouse_y; if (!disp.wheel) clicked = true; } | |
22673 | else { x1 = disp.mouse_x; y1 = disp.mouse_y; } | |
22674 | if (disp.button&1) { | |
22675 | const float | |
22676 | R = 0.45f*cimg::min(disp.width,disp.height), | |
22677 | R2 = R*R, | |
22678 | u0 = (float)(x0-disp.dimx()/2), | |
22679 | v0 = (float)(y0-disp.dimy()/2), | |
22680 | u1 = (float)(x1-disp.dimx()/2), | |
22681 | v1 = (float)(y1-disp.dimy()/2), | |
22682 | n0 = (float)std::sqrt(u0*u0+v0*v0), | |
22683 | n1 = (float)std::sqrt(u1*u1+v1*v1), | |
22684 | nu0 = n0>R?(u0*R/n0):u0, | |
22685 | nv0 = n0>R?(v0*R/n0):v0, | |
22686 | nw0 = (float)std::sqrt(cimg::max(0.0f,R2-nu0*nu0-nv0*nv0)), | |
22687 | nu1 = n1>R?(u1*R/n1):u1, | |
22688 | nv1 = n1>R?(v1*R/n1):v1, | |
22689 | nw1 = (float)std::sqrt(cimg::max(0.0f,R2-nu1*nu1-nv1*nv1)), | |
22690 | u = nv0*nw1-nw0*nv1, | |
22691 | v = nw0*nu1-nu0*nw1, | |
22692 | w = nv0*nu1-nu0*nv1, | |
22693 | n = (float)std::sqrt(u*u+v*v+w*w), | |
22694 | alpha = (float)std::asin(n/R2); | |
22695 | rot_mat = CImg<float>::rotation_matrix(u,v,w,alpha); | |
22696 | rot_mat *= pose.get_crop(0,0,2,2); | |
22697 | pose.draw_image(rot_mat,0,0); | |
22698 | x0=x1; y0=y1; | |
22699 | } | |
22700 | if (disp.button&2) { pose(3,2)+=(y1-y0); x0 = x1; y0 = y1; } | |
22701 | if (disp.wheel) { pose(3,2)-=15*disp.wheel; disp.wheel = 0; } | |
22702 | if (disp.button&4) { pose(3,0)+=(x1-x0); pose(3,1)+=(y1-y0); x0 = x1; y0 = y1; } | |
22703 | if ((disp.button&1) && (disp.button&2)) { init = true; disp.button = 0; x0 = x1; y0 = y1; pose = CImg<float>::identity_matrix(4); } | |
22704 | } else if (clicked) { x0 = x1; y0 = y1; clicked = false; redraw = true; } | |
22705 | key = disp.key; | |
22706 | if (key && key!=cimg::keyCTRLLEFT && key!=cimg::keyCTRLRIGHT) { | |
22707 | if (disp.is_key(cimg::keyCTRLLEFT,true) || disp.is_key(cimg::keyCTRLRIGHT,true)) { | |
22708 | switch (key) { | |
22709 | case cimg::keyD: if (disp.is_fullscreen) disp.toggle_fullscreen(); disp.resize(-200,-200); disp.is_resized = true; break; | |
22710 | case cimg::keyC: if (disp.is_fullscreen) disp.toggle_fullscreen(); disp.resize(-50,-50); disp.is_resized = true; break; | |
22711 | case cimg::keyR: if (disp.is_fullscreen) disp.toggle_fullscreen(); disp.resize(*this); disp.is_resized = true; break; | |
22712 | case cimg::keyF: disp.resize(disp.screen_dimx(),disp.screen_dimy()).toggle_fullscreen().is_resized = true; break; | |
22713 | case cimg::keyS: { | |
22714 | static unsigned int snap_number = 0; | |
22715 | char filename[32] = { 0 }; | |
22716 | std::FILE *file; | |
22717 | do { | |
22718 | std::sprintf(filename,"CImg_%.4u.bmp",snap_number++); | |
22719 | if ((file=std::fopen(filename,"r"))!=0) std::fclose(file); | |
22720 | } while (file); | |
22721 | (+visu).draw_text(2,2,fgcolor,bgcolor,11,1.0f,"Saving snapshot...",filename).display(disp); | |
22722 | visu.save(filename); | |
22723 | visu.draw_text(2,2,fgcolor,bgcolor,11,1.0f,"Snapshot '%s' saved.",filename).display(disp); | |
22724 | } break; | |
22725 | case cimg::keyO: { | |
22726 | static unsigned int snap_number = 0; | |
22727 | char filename[32] = { 0 }; | |
22728 | std::FILE *file; | |
22729 | do { | |
22730 | std::sprintf(filename,"CImg_%.4u.off",snap_number++); | |
22731 | if ((file=std::fopen(filename,"r"))!=0) std::fclose(file); | |
22732 | } while (file); | |
22733 | visu.draw_text(2,2,fgcolor,bgcolor,11,1.0f,"Saving object...",filename).display(disp); | |
22734 | points.save_off(filename,primitives,colors); | |
22735 | visu.draw_text(2,2,fgcolor,bgcolor,11,1.0f,"Object '%s' saved.",filename).display(disp); | |
22736 | } break; | |
22737 | } | |
22738 | disp.key = key = 0; | |
22739 | } | |
22740 | } else key = 0; | |
22741 | if (disp.is_resized) { disp.resize(false); visu0 = get_resize(disp,1); redraw = true; } | |
22742 | } | |
22743 | if (pose_matrix) std::memcpy(pose_matrix,pose.data,16*sizeof(float)); | |
22744 | disp.events = old_events; | |
22745 | disp.button = 0; | |
22746 | return *this; | |
22747 | } | |
22748 | template<typename tp, typename tf, typename tc, typename to> | |
22749 | const CImg<T>& display_object3d(const CImgList<tp>& points, const CImgList<tf>& primitives, | |
22750 | const CImgList<tc>& colors, const CImgList<to>& opacities, CImgDisplay &disp, | |
22751 | const bool centering=true, | |
22752 | const int render_static=4, const int render_motion=1, | |
22753 | const bool double_sided=false, const float focale=500.0f, | |
22754 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22755 | const bool display_axes=true, float *const pose_matrix=0) const { | |
22756 | CImg<tp> npoints(points.size,3,1,1,0); | |
22757 | tp *ptrX = npoints.data, *ptrY = npoints.ptr(0,1), *ptrZ = npoints.ptr(0,2); | |
22758 | for (int l = 0; l<(int)((npoints).width); ++l) { | |
22759 | const CImg<tp>& point = points[l]; | |
22760 | const unsigned int siz = point.size(); | |
22761 | if (!siz) | |
22762 | throw CImgArgumentException("CImg<%s>::display_object3d() : Given points (size=%u) contains a null element at " | |
22763 | "position %u.",pixel_type(),points.size,l); | |
22764 | *(ptrZ++) = (siz>2)?point(2):0; | |
22765 | *(ptrY++) = (siz>1)?point(1):0; | |
22766 | *(ptrX++) = point(0); | |
22767 | } | |
22768 | return display_object3d(npoints,primitives,colors,opacities,disp,centering, | |
22769 | render_static,render_motion,double_sided,focale,specular_light,specular_shine, | |
22770 | display_axes,pose_matrix); | |
22771 | } | |
22772 | template<typename tp, typename tf, typename tc, typename to> | |
22773 | const CImg<T>& display_object3d(const CImg<tp>& points, const CImgList<tf>& primitives, | |
22774 | const CImgList<tc>& colors, const CImg<to>& opacities, CImgDisplay& disp, | |
22775 | const bool centering=true, | |
22776 | const int render_static=4, const int render_motion=1, | |
22777 | const bool double_sided=false, const float focale=500.0f, | |
22778 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22779 | const bool display_axes=true, float *const pose_matrix=0) const { | |
22780 | CImgList<to> nopacities(opacities.size(),1); | |
22781 | for (unsigned int l=0; l<(nopacities).size; ++l) nopacities(l,0) = opacities(l); | |
22782 | return display_object3d(points,primitives,colors,nopacities,disp,centering, | |
22783 | render_static,render_motion,double_sided,focale,specular_light,specular_shine, | |
22784 | display_axes,pose_matrix); | |
22785 | } | |
22786 | template<typename tp, typename tf, typename tc, typename to> | |
22787 | const CImg<T>& display_object3d(const CImgList<tp>& points, const CImgList<tf>& primitives, | |
22788 | const CImgList<tc>& colors, const CImg<to>& opacities, CImgDisplay& disp, | |
22789 | const bool centering=true, | |
22790 | const int render_static=4, const int render_motion=1, | |
22791 | const bool double_sided=false, const float focale=500.0f, | |
22792 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22793 | const bool display_axes=true, float *const pose_matrix=0) const { | |
22794 | CImgList<to> nopacities(opacities.size(),1); | |
22795 | for (unsigned int l=0; l<(nopacities).size; ++l) nopacities(l,0) = opacities(l); | |
22796 | if (!points) throw CImgArgumentException("CImg<%s>::display_object3d() : Given points are empty.", | |
22797 | pixel_type()); | |
22798 | CImg<tp> npoints(points.size,3,1,1,0); | |
22799 | tp *ptrX = npoints.data, *ptrY = npoints.ptr(0,1), *ptrZ = npoints.ptr(0,2); | |
22800 | { for (int l = 0; l<(int)((npoints).width); ++l) { | |
22801 | const CImg<tp>& point = points[l]; | |
22802 | const unsigned int siz = point.size(); | |
22803 | if (!siz) | |
22804 | throw CImgArgumentException("CImg<%s>::display_object3d() : Given points (size=%u) contains a null element at " | |
22805 | "position %u.",pixel_type(),points.size,l); | |
22806 | *(ptrZ++) = (siz>2)?point(2):0; | |
22807 | *(ptrY++) = (siz>1)?point(1):0; | |
22808 | *(ptrX++) = point(0); | |
22809 | } | |
22810 | } | |
22811 | return display_object3d(npoints,primitives,colors,nopacities,disp,centering, | |
22812 | render_static,render_motion,double_sided,focale,specular_light,specular_shine, | |
22813 | display_axes,pose_matrix); | |
22814 | } | |
22815 | template<typename tp, typename tf, typename tc, typename to> | |
22816 | const CImg<T>& display_object3d(const tp& points, const CImgList<tf>& primitives, | |
22817 | const CImgList<tc>& colors, const to& opacities, | |
22818 | const bool centering=true, | |
22819 | const int render_static=4, const int render_motion=1, | |
22820 | const bool double_sided=false, const float focale=500.0f, | |
22821 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22822 | const bool display_axes=true, float *const pose_matrix=0) const { | |
22823 | CImgDisplay disp(width,height,0,0); | |
22824 | return display_object3d(points,primitives,colors,opacities,disp,centering, | |
22825 | render_static,render_motion,double_sided,focale,specular_light,specular_shine, | |
22826 | display_axes,pose_matrix); | |
22827 | } | |
22828 | template<typename tp, typename tf, typename tc> | |
22829 | const CImg<T>& display_object3d(const tp& points, const CImgList<tf>& primitives, | |
22830 | const CImgList<tc>& colors, | |
22831 | const bool centering=true, | |
22832 | const int render_static=4, const int render_motion=1, | |
22833 | const bool double_sided=false, const float focale=500.0f, | |
22834 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22835 | const bool display_axes=true, float *const pose_matrix=0, | |
22836 | const float opacity=1.0f) const { | |
22837 | CImgDisplay disp(width,height," ",0); | |
22838 | return display_object3d(points,primitives,colors,CImg<float>::vector(opacity), | |
22839 | disp,centering,render_static,render_motion,double_sided, | |
22840 | focale,specular_light,specular_shine,display_axes,pose_matrix); | |
22841 | } | |
22842 | template<typename tp, typename tf, typename tc> | |
22843 | const CImg<T>& display_object3d(const tp& points, const CImgList<tf>& primitives, | |
22844 | const CImgList<tc>& colors, CImgDisplay &disp, | |
22845 | const bool centering=true, | |
22846 | const int render_static=4, const int render_motion=1, | |
22847 | const bool double_sided=false, const float focale=500.0f, | |
22848 | const float specular_light=0.2f, const float specular_shine=0.1f, | |
22849 | const bool display_axes=true, float *const pose_matrix=0, | |
22850 | const float opacity=1.0f) const { | |
22851 | return display_object3d(points,primitives,colors,CImg<float>::vector(opacity), | |
22852 | disp,centering,render_static,render_motion,double_sided, | |
22853 | focale,specular_light,specular_shine,display_axes,pose_matrix); | |
22854 | } | |
22855 | static CImg<T> get_load(const char *const filename) { | |
22856 | return CImg<T>().load(filename); | |
22857 | } | |
22858 | CImg<T>& load(const char *const filename) { | |
22859 | const char *ext = cimg::filename_split(filename); | |
22860 | if (!cimg::strncasecmp(ext,"asc",3)) return load_ascii(filename); | |
22861 | if (!cimg::strncasecmp(ext,"dlm",3) || | |
22862 | !cimg::strncasecmp(ext,"txt",3)) return load_dlm(filename); | |
22863 | if (!cimg::strncasecmp(ext,"inr",3)) return load_inr(filename); | |
22864 | if (!cimg::strncasecmp(ext,"hdr",3) || | |
22865 | !cimg::strncasecmp(ext,"nii",3)) return load_analyze(filename); | |
22866 | if (!cimg::strncasecmp(ext,"par",3) || | |
22867 | !cimg::strncasecmp(ext,"rec",3)) return load_parrec(filename); | |
22868 | if (!cimg::strncasecmp(ext,"pan",3)) return load_pandore(filename); | |
22869 | if (!cimg::strncasecmp(ext,"bmp",3)) return load_bmp(filename); | |
22870 | if (!cimg::strncasecmp(ext,"png",3)) return load_png(filename); | |
22871 | if (!cimg::strncasecmp(ext,"tif",3)) return load_tiff(filename); | |
22872 | if (!cimg::strncasecmp(ext,"jpg",3) || | |
22873 | !cimg::strncasecmp(ext,"jpeg",4)) return load_jpeg(filename); | |
22874 | if (!cimg::strncasecmp(ext,"ppm",3) || | |
22875 | !cimg::strncasecmp(ext,"pgm",3) || | |
22876 | !cimg::strncasecmp(ext,"pnm",3)) return load_pnm(filename); | |
22877 | if (!cimg::strncasecmp(ext,"cimg",4) || | |
22878 | ext[0]=='\0') return load_cimg(filename); | |
22879 | if (!cimg::strncasecmp(ext,"dcm",3) || | |
22880 | !cimg::strncasecmp(ext,"dicom",5)) return load_dicom(filename); | |
22881 | if (!cimg::strncasecmp(ext,"avi",3) || | |
22882 | !cimg::strncasecmp(ext,"mov",3) || | |
22883 | !cimg::strncasecmp(ext,"mpg",3) || | |
22884 | !cimg::strncasecmp(ext,"mpeg",4)) return load_ffmpeg(filename); | |
22885 | return load_other(filename); | |
22886 | } | |
22887 | static CImg<T> get_load_ascii(std::FILE *const file, const char *const filename=0) { | |
22888 | return CImg<T>().load_ascii(file,filename); | |
22889 | } | |
22890 | CImg<T>& load_ascii(std::FILE *const file, const char *const filename=0) { | |
22891 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
22892 | char line[256] = { 0 }; | |
22893 | std::fscanf(nfile,"%255[^\n]",line); | |
22894 | unsigned int off, dx = 0, dy = 1, dz = 1, dv = 1; | |
22895 | int err = 1; | |
22896 | std::sscanf(line,"%u %u %u %u",&dx,&dy,&dz,&dv); | |
22897 | if (!dx || !dy || !dz || !dv) { | |
22898 | if (!file) cimg::fclose(nfile); | |
22899 | throw CImgIOException("CImg<%s>::load_ascii() : File '%s' is not a valid .ASC file.\n" | |
22900 | "Specified image dimensions are (%u,%u,%u,%u).", | |
22901 | pixel_type(),filename?filename:"(FILE*)",dx,dy,dz,dv); | |
22902 | } | |
22903 | assign(dx,dy,dz,dv); | |
22904 | const unsigned int siz = size(); | |
22905 | double val; | |
22906 | T *ptr = data; | |
22907 | for (off=0; off<siz && err==1; ++off) { | |
22908 | err = std::fscanf(nfile,"%lf%*[^0-9.eE+-]",&val); | |
22909 | *(ptr++) = (T)val; | |
22910 | } | |
22911 | if (off<size()) cimg::warn("CImg<%s>::load_ascii() : File '%s', only %u/%u values read.", | |
22912 | pixel_type(),filename?filename:"(FILE*)",off,siz); | |
22913 | if (!file) cimg::fclose(nfile); | |
22914 | return *this; | |
22915 | } | |
22916 | static CImg<T> get_load_ascii(const char *const filename) { | |
22917 | return CImg<T>().load_ascii(0,filename); | |
22918 | } | |
22919 | CImg<T>& load_ascii(const char *const filename) { | |
22920 | return load_ascii(0,filename); | |
22921 | } | |
22922 | static CImg<T> get_load_dlm(std::FILE *const file, const char *const filename=0) { | |
22923 | return CImg<T>().load_dlm(file,filename); | |
22924 | } | |
22925 | CImg<T>& load_dlm(std::FILE *const file, const char *const filename=0) { | |
22926 | std::FILE *const nfile = file?file:cimg::fopen(filename,"r"); | |
22927 | assign(256,256); | |
22928 | char c, delimiter[256] = { 0 }, tmp[256]; | |
22929 | unsigned int cdx = 0, dx = 0, dy = 0; | |
22930 | int oerr = 0, err; | |
22931 | double val; | |
22932 | while ((err = std::fscanf(nfile,"%lf%255[^0-9.eE+-]",&val,delimiter))!=(-1)) { | |
22933 | oerr = err; | |
22934 | if (err>0) (*this)(cdx++,dy) = (T)val; | |
22935 | if (cdx>=width) resize(width+256,1,1,1,0); | |
22936 | c = 0; if (!std::sscanf(delimiter,"%255[^\n]%c",tmp,&c) || c=='\n') { | |
22937 | dx = cimg::max(cdx,dx); | |
22938 | ++dy; | |
22939 | if (dy>=height) resize(width,height+256,1,1,0); | |
22940 | cdx = 0; | |
22941 | } | |
22942 | } | |
22943 | if (cdx && oerr==1) { dx=cdx; ++dy; } | |
22944 | if (!dx || !dy) { | |
22945 | if (!file) cimg::fclose(nfile); | |
22946 | throw CImgIOException("CImg<%s>::load_dlm() : File '%s' is not a valid DLM file.\n" | |
22947 | "Specified image dimensions are (%u,%u).", | |
22948 | pixel_type(),filename?filename:"(FILE*)",dx,dy); | |
22949 | } | |
22950 | resize(dx,dy,1,1,0); | |
22951 | if (!file) cimg::fclose(nfile); | |
22952 | return *this; | |
22953 | } | |
22954 | static CImg<T> get_load_dlm(const char *const filename) { | |
22955 | return CImg<T>().load_dlm(0,filename); | |
22956 | } | |
22957 | CImg<T>& load_dlm(const char *const filename) { | |
22958 | return load_dlm(0,filename); | |
22959 | } | |
22960 | static CImg<T> get_load_pnm(std::FILE *const file, const char *const filename=0) { | |
22961 | return CImg<T>().load_pnm(file, filename); | |
22962 | } | |
22963 | CImg<T>& load_pnm(std::FILE *const file, const char *const filename=0) { | |
22964 | std::FILE *const nfile=file?file:cimg::fopen(filename,"rb"); | |
22965 | unsigned int ppm_type, W, H, colormax=255; | |
22966 | char item[1024] = { 0 }; | |
22967 | int err, rval, gval, bval; | |
22968 | const int cimg_iobuffer = 12*1024*1024; | |
22969 | while ((err=std::fscanf(nfile,"%1023[^\n]",item))!=(-1) && (item[0]=='#' || !err)) std::fgetc(nfile); | |
22970 | if(std::sscanf(item," P%u",&ppm_type)!=1) { | |
22971 | if (!file) cimg::fclose(nfile); | |
22972 | throw CImgIOException("CImg<%s>::load_pnm() : File '%s', PNM header 'P?' not found.", | |
22973 | pixel_type(),filename?filename:"(FILE*)"); | |
22974 | } | |
22975 | while ((err=std::fscanf(nfile," %1023[^\n]",item))!=(-1) && (item[0]=='#' || !err)) std::fgetc(nfile); | |
22976 | if ((err=std::sscanf(item," %u %u %u",&W,&H,&colormax))<2) { | |
22977 | if (!file) cimg::fclose(nfile); | |
22978 | throw CImgIOException("CImg<%s>::load_pnm() : File '%s', WIDTH and HEIGHT fields are not defined in PNM header.", | |
22979 | pixel_type(),filename?filename:"(FILE*)"); | |
22980 | } | |
22981 | if (err==2) { | |
22982 | while ((err=std::fscanf(nfile," %1023[^\n]",item))!=(-1) && (item[0]=='#' || !err)) std::fgetc(nfile); | |
22983 | if (std::sscanf(item,"%u",&colormax)!=1) | |
22984 | cimg::warn("CImg<%s>::load_pnm() : File '%s', COLORMAX field is not defined in PNM header.", | |
22985 | pixel_type(),filename?filename:"(FILE*)"); | |
22986 | } | |
22987 | std::fgetc(nfile); | |
22988 | assign(); | |
22989 | switch (ppm_type) { | |
22990 | case 2: { | |
22991 | assign(W,H,1,1); | |
22992 | T* rdata = data; | |
22993 | for (unsigned int off = 0; off<(*this).size(); ++off) { std::fscanf(nfile,"%d",&rval); *(rdata++) = (T)rval; } | |
22994 | } break; | |
22995 | case 3: { | |
22996 | assign(W,H,1,3); | |
22997 | T *rdata = ptr(0,0,0,0), *gdata = ptr(0,0,0,1), *bdata = ptr(0,0,0,2); | |
22998 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
22999 | std::fscanf(nfile,"%d %d %d",&rval,&gval,&bval); | |
23000 | *(rdata++) = (T)rval; | |
23001 | *(gdata++) = (T)gval; | |
23002 | *(bdata++) = (T)bval; } | |
23003 | } break; | |
23004 | case 5: { | |
23005 | if (colormax<256) { | |
23006 | CImg<unsigned char> raw; | |
23007 | assign(W,H,1,1); | |
23008 | T *ptrd = ptr(0,0,0,0); | |
23009 | for (int toread = (int)size(); toread>0; ) { | |
23010 | raw.assign(cimg::min(toread,cimg_iobuffer)); | |
23011 | cimg::fread(raw.data,raw.width,nfile); | |
23012 | toread-=raw.width; | |
23013 | const unsigned char *ptrs = raw.data; | |
23014 | for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); | |
23015 | } | |
23016 | } else { | |
23017 | CImg<unsigned short> raw; | |
23018 | assign(W,H,1,1); | |
23019 | T *ptrd = ptr(0,0,0,0); | |
23020 | for (int toread = (int)size(); toread>0; ) { | |
23021 | raw.assign(cimg::min(toread,cimg_iobuffer/2)); | |
23022 | cimg::fread(raw.data,raw.width,nfile); | |
23023 | toread-=raw.width; | |
23024 | const unsigned short *ptrs = raw.data; | |
23025 | for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); | |
23026 | } | |
23027 | } | |
23028 | } break; | |
23029 | case 6: { | |
23030 | if (colormax<256) { | |
23031 | CImg<unsigned char> raw; | |
23032 | assign(W,H,1,3); | |
23033 | T | |
23034 | *ptr_r = ptr(0,0,0,0), | |
23035 | *ptr_g = ptr(0,0,0,1), | |
23036 | *ptr_b = ptr(0,0,0,2); | |
23037 | for (int toread = (int)size(); toread>0; ) { | |
23038 | raw.assign(cimg::min(toread,cimg_iobuffer)); | |
23039 | cimg::fread(raw.data,raw.width,nfile); | |
23040 | toread-=raw.width; | |
23041 | const unsigned char *ptrs = raw.data; | |
23042 | for (unsigned int off = raw.width/3; off; --off) { | |
23043 | *(ptr_r++) = (T)*(ptrs++); | |
23044 | *(ptr_g++) = (T)*(ptrs++); | |
23045 | *(ptr_b++) = (T)*(ptrs++); | |
23046 | } | |
23047 | } | |
23048 | } else { | |
23049 | CImg<unsigned short> raw; | |
23050 | assign(W,H,1,3); | |
23051 | T | |
23052 | *ptr_r = ptr(0,0,0,0), | |
23053 | *ptr_g = ptr(0,0,0,1), | |
23054 | *ptr_b = ptr(0,0,0,2); | |
23055 | for (int toread = (int)size(); toread>0; ) { | |
23056 | raw.assign(cimg::min(toread,cimg_iobuffer/2)); | |
23057 | cimg::fread(raw.data,raw.width,nfile); | |
23058 | if (!cimg::endian()) cimg::endian_swap(raw.data,raw.width); | |
23059 | toread-=raw.width; | |
23060 | const unsigned short *ptrs = raw.data; | |
23061 | for (unsigned int off = raw.width/3; off; --off) { | |
23062 | *(ptr_r++) = (T)*(ptrs++); | |
23063 | *(ptr_g++) = (T)*(ptrs++); | |
23064 | *(ptr_b++) = (T)*(ptrs++); | |
23065 | } | |
23066 | } | |
23067 | } | |
23068 | } break; | |
23069 | default: | |
23070 | if (!file) cimg::fclose(nfile); | |
23071 | throw CImgIOException("CImg<%s>::load_pnm() : File '%s', PPM type 'P%d' not supported.", | |
23072 | pixel_type(),filename?filename:"(FILE*)",ppm_type); | |
23073 | } | |
23074 | if (!file) cimg::fclose(nfile); | |
23075 | return *this; | |
23076 | } | |
23077 | static CImg<T> get_load_pnm(const char *const filename) { | |
23078 | return get_load_pnm(0,filename); | |
23079 | } | |
23080 | CImg<T>& load_pnm(const char *const filename) { | |
23081 | return load_pnm(0,filename); | |
23082 | } | |
23083 | static CImg<T> get_load_bmp(std::FILE *const file, const char *const filename=0) { | |
23084 | return CImg<T>().load_bmp(file,filename); | |
23085 | } | |
23086 | CImg<T>& load_bmp(std::FILE *const file, const char *const filename=0) { | |
23087 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
23088 | unsigned char header[64]; | |
23089 | cimg::fread(header,54,nfile); | |
23090 | if (header[0]!='B' || header[1]!='M') { | |
23091 | if (!file) cimg::fclose(nfile); | |
23092 | throw CImgIOException("CImg<%s>::load_bmp() : File '%s' is not a valid BMP file.", | |
23093 | pixel_type(),filename?filename:"(FILE*)"); | |
23094 | } | |
23095 | assign(); | |
23096 | int | |
23097 | file_size = header[0x02] + (header[0x03]<<8) + (header[0x04]<<16) + (header[0x05]<<24), | |
23098 | offset = header[0x0A] + (header[0x0B]<<8) + (header[0x0C]<<16) + (header[0x0D]<<24), | |
23099 | dx = header[0x12] + (header[0x13]<<8) + (header[0x14]<<16) + (header[0x15]<<24), | |
23100 | dy = header[0x16] + (header[0x17]<<8) + (header[0x18]<<16) + (header[0x19]<<24), | |
23101 | compression = header[0x1E] + (header[0x1F]<<8) + (header[0x20]<<16) + (header[0x21]<<24), | |
23102 | nb_colors = header[0x2E] + (header[0x2F]<<8) + (header[0x30]<<16) + (header[0x31]<<24), | |
23103 | bpp = header[0x1C] + (header[0x1D]<<8), | |
23104 | *palette = 0; | |
23105 | const int | |
23106 | dx_bytes = (bpp==1)?(dx/8+(dx%8?1:0)):((bpp==4)?(dx/2+(dx%2?1:0)):(dx*bpp/8)), | |
23107 | align = (4-dx_bytes%4)%4, | |
23108 | buf_size = cimg::min(cimg::abs(dy)*(dx_bytes+align),file_size-offset); | |
23109 | if (bpp<16) { if (!nb_colors) nb_colors=1<<bpp; } else nb_colors = 0; | |
23110 | if (nb_colors) { palette = new int[nb_colors]; cimg::fread(palette,nb_colors,nfile); } | |
23111 | const int xoffset = offset-54-4*nb_colors; | |
23112 | if (xoffset>0) std::fseek(nfile,xoffset,1); | |
23113 | unsigned char *buffer = new unsigned char[buf_size], *ptrs = buffer; | |
23114 | cimg::fread(buffer,buf_size,nfile); | |
23115 | if (!file) cimg::fclose(nfile); | |
23116 | if (compression) { | |
23117 | delete[] buffer; | |
23118 | if (file) { | |
23119 | throw CImgIOException("CImg<%s>::load_bmp() : Not able to read a compressed BMP file using a *FILE input",pixel_type()); | |
23120 | } else return load_other(filename); | |
23121 | } | |
23122 | assign(dx,cimg::abs(dy),1,3); | |
23123 | switch (bpp) { | |
23124 | case 1: { | |
23125 | for (int y=height-1; y>=0; --y) { | |
23126 | unsigned char mask = 0x80, val = 0; | |
23127 | for (int x = 0; x<(int)((*this).width); ++x) { | |
23128 | if (mask==0x80) val = *(ptrs++); | |
23129 | const unsigned char *col = (unsigned char*)(palette+(val&mask?1:0)); | |
23130 | (*this)(x,y,2) = (T)*(col++); | |
23131 | (*this)(x,y,1) = (T)*(col++); | |
23132 | (*this)(x,y,0) = (T)*(col++); | |
23133 | mask = cimg::ror(mask); | |
23134 | } ptrs+=align; } | |
23135 | } break; | |
23136 | case 4: { | |
23137 | for (int y=height-1; y>=0; --y) { | |
23138 | unsigned char mask = 0xF0, val = 0; | |
23139 | for (int x = 0; x<(int)((*this).width); ++x) { | |
23140 | if (mask==0xF0) val = *(ptrs++); | |
23141 | const unsigned char color = (unsigned char)((mask<16)?(val&mask):((val&mask)>>4)); | |
23142 | unsigned char *col = (unsigned char*)(palette+color); | |
23143 | (*this)(x,y,2) = (T)*(col++); | |
23144 | (*this)(x,y,1) = (T)*(col++); | |
23145 | (*this)(x,y,0) = (T)*(col++); | |
23146 | mask = cimg::ror(mask,4); | |
23147 | } ptrs+=align; } | |
23148 | } break; | |
23149 | case 8: { | |
23150 | for (int y=height-1; y>=0; --y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
23151 | const unsigned char *col = (unsigned char*)(palette+*(ptrs++)); | |
23152 | (*this)(x,y,2) = (T)*(col++); | |
23153 | (*this)(x,y,1) = (T)*(col++); | |
23154 | (*this)(x,y,0) = (T)*(col++); | |
23155 | } ptrs+=align; } | |
23156 | } break; | |
23157 | case 16: { | |
23158 | for (int y=height-1; y>=0; --y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
23159 | const unsigned char c1 = *(ptrs++), c2 = *(ptrs++); | |
23160 | const unsigned short col = (unsigned short)(c1|(c2<<8)); | |
23161 | (*this)(x,y,2) = (T)(col&0x1F); | |
23162 | (*this)(x,y,1) = (T)((col>>5)&0x1F); | |
23163 | (*this)(x,y,0) = (T)((col>>10)&0x1F); | |
23164 | } ptrs+=align; } | |
23165 | } break; | |
23166 | case 24: { | |
23167 | for (int y=height-1; y>=0; --y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
23168 | (*this)(x,y,2) = (T)*(ptrs++); | |
23169 | (*this)(x,y,1) = (T)*(ptrs++); | |
23170 | (*this)(x,y,0) = (T)*(ptrs++); | |
23171 | } ptrs+=align; } | |
23172 | } break; | |
23173 | case 32: { | |
23174 | for (int y=height-1; y>=0; --y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
23175 | (*this)(x,y,2) = (T)*(ptrs++); | |
23176 | (*this)(x,y,1) = (T)*(ptrs++); | |
23177 | (*this)(x,y,0) = (T)*(ptrs++); | |
23178 | ++ptrs; | |
23179 | } ptrs+=align; } | |
23180 | } break; | |
23181 | } | |
23182 | if (palette) delete[] palette; | |
23183 | delete[] buffer; | |
23184 | if (dy<0) mirror('y'); | |
23185 | return *this; | |
23186 | } | |
23187 | static CImg<T> get_load_bmp(const char *const filename) { | |
23188 | return CImg<T>().load_bmp(0,filename); | |
23189 | } | |
23190 | CImg<T>& load_bmp(const char *const filename) { | |
23191 | return load_bmp(0,filename); | |
23192 | } | |
23193 | static CImg<T> get_load_png(std::FILE *const file, const char *const filename=0) { | |
23194 | return CImg<T>().load_png(file,filename); | |
23195 | } | |
23196 | CImg<T>& load_png(std::FILE *const file, const char *const filename=0) { | |
23197 | if (file) | |
23198 | throw CImgIOException("CImg<%s>::load_png() : File '(FILE*)' cannot be read without using libpng.",pixel_type()); | |
23199 | else return load_other(filename); | |
23200 | } | |
23201 | static CImg<T> get_load_png(const char *const filename) { | |
23202 | return CImg<T>().load_png(0,filename); | |
23203 | } | |
23204 | CImg<T>& load_png(const char *const filename) { | |
23205 | return load_png(0,filename); | |
23206 | } | |
23207 | static CImg<T> get_load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U) { | |
23208 | return CImg<T>().load_tiff(filename,first_frame,last_frame); | |
23209 | } | |
23210 | CImg<T>& load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U) { | |
23211 | if (first_frame>last_frame) | |
23212 | throw CImgArgumentException("CImg<%s>::load_tiff() : File '%s', specified first frame = %u is higher than last frame = %u.", | |
23213 | pixel_type(),first_frame,last_frame); | |
23214 | if (first_frame || last_frame!=~0U) | |
23215 | throw CImgArgumentException("CImg<%s>::load_tiff() : File '%s', reading sub-images from a tiff file requires the use of libtiff.\n" | |
23216 | "('cimg_use_tiff' must be defined).",pixel_type(),filename); | |
23217 | return load_other(filename); | |
23218 | } | |
23219 | static CImg<T> get_load_jpeg(std::FILE *const file, const char *const filename=0) { | |
23220 | return CImg<T>().load_jpeg(file,filename); | |
23221 | } | |
23222 | CImg<T>& load_jpeg(std::FILE *const file, const char *const filename=0) { | |
23223 | if (file) | |
23224 | throw CImgIOException("CImg<%s>::load_jpeg() : File '(FILE*)' cannot be read without using libjpeg.", | |
23225 | pixel_type()); | |
23226 | else return load_other(filename); | |
23227 | } | |
23228 | static CImg<T> get_load_jpeg(const char *const filename) { | |
23229 | return CImg<T>().load_jpeg(0,filename); | |
23230 | } | |
23231 | CImg<T>& load_jpeg(const char *const filename) { | |
23232 | return load_jpeg(0,filename); | |
23233 | } | |
23234 | static CImg<T> get_load_magick(const char *const filename) { | |
23235 | return CImg<T>().load_magick(filename); | |
23236 | } | |
23237 | CImg<T>& load_magick(const char *const filename) { | |
23238 | throw CImgIOException("CImg<%s>::load_magick() : File '%s', Magick++ has not been linked during compilation.", | |
23239 | pixel_type(),filename?filename:"(null)"); | |
23240 | return *this; | |
23241 | } | |
23242 | static CImg<T> get_load_raw(std::FILE *const file, const char *const filename, | |
23243 | const unsigned int sizex, const unsigned int sizey=1, | |
23244 | const unsigned int sizez=1, const unsigned int sizev=1, | |
23245 | const bool multiplexed=false, const bool endian_swap=false) { | |
23246 | return CImg<T>().load_raw(file,filename,sizex,sizey,sizez,sizev,multiplexed,endian_swap); | |
23247 | } | |
23248 | CImg<T>& load_raw(std::FILE *const file, const char *const filename, | |
23249 | const unsigned int sizex, const unsigned int sizey=1, | |
23250 | const unsigned int sizez=1, const unsigned int sizev=1, | |
23251 | const bool multiplexed = false, const bool endian_swap = false) { | |
23252 | assign(sizex,sizey,sizez,sizev,0); | |
23253 | const unsigned int siz = size(); | |
23254 | if (siz) { | |
23255 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
23256 | if (!multiplexed) { | |
23257 | cimg::fread(data,siz,nfile); | |
23258 | if (endian_swap) cimg::endian_swap(data,siz); | |
23259 | } | |
23260 | else { | |
23261 | CImg<T> buf(1,1,1,sizev); | |
23262 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
23263 | cimg::fread(buf.data,sizev,nfile); | |
23264 | if (endian_swap) cimg::endian_swap(buf.data,sizev); | |
23265 | set_vector_at(buf,x,y,z); } | |
23266 | } | |
23267 | if (!file) cimg::fclose(nfile); | |
23268 | } | |
23269 | return *this; | |
23270 | } | |
23271 | static CImg<T> get_load_raw(const char *const filename, | |
23272 | const unsigned int sizex, const unsigned int sizey=1, | |
23273 | const unsigned int sizez=1, const unsigned int sizev=1, | |
23274 | const bool multiplexed = false, const bool endian_swap = false) { | |
23275 | return CImg<T>().load_raw(0,filename,sizex,sizey,sizez,sizev,multiplexed,endian_swap); | |
23276 | } | |
23277 | CImg<T>& load_raw(const char *const filename, | |
23278 | const unsigned int sizex, const unsigned int sizey=1, | |
23279 | const unsigned int sizez=1, const unsigned int sizev=1, | |
23280 | const bool multiplexed = false, const bool endian_swap = false) { | |
23281 | return load_raw(0,filename,sizex,sizey,sizez,sizev,multiplexed,endian_swap); | |
23282 | } | |
23283 | static CImg<T> get_load_rgba(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23284 | return CImg<T>().load_rgba(file,filename,dimw,dimh); | |
23285 | } | |
23286 | CImg<T>& load_rgba(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23287 | const int cimg_iobuffer = 12*1024*1024; | |
23288 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
23289 | CImg<unsigned char> raw; | |
23290 | assign(dimw,dimh,1,4); | |
23291 | T | |
23292 | *ptr_r = ptr(0,0,0,0), | |
23293 | *ptr_g = ptr(0,0,0,1), | |
23294 | *ptr_b = ptr(0,0,0,2), | |
23295 | *ptr_a = ptr(0,0,0,3); | |
23296 | for (int toread = (int)size(); toread>0; ) { | |
23297 | raw.assign(cimg::min(toread,cimg_iobuffer)); | |
23298 | cimg::fread(raw.data,raw.width,nfile); | |
23299 | toread-=raw.width; | |
23300 | const unsigned char *ptrs = raw.data; | |
23301 | for (unsigned int off = raw.width/4; off; --off) { | |
23302 | *(ptr_r++) = (T)*(ptrs++); | |
23303 | *(ptr_g++) = (T)*(ptrs++); | |
23304 | *(ptr_b++) = (T)*(ptrs++); | |
23305 | *(ptr_a++) = (T)*(ptrs++); | |
23306 | } | |
23307 | } | |
23308 | if (!file) cimg::fclose(nfile); | |
23309 | return *this; | |
23310 | } | |
23311 | static CImg<T> get_load_rgba(const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23312 | return CImg<T>().load_rgba(0,filename,dimw,dimh); | |
23313 | } | |
23314 | CImg<T>& load_rgba(const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23315 | return load_rgba(0,filename,dimw,dimh); | |
23316 | } | |
23317 | static CImg<T> get_load_rgb(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23318 | return CImg<T>().load_rgb(file,filename,dimw,dimh); | |
23319 | } | |
23320 | CImg<T>& load_rgb(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23321 | const int cimg_iobuffer = 12*1024*1024; | |
23322 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
23323 | CImg<unsigned char> raw; | |
23324 | assign(dimw,dimh,1,3); | |
23325 | T | |
23326 | *ptr_r = ptr(0,0,0,0), | |
23327 | *ptr_g = ptr(0,0,0,1), | |
23328 | *ptr_b = ptr(0,0,0,2); | |
23329 | for (int toread = (int)size(); toread>0; ) { | |
23330 | raw.assign(cimg::min(toread,cimg_iobuffer)); | |
23331 | cimg::fread(raw.data,raw.width,nfile); | |
23332 | toread-=raw.width; | |
23333 | const unsigned char *ptrs = raw.data; | |
23334 | for (unsigned int off = raw.width/3; off; --off) { | |
23335 | *(ptr_r++) = (T)*(ptrs++); | |
23336 | *(ptr_g++) = (T)*(ptrs++); | |
23337 | *(ptr_b++) = (T)*(ptrs++); | |
23338 | } | |
23339 | } | |
23340 | if (!file) cimg::fclose(nfile); | |
23341 | return *this; | |
23342 | } | |
23343 | static CImg<T> get_load_rgb(const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23344 | return CImg<T>().load_rgb(0,filename,dimw,dimh); | |
23345 | } | |
23346 | CImg<T>& load_rgb(const char *const filename, const unsigned int dimw, const unsigned int dimh) { | |
23347 | return load_rgb(0,filename,dimw,dimh); | |
23348 | } | |
23349 | static CImg<T> get_load_inr(std::FILE *const file, const char *const filename=0, float *voxsize=0) { | |
23350 | return CImg<T>().load_inr(file,filename,voxsize); | |
23351 | } | |
23352 | CImg<T>& load_inr(std::FILE *const file, const char *const filename=0, float *const voxsize=0) { | |
23353 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
23354 | int fopt[8], endian=cimg::endian()?1:0; | |
23355 | bool loaded = false; | |
23356 | if (voxsize) voxsize[0]=voxsize[1]=voxsize[2]=1; | |
23357 | _load_inr(nfile,fopt,voxsize); | |
23358 | assign(fopt[0],fopt[1],fopt[2],fopt[3]); | |
23359 | if (!loaded && fopt[6]==8 && fopt[4]==0 && fopt[5]==0) { unsigned char *xval, *val = new unsigned char[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23360 | if (!loaded && fopt[6]==8 && fopt[4]==0 && fopt[5]==1) { char *xval, *val = new char[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23361 | if (!loaded && fopt[6]==16 && fopt[4]==0 && fopt[5]==0) { unsigned short *xval, *val = new unsigned short[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23362 | if (!loaded && fopt[6]==16 && fopt[4]==0 && fopt[5]==1) { short *xval, *val = new short[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23363 | if (!loaded && fopt[6]==32 && fopt[4]==0 && fopt[5]==0) { unsigned int *xval, *val = new unsigned int[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23364 | if (!loaded && fopt[6]==32 && fopt[4]==0 && fopt[5]==1) { int *xval, *val = new int[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23365 | if (!loaded && fopt[6]==32 && fopt[4]==1 && fopt[5]==0) { float *xval, *val = new float[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23366 | if (!loaded && fopt[6]==32 && fopt[4]==1 && fopt[5]==1) { float *xval, *val = new float[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23367 | if (!loaded && fopt[6]==64 && fopt[4]==1 && fopt[5]==0) { double *xval, *val = new double[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23368 | if (!loaded && fopt[6]==64 && fopt[4]==1 && fopt[5]==1) { double *xval, *val = new double[fopt[0]*fopt[3]]; for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { cimg::fread(val,fopt[0]*fopt[3],nfile); if (fopt[7]!=endian) cimg::endian_swap(val,fopt[0]*fopt[3]); xval = val; for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) (*this)(x,y,z,k) = (T)*(xval++); } delete[] val; loaded = true; }; | |
23369 | if (!loaded) { | |
23370 | if (!file) cimg::fclose(nfile); | |
23371 | throw CImgIOException("CImg<%s>::load_inr() : File '%s', cannot read images of the type specified in the file", | |
23372 | pixel_type(),filename?filename:"(FILE*)"); | |
23373 | } | |
23374 | if (!file) cimg::fclose(nfile); | |
23375 | return *this; | |
23376 | } | |
23377 | static void _load_inr(std::FILE *file, int out[8], float *const voxsize=0) { | |
23378 | char item[1024], tmp1[64], tmp2[64]; | |
23379 | out[0] = out[1] = out[2] = out[3] = out[5] = 1; out[4] = out[6] = out[7] = -1; | |
23380 | std::fscanf(file,"%63s",item); | |
23381 | if(cimg::strncasecmp(item,"#INRIMAGE-4#{",13)!=0) | |
23382 | throw CImgIOException("CImg<%s>::load_inr() : File does not appear to be a valid INR file.\n" | |
23383 | "(INRIMAGE-4 identifier not found)",pixel_type()); | |
23384 | while (std::fscanf(file," %63[^\n]%*c",item)!=(-1) && cimg::strncmp(item,"##}",3)) { | |
23385 | std::sscanf(item," XDIM%*[^0-9]%d",out); | |
23386 | std::sscanf(item," YDIM%*[^0-9]%d",out+1); | |
23387 | std::sscanf(item," ZDIM%*[^0-9]%d",out+2); | |
23388 | std::sscanf(item," VDIM%*[^0-9]%d",out+3); | |
23389 | std::sscanf(item," PIXSIZE%*[^0-9]%d",out+6); | |
23390 | if (voxsize) { | |
23391 | std::sscanf(item," VX%*[^0-9.eE+-]%f",voxsize); | |
23392 | std::sscanf(item," VY%*[^0-9.eE+-]%f",voxsize+1); | |
23393 | std::sscanf(item," VZ%*[^0-9.eE+-]%f",voxsize+2); | |
23394 | } | |
23395 | if (std::sscanf(item," CPU%*[ =]%s",tmp1)) out[7]=cimg::strncasecmp(tmp1,"sun",3)?0:1; | |
23396 | switch(std::sscanf(item," TYPE%*[ =]%s %s",tmp1,tmp2)) { | |
23397 | case 0: break; | |
23398 | case 2: out[5] = cimg::strncasecmp(tmp1,"unsigned",8)?1:0; std::strcpy(tmp1,tmp2); | |
23399 | case 1: | |
23400 | if (!cimg::strncasecmp(tmp1,"int",3) || !cimg::strncasecmp(tmp1,"fixed",5)) out[4] = 0; | |
23401 | if (!cimg::strncasecmp(tmp1,"float",5) || !cimg::strncasecmp(tmp1,"double",6)) out[4] = 1; | |
23402 | if (!cimg::strncasecmp(tmp1,"packed",6)) out[4] = 2; | |
23403 | if (out[4]>=0) break; | |
23404 | default: throw CImgIOException("cimg::inr_header_read() : Invalid TYPE '%s'",tmp2); | |
23405 | } | |
23406 | } | |
23407 | if(out[0]<0 || out[1]<0 || out[2]<0 || out[3]<0) | |
23408 | throw CImgIOException("CImg<%s>::load_inr() : Bad dimensions in .inr file = ( %d , %d , %d , %d )", | |
23409 | pixel_type(),out[0],out[1],out[2],out[3]); | |
23410 | if(out[4]<0 || out[5]<0) throw CImgIOException("CImg<%s>::load_inr() : TYPE is not fully defined",pixel_type()); | |
23411 | if(out[6]<0) throw CImgIOException("CImg<%s>::load_inr() : PIXSIZE is not fully defined",pixel_type()); | |
23412 | if(out[7]<0) throw CImgIOException("CImg<%s>::load_inr() : Big/Little Endian coding type is not defined",pixel_type()); | |
23413 | } | |
23414 | static CImg<T> get_load_inr(const char *const filename, float *const voxsize=0) { | |
23415 | return CImg<T>().load_inr(0,filename,voxsize); | |
23416 | } | |
23417 | CImg<T>& load_inr(const char *const filename, float *const voxsize=0) { | |
23418 | return load_inr(0,filename,voxsize); | |
23419 | } | |
23420 | static CImg<T> get_load_pandore(std::FILE *const file, const char *const filename=0) { | |
23421 | return CImg<T>().load_pandore(file,filename); | |
23422 | } | |
23423 | CImg<T>& load_pandore(std::FILE *const file, const char *const filename) { | |
23424 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
23425 | typedef unsigned char uchar; | |
23426 | typedef unsigned short ushort; | |
23427 | typedef unsigned int uint; | |
23428 | typedef unsigned long ulong; | |
23429 | char tmp[32]; | |
23430 | cimg::fread(tmp,12,nfile); | |
23431 | if (cimg::strncasecmp("PANDORE",tmp,7)) { | |
23432 | if (!file) cimg::fclose(nfile); | |
23433 | throw CImgIOException("CImg<%s>::load_pandore() : File '%s' is not a valid PANDORE file.\n" | |
23434 | "(PANDORE identifier not found).",pixel_type(),filename?filename:"(FILE*)"); | |
23435 | } | |
23436 | unsigned int imageid,dims[8]; | |
23437 | int ptbuf[4]; | |
23438 | cimg::fread(&imageid,1,nfile); | |
23439 | const bool endian = (imageid>255); | |
23440 | if (endian) cimg::endian_swap(imageid); | |
23441 | cimg::fread(tmp,20,nfile); | |
23442 | switch (imageid) { | |
23443 | case 2: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,1); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23444 | case 3: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,1); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23445 | case 4: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,1); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23446 | case 5: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,1); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23447 | case 6: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,1); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23448 | case 7: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,1); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23449 | case 8: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],1); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23450 | case 9: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],1); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23451 | case 10: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],1); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23452 | case 11: { | |
23453 | cimg::fread(dims,3,nfile); | |
23454 | if (endian) cimg::endian_swap(dims,3); | |
23455 | assign(dims[1],1,1,1); | |
23456 | const unsigned siz = size(); | |
23457 | if (dims[2]<256) { | |
23458 | unsigned char *buffer = new unsigned char[siz]; | |
23459 | cimg::fread(buffer,siz,nfile); | |
23460 | T *ptrd = data; | |
23461 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23462 | buffer-=siz; | |
23463 | delete[] buffer; | |
23464 | } else { | |
23465 | if (dims[2]<65536) { | |
23466 | unsigned short *buffer = new unsigned short[siz]; | |
23467 | cimg::fread(buffer,siz,nfile); | |
23468 | if (endian) cimg::endian_swap(buffer,siz); | |
23469 | T *ptrd = data; | |
23470 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23471 | buffer-=siz; | |
23472 | delete[] buffer; | |
23473 | } else { | |
23474 | unsigned int *buffer = new unsigned int[siz]; | |
23475 | cimg::fread(buffer,siz,nfile); | |
23476 | if (endian) cimg::endian_swap(buffer,siz); | |
23477 | T *ptrd = data; | |
23478 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23479 | buffer-=siz; | |
23480 | delete[] buffer; | |
23481 | } | |
23482 | } | |
23483 | } | |
23484 | break; | |
23485 | case 12: { | |
23486 | cimg::fread(dims,4,nfile); | |
23487 | if (endian) cimg::endian_swap(dims,4); | |
23488 | assign(dims[2],dims[1],1,1); | |
23489 | const unsigned int siz = size(); | |
23490 | if (dims[3]<256) { | |
23491 | unsigned char *buffer = new unsigned char[siz]; | |
23492 | cimg::fread(buffer,siz,nfile); | |
23493 | T *ptrd = data; | |
23494 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23495 | buffer-=siz; | |
23496 | delete[] buffer; | |
23497 | } else { | |
23498 | if (dims[3]<65536) { | |
23499 | unsigned short *buffer = new unsigned short[siz]; | |
23500 | cimg::fread(buffer,siz,nfile); | |
23501 | if (endian) cimg::endian_swap(buffer,siz); | |
23502 | T *ptrd = data; | |
23503 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23504 | buffer-=siz; | |
23505 | delete[] buffer; | |
23506 | } else { | |
23507 | unsigned long *buffer = new unsigned long[siz]; | |
23508 | cimg::fread(buffer,siz,nfile); | |
23509 | if (endian) cimg::endian_swap(buffer,siz); | |
23510 | T *ptrd = data; | |
23511 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23512 | buffer-=siz; | |
23513 | delete[] buffer; | |
23514 | } | |
23515 | } | |
23516 | } | |
23517 | break; | |
23518 | case 13: { | |
23519 | cimg::fread(dims,5,nfile); | |
23520 | if (endian) cimg::endian_swap(dims,5); | |
23521 | assign(dims[3],dims[2],dims[1],1); | |
23522 | const unsigned int siz = size(); | |
23523 | if (dims[4]<256) { | |
23524 | unsigned char *buffer = new unsigned char[siz]; | |
23525 | cimg::fread(buffer,siz,nfile); | |
23526 | T *ptrd = data; | |
23527 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23528 | buffer-=siz; | |
23529 | delete[] buffer; | |
23530 | } else { | |
23531 | if (dims[4]<65536) { | |
23532 | unsigned short *buffer = new unsigned short[siz]; | |
23533 | cimg::fread(buffer,siz,nfile); | |
23534 | if (endian) cimg::endian_swap(buffer,siz); | |
23535 | T *ptrd = data; | |
23536 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23537 | buffer-=siz; | |
23538 | delete[] buffer; | |
23539 | } else { | |
23540 | unsigned int *buffer = new unsigned int[siz]; | |
23541 | cimg::fread(buffer,siz,nfile); | |
23542 | if (endian) cimg::endian_swap(buffer,siz); | |
23543 | T *ptrd = data; | |
23544 | for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); | |
23545 | buffer-=siz; | |
23546 | delete[] buffer; | |
23547 | } | |
23548 | } | |
23549 | } | |
23550 | break; | |
23551 | case 16: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[2],dims[1],1,3); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23552 | case 17: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[2],dims[1],1,3); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23553 | case 18: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[2],dims[1],1,3); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23554 | case 19: { cimg::fread(dims,5,nfile); if (endian) cimg::endian_swap(dims,5); assign(dims[3],dims[2],dims[1],3); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23555 | case 20: { cimg::fread(dims,5,nfile); if (endian) cimg::endian_swap(dims,5); assign(dims[3],dims[2],dims[1],3); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23556 | case 21: { cimg::fread(dims,5,nfile); if (endian) cimg::endian_swap(dims,5); assign(dims[3],dims[2],dims[1],3); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23557 | case 22: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,dims[0]); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23558 | case 23: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,dims[0]); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23559 | case 24: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,dims[0]); const unsigned int siz = size(); ulong *buffer = new ulong[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23560 | case 25: { cimg::fread(dims,2,nfile); if (endian) cimg::endian_swap(dims,2); assign(dims[1],1,1,dims[0]); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23561 | case 26: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,dims[0]); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23562 | case 27: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,dims[0]); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23563 | case 28: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,dims[0]); const unsigned int siz = size(); ulong *buffer = new ulong[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23564 | case 29: { cimg::fread(dims,3,nfile); if (endian) cimg::endian_swap(dims,3); assign(dims[2],dims[1],1,dims[0]); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23565 | case 30: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],dims[0]); const unsigned int siz = size(); uchar *buffer = new uchar[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23566 | case 31: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],dims[0]); const unsigned int siz = size(); long *buffer = new long[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23567 | case 32: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],dims[0]); const unsigned int siz = size(); ulong *buffer = new ulong[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23568 | case 33: { cimg::fread(dims,4,nfile); if (endian) cimg::endian_swap(dims,4); assign(dims[3],dims[2],dims[1],dims[0]); const unsigned int siz = size(); float *buffer = new float[siz]; cimg::fread(buffer,siz,nfile); if (endian) cimg::endian_swap(buffer,siz); T *ptrd = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(ptrd++) = (T)*(buffer++); buffer-=siz; delete[] buffer; } break;; | |
23569 | case 34: | |
23570 | cimg::fread(ptbuf,1,nfile); | |
23571 | if (endian) cimg::endian_swap(ptbuf,1); | |
23572 | assign(1); (*this)(0) = (T)ptbuf[0]; | |
23573 | break; | |
23574 | case 35: | |
23575 | cimg::fread(ptbuf,2,nfile); | |
23576 | if (endian) cimg::endian_swap(ptbuf,2); | |
23577 | assign(2); (*this)(0) = (T)ptbuf[1]; (*this)(1) = (T)ptbuf[0]; | |
23578 | break; | |
23579 | case 36: | |
23580 | cimg::fread(ptbuf,3,nfile); | |
23581 | if (endian) cimg::endian_swap(ptbuf,3); | |
23582 | assign(3); (*this)(0) = (T)ptbuf[2]; (*this)(1) = (T)ptbuf[1]; (*this)(2) = (T)ptbuf[0]; | |
23583 | break; | |
23584 | default: | |
23585 | if (!file) cimg::fclose(nfile); | |
23586 | throw CImgIOException("CImg<%s>::load_pandore() : File '%s', cannot read images with ID_type=%u", | |
23587 | pixel_type(),filename?filename:"(FILE*)",imageid); | |
23588 | } | |
23589 | if (!file) cimg::fclose(nfile); | |
23590 | return *this; | |
23591 | } | |
23592 | static CImg<T> get_load_pandore(const char *const filename) { | |
23593 | return CImg<T>().load_pandore(0,filename); | |
23594 | } | |
23595 | CImg<T>& load_pandore(const char *const filename) { | |
23596 | return load_pandore(0,filename); | |
23597 | } | |
23598 | static CImg<T> get_load_analyze(const char *const filename, float *const voxsize=0) { | |
23599 | return CImg<T>().load_analyze(filename,voxsize); | |
23600 | } | |
23601 | CImg<T>& load_analyze(const char *const filename, float *const voxsize=0) { | |
23602 | std::FILE *file_header = 0, *file = 0; | |
23603 | bool error_file = false; | |
23604 | char body[1024]; | |
23605 | const char *ext = cimg::filename_split(filename,body); | |
23606 | if (!cimg::strncasecmp(ext,"nii",3)) file_header = cimg::fopen(filename,"rb"); | |
23607 | else { | |
23608 | if (!cimg::strncasecmp(ext,"hdr",3) || | |
23609 | !cimg::strncasecmp(ext,"img",3)) { | |
23610 | std::sprintf(body+cimg::strlen(body),".hdr"); | |
23611 | file_header = cimg::fopen(body,"rb"); | |
23612 | if (!file_header) error_file = true; | |
23613 | else { | |
23614 | std::sprintf(body+cimg::strlen(body)-3,"img"); | |
23615 | file = cimg::fopen(body,"rb"); | |
23616 | if (!file) { cimg::fclose(file_header); error_file = true; } | |
23617 | } | |
23618 | } | |
23619 | } | |
23620 | if (error_file) throw CImgIOException("CImg<%s>::load_analyze() : Filename '%s', not recognized as an Analyze 7.5 or NIFTI file.", | |
23621 | pixel_type(),filename); | |
23622 | bool endian = false; | |
23623 | unsigned int header_size; | |
23624 | cimg::fread(&header_size,1,file_header); | |
23625 | if (header_size>=4096) { endian = true; cimg::endian_swap(header_size); } | |
23626 | unsigned char *header = new unsigned char[header_size]; | |
23627 | cimg::fread(header+4,header_size-4,file_header); | |
23628 | if (file) cimg::fclose(file_header); | |
23629 | if (endian) { | |
23630 | cimg::endian_swap((short*)(header+40),5); | |
23631 | cimg::endian_swap((short*)(header+70),1); | |
23632 | cimg::endian_swap((short*)(header+72),1); | |
23633 | cimg::endian_swap((float*)(header+76),4); | |
23634 | cimg::endian_swap((float*)(header+112),1); | |
23635 | } | |
23636 | unsigned short *dim = (unsigned short*)(header+40), dimx=1, dimy=1, dimz=1, dimv=1; | |
23637 | if (!dim[0]) cimg::warn("CImg<%s>::load_analyze() : Specified image has zero dimensions.",pixel_type()); | |
23638 | if (dim[0]>4) cimg::warn("CImg<%s>::load_analyze() : Number of image dimension is %d, reading only the 4 first dimensions", | |
23639 | pixel_type(),dim[0]); | |
23640 | if (dim[0]>=1) dimx = dim[1]; | |
23641 | if (dim[0]>=2) dimy = dim[2]; | |
23642 | if (dim[0]>=3) dimz = dim[3]; | |
23643 | if (dim[0]>=4) dimv = dim[4]; | |
23644 | float scalefactor = *(float*)(header+112); if (scalefactor==0) scalefactor=1; | |
23645 | const unsigned short datatype = *(short*)(header+70); | |
23646 | if (voxsize) { const float *vsize = (float*)(header+76); voxsize[0] = vsize[1]; voxsize[1] = vsize[2]; voxsize[2] = vsize[3]; } | |
23647 | delete[] header; | |
23648 | std::FILE *nfile = file?file:file_header; | |
23649 | assign(dimx,dimy,dimz,dimv); | |
23650 | switch (datatype) { | |
23651 | case 2: { | |
23652 | unsigned char *buffer = new unsigned char[dimx*dimy*dimz*dimv]; | |
23653 | cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile); | |
23654 | for (unsigned int off = 0; off<(*this).size(); ++off) data[off] = (T)(buffer[off]*scalefactor); | |
23655 | delete[] buffer; | |
23656 | } break; | |
23657 | case 4: { | |
23658 | short *buffer = new short[dimx*dimy*dimz*dimv]; | |
23659 | cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile); | |
23660 | if (endian) cimg::endian_swap(buffer,dimx*dimy*dimz*dimv); | |
23661 | for (unsigned int off = 0; off<(*this).size(); ++off) data[off] = (T)(buffer[off]*scalefactor); | |
23662 | delete[] buffer; | |
23663 | } break; | |
23664 | case 8: { | |
23665 | int *buffer = new int[dimx*dimy*dimz*dimv]; | |
23666 | cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile); | |
23667 | if (endian) cimg::endian_swap(buffer,dimx*dimy*dimz*dimv); | |
23668 | for (unsigned int off = 0; off<(*this).size(); ++off) data[off] = (T)(buffer[off]*scalefactor); | |
23669 | delete[] buffer; | |
23670 | } break; | |
23671 | case 16: { | |
23672 | float *buffer = new float[dimx*dimy*dimz*dimv]; | |
23673 | cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile); | |
23674 | if (endian) cimg::endian_swap(buffer,dimx*dimy*dimz*dimv); | |
23675 | for (unsigned int off = 0; off<(*this).size(); ++off) data[off] = (T)(buffer[off]*scalefactor); | |
23676 | delete[] buffer; | |
23677 | } break; | |
23678 | case 64: { | |
23679 | double *buffer = new double[dimx*dimy*dimz*dimv]; | |
23680 | cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile); | |
23681 | if (endian) cimg::endian_swap(buffer,dimx*dimy*dimz*dimv); | |
23682 | for (unsigned int off = 0; off<(*this).size(); ++off) data[off] = (T)(buffer[off]*scalefactor); | |
23683 | delete[] buffer; | |
23684 | } break; | |
23685 | default: | |
23686 | cimg::fclose(nfile); | |
23687 | throw CImgIOException("CImg<%s>::load_analyze() : File '%s, cannot read images with 'datatype = %d'", | |
23688 | pixel_type(),filename,datatype); | |
23689 | } | |
23690 | cimg::fclose(nfile); | |
23691 | return *this; | |
23692 | } | |
23693 | template<typename tf, typename tc> | |
23694 | static CImg<T> get_load_off(const char *const filename, CImgList<tf>& primitives, CImgList<tc>& colors, | |
23695 | const bool invert_faces=false) { | |
23696 | return CImg<T>().load_off(filename,primitives,colors,invert_faces); | |
23697 | } | |
23698 | template<typename tf, typename tc> | |
23699 | CImg<T>& load_off(const char *const filename, CImgList<tf>& primitives, CImgList<tc>& colors, const bool invert_faces=false) { | |
23700 | std::FILE *file=cimg::fopen(filename,"r"); | |
23701 | unsigned int nb_points = 0, nb_primitives = 0, nb_read = 0; | |
23702 | char line[256] = { 0 }; | |
23703 | int err; | |
23704 | do { err = std::fscanf(file,"%255[^\n] ",line); } while (!err || (err==1 && line[0]=='#')); | |
23705 | if (cimg::strncasecmp(line,"OFF",3) && cimg::strncasecmp(line,"COFF",4)) { | |
23706 | cimg::fclose(file); | |
23707 | throw CImgIOException("CImg<%s>::load_off() : File '%s', keyword 'OFF' not found.",pixel_type(),filename); | |
23708 | } | |
23709 | do { err = std::fscanf(file,"%255[^\n] ",line); } while (!err || (err==1 && line[0]=='#')); | |
23710 | if ((err = std::sscanf(line,"%u%u%*[^\n] ",&nb_points,&nb_primitives))!=2) { | |
23711 | cimg::fclose(file); | |
23712 | throw CImgIOException("CImg<%s>::load_off() : File '%s', invalid vertices/primitives numbers.",pixel_type(),filename); | |
23713 | } | |
23714 | assign(nb_points,3); | |
23715 | float X = 0, Y = 0, Z = 0; | |
23716 | for (int l = 0; l<(int)((*this).width); ++l) { | |
23717 | do { err = std::fscanf(file,"%255[^\n] ",line); } while (!err || (err==1 && line[0]=='#')); | |
23718 | if ((err = std::sscanf(line,"%f%f%f%*[^\n] ",&X,&Y,&Z))!=3) { | |
23719 | cimg::fclose(file); | |
23720 | throw CImgIOException("CImg<%s>::load_off() : File '%s', cannot read point %u/%u.\n",pixel_type(),filename,l+1,nb_points); | |
23721 | } | |
23722 | (*this)(l,0) = (T)X; (*this)(l,1) = (T)Y; (*this)(l,2) = (T)Z; | |
23723 | } | |
23724 | primitives.assign(); | |
23725 | colors.assign(); | |
23726 | bool stopflag = false; | |
23727 | while (!stopflag) { | |
23728 | float c0 = 0.7f, c1 = 0.7f, c2 = 0.7f; | |
23729 | unsigned int prim = 0, i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0; | |
23730 | line[0]='\0'; | |
23731 | if ((err = std::fscanf(file,"%u",&prim))!=1) stopflag=true; | |
23732 | else { | |
23733 | ++nb_read; | |
23734 | switch (prim) { | |
23735 | case 1: { | |
23736 | if ((err = std::fscanf(file,"%u%255[^\n] ",&i0,line))<2) { | |
23737 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23738 | pixel_type(),filename,nb_read,nb_primitives); | |
23739 | std::fscanf(file,"%*[^\n] "); | |
23740 | } else { | |
23741 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23742 | primitives.insert(CImg<tf>::vector(i0)); | |
23743 | colors.insert(CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255))); | |
23744 | } | |
23745 | } break; | |
23746 | case 2: { | |
23747 | if ((err = std::fscanf(file,"%u%u%255[^\n] ",&i0,&i1,line))<2) { | |
23748 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23749 | pixel_type(),filename,nb_read,nb_primitives); | |
23750 | std::fscanf(file,"%*[^\n] "); | |
23751 | } else { | |
23752 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23753 | primitives.insert(CImg<tf>::vector(i0,i1)); | |
23754 | colors.insert(CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255))); | |
23755 | } | |
23756 | } break; | |
23757 | case 3: { | |
23758 | if ((err = std::fscanf(file,"%u%u%u%255[^\n] ",&i0,&i1,&i2,line))<3) { | |
23759 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23760 | pixel_type(),filename,nb_read,nb_primitives); | |
23761 | std::fscanf(file,"%*[^\n] "); | |
23762 | } else { | |
23763 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23764 | if (invert_faces) primitives.insert(CImg<tf>::vector(i0,i1,i2)); | |
23765 | else primitives.insert(CImg<tf>::vector(i0,i2,i1)); | |
23766 | colors.insert(CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255))); | |
23767 | } | |
23768 | } break; | |
23769 | case 4: { | |
23770 | if ((err = std::fscanf(file,"%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,line))<4) { | |
23771 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23772 | pixel_type(),filename,nb_read,nb_primitives); | |
23773 | std::fscanf(file,"%*[^\n] "); | |
23774 | } else { | |
23775 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23776 | if (invert_faces) primitives.insert(CImg<tf>::vector(i0,i1,i2,i3)); | |
23777 | else primitives.insert(CImg<tf>::vector(i0,i3,i2,i1)); | |
23778 | colors.insert(CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255))); | |
23779 | } | |
23780 | } break; | |
23781 | case 5: { | |
23782 | if ((err = std::fscanf(file,"%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,line))<5) { | |
23783 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23784 | pixel_type(),filename,nb_read,nb_primitives); | |
23785 | std::fscanf(file,"%*[^\n] "); | |
23786 | } else { | |
23787 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23788 | if (invert_faces) { | |
23789 | primitives.insert(CImg<tf>::vector(i0,i1,i2,i3)); | |
23790 | primitives.insert(CImg<tf>::vector(i0,i3,i4)); | |
23791 | } | |
23792 | else { | |
23793 | primitives.insert(CImg<tf>::vector(i0,i3,i2,i1)); | |
23794 | primitives.insert(CImg<tf>::vector(i0,i4,i3)); | |
23795 | } | |
23796 | colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255))); | |
23797 | ++nb_primitives; | |
23798 | } | |
23799 | } break; | |
23800 | case 6: { | |
23801 | if ((err = std::fscanf(file,"%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,line))<6) { | |
23802 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23803 | pixel_type(),filename,nb_read,nb_primitives); | |
23804 | std::fscanf(file,"%*[^\n] "); | |
23805 | } else { | |
23806 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23807 | if (invert_faces) { | |
23808 | primitives.insert(CImg<tf>::vector(i0,i1,i2,i3)); | |
23809 | primitives.insert(CImg<tf>::vector(i0,i3,i4,i5)); | |
23810 | } | |
23811 | else { | |
23812 | primitives.insert(CImg<tf>::vector(i0,i3,i2,i1)); | |
23813 | primitives.insert(CImg<tf>::vector(i0,i5,i4,i3)); | |
23814 | } | |
23815 | colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255))); | |
23816 | ++nb_primitives; | |
23817 | } | |
23818 | } break; | |
23819 | case 7: { | |
23820 | if ((err = std::fscanf(file,"%u%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,&i6,line))<7) { | |
23821 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23822 | pixel_type(),filename,nb_read,nb_primitives); | |
23823 | std::fscanf(file,"%*[^\n] "); | |
23824 | } else { | |
23825 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23826 | if (invert_faces) { | |
23827 | primitives.insert(CImg<tf>::vector(i0,i1,i3,i4)); | |
23828 | primitives.insert(CImg<tf>::vector(i0,i4,i5,i6)); | |
23829 | primitives.insert(CImg<tf>::vector(i1,i2,i3)); | |
23830 | } | |
23831 | else { | |
23832 | primitives.insert(CImg<tf>::vector(i0,i4,i3,i1)); | |
23833 | primitives.insert(CImg<tf>::vector(i0,i6,i5,i4)); | |
23834 | primitives.insert(CImg<tf>::vector(i3,i2,i1)); | |
23835 | } | |
23836 | colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255))); | |
23837 | ++(++nb_primitives); | |
23838 | } | |
23839 | } break; | |
23840 | case 8: { | |
23841 | if ((err = std::fscanf(file,"%u%u%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,&i6,&i7,line))<7) { | |
23842 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.", | |
23843 | pixel_type(),filename,nb_read,nb_primitives); | |
23844 | std::fscanf(file,"%*[^\n] "); | |
23845 | } else { | |
23846 | std::sscanf(line,"%f%f%f",&c0,&c1,&c2); | |
23847 | if (invert_faces) { | |
23848 | primitives.insert(CImg<tf>::vector(i0,i1,i2,i3)); | |
23849 | primitives.insert(CImg<tf>::vector(i0,i3,i4,i5)); | |
23850 | primitives.insert(CImg<tf>::vector(i0,i5,i6,i7)); | |
23851 | } | |
23852 | else { | |
23853 | primitives.insert(CImg<tf>::vector(i0,i3,i2,i1)); | |
23854 | primitives.insert(CImg<tf>::vector(i0,i5,i4,i3)); | |
23855 | primitives.insert(CImg<tf>::vector(i0,i7,i6,i5)); | |
23856 | } | |
23857 | colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255))); | |
23858 | ++(++nb_primitives); | |
23859 | } | |
23860 | } break; | |
23861 | default: | |
23862 | cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u (%u vertices).", | |
23863 | pixel_type(),filename,nb_read,nb_primitives,prim); | |
23864 | std::fscanf(file,"%*[^\n] "); | |
23865 | break; | |
23866 | } | |
23867 | } | |
23868 | } | |
23869 | cimg::fclose(file); | |
23870 | if (primitives.size!=nb_primitives) | |
23871 | cimg::warn("CImg<%s>::load_off() : File '%s', read only %u primitives instead of %u as claimed in the header.", | |
23872 | pixel_type(),filename,primitives.size,nb_primitives); | |
23873 | return *this; | |
23874 | } | |
23875 | static CImg<T> get_load_dicom(const char *const filename) { | |
23876 | return CImg<T>().load_dicom(filename); | |
23877 | } | |
23878 | CImg<T>& load_dicom(const char *const filename) { | |
23879 | char command[1024], filetmp[512], body[512]; | |
23880 | cimg::fclose(cimg::fopen(filename,"r")); | |
23881 | std::FILE *file; | |
23882 | do { | |
23883 | std::sprintf(filetmp,"%s.hdr",cimg::filenamerand()); | |
23884 | if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file); | |
23885 | } while (file); | |
23886 | std::sprintf(command,"%s -w -c anlz -o %s -f %s",cimg::medcon_path(),filetmp,filename); | |
23887 | cimg::system(command); | |
23888 | cimg::filename_split(filetmp,body); | |
23889 | std::sprintf(command,"m000-%s.hdr",body); | |
23890 | file = std::fopen(command,"rb"); | |
23891 | if (!file) { | |
23892 | throw CImgIOException("CImg<%s>::load_dicom() : Failed to open image '%s'.\n\n" | |
23893 | "Path of 'medcon' : \"%s\"\n" | |
23894 | "Path of temporary filename : \"%s\"", | |
23895 | pixel_type(),filename,cimg::medcon_path(),filetmp); | |
23896 | } else cimg::fclose(file); | |
23897 | load_analyze(command); | |
23898 | std::remove(command); | |
23899 | std::sprintf(command,"m000-%s.img",body); | |
23900 | std::remove(command); | |
23901 | return *this; | |
23902 | } | |
23903 | static CImg<T> get_load_imagemagick(const char *const filename) { | |
23904 | return CImg<T>().load_imagemagick(filename); | |
23905 | } | |
23906 | CImg<T>& load_imagemagick(const char *const filename) { | |
23907 | char command[1024], filetmp[512]; | |
23908 | std::FILE *file = 0; | |
23909 | do { | |
23910 | std::sprintf(filetmp,"%s%s%s.ppm",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
23911 | if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file); | |
23912 | } while (file); | |
23913 | std::sprintf(command,"%s \"%s\" %s",cimg::imagemagick_path(),filename,filetmp); | |
23914 | cimg::system(command,cimg::imagemagick_path()); | |
23915 | if (!(file = std::fopen(filetmp,"rb"))) { | |
23916 | cimg::fclose(cimg::fopen(filename,"r")); | |
23917 | throw CImgIOException("CImg<%s>::load_imagemagick() : Failed to open image '%s'.\n\n" | |
23918 | "Path of 'ImageMagick's convert' : \"%s\"\n" | |
23919 | "Path of temporary filename : \"%s\"", | |
23920 | pixel_type(),filename,cimg::imagemagick_path(),filetmp); | |
23921 | } else cimg::fclose(file); | |
23922 | load_pnm(filetmp); | |
23923 | std::remove(filetmp); | |
23924 | return *this; | |
23925 | } | |
23926 | static CImg<T> get_load_graphicsmagick(const char *const filename) { | |
23927 | return CImg<T>().load_graphicsmagick(filename); | |
23928 | } | |
23929 | CImg<T>& load_graphicsmagick(const char *const filename) { | |
23930 | char command[1024], filetmp[512]; | |
23931 | std::FILE *file = 0; | |
23932 | do { | |
23933 | std::sprintf(filetmp,"%s%s%s.ppm",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
23934 | if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file); | |
23935 | } while (file); | |
23936 | std::sprintf(command,"%s convert \"%s\" %s",cimg::graphicsmagick_path(),filename,filetmp); | |
23937 | cimg::system(command,cimg::graphicsmagick_path()); | |
23938 | if (!(file = std::fopen(filetmp,"rb"))) { | |
23939 | cimg::fclose(cimg::fopen(filename,"r")); | |
23940 | throw CImgIOException("CImg<%s>::load_graphicsmagick() : Failed to open image '%s'.\n\n" | |
23941 | "Path of 'GraphicsMagick's gm' : \"%s\"\n" | |
23942 | "Path of temporary filename : \"%s\"", | |
23943 | pixel_type(),filename,cimg::graphicsmagick_path(),filetmp); | |
23944 | } else cimg::fclose(file); | |
23945 | load_pnm(filetmp); | |
23946 | std::remove(filetmp); | |
23947 | return *this; | |
23948 | } | |
23949 | static CImg<T> get_load_other(const char *const filename) { | |
23950 | return CImg<T>().load_other(filename); | |
23951 | } | |
23952 | CImg<T>& load_other(const char *const filename) { | |
23953 | const unsigned int odebug = cimg::exception_mode(); | |
23954 | cimg::exception_mode() = 0; | |
23955 | try { load_magick(filename); } | |
23956 | catch (CImgException&) { | |
23957 | try { load_imagemagick(filename); } | |
23958 | catch (CImgException&) { | |
23959 | try { load_graphicsmagick(filename); } | |
23960 | catch (CImgException&) { | |
23961 | assign(); | |
23962 | } | |
23963 | } | |
23964 | } | |
23965 | cimg::exception_mode() = odebug; | |
23966 | if (is_empty()) | |
23967 | throw CImgIOException("CImg<%s>::load_other() : Failed to open image '%s'.\n" | |
23968 | "Check you have either the ImageMagick or GraphicsMagick package installed.", | |
23969 | pixel_type(),filename); | |
23970 | return *this; | |
23971 | } | |
23972 | static CImg<T> get_load_parrec(const char *const filename, const char axis='v', const char align='p') { | |
23973 | return CImg<T>().load_parrec(filename,axis,align); | |
23974 | } | |
23975 | CImg<T>& load_parrec(const char *const filename, const char axis='v', const char align='p') { | |
23976 | CImgList<T> list; | |
23977 | list.load_parrec(filename); | |
23978 | if (list.size==1) return list[0].transfer_to(*this); | |
23979 | return assign(list.get_append(axis,align)); | |
23980 | } | |
23981 | static CImg<T> get_load_cimg(std::FILE *const file, const char axis='z', const char align='p') { | |
23982 | return CImg<T>().load_cimg(file,axis,align); | |
23983 | } | |
23984 | CImg<T>& load_cimg(std::FILE *const file, const char axis='z', const char align='p') { | |
23985 | CImgList<T> list; | |
23986 | list.load_cimg(file); | |
23987 | if (list.size==1) return list[0].transfer_to(*this); | |
23988 | return assign(list.get_append(axis,align)); | |
23989 | } | |
23990 | static CImg<T> get_load_cimg(const char *const filename, const char axis='z', const char align='p') { | |
23991 | return CImg<T>().load_cimg(filename,axis,align); | |
23992 | } | |
23993 | CImg<T>& load_cimg(const char *const filename, const char axis='z', const char align='p') { | |
23994 | CImgList<T> list; | |
23995 | list.load_cimg(filename); | |
23996 | if (list.size==1) return list[0].transfer_to(*this); | |
23997 | return assign(list.get_append(axis,align)); | |
23998 | } | |
23999 | static CImg<T> get_load_cimg(std::FILE *const file, | |
24000 | const unsigned int n0, const unsigned int n1, | |
24001 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
24002 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, | |
24003 | const char axis='z', const char align='p') { | |
24004 | return CImg<T>().load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1,axis,align); | |
24005 | } | |
24006 | CImg<T>& load_cimg(std::FILE *const file, | |
24007 | const unsigned int n0, const unsigned int n1, | |
24008 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
24009 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, | |
24010 | const char axis='z', const char align='p') { | |
24011 | CImgList<T> list; | |
24012 | list.load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
24013 | if (list.size==1) return list[0].transfer_to(*this); | |
24014 | return assign(list.get_append(axis,align)); | |
24015 | } | |
24016 | static CImg<T> get_load_cimg(const char *const filename, | |
24017 | const unsigned int n0, const unsigned int n1, | |
24018 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
24019 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, | |
24020 | const char axis='z', const char align='p') { | |
24021 | return CImg<T>().load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1,axis,align); | |
24022 | } | |
24023 | CImg<T>& load_cimg(const char *const filename, | |
24024 | const unsigned int n0, const unsigned int n1, | |
24025 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
24026 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, | |
24027 | const char axis='z', const char align='p') { | |
24028 | CImgList<T> list; | |
24029 | list.load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
24030 | if (list.size==1) return list[0].transfer_to(*this); | |
24031 | return assign(list.get_append(axis,align)); | |
24032 | } | |
24033 | static CImg<T> get_load_yuv(std::FILE *const file, const char *const filename, | |
24034 | const unsigned int sizex, const unsigned int sizey=1, | |
24035 | const unsigned int first_frame=0, const int last_frame=-1, | |
24036 | const bool yuv2rgb = false, const char axis='z', const char align='p') { | |
24037 | return CImgList<T>().load_yuv(file,filename,sizex,sizey,first_frame,last_frame,yuv2rgb).get_append(axis,align); | |
24038 | } | |
24039 | CImg<T>& load_yuv(std::FILE *const file, const char *const filename, | |
24040 | const unsigned int sizex, const unsigned int sizey=1, | |
24041 | const unsigned int first_frame=0, const int last_frame=-1, | |
24042 | const bool yuv2rgb = false, const char axis='z', const char align='p') { | |
24043 | return get_load_yuv(file,filename,sizex,sizey,first_frame,last_frame,yuv2rgb,axis,align).transfer_to(*this); | |
24044 | } | |
24045 | static CImg<T> get_load_yuv(const char *const filename, | |
24046 | const unsigned int sizex, const unsigned int sizey=1, | |
24047 | const unsigned int first_frame=0, const int last_frame=-1, | |
24048 | const bool yuv2rgb = false, const char axis='z', const char align='p') { | |
24049 | return CImgList<T>().load_yuv(filename,sizex,sizey,first_frame,last_frame,yuv2rgb).get_append(axis,align); | |
24050 | } | |
24051 | CImg<T>& load_yuv(const char *const filename, | |
24052 | const unsigned int sizex, const unsigned int sizey=1, | |
24053 | const unsigned int first_frame=0, const int last_frame=-1, | |
24054 | const bool yuv2rgb = false, const char axis='z', const char align='p') { | |
24055 | return get_load_yuv(0,filename,sizex,sizey,first_frame,last_frame,yuv2rgb,axis,align).transfer_to(*this); | |
24056 | } | |
24057 | static CImg<T> get_load_ffmpeg(const char *const filename, const char axis='z', const char align='p') { | |
24058 | return CImgList<T>().load_ffmpeg(filename).get_append(axis,align); | |
24059 | } | |
24060 | CImg<T>& load_ffmpeg(const char *const filename, const char axis='z', const char align='p') { | |
24061 | return get_load_ffmpeg(filename,axis,align).transfer_to(*this); | |
24062 | } | |
24063 | const CImg<T>& save(const char *const filename, const int number=-1) const { | |
24064 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24065 | pixel_type(),width,height,depth,dim,data,filename); | |
24066 | if (!filename) throw CImgArgumentException("CImg<%s>::save() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24067 | pixel_type(),width,height,depth,dim,data); | |
24068 | const char *ext = cimg::filename_split(filename); | |
24069 | char nfilename[1024]; | |
24070 | const char *const fn = (number>=0)?cimg::filename_number(filename,number,6,nfilename):filename; | |
24071 | if (!cimg::strncasecmp(ext,"asc",3)) return save_ascii(fn); | |
24072 | if (!cimg::strncasecmp(ext,"dlm",3) || | |
24073 | !cimg::strncasecmp(ext,"txt",3)) return save_dlm(fn); | |
24074 | if (!cimg::strncasecmp(ext,"inr",3)) return save_inr(fn); | |
24075 | if (!cimg::strncasecmp(ext,"hdr",3) || | |
24076 | !cimg::strncasecmp(ext,"nii",3)) return save_analyze(fn); | |
24077 | if (!cimg::strncasecmp(ext,"dcm",3)) return save_dicom(fn); | |
24078 | if (!cimg::strncasecmp(ext,"pan",3)) return save_pandore(fn); | |
24079 | if (!cimg::strncasecmp(ext,"bmp",3)) return save_bmp(fn); | |
24080 | if (!cimg::strncasecmp(ext,"png",3)) return save_png(fn); | |
24081 | if (!cimg::strncasecmp(ext,"tif",3)) return save_tiff(fn); | |
24082 | if (!cimg::strncasecmp(ext,"jpg",3) || | |
24083 | !cimg::strncasecmp(ext,"jpeg",4)) return save_jpeg(fn); | |
24084 | if (!cimg::strncasecmp(ext,"rgba",4)) return save_rgba(fn); | |
24085 | if (!cimg::strncasecmp(ext,"rgb",3)) return save_rgb(fn); | |
24086 | if (!cimg::strncasecmp(ext,"raw",3)) return save_raw(fn); | |
24087 | if (!cimg::strncasecmp(ext,"cimg",4) || ext[0]=='\0') return save_cimg(fn); | |
24088 | if (!cimg::strncasecmp(ext,"pgm",3) || | |
24089 | !cimg::strncasecmp(ext,"ppm",3) || | |
24090 | !cimg::strncasecmp(ext,"pnm",3)) return save_pnm(fn); | |
24091 | if (!cimg::strncasecmp(ext,"yuv",3)) return save_yuv(fn,true); | |
24092 | if (!cimg::strncasecmp(ext,"avi",3) || | |
24093 | !cimg::strncasecmp(ext,"mov",3) || | |
24094 | !cimg::strncasecmp(ext,"mpg",3) || | |
24095 | !cimg::strncasecmp(ext,"mpeg",4)) return save_ffmpeg(fn); | |
24096 | return save_other(fn); | |
24097 | } | |
24098 | const CImg<T>& save_ascii(std::FILE *const file, const char *const filename=0) const { | |
24099 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_ascii() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24100 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24101 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_ascii() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24102 | pixel_type(),width,height,depth,dim,data); | |
24103 | std::FILE *const nfile = file?file:cimg::fopen(filename,"w"); | |
24104 | std::fprintf(nfile,"%u %u %u %u\n",width,height,depth,dim); | |
24105 | const T* ptrs = data; | |
24106 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
24107 | for (int x = 0; x<(int)((*this).width); ++x) std::fprintf(nfile,"%g ",(double)*(ptrs++)); | |
24108 | std::fputc('\n',nfile); | |
24109 | } | |
24110 | if (!file) cimg::fclose(nfile); | |
24111 | return *this; | |
24112 | } | |
24113 | const CImg<T>& save_ascii(const char *const filename) const { | |
24114 | return save_ascii(0,filename); | |
24115 | } | |
24116 | const CImg<T>& save_dlm(std::FILE *const file, const char *const filename=0) const { | |
24117 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_dlm() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24118 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24119 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_dlm() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24120 | pixel_type(),width,height,depth,dim,data); | |
24121 | if (depth>1) | |
24122 | cimg::warn("CImg<%s>::save_dlm() : Instance image (%u,%u,%u,%u,%p) is volumetric. Pixel values along Z will be unrolled (file '%s').", | |
24123 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24124 | if (dim>1) | |
24125 | cimg::warn("CImg<%s>::save_dlm() : Instance image (%u,%u,%u,%u,%p) is multispectral. Pixel values along V will be unrolled (file '%s').", | |
24126 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24127 | std::FILE *const nfile = file?file:cimg::fopen(filename,"w"); | |
24128 | const T* ptrs = data; | |
24129 | for (int v = 0; v<(int)((*this).dim); ++v) for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) { | |
24130 | for (int x = 0; x<(int)((*this).width); ++x) std::fprintf(nfile,"%g%s",(double)*(ptrs++),(x==dimx()-1)?"":","); | |
24131 | std::fputc('\n',nfile); | |
24132 | } | |
24133 | if (!file) cimg::fclose(nfile); | |
24134 | return *this; | |
24135 | } | |
24136 | const CImg<T>& save_dlm(const char *const filename) const { | |
24137 | return save_dlm(0,filename); | |
24138 | } | |
24139 | const CImg<T>& save_pnm(std::FILE *const file, const char *const filename=0) const { | |
24140 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24141 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24142 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24143 | pixel_type(),width,height,depth,dim,data); | |
24144 | double stmin, stmax = (double)maxmin(stmin); | |
24145 | if (depth>1) | |
24146 | cimg::warn("CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved (file '%s').", | |
24147 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24148 | if (dim>3) | |
24149 | cimg::warn("CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved (file '%s').", | |
24150 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24151 | if (stmin<0 || stmax>65535) cimg::warn("CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow (file '%s').",pixel_type(),width,height,depth,dim,data,stmin,stmax,filename?filename:"(unknown)"); | |
24152 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24153 | const T | |
24154 | *ptrR = ptr(0,0,0,0), | |
24155 | *ptrG = (dim>=2)?ptr(0,0,0,1):0, | |
24156 | *ptrB = (dim>=3)?ptr(0,0,0,2):0; | |
24157 | const unsigned int buf_size = width*height*(dim==1?1:3); | |
24158 | std::fprintf(nfile,"P%c\n# CREATOR: CImg : Original size=%ux%ux%ux%u\n%u %u\n%u\n", | |
24159 | (dim==1?'5':'6'),width,height,depth,dim,width,height,stmax<256?255:65535); | |
24160 | switch(dim) { | |
24161 | case 1: { | |
24162 | if (stmax<256) { | |
24163 | unsigned char *ptrd = new unsigned char[buf_size], *xptrd = ptrd; | |
24164 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) *(xptrd++) = (unsigned char)*(ptrR++); | |
24165 | cimg::fwrite(ptrd,buf_size,nfile); | |
24166 | delete[] ptrd; | |
24167 | } else { | |
24168 | unsigned short *ptrd = new unsigned short[buf_size], *xptrd = ptrd; | |
24169 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) *(xptrd++) = (unsigned short)*(ptrR++); | |
24170 | if (!cimg::endian()) cimg::endian_swap(ptrd,buf_size); | |
24171 | cimg::fwrite(ptrd,buf_size,nfile); | |
24172 | delete[] ptrd; | |
24173 | } | |
24174 | } break; | |
24175 | case 2: { | |
24176 | if (stmax<256) { | |
24177 | unsigned char *ptrd = new unsigned char[buf_size], *xptrd = ptrd; | |
24178 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
24179 | *(xptrd++) = (unsigned char)*(ptrR++); | |
24180 | *(xptrd++) = (unsigned char)*(ptrG++); | |
24181 | *(xptrd++) = 0; | |
24182 | } | |
24183 | cimg::fwrite(ptrd,buf_size,nfile); | |
24184 | delete[] ptrd; | |
24185 | } else { | |
24186 | unsigned short *ptrd = new unsigned short[buf_size], *xptrd = ptrd; | |
24187 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
24188 | *(xptrd++) = (unsigned short)*(ptrR++); | |
24189 | *(xptrd++) = (unsigned short)*(ptrG++); | |
24190 | *(xptrd++) = 0; | |
24191 | } | |
24192 | if (!cimg::endian()) cimg::endian_swap(ptrd,buf_size); | |
24193 | cimg::fwrite(ptrd,buf_size,nfile); | |
24194 | delete[] ptrd; | |
24195 | } | |
24196 | } break; | |
24197 | default: { | |
24198 | if (stmax<256) { | |
24199 | unsigned char *ptrd = new unsigned char[buf_size], *xptrd = ptrd; | |
24200 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
24201 | *(xptrd++) = (unsigned char)*(ptrR++); | |
24202 | *(xptrd++) = (unsigned char)*(ptrG++); | |
24203 | *(xptrd++) = (unsigned char)*(ptrB++); | |
24204 | } | |
24205 | cimg::fwrite(ptrd,buf_size,nfile); | |
24206 | delete[] ptrd; | |
24207 | } else { | |
24208 | unsigned short *ptrd = new unsigned short[buf_size], *xptrd = ptrd; | |
24209 | for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
24210 | *(xptrd++) = (unsigned short)*(ptrR++); | |
24211 | *(xptrd++) = (unsigned short)*(ptrG++); | |
24212 | *(xptrd++) = (unsigned short)*(ptrB++); | |
24213 | } | |
24214 | if (!cimg::endian()) cimg::endian_swap(ptrd,buf_size); | |
24215 | cimg::fwrite(ptrd,buf_size,nfile); | |
24216 | delete[] ptrd; | |
24217 | } | |
24218 | } break; | |
24219 | } | |
24220 | if (!file) cimg::fclose(nfile); | |
24221 | return *this; | |
24222 | } | |
24223 | const CImg<T>& save_pnm(const char *const filename) const { | |
24224 | return save_pnm(0,filename); | |
24225 | } | |
24226 | const CImg<T>& save_dicom(const char *const filename) const { | |
24227 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_dicom() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24228 | pixel_type(),width,height,depth,dim,data,filename); | |
24229 | if (!filename) throw CImgArgumentException("CImg<%s>::save_dicom() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24230 | pixel_type(),width,height,depth,dim,data); | |
24231 | char command[1024], filetmp[512], body[512]; | |
24232 | std::FILE *file; | |
24233 | do { | |
24234 | std::sprintf(filetmp,"%s.hdr",cimg::filenamerand()); | |
24235 | if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file); | |
24236 | } while (file); | |
24237 | save_analyze(filetmp); | |
24238 | std::sprintf(command,"%s -w -c dicom -o %s -f %s",cimg::medcon_path(),filename,filetmp); | |
24239 | cimg::system(command); | |
24240 | std::remove(filetmp); | |
24241 | cimg::filename_split(filetmp,body); | |
24242 | std::sprintf(filetmp,"%s.img",body); | |
24243 | std::remove(filetmp); | |
24244 | std::sprintf(command,"m000-%s",filename); | |
24245 | file = std::fopen(command,"rb"); | |
24246 | if (!file) { | |
24247 | cimg::fclose(cimg::fopen(filename,"r")); | |
24248 | throw CImgIOException("CImg<%s>::save_dicom() : Failed to save image '%s'.\n\n" | |
24249 | "Path of 'medcon' : \"%s\"\n" | |
24250 | "Path of temporary filename : \"%s\"", | |
24251 | pixel_type(),filename,cimg::medcon_path(),filetmp); | |
24252 | } else cimg::fclose(file); | |
24253 | std::rename(command,filename); | |
24254 | return *this; | |
24255 | } | |
24256 | const CImg<T>& save_analyze(const char *const filename, const float *const voxsize=0) const { | |
24257 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_analyze() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.", | |
24258 | pixel_type(),width,height,depth,dim,data,filename); | |
24259 | if (!filename) throw CImgArgumentException("CImg<%s>::save_analyze() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24260 | pixel_type(),width,height,depth,dim,data); | |
24261 | std::FILE *file; | |
24262 | char header[348], hname[1024], iname[1024]; | |
24263 | const char *ext = cimg::filename_split(filename); | |
24264 | short datatype=-1; | |
24265 | std::memset(header,0,348); | |
24266 | if (!ext[0]) { std::sprintf(hname,"%s.hdr",filename); std::sprintf(iname,"%s.img",filename); } | |
24267 | if (!cimg::strncasecmp(ext,"hdr",3)) { | |
24268 | std::strcpy(hname,filename); std::strcpy(iname,filename); std::sprintf(iname+cimg::strlen(iname)-3,"img"); | |
24269 | } | |
24270 | if (!cimg::strncasecmp(ext,"img",3)) { | |
24271 | std::strcpy(hname,filename); std::strcpy(iname,filename); std::sprintf(hname+cimg::strlen(iname)-3,"hdr"); | |
24272 | } | |
24273 | if (!cimg::strncasecmp(ext,"nii",3)) { | |
24274 | std::strcpy(hname,filename); iname[0] = 0; | |
24275 | } | |
24276 | ((int*)(header))[0] = 348; | |
24277 | std::sprintf(header+4,"CImg"); | |
24278 | std::sprintf(header+14," "); | |
24279 | ((short*)(header+36))[0] = 4096; | |
24280 | ((char*)(header+38))[0] = 114; | |
24281 | ((short*)(header+40))[0] = 4; | |
24282 | ((short*)(header+40))[1] = width; | |
24283 | ((short*)(header+40))[2] = height; | |
24284 | ((short*)(header+40))[3] = depth; | |
24285 | ((short*)(header+40))[4] = dim; | |
24286 | if (!cimg::strcasecmp(pixel_type(),"bool")) datatype = 2; | |
24287 | if (!cimg::strcasecmp(pixel_type(),"unsigned char")) datatype = 2; | |
24288 | if (!cimg::strcasecmp(pixel_type(),"char")) datatype = 2; | |
24289 | if (!cimg::strcasecmp(pixel_type(),"unsigned short")) datatype = 4; | |
24290 | if (!cimg::strcasecmp(pixel_type(),"short")) datatype = 4; | |
24291 | if (!cimg::strcasecmp(pixel_type(),"unsigned int")) datatype = 8; | |
24292 | if (!cimg::strcasecmp(pixel_type(),"int")) datatype = 8; | |
24293 | if (!cimg::strcasecmp(pixel_type(),"unsigned long")) datatype = 8; | |
24294 | if (!cimg::strcasecmp(pixel_type(),"long")) datatype = 8; | |
24295 | if (!cimg::strcasecmp(pixel_type(),"float")) datatype = 16; | |
24296 | if (!cimg::strcasecmp(pixel_type(),"double")) datatype = 64; | |
24297 | if (datatype<0) | |
24298 | throw CImgIOException("CImg<%s>::save_analyze() : Cannot save image '%s' since pixel type (%s)" | |
24299 | "is not handled in Analyze7.5 specifications.\n", | |
24300 | pixel_type(),filename,pixel_type()); | |
24301 | ((short*)(header+70))[0] = datatype; | |
24302 | ((short*)(header+72))[0] = sizeof(T); | |
24303 | ((float*)(header+112))[0] = 1; | |
24304 | ((float*)(header+76))[0] = 0; | |
24305 | if (voxsize) { | |
24306 | ((float*)(header+76))[1] = voxsize[0]; | |
24307 | ((float*)(header+76))[2] = voxsize[1]; | |
24308 | ((float*)(header+76))[3] = voxsize[2]; | |
24309 | } else ((float*)(header+76))[1] = ((float*)(header+76))[2] = ((float*)(header+76))[3] = 1; | |
24310 | file = cimg::fopen(hname,"wb"); | |
24311 | cimg::fwrite(header,348,file); | |
24312 | if (iname[0]) { cimg::fclose(file); file = cimg::fopen(iname,"wb"); } | |
24313 | cimg::fwrite(data,size(),file); | |
24314 | cimg::fclose(file); | |
24315 | return *this; | |
24316 | } | |
24317 | const CImg<T>& save_cimg(std::FILE *const file, const char *const filename=0) const { | |
24318 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_cimg() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24319 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24320 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_cimg() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24321 | pixel_type(),width,height,depth,dim,data); | |
24322 | CImgList<T> tmp(1); | |
24323 | tmp[0].width = width; | |
24324 | tmp[0].height = height; | |
24325 | tmp[0].depth = depth; | |
24326 | tmp[0].dim = dim; | |
24327 | tmp[0].data = data; | |
24328 | tmp.save_cimg(file,filename); | |
24329 | tmp[0].width = tmp[0].height = tmp[0].depth = tmp[0].dim = 0; | |
24330 | tmp[0].data = 0; | |
24331 | return *this; | |
24332 | } | |
24333 | const CImg<T>& save_cimg(const char *const filename) const { | |
24334 | return save_cimg(0,filename); | |
24335 | } | |
24336 | const CImg<T>& save_cimg(std::FILE *const file, | |
24337 | const unsigned int n0, | |
24338 | const unsigned int x0, const unsigned int y0, | |
24339 | const unsigned int z0, const unsigned int v0) const { | |
24340 | CImgList<T> tmp(1); | |
24341 | tmp[0].width = width; | |
24342 | tmp[0].height = height; | |
24343 | tmp[0].depth = depth; | |
24344 | tmp[0].dim = dim; | |
24345 | tmp[0].data = data; | |
24346 | tmp.save_cimg(file,n0,x0,y0,z0,v0); | |
24347 | tmp[0].width = tmp[0].height = tmp[0].depth = tmp[0].dim = 0; | |
24348 | tmp[0].data = 0; | |
24349 | return *this; | |
24350 | } | |
24351 | const CImg<T>& save_cimg(const char *const filename, | |
24352 | const unsigned int n0, | |
24353 | const unsigned int x0, const unsigned int y0, | |
24354 | const unsigned int z0, const unsigned int v0) const { | |
24355 | CImgList<T> tmp(1); | |
24356 | tmp[0].width = width; | |
24357 | tmp[0].height = height; | |
24358 | tmp[0].depth = depth; | |
24359 | tmp[0].dim = dim; | |
24360 | tmp[0].data = data; | |
24361 | tmp.save_cimg(filename,n0,x0,y0,z0,v0); | |
24362 | tmp[0].width = tmp[0].height = tmp[0].depth = tmp[0].dim = 0; | |
24363 | tmp[0].data = 0; | |
24364 | return *this; | |
24365 | } | |
24366 | static void save_empty_cimg(std::FILE *const file, | |
24367 | const unsigned int dx, const unsigned int dy=1, | |
24368 | const unsigned int dz=1, const unsigned int dv=1) { | |
24369 | return CImgList<T>::save_empty_cimg(file,1,dx,dy,dz,dv); | |
24370 | } | |
24371 | static void save_empty_cimg(const char *const filename, | |
24372 | const unsigned int dx, const unsigned int dy=1, | |
24373 | const unsigned int dz=1, const unsigned int dv=1) { | |
24374 | return CImgList<T>::save_empty_cimg(filename,1,dx,dy,dz,dv); | |
24375 | } | |
24376 | const CImg<T>& save_raw(std::FILE *const file, const char *const filename=0, const bool multiplexed=false) const { | |
24377 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_raw() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24378 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24379 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_raw() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24380 | pixel_type(),width,height,depth,dim,data); | |
24381 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24382 | if (!multiplexed) cimg::fwrite(data,size(),nfile); | |
24383 | else { | |
24384 | CImg<T> buf(dim); | |
24385 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) { | |
24386 | for (int k = 0; k<(int)((*this).dim); ++k) buf[k] = (*this)(x,y,z,k); | |
24387 | cimg::fwrite(buf.data,dim,nfile); | |
24388 | } | |
24389 | } | |
24390 | if (!file) cimg::fclose(nfile); | |
24391 | return *this; | |
24392 | } | |
24393 | const CImg<T>& save_raw(const char *const filename=0, const bool multiplexed=false) const { | |
24394 | return save_raw(0,filename,multiplexed); | |
24395 | } | |
24396 | const CImg<T>& save_imagemagick(const char *const filename, const unsigned int quality=100) const { | |
24397 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_imagemagick() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s')", | |
24398 | pixel_type(),width,height,depth,dim,data,filename); | |
24399 | if (!filename) throw CImgArgumentException("CImg<%s>::save_imagemagick() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24400 | pixel_type(),width,height,depth,dim,data); | |
24401 | char command[1024],filetmp[512]; | |
24402 | std::FILE *file; | |
24403 | do { | |
24404 | if (dim==1) std::sprintf(filetmp,"%s%s%s.pgm",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
24405 | else std::sprintf(filetmp,"%s%s%s.ppm",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
24406 | if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file); | |
24407 | } while (file); | |
24408 | save_pnm(filetmp); | |
24409 | std::sprintf(command,"%s -quality %u%% %s \"%s\"",cimg::imagemagick_path(),quality,filetmp,filename); | |
24410 | cimg::system(command); | |
24411 | file = std::fopen(filename,"rb"); | |
24412 | if (!file) throw CImgIOException("CImg<%s>::save_imagemagick() : Failed to save image '%s'.\n\n" | |
24413 | "Path of 'convert' : \"%s\"\n" | |
24414 | "Path of temporary filename : \"%s\"\n", | |
24415 | pixel_type(),filename,cimg::imagemagick_path(),filetmp); | |
24416 | if (file) cimg::fclose(file); | |
24417 | std::remove(filetmp); | |
24418 | return *this; | |
24419 | } | |
24420 | const CImg<T>& save_graphicsmagick(const char *const filename, const unsigned int quality=100) const { | |
24421 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_graphicsmagick() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s')", | |
24422 | pixel_type(),width,height,depth,dim,data,filename); | |
24423 | if (!filename) throw CImgArgumentException("CImg<%s>::save_graphicsmagick() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24424 | pixel_type(),width,height,depth,dim,data); | |
24425 | char command[1024],filetmp[512]; | |
24426 | std::FILE *file; | |
24427 | do { | |
24428 | if (dim==1) std::sprintf(filetmp,"%s%s%s.pgm",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
24429 | else std::sprintf(filetmp,"%s%s%s.ppm",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
24430 | if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file); | |
24431 | } while (file); | |
24432 | save_pnm(filetmp); | |
24433 | std::sprintf(command,"%s -quality %u%% %s \"%s\"",cimg::graphicsmagick_path(),quality,filetmp,filename); | |
24434 | cimg::system(command); | |
24435 | file = std::fopen(filename,"rb"); | |
24436 | if (!file) throw CImgIOException("CImg<%s>::save_graphicsmagick() : Failed to save image '%s'.\n\n" | |
24437 | "Path of 'gm' : \"%s\"\n" | |
24438 | "Path of temporary filename : \"%s\"\n", | |
24439 | pixel_type(),filename,cimg::graphicsmagick_path(),filetmp); | |
24440 | if (file) cimg::fclose(file); | |
24441 | std::remove(filetmp); | |
24442 | return *this; | |
24443 | } | |
24444 | const CImg<T>& save_other(const char *const filename, const unsigned int quality=100) const { | |
24445 | const unsigned int odebug = cimg::exception_mode(); | |
24446 | bool is_saved = true; | |
24447 | cimg::exception_mode() = 0; | |
24448 | try { save_magick(filename); } | |
24449 | catch (CImgException&) { | |
24450 | try { save_imagemagick(filename,quality); } | |
24451 | catch (CImgException&) { | |
24452 | try { save_graphicsmagick(filename,quality); } | |
24453 | catch (CImgException&) { | |
24454 | is_saved = false; | |
24455 | } | |
24456 | } | |
24457 | } | |
24458 | cimg::exception_mode() = odebug; | |
24459 | if (!is_saved) throw CImgIOException("CImg<%s>::save_other() : File '%s' cannot be saved.\n" | |
24460 | "Check you have either the ImageMagick or GraphicsMagick package installed.", | |
24461 | pixel_type(),filename); | |
24462 | return *this; | |
24463 | } | |
24464 | const CImg<T>& save_inr(std::FILE *const file, const char *const filename=0, const float *const voxsize=0) const { | |
24465 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_inr() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24466 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24467 | if (!filename) throw CImgArgumentException("CImg<%s>::save_inr() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24468 | pixel_type(),width,height,depth,dim,data); | |
24469 | int inrpixsize=-1; | |
24470 | const char *inrtype = "unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0"; | |
24471 | if (!cimg::strcasecmp(pixel_type(),"unsigned char")) { inrtype = "unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; } | |
24472 | if (!cimg::strcasecmp(pixel_type(),"char")) { inrtype = "fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; } | |
24473 | if (!cimg::strcasecmp(pixel_type(),"unsigned short")) { inrtype = "unsigned fixed\nPIXSIZE=16 bits\nSCALE=2**0";inrpixsize = 2; } | |
24474 | if (!cimg::strcasecmp(pixel_type(),"short")) { inrtype = "fixed\nPIXSIZE=16 bits\nSCALE=2**0"; inrpixsize = 2; } | |
24475 | if (!cimg::strcasecmp(pixel_type(),"unsigned int")) { inrtype = "unsigned fixed\nPIXSIZE=32 bits\nSCALE=2**0";inrpixsize = 4; } | |
24476 | if (!cimg::strcasecmp(pixel_type(),"int")) { inrtype = "fixed\nPIXSIZE=32 bits\nSCALE=2**0"; inrpixsize = 4; } | |
24477 | if (!cimg::strcasecmp(pixel_type(),"float")) { inrtype = "float\nPIXSIZE=32 bits"; inrpixsize = 4; } | |
24478 | if (!cimg::strcasecmp(pixel_type(),"double")) { inrtype = "float\nPIXSIZE=64 bits"; inrpixsize = 8; } | |
24479 | if (inrpixsize<=0) throw CImgIOException("CImg<%s>::save_inr() : Don't know how to save images of '%s'",pixel_type(),pixel_type()); | |
24480 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24481 | char header[257]; | |
24482 | int err = std::sprintf(header,"#INRIMAGE-4#{\nXDIM=%u\nYDIM=%u\nZDIM=%u\nVDIM=%u\n",width,height,depth,dim); | |
24483 | if (voxsize) err += std::sprintf(header+err,"VX=%g\nVY=%g\nVZ=%g\n",voxsize[0],voxsize[1],voxsize[2]); | |
24484 | err += std::sprintf(header+err,"TYPE=%s\nCPU=%s\n",inrtype,cimg::endian()?"sun":"decm"); | |
24485 | std::memset(header+err,'\n',252-err); | |
24486 | std::memcpy(header+252,"##}\n",4); | |
24487 | cimg::fwrite(header,256,nfile); | |
24488 | for (int z = 0; z<(int)((*this).depth); ++z) for (int y = 0; y<(int)((*this).height); ++y) for (int x = 0; x<(int)((*this).width); ++x) for (int k = 0; k<(int)((*this).dim); ++k) cimg::fwrite(&((*this)(x,y,z,k)),1,nfile); | |
24489 | if (!file) cimg::fclose(nfile); | |
24490 | return *this; | |
24491 | } | |
24492 | const CImg<T>& save_inr(const char *const filename, const float *const voxsize=0) const { | |
24493 | return save_inr(0,filename,voxsize); | |
24494 | } | |
24495 | unsigned int _save_pandore_header_length(unsigned int id, unsigned int *dims, const unsigned int colorspace=0) const { | |
24496 | unsigned int nbdims = 0; | |
24497 | if (id==2 || id==3 || id==4) { dims[0] = 1; dims[1] = width; nbdims = 2; } | |
24498 | if (id==5 || id==6 || id==7) { dims[0] = 1; dims[1] = height; dims[2] = width; nbdims=3; } | |
24499 | if (id==8 || id==9 || id==10) { dims[0] = dim; dims[1] = depth; dims[2] = height; dims[3] = width; nbdims = 4; } | |
24500 | if (id==16 || id==17 || id==18) { dims[0] = 3; dims[1] = height; dims[2] = width; dims[3] = colorspace; nbdims = 4; } | |
24501 | if (id==19 || id==20 || id==21) { dims[0] = 3; dims[1] = depth; dims[2] = height; dims[3] = width; dims[4] = colorspace; nbdims = 5; } | |
24502 | if (id==22 || id==23 || id==25) { dims[0] = dim; dims[1] = width; nbdims = 2; } | |
24503 | if (id==26 || id==27 || id==29) { dims[0] = dim; dims[1] = height; dims[2] = width; nbdims=3; } | |
24504 | if (id==30 || id==31 || id==33) { dims[0] = dim; dims[1] = depth; dims[2] = height; dims[3] = width; nbdims = 4; } | |
24505 | return nbdims; | |
24506 | } | |
24507 | const CImg<T>& save_pandore(std::FILE *const file, const char *const filename=0, const unsigned int colorspace=0) const { | |
24508 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_pandore() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24509 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24510 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_pandore() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24511 | pixel_type(),width,height,depth,dim,data); | |
24512 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24513 | unsigned char header[36] = { 'P','A','N','D','O','R','E','0','4',0,0,0, | |
24514 | 0,0,0,0, | |
24515 | 'C','I','m','g',0,0,0,0,0, | |
24516 | 'N','o',' ','d','a','t','e',0,0,0, | |
24517 | 0 }; | |
24518 | unsigned int nbdims,dims[5]; | |
24519 | bool saved=false; | |
24520 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=2),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (2==2 || 2==5 || 2==8 || 2==16 || 2==19 || 2==22 || 2==26 || 2==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (2==3 || 2==6 || 2==9 || 2==17 || 2==20 || 2==23 || 2==27 || 2==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (2==4 || 2==7 || 2==10 || 2==18 || 2==21 || 2==25 || 2==29 || 2==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24521 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=3),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (3==2 || 3==5 || 3==8 || 3==16 || 3==19 || 3==22 || 3==26 || 3==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==3 || 3==6 || 3==9 || 3==17 || 3==20 || 3==23 || 3==27 || 3==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==4 || 3==7 || 3==10 || 3==18 || 3==21 || 3==25 || 3==29 || 3==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24522 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=3),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (3==2 || 3==5 || 3==8 || 3==16 || 3==19 || 3==22 || 3==26 || 3==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==3 || 3==6 || 3==9 || 3==17 || 3==20 || 3==23 || 3==27 || 3==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==4 || 3==7 || 3==10 || 3==18 || 3==21 || 3==25 || 3==29 || 3==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24523 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=3),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (3==2 || 3==5 || 3==8 || 3==16 || 3==19 || 3==22 || 3==26 || 3==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==3 || 3==6 || 3==9 || 3==17 || 3==20 || 3==23 || 3==27 || 3==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==4 || 3==7 || 3==10 || 3==18 || 3==21 || 3==25 || 3==29 || 3==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24524 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=3),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (3==2 || 3==5 || 3==8 || 3==16 || 3==19 || 3==22 || 3==26 || 3==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==3 || 3==6 || 3==9 || 3==17 || 3==20 || 3==23 || 3==27 || 3==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==4 || 3==7 || 3==10 || 3==18 || 3==21 || 3==25 || 3==29 || 3==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24525 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=3),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (3==2 || 3==5 || 3==8 || 3==16 || 3==19 || 3==22 || 3==26 || 3==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==3 || 3==6 || 3==9 || 3==17 || 3==20 || 3==23 || 3==27 || 3==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==4 || 3==7 || 3==10 || 3==18 || 3==21 || 3==25 || 3==29 || 3==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24526 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=4),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (4==2 || 4==5 || 4==8 || 4==16 || 4==19 || 4==22 || 4==26 || 4==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (4==3 || 4==6 || 4==9 || 4==17 || 4==20 || 4==23 || 4==27 || 4==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (4==4 || 4==7 || 4==10 || 4==18 || 4==21 || 4==25 || 4==29 || 4==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24527 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=3),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (3==2 || 3==5 || 3==8 || 3==16 || 3==19 || 3==22 || 3==26 || 3==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==3 || 3==6 || 3==9 || 3==17 || 3==20 || 3==23 || 3==27 || 3==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (3==4 || 3==7 || 3==10 || 3==18 || 3==21 || 3==25 || 3==29 || 3==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24528 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=4),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (4==2 || 4==5 || 4==8 || 4==16 || 4==19 || 4==22 || 4==26 || 4==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (4==3 || 4==6 || 4==9 || 4==17 || 4==20 || 4==23 || 4==27 || 4==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (4==4 || 4==7 || 4==10 || 4==18 || 4==21 || 4==25 || 4==29 || 4==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24529 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=4),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (4==2 || 4==5 || 4==8 || 4==16 || 4==19 || 4==22 || 4==26 || 4==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (4==3 || 4==6 || 4==9 || 4==17 || 4==20 || 4==23 || 4==27 || 4==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (4==4 || 4==7 || 4==10 || 4==18 || 4==21 || 4==25 || 4==29 || 4==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24530 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=5),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (5==2 || 5==5 || 5==8 || 5==16 || 5==19 || 5==22 || 5==26 || 5==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (5==3 || 5==6 || 5==9 || 5==17 || 5==20 || 5==23 || 5==27 || 5==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (5==4 || 5==7 || 5==10 || 5==18 || 5==21 || 5==25 || 5==29 || 5==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24531 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=6),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (6==2 || 6==5 || 6==8 || 6==16 || 6==19 || 6==22 || 6==26 || 6==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==3 || 6==6 || 6==9 || 6==17 || 6==20 || 6==23 || 6==27 || 6==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==4 || 6==7 || 6==10 || 6==18 || 6==21 || 6==25 || 6==29 || 6==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24532 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=6),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (6==2 || 6==5 || 6==8 || 6==16 || 6==19 || 6==22 || 6==26 || 6==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==3 || 6==6 || 6==9 || 6==17 || 6==20 || 6==23 || 6==27 || 6==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==4 || 6==7 || 6==10 || 6==18 || 6==21 || 6==25 || 6==29 || 6==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24533 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=6),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (6==2 || 6==5 || 6==8 || 6==16 || 6==19 || 6==22 || 6==26 || 6==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==3 || 6==6 || 6==9 || 6==17 || 6==20 || 6==23 || 6==27 || 6==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==4 || 6==7 || 6==10 || 6==18 || 6==21 || 6==25 || 6==29 || 6==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24534 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=6),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (6==2 || 6==5 || 6==8 || 6==16 || 6==19 || 6==22 || 6==26 || 6==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==3 || 6==6 || 6==9 || 6==17 || 6==20 || 6==23 || 6==27 || 6==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==4 || 6==7 || 6==10 || 6==18 || 6==21 || 6==25 || 6==29 || 6==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24535 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=6),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (6==2 || 6==5 || 6==8 || 6==16 || 6==19 || 6==22 || 6==26 || 6==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==3 || 6==6 || 6==9 || 6==17 || 6==20 || 6==23 || 6==27 || 6==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==4 || 6==7 || 6==10 || 6==18 || 6==21 || 6==25 || 6==29 || 6==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24536 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=7),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (7==2 || 7==5 || 7==8 || 7==16 || 7==19 || 7==22 || 7==26 || 7==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (7==3 || 7==6 || 7==9 || 7==17 || 7==20 || 7==23 || 7==27 || 7==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (7==4 || 7==7 || 7==10 || 7==18 || 7==21 || 7==25 || 7==29 || 7==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24537 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=6),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (6==2 || 6==5 || 6==8 || 6==16 || 6==19 || 6==22 || 6==26 || 6==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==3 || 6==6 || 6==9 || 6==17 || 6==20 || 6==23 || 6==27 || 6==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (6==4 || 6==7 || 6==10 || 6==18 || 6==21 || 6==25 || 6==29 || 6==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24538 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=7),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (7==2 || 7==5 || 7==8 || 7==16 || 7==19 || 7==22 || 7==26 || 7==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (7==3 || 7==6 || 7==9 || 7==17 || 7==20 || 7==23 || 7==27 || 7==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (7==4 || 7==7 || 7==10 || 7==18 || 7==21 || 7==25 || 7==29 || 7==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24539 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (1?(1==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=7),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (7==2 || 7==5 || 7==8 || 7==16 || 7==19 || 7==22 || 7==26 || 7==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (7==3 || 7==6 || 7==9 || 7==17 || 7==20 || 7==23 || 7==27 || 7==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (7==4 || 7==7 || 7==10 || 7==18 || 7==21 || 7==25 || 7==29 || 7==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24540 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=8),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (8==2 || 8==5 || 8==8 || 8==16 || 8==19 || 8==22 || 8==26 || 8==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (8==3 || 8==6 || 8==9 || 8==17 || 8==20 || 8==23 || 8==27 || 8==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (8==4 || 8==7 || 8==10 || 8==18 || 8==21 || 8==25 || 8==29 || 8==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24541 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=9),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (9==2 || 9==5 || 9==8 || 9==16 || 9==19 || 9==22 || 9==26 || 9==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==3 || 9==6 || 9==9 || 9==17 || 9==20 || 9==23 || 9==27 || 9==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==4 || 9==7 || 9==10 || 9==18 || 9==21 || 9==25 || 9==29 || 9==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24542 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=9),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (9==2 || 9==5 || 9==8 || 9==16 || 9==19 || 9==22 || 9==26 || 9==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==3 || 9==6 || 9==9 || 9==17 || 9==20 || 9==23 || 9==27 || 9==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==4 || 9==7 || 9==10 || 9==18 || 9==21 || 9==25 || 9==29 || 9==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24543 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=9),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (9==2 || 9==5 || 9==8 || 9==16 || 9==19 || 9==22 || 9==26 || 9==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==3 || 9==6 || 9==9 || 9==17 || 9==20 || 9==23 || 9==27 || 9==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==4 || 9==7 || 9==10 || 9==18 || 9==21 || 9==25 || 9==29 || 9==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24544 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=9),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (9==2 || 9==5 || 9==8 || 9==16 || 9==19 || 9==22 || 9==26 || 9==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==3 || 9==6 || 9==9 || 9==17 || 9==20 || 9==23 || 9==27 || 9==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==4 || 9==7 || 9==10 || 9==18 || 9==21 || 9==25 || 9==29 || 9==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24545 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=9),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (9==2 || 9==5 || 9==8 || 9==16 || 9==19 || 9==22 || 9==26 || 9==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==3 || 9==6 || 9==9 || 9==17 || 9==20 || 9==23 || 9==27 || 9==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==4 || 9==7 || 9==10 || 9==18 || 9==21 || 9==25 || 9==29 || 9==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24546 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=10),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (10==2 || 10==5 || 10==8 || 10==16 || 10==19 || 10==22 || 10==26 || 10==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (10==3 || 10==6 || 10==9 || 10==17 || 10==20 || 10==23 || 10==27 || 10==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (10==4 || 10==7 || 10==10 || 10==18 || 10==21 || 10==25 || 10==29 || 10==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24547 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=9),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (9==2 || 9==5 || 9==8 || 9==16 || 9==19 || 9==22 || 9==26 || 9==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==3 || 9==6 || 9==9 || 9==17 || 9==20 || 9==23 || 9==27 || 9==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (9==4 || 9==7 || 9==10 || 9==18 || 9==21 || 9==25 || 9==29 || 9==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24548 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=10),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (10==2 || 10==5 || 10==8 || 10==16 || 10==19 || 10==22 || 10==26 || 10==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (10==3 || 10==6 || 10==9 || 10==17 || 10==20 || 10==23 || 10==27 || 10==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (10==4 || 10==7 || 10==10 || 10==18 || 10==21 || 10==25 || 10==29 || 10==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24549 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (1?(1==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=10),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (10==2 || 10==5 || 10==8 || 10==16 || 10==19 || 10==22 || 10==26 || 10==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (10==3 || 10==6 || 10==9 || 10==17 || 10==20 || 10==23 || 10==27 || 10==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (10==4 || 10==7 || 10==10 || 10==18 || 10==21 || 10==25 || 10==29 || 10==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24550 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=16),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (16==2 || 16==5 || 16==8 || 16==16 || 16==19 || 16==22 || 16==26 || 16==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (16==3 || 16==6 || 16==9 || 16==17 || 16==20 || 16==23 || 16==27 || 16==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (16==4 || 16==7 || 16==10 || 16==18 || 16==21 || 16==25 || 16==29 || 16==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24551 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=17),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (17==2 || 17==5 || 17==8 || 17==16 || 17==19 || 17==22 || 17==26 || 17==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==3 || 17==6 || 17==9 || 17==17 || 17==20 || 17==23 || 17==27 || 17==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==4 || 17==7 || 17==10 || 17==18 || 17==21 || 17==25 || 17==29 || 17==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24552 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=17),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (17==2 || 17==5 || 17==8 || 17==16 || 17==19 || 17==22 || 17==26 || 17==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==3 || 17==6 || 17==9 || 17==17 || 17==20 || 17==23 || 17==27 || 17==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==4 || 17==7 || 17==10 || 17==18 || 17==21 || 17==25 || 17==29 || 17==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24553 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=17),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (17==2 || 17==5 || 17==8 || 17==16 || 17==19 || 17==22 || 17==26 || 17==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==3 || 17==6 || 17==9 || 17==17 || 17==20 || 17==23 || 17==27 || 17==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==4 || 17==7 || 17==10 || 17==18 || 17==21 || 17==25 || 17==29 || 17==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24554 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=17),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (17==2 || 17==5 || 17==8 || 17==16 || 17==19 || 17==22 || 17==26 || 17==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==3 || 17==6 || 17==9 || 17==17 || 17==20 || 17==23 || 17==27 || 17==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==4 || 17==7 || 17==10 || 17==18 || 17==21 || 17==25 || 17==29 || 17==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24555 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=17),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (17==2 || 17==5 || 17==8 || 17==16 || 17==19 || 17==22 || 17==26 || 17==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==3 || 17==6 || 17==9 || 17==17 || 17==20 || 17==23 || 17==27 || 17==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==4 || 17==7 || 17==10 || 17==18 || 17==21 || 17==25 || 17==29 || 17==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24556 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=18),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (18==2 || 18==5 || 18==8 || 18==16 || 18==19 || 18==22 || 18==26 || 18==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (18==3 || 18==6 || 18==9 || 18==17 || 18==20 || 18==23 || 18==27 || 18==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (18==4 || 18==7 || 18==10 || 18==18 || 18==21 || 18==25 || 18==29 || 18==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24557 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=17),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (17==2 || 17==5 || 17==8 || 17==16 || 17==19 || 17==22 || 17==26 || 17==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==3 || 17==6 || 17==9 || 17==17 || 17==20 || 17==23 || 17==27 || 17==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (17==4 || 17==7 || 17==10 || 17==18 || 17==21 || 17==25 || 17==29 || 17==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24558 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=18),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (18==2 || 18==5 || 18==8 || 18==16 || 18==19 || 18==22 || 18==26 || 18==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (18==3 || 18==6 || 18==9 || 18==17 || 18==20 || 18==23 || 18==27 || 18==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (18==4 || 18==7 || 18==10 || 18==18 || 18==21 || 18==25 || 18==29 || 18==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24559 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (3?(3==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=18),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (18==2 || 18==5 || 18==8 || 18==16 || 18==19 || 18==22 || 18==26 || 18==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (18==3 || 18==6 || 18==9 || 18==17 || 18==20 || 18==23 || 18==27 || 18==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (18==4 || 18==7 || 18==10 || 18==18 || 18==21 || 18==25 || 18==29 || 18==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24560 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=19),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (19==2 || 19==5 || 19==8 || 19==16 || 19==19 || 19==22 || 19==26 || 19==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (19==3 || 19==6 || 19==9 || 19==17 || 19==20 || 19==23 || 19==27 || 19==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (19==4 || 19==7 || 19==10 || 19==18 || 19==21 || 19==25 || 19==29 || 19==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24561 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=20),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (20==2 || 20==5 || 20==8 || 20==16 || 20==19 || 20==22 || 20==26 || 20==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==3 || 20==6 || 20==9 || 20==17 || 20==20 || 20==23 || 20==27 || 20==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==4 || 20==7 || 20==10 || 20==18 || 20==21 || 20==25 || 20==29 || 20==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24562 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=20),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (20==2 || 20==5 || 20==8 || 20==16 || 20==19 || 20==22 || 20==26 || 20==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==3 || 20==6 || 20==9 || 20==17 || 20==20 || 20==23 || 20==27 || 20==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==4 || 20==7 || 20==10 || 20==18 || 20==21 || 20==25 || 20==29 || 20==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24563 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=20),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (20==2 || 20==5 || 20==8 || 20==16 || 20==19 || 20==22 || 20==26 || 20==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==3 || 20==6 || 20==9 || 20==17 || 20==20 || 20==23 || 20==27 || 20==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==4 || 20==7 || 20==10 || 20==18 || 20==21 || 20==25 || 20==29 || 20==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24564 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=20),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (20==2 || 20==5 || 20==8 || 20==16 || 20==19 || 20==22 || 20==26 || 20==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==3 || 20==6 || 20==9 || 20==17 || 20==20 || 20==23 || 20==27 || 20==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==4 || 20==7 || 20==10 || 20==18 || 20==21 || 20==25 || 20==29 || 20==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24565 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=20),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (20==2 || 20==5 || 20==8 || 20==16 || 20==19 || 20==22 || 20==26 || 20==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==3 || 20==6 || 20==9 || 20==17 || 20==20 || 20==23 || 20==27 || 20==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==4 || 20==7 || 20==10 || 20==18 || 20==21 || 20==25 || 20==29 || 20==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24566 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=21),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (21==2 || 21==5 || 21==8 || 21==16 || 21==19 || 21==22 || 21==26 || 21==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (21==3 || 21==6 || 21==9 || 21==17 || 21==20 || 21==23 || 21==27 || 21==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (21==4 || 21==7 || 21==10 || 21==18 || 21==21 || 21==25 || 21==29 || 21==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24567 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=20),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (20==2 || 20==5 || 20==8 || 20==16 || 20==19 || 20==22 || 20==26 || 20==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==3 || 20==6 || 20==9 || 20==17 || 20==20 || 20==23 || 20==27 || 20==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (20==4 || 20==7 || 20==10 || 20==18 || 20==21 || 20==25 || 20==29 || 20==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24568 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=21),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (21==2 || 21==5 || 21==8 || 21==16 || 21==19 || 21==22 || 21==26 || 21==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (21==3 || 21==6 || 21==9 || 21==17 || 21==20 || 21==23 || 21==27 || 21==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (21==4 || 21==7 || 21==10 || 21==18 || 21==21 || 21==25 || 21==29 || 21==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24569 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (3?(3==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=21),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (21==2 || 21==5 || 21==8 || 21==16 || 21==19 || 21==22 || 21==26 || 21==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (21==3 || 21==6 || 21==9 || 21==17 || 21==20 || 21==23 || 21==27 || 21==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (21==4 || 21==7 || 21==10 || 21==18 || 21==21 || 21==25 || 21==29 || 21==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24570 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=22),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (22==2 || 22==5 || 22==8 || 22==16 || 22==19 || 22==22 || 22==26 || 22==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (22==3 || 22==6 || 22==9 || 22==17 || 22==20 || 22==23 || 22==27 || 22==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (22==4 || 22==7 || 22==10 || 22==18 || 22==21 || 22==25 || 22==29 || 22==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24571 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=23),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (23==2 || 23==5 || 23==8 || 23==16 || 23==19 || 23==22 || 23==26 || 23==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==3 || 23==6 || 23==9 || 23==17 || 23==20 || 23==23 || 23==27 || 23==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==4 || 23==7 || 23==10 || 23==18 || 23==21 || 23==25 || 23==29 || 23==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24572 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=23),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (23==2 || 23==5 || 23==8 || 23==16 || 23==19 || 23==22 || 23==26 || 23==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==3 || 23==6 || 23==9 || 23==17 || 23==20 || 23==23 || 23==27 || 23==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==4 || 23==7 || 23==10 || 23==18 || 23==21 || 23==25 || 23==29 || 23==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24573 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=23),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (23==2 || 23==5 || 23==8 || 23==16 || 23==19 || 23==22 || 23==26 || 23==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==3 || 23==6 || 23==9 || 23==17 || 23==20 || 23==23 || 23==27 || 23==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==4 || 23==7 || 23==10 || 23==18 || 23==21 || 23==25 || 23==29 || 23==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24574 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=23),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (23==2 || 23==5 || 23==8 || 23==16 || 23==19 || 23==22 || 23==26 || 23==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==3 || 23==6 || 23==9 || 23==17 || 23==20 || 23==23 || 23==27 || 23==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==4 || 23==7 || 23==10 || 23==18 || 23==21 || 23==25 || 23==29 || 23==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24575 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=23),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (23==2 || 23==5 || 23==8 || 23==16 || 23==19 || 23==22 || 23==26 || 23==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==3 || 23==6 || 23==9 || 23==17 || 23==20 || 23==23 || 23==27 || 23==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==4 || 23==7 || 23==10 || 23==18 || 23==21 || 23==25 || 23==29 || 23==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24576 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=25),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (25==2 || 25==5 || 25==8 || 25==16 || 25==19 || 25==22 || 25==26 || 25==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (25==3 || 25==6 || 25==9 || 25==17 || 25==20 || 25==23 || 25==27 || 25==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (25==4 || 25==7 || 25==10 || 25==18 || 25==21 || 25==25 || 25==29 || 25==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24577 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=23),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (23==2 || 23==5 || 23==8 || 23==16 || 23==19 || 23==22 || 23==26 || 23==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==3 || 23==6 || 23==9 || 23==17 || 23==20 || 23==23 || 23==27 || 23==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (23==4 || 23==7 || 23==10 || 23==18 || 23==21 || 23==25 || 23==29 || 23==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24578 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=25),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (25==2 || 25==5 || 25==8 || 25==16 || 25==19 || 25==22 || 25==26 || 25==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (25==3 || 25==6 || 25==9 || 25==17 || 25==20 || 25==23 || 25==27 || 25==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (25==4 || 25==7 || 25==10 || 25==18 || 25==21 || 25==25 || 25==29 || 25==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24579 | if (!saved && (1?(1==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=25),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (25==2 || 25==5 || 25==8 || 25==16 || 25==19 || 25==22 || 25==26 || 25==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (25==3 || 25==6 || 25==9 || 25==17 || 25==20 || 25==23 || 25==27 || 25==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (25==4 || 25==7 || 25==10 || 25==18 || 25==21 || 25==25 || 25==29 || 25==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24580 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=26),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (26==2 || 26==5 || 26==8 || 26==16 || 26==19 || 26==22 || 26==26 || 26==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (26==3 || 26==6 || 26==9 || 26==17 || 26==20 || 26==23 || 26==27 || 26==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (26==4 || 26==7 || 26==10 || 26==18 || 26==21 || 26==25 || 26==29 || 26==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24581 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=27),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (27==2 || 27==5 || 27==8 || 27==16 || 27==19 || 27==22 || 27==26 || 27==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==3 || 27==6 || 27==9 || 27==17 || 27==20 || 27==23 || 27==27 || 27==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==4 || 27==7 || 27==10 || 27==18 || 27==21 || 27==25 || 27==29 || 27==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24582 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=27),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (27==2 || 27==5 || 27==8 || 27==16 || 27==19 || 27==22 || 27==26 || 27==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==3 || 27==6 || 27==9 || 27==17 || 27==20 || 27==23 || 27==27 || 27==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==4 || 27==7 || 27==10 || 27==18 || 27==21 || 27==25 || 27==29 || 27==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24583 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=27),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (27==2 || 27==5 || 27==8 || 27==16 || 27==19 || 27==22 || 27==26 || 27==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==3 || 27==6 || 27==9 || 27==17 || 27==20 || 27==23 || 27==27 || 27==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==4 || 27==7 || 27==10 || 27==18 || 27==21 || 27==25 || 27==29 || 27==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24584 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=27),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (27==2 || 27==5 || 27==8 || 27==16 || 27==19 || 27==22 || 27==26 || 27==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==3 || 27==6 || 27==9 || 27==17 || 27==20 || 27==23 || 27==27 || 27==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==4 || 27==7 || 27==10 || 27==18 || 27==21 || 27==25 || 27==29 || 27==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24585 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=27),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (27==2 || 27==5 || 27==8 || 27==16 || 27==19 || 27==22 || 27==26 || 27==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==3 || 27==6 || 27==9 || 27==17 || 27==20 || 27==23 || 27==27 || 27==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==4 || 27==7 || 27==10 || 27==18 || 27==21 || 27==25 || 27==29 || 27==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24586 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=29),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (29==2 || 29==5 || 29==8 || 29==16 || 29==19 || 29==22 || 29==26 || 29==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (29==3 || 29==6 || 29==9 || 29==17 || 29==20 || 29==23 || 29==27 || 29==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (29==4 || 29==7 || 29==10 || 29==18 || 29==21 || 29==25 || 29==29 || 29==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24587 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=27),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (27==2 || 27==5 || 27==8 || 27==16 || 27==19 || 27==22 || 27==26 || 27==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==3 || 27==6 || 27==9 || 27==17 || 27==20 || 27==23 || 27==27 || 27==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (27==4 || 27==7 || 27==10 || 27==18 || 27==21 || 27==25 || 27==29 || 27==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24588 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=29),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (29==2 || 29==5 || 29==8 || 29==16 || 29==19 || 29==22 || 29==26 || 29==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (29==3 || 29==6 || 29==9 || 29==17 || 29==20 || 29==23 || 29==27 || 29==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (29==4 || 29==7 || 29==10 || 29==18 || 29==21 || 29==25 || 29==29 || 29==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24589 | if (!saved && (0?(0==height):true) && (1?(1==depth):true) && (0?(0==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=29),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (29==2 || 29==5 || 29==8 || 29==16 || 29==19 || 29==22 || 29==26 || 29==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (29==3 || 29==6 || 29==9 || 29==17 || 29==20 || 29==23 || 29==27 || 29==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (29==4 || 29==7 || 29==10 || 29==18 || 29==21 || 29==25 || 29==29 || 29==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24590 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("unsigned char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=30),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (30==2 || 30==5 || 30==8 || 30==16 || 30==19 || 30==22 || 30==26 || 30==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (30==3 || 30==6 || 30==9 || 30==17 || 30==20 || 30==23 || 30==27 || 30==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (30==4 || 30==7 || 30==10 || 30==18 || 30==21 || 30==25 || 30==29 || 30==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24591 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("char",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=31),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (31==2 || 31==5 || 31==8 || 31==16 || 31==19 || 31==22 || 31==26 || 31==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==3 || 31==6 || 31==9 || 31==17 || 31==20 || 31==23 || 31==27 || 31==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==4 || 31==7 || 31==10 || 31==18 || 31==21 || 31==25 || 31==29 || 31==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24592 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=31),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (31==2 || 31==5 || 31==8 || 31==16 || 31==19 || 31==22 || 31==26 || 31==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==3 || 31==6 || 31==9 || 31==17 || 31==20 || 31==23 || 31==27 || 31==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==4 || 31==7 || 31==10 || 31==18 || 31==21 || 31==25 || 31==29 || 31==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24593 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("unsigned short",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=31),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (31==2 || 31==5 || 31==8 || 31==16 || 31==19 || 31==22 || 31==26 || 31==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==3 || 31==6 || 31==9 || 31==17 || 31==20 || 31==23 || 31==27 || 31==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==4 || 31==7 || 31==10 || 31==18 || 31==21 || 31==25 || 31==29 || 31==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24594 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("unsigned int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=31),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (31==2 || 31==5 || 31==8 || 31==16 || 31==19 || 31==22 || 31==26 || 31==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==3 || 31==6 || 31==9 || 31==17 || 31==20 || 31==23 || 31==27 || 31==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==4 || 31==7 || 31==10 || 31==18 || 31==21 || 31==25 || 31==29 || 31==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24595 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("int",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=31),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (31==2 || 31==5 || 31==8 || 31==16 || 31==19 || 31==22 || 31==26 || 31==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==3 || 31==6 || 31==9 || 31==17 || 31==20 || 31==23 || 31==27 || 31==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==4 || 31==7 || 31==10 || 31==18 || 31==21 || 31==25 || 31==29 || 31==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24596 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("unsigned long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=33),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (33==2 || 33==5 || 33==8 || 33==16 || 33==19 || 33==22 || 33==26 || 33==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (33==3 || 33==6 || 33==9 || 33==17 || 33==20 || 33==23 || 33==27 || 33==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (33==4 || 33==7 || 33==10 || 33==18 || 33==21 || 33==25 || 33==29 || 33==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24597 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("long",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=31),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (31==2 || 31==5 || 31==8 || 31==16 || 31==19 || 31==22 || 31==26 || 31==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==3 || 31==6 || 31==9 || 31==17 || 31==20 || 31==23 || 31==27 || 31==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (31==4 || 31==7 || 31==10 || 31==18 || 31==21 || 31==25 || 31==29 || 31==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24598 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("float",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=33),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (33==2 || 33==5 || 33==8 || 33==16 || 33==19 || 33==22 || 33==26 || 33==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (33==3 || 33==6 || 33==9 || 33==17 || 33==20 || 33==23 || 33==27 || 33==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (33==4 || 33==7 || 33==10 || 33==18 || 33==21 || 33==25 || 33==29 || 33==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24599 | if (!saved && (0?(0==height):true) && (0?(0==depth):true) && (0?(0==dim):true) && !strcmp("double",pixel_type())) { unsigned int *iheader = (unsigned int*)(header+12); nbdims = _save_pandore_header_length((*iheader=33),dims,colorspace); cimg::fwrite(header,36,nfile); cimg::fwrite(dims,nbdims,nfile); if (33==2 || 33==5 || 33==8 || 33==16 || 33==19 || 33==22 || 33==26 || 33==30) { unsigned char *buffer = new unsigned char[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (unsigned char)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (33==3 || 33==6 || 33==9 || 33==17 || 33==20 || 33==23 || 33==27 || 33==31) { unsigned long *buffer = new unsigned long[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (long)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } if (33==4 || 33==7 || 33==10 || 33==18 || 33==21 || 33==25 || 33==29 || 33==33) { float *buffer = new float[size()]; const T *ptrs = data; for (unsigned int off = 0; off<(*this).size(); ++off) *(buffer++) = (float)(*(ptrs++)); buffer-=size(); cimg::fwrite(buffer,size(),nfile); delete[] buffer; } saved = true; }; | |
24600 | if (!file) cimg::fclose(nfile); | |
24601 | return *this; | |
24602 | } | |
24603 | const CImg<T>& save_pandore(const char *const filename=0, const unsigned int colorspace=0) const { | |
24604 | return save_pandore(0,filename,colorspace); | |
24605 | } | |
24606 | const CImg<T>& save_yuv(std::FILE *const file, const char *const filename=0, const bool rgb2yuv=true) const { | |
24607 | get_split('z').save_yuv(file,filename,rgb2yuv); | |
24608 | return *this; | |
24609 | } | |
24610 | const CImg<T>& save_yuv(const char *const filename, const bool rgb2yuv=true) const { | |
24611 | return save_yuv(0,filename,rgb2yuv); | |
24612 | } | |
24613 | const CImg<T>& save_ffmpeg(const char *const filename, const char *const codec="mpeg2video") const { | |
24614 | get_split('z').save_ffmpeg(filename,codec); | |
24615 | return *this; | |
24616 | } | |
24617 | const CImg<T>& save_bmp(std::FILE *const file, const char *const filename=0) const { | |
24618 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_bmp() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24619 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24620 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_bmp() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24621 | pixel_type(),width,height,depth,dim,data); | |
24622 | if (depth>1) | |
24623 | cimg::warn("CImg<%s>::save_bmp() : Instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved (file '%s').", | |
24624 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24625 | if (dim>3) | |
24626 | cimg::warn("CImg<%s>::save_bmp() : Instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved (file '%s').", | |
24627 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24628 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24629 | unsigned char header[54] = { 0 }, align_buf[4] = { 0 }; | |
24630 | const unsigned int | |
24631 | align = (4-(3*width)%4)%4, | |
24632 | buf_size = (3*width+align)*dimy(), | |
24633 | file_size = 54+buf_size; | |
24634 | header[0] = 'B'; header[1] = 'M'; | |
24635 | header[0x02] = file_size&0xFF; | |
24636 | header[0x03] = (file_size>>8)&0xFF; | |
24637 | header[0x04] = (file_size>>16)&0xFF; | |
24638 | header[0x05] = (file_size>>24)&0xFF; | |
24639 | header[0x0A] = 0x36; | |
24640 | header[0x0E] = 0x28; | |
24641 | header[0x12] = width&0xFF; | |
24642 | header[0x13] = (width>>8)&0xFF; | |
24643 | header[0x14] = (width>>16)&0xFF; | |
24644 | header[0x15] = (width>>24)&0xFF; | |
24645 | header[0x16] = height&0xFF; | |
24646 | header[0x17] = (height>>8)&0xFF; | |
24647 | header[0x18] = (height>>16)&0xFF; | |
24648 | header[0x19] = (height>>24)&0xFF; | |
24649 | header[0x1A] = 1; | |
24650 | header[0x1B] = 0; | |
24651 | header[0x1C] = 24; | |
24652 | header[0x1D] = 0; | |
24653 | header[0x22] = buf_size&0xFF; | |
24654 | header[0x23] = (buf_size>>8)&0xFF; | |
24655 | header[0x24] = (buf_size>>16)&0xFF; | |
24656 | header[0x25] = (buf_size>>24)&0xFF; | |
24657 | header[0x27] = 0x1; | |
24658 | header[0x2B] = 0x1; | |
24659 | cimg::fwrite(header,54,nfile); | |
24660 | const T | |
24661 | *pR = ptr(0,height-1,0,0), | |
24662 | *pG = (dim>=2)?ptr(0,height-1,0,1):0, | |
24663 | *pB = (dim>=3)?ptr(0,height-1,0,2):0; | |
24664 | switch (dim) { | |
24665 | case 1: { | |
24666 | for (int y = 0; y<(int)((*this).height); ++y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
24667 | const unsigned char val = (unsigned char)*(pR++); | |
24668 | std::fputc(val,nfile); std::fputc(val,nfile); std::fputc(val,nfile); | |
24669 | } | |
24670 | cimg::fwrite(align_buf,align,nfile); | |
24671 | pR-=2*width; | |
24672 | }} break; | |
24673 | case 2: { | |
24674 | for (int y = 0; y<(int)((*this).height); ++y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
24675 | std::fputc(0,nfile); | |
24676 | std::fputc((unsigned char)(*(pG++)),nfile); | |
24677 | std::fputc((unsigned char)(*(pR++)),nfile); | |
24678 | } | |
24679 | cimg::fwrite(align_buf,align,nfile); | |
24680 | pR-=2*width; pG-=2*width; | |
24681 | }} break; | |
24682 | default: { | |
24683 | for (int y = 0; y<(int)((*this).height); ++y) { for (int x = 0; x<(int)((*this).width); ++x) { | |
24684 | std::fputc((unsigned char)(*(pB++)),nfile); | |
24685 | std::fputc((unsigned char)(*(pG++)),nfile); | |
24686 | std::fputc((unsigned char)(*(pR++)),nfile); | |
24687 | } | |
24688 | cimg::fwrite(align_buf,align,nfile); | |
24689 | pR-=2*width; pG-=2*width; pB-=2*width; | |
24690 | }} break; | |
24691 | } | |
24692 | if (!file) cimg::fclose(nfile); | |
24693 | return *this; | |
24694 | } | |
24695 | const CImg<T>& save_bmp(const char *const filename) const { | |
24696 | return save_bmp(0,filename); | |
24697 | } | |
24698 | const CImg<T>& save_png(std::FILE *const file, const char *const filename=0) const { | |
24699 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_png() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24700 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24701 | if (!filename) throw CImgArgumentException("CImg<%s>::save_png() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24702 | pixel_type(),width,height,depth,dim,data); | |
24703 | if (depth>1) | |
24704 | cimg::warn("CImg<%s>::save_png() : Instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved (file '%s').", | |
24705 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24706 | if (!file) return save_other(filename); | |
24707 | else throw CImgIOException("CImg<%s>::save_png() : Cannot save a PNG image in a *FILE output. You must use 'libpng' to do this instead.", | |
24708 | pixel_type()); | |
24709 | } | |
24710 | const CImg<T>& save_png(const char *const filename) const { | |
24711 | return save_png(0,filename); | |
24712 | } | |
24713 | const CImg<T>& save_tiff(const char *const filename) const { | |
24714 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_tiff() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.", | |
24715 | pixel_type(),filename,width,height,depth,dim,data); | |
24716 | if (!filename) throw CImgArgumentException("CImg<%s>::save_tiff() : Specified filename is (null) for instance image (%u,%u,%u,%u,%p).", | |
24717 | pixel_type(),width,height,depth,dim,data); | |
24718 | return save_other(filename); | |
24719 | return *this; | |
24720 | } | |
24721 | const CImg<T>& save_jpeg(std::FILE *const file, const char *const filename=0, const unsigned int quality=100) const { | |
24722 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_jpeg() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24723 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24724 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_jpeg() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).", | |
24725 | pixel_type(),width,height,depth,dim,data); | |
24726 | if (depth>1) | |
24727 | cimg::warn("CImg<%s>::save_jpeg() : Instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved (file '%s').", | |
24728 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24729 | if (!file) return save_other(filename,quality); | |
24730 | else throw CImgIOException("CImg<%s>::save_jpeg() : Cannot save a JPEG image in a *FILE output. Use libjpeg instead.", | |
24731 | pixel_type()); | |
24732 | } | |
24733 | const CImg<T>& save_jpeg(const char *const filename, const unsigned int quality=100) const { | |
24734 | return save_jpeg(0,filename,quality); | |
24735 | } | |
24736 | const CImg<T>& save_magick(const char *const filename) const { | |
24737 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_magick() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24738 | pixel_type(),width,height,depth,dim,data); | |
24739 | if (!filename) throw CImgArgumentException("CImg<%s>::save_magick() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24740 | pixel_type(),width,height,depth,dim,data); | |
24741 | throw CImgIOException("CImg<%s>::save_magick() : File '%s', Magick++ library has not been linked.", | |
24742 | pixel_type(),filename); | |
24743 | return *this; | |
24744 | } | |
24745 | const CImg<T>& save_rgba(std::FILE *const file, const char *const filename=0) const { | |
24746 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_rgba() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24747 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24748 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_rgba() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24749 | pixel_type(),width,height,depth,dim,data); | |
24750 | if (dim!=4) | |
24751 | cimg::warn("CImg<%s>::save_rgba() : Instance image (%u,%u,%u,%u,%p) has not exactly 4 channels (file '%s').", | |
24752 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24753 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24754 | const unsigned int wh = width*height; | |
24755 | unsigned char *buffer = new unsigned char[4*wh], *nbuffer=buffer; | |
24756 | const T | |
24757 | *ptr1 = ptr(0,0,0,0), | |
24758 | *ptr2 = dim>1?ptr(0,0,0,1):0, | |
24759 | *ptr3 = dim>2?ptr(0,0,0,2):0, | |
24760 | *ptr4 = dim>3?ptr(0,0,0,3):0; | |
24761 | switch (dim) { | |
24762 | case 1: { | |
24763 | for (unsigned int k=0; k<wh; ++k) { | |
24764 | const unsigned char val = (unsigned char)*(ptr1++); | |
24765 | *(nbuffer++) = val; | |
24766 | *(nbuffer++) = val; | |
24767 | *(nbuffer++) = val; | |
24768 | *(nbuffer++) = 255; | |
24769 | }} break; | |
24770 | case 2: { | |
24771 | for (unsigned int k=0; k<wh; ++k) { | |
24772 | *(nbuffer++) = (unsigned char)(*(ptr1++)); | |
24773 | *(nbuffer++) = (unsigned char)(*(ptr2++)); | |
24774 | *(nbuffer++) = 0; | |
24775 | *(nbuffer++) = 255; | |
24776 | }} break; | |
24777 | case 3: { | |
24778 | for (unsigned int k=0; k<wh; ++k) { | |
24779 | *(nbuffer++) = (unsigned char)(*(ptr1++)); | |
24780 | *(nbuffer++) = (unsigned char)(*(ptr2++)); | |
24781 | *(nbuffer++) = (unsigned char)(*(ptr3++)); | |
24782 | *(nbuffer++) = 255; | |
24783 | }} break; | |
24784 | default: { | |
24785 | for (unsigned int k=0; k<wh; ++k) { | |
24786 | *(nbuffer++) = (unsigned char)(*(ptr1++)); | |
24787 | *(nbuffer++) = (unsigned char)(*(ptr2++)); | |
24788 | *(nbuffer++) = (unsigned char)(*(ptr3++)); | |
24789 | *(nbuffer++) = (unsigned char)(*(ptr4++)); | |
24790 | }} break; | |
24791 | } | |
24792 | cimg::fwrite(buffer,4*wh,nfile); | |
24793 | if (!file) cimg::fclose(nfile); | |
24794 | delete[] buffer; | |
24795 | return *this; | |
24796 | } | |
24797 | const CImg<T>& save_rgba(const char *const filename) const { | |
24798 | return save_rgba(0,filename); | |
24799 | } | |
24800 | const CImg<T>& save_rgb(std::FILE *const file, const char *const filename=0) const { | |
24801 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_rgb() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24802 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24803 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_rgb() : Instance image (%u,%u,%u,%u,%p), specified file is (null).", | |
24804 | pixel_type(),width,height,depth,dim,data); | |
24805 | if (dim!=3) | |
24806 | cimg::warn("CImg<%s>::save_rgb() : Instance image (%u,%u,%u,%u,%p) has not exactly 3 channels (file '%s').", | |
24807 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24808 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
24809 | const unsigned int wh = width*height; | |
24810 | unsigned char *buffer = new unsigned char[3*wh], *nbuffer=buffer; | |
24811 | const T | |
24812 | *ptr1 = ptr(0,0,0,0), | |
24813 | *ptr2 = dim>1?ptr(0,0,0,1):0, | |
24814 | *ptr3 = dim>2?ptr(0,0,0,2):0; | |
24815 | switch (dim) { | |
24816 | case 1: { | |
24817 | for (unsigned int k=0; k<wh; ++k) { | |
24818 | const unsigned char val = (unsigned char)*(ptr1++); | |
24819 | *(nbuffer++) = val; | |
24820 | *(nbuffer++) = val; | |
24821 | *(nbuffer++) = val; | |
24822 | }} break; | |
24823 | case 2: { | |
24824 | for (unsigned int k=0; k<wh; ++k) { | |
24825 | *(nbuffer++) = (unsigned char)(*(ptr1++)); | |
24826 | *(nbuffer++) = (unsigned char)(*(ptr2++)); | |
24827 | *(nbuffer++) = 0; | |
24828 | }} break; | |
24829 | default: { | |
24830 | for (unsigned int k=0; k<wh; ++k) { | |
24831 | *(nbuffer++) = (unsigned char)(*(ptr1++)); | |
24832 | *(nbuffer++) = (unsigned char)(*(ptr2++)); | |
24833 | *(nbuffer++) = (unsigned char)(*(ptr3++)); | |
24834 | }} break; | |
24835 | } | |
24836 | cimg::fwrite(buffer,3*wh,nfile); | |
24837 | if (!file) cimg::fclose(nfile); | |
24838 | delete[] buffer; | |
24839 | return *this; | |
24840 | } | |
24841 | const CImg<T>& save_rgb(const char *const filename) const { | |
24842 | return save_rgb(0,filename); | |
24843 | } | |
24844 | template<typename tf, typename tc> | |
24845 | const CImg<T>& save_off(std::FILE *const file, const char *const filename, | |
24846 | const CImgList<tf>& primitives, const CImgList<tc>& colors, const bool invert_faces=false) const { | |
24847 | if (is_empty()) throw CImgInstanceException("CImg<%s>::save_off() : Instance image (%u,%u,%u,%u,%p) is empty (file '%s').", | |
24848 | pixel_type(),width,height,depth,dim,data,filename?filename:"(unknown)"); | |
24849 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_off() : Specified filename is (null).",pixel_type()); | |
24850 | if (height<3) return get_resize(-100,3,1,1,0).save_off(file,filename,primitives,colors,invert_faces); | |
24851 | std::FILE *const nfile = file?file:cimg::fopen(filename,"w"); | |
24852 | std::fprintf(nfile,"OFF\n%u %u %u\n",width,primitives.size,3*primitives.size); | |
24853 | for (int i = 0; i<(int)((*this).width); ++i) std::fprintf(nfile,"%f %f %f\n",(float)((*this)(i,0)),(float)((*this)(i,1)),(float)((*this)(i,2))); | |
24854 | for (unsigned int l=0; l<(primitives).size; ++l) { | |
24855 | const unsigned int prim = primitives[l].size(); | |
24856 | const bool textured = (prim>4); | |
24857 | const CImg<tc>& color = colors[l]; | |
24858 | const unsigned int s = textured?color.dimv():color.size(); | |
24859 | const float | |
24860 | r = textured?(s>0?(float)(color.get_shared_channel(0).mean()/255.0f):1.0f):(s>0?(float)(color(0)/255.0f):1.0f), | |
24861 | g = textured?(s>1?(float)(color.get_shared_channel(1).mean()/255.0f):r) :(s>1?(float)(color(1)/255.0f):r), | |
24862 | b = textured?(s>2?(float)(color.get_shared_channel(2).mean()/255.0f):r) :(s>2?(float)(color(2)/255.0f):r); | |
24863 | switch (prim) { | |
24864 | case 1: | |
24865 | std::fprintf(nfile,"1 %u %f %f %f\n",(unsigned int)primitives(l,0),r,g,b); | |
24866 | break; | |
24867 | case 2: case 6: | |
24868 | std::fprintf(nfile,"2 %u %u %f %f %f\n",(unsigned int)primitives(l,0),(unsigned int)primitives(l,1),r,g,b); | |
24869 | break; | |
24870 | case 3: case 9: | |
24871 | if (invert_faces) | |
24872 | std::fprintf(nfile,"3 %u %u %u %f %f %f\n",(unsigned int)primitives(l,0),(unsigned int)primitives(l,1),(unsigned int)primitives(l,2),r,g,b); | |
24873 | else | |
24874 | std::fprintf(nfile,"3 %u %u %u %f %f %f\n",(unsigned int)primitives(l,0),(unsigned int)primitives(l,2),(unsigned int)primitives(l,1),r,g,b); | |
24875 | break; | |
24876 | case 4: case 12: | |
24877 | if (invert_faces) | |
24878 | std::fprintf(nfile,"4 %u %u %u %u %f %f %f\n", | |
24879 | (unsigned int)primitives(l,0),(unsigned int)primitives(l,1),(unsigned int)primitives(l,2),(unsigned int)primitives(l,3),r,g,b); | |
24880 | else | |
24881 | std::fprintf(nfile,"4 %u %u %u %u %f %f %f\n", | |
24882 | (unsigned int)primitives(l,0),(unsigned int)primitives(l,3),(unsigned int)primitives(l,2),(unsigned int)primitives(l,1),r,g,b); | |
24883 | break; | |
24884 | } | |
24885 | } | |
24886 | if (!file) cimg::fclose(nfile); | |
24887 | return *this; | |
24888 | } | |
24889 | template<typename tf, typename tc> | |
24890 | const CImg<T>& save_off(const char *const filename, | |
24891 | const CImgList<tf>& primitives, const CImgList<tc>& colors, const bool invert_faces=false) const { | |
24892 | return save_off(0,filename,primitives,colors,invert_faces); | |
24893 | } | |
24894 | static CImg<T> get_logo40x38() { | |
24895 | static bool first_time = true; | |
24896 | static CImg<T> res(40,38,1,3); | |
24897 | if (first_time) { | |
24898 | const unsigned char *ptrs = cimg::logo40x38; | |
24899 | T *ptr1 = res.ptr(0,0,0,0), *ptr2 = res.ptr(0,0,0,1), *ptr3 = res.ptr(0,0,0,2); | |
24900 | for (unsigned int off = 0; off<res.width*res.height;) { | |
24901 | const unsigned char n = *(ptrs++), r = *(ptrs++), g = *(ptrs++), b = *(ptrs++); | |
24902 | for (unsigned int l=0; l<n; ++off, ++l) { *(ptr1++) = (T)r; *(ptr2++) = (T)g; *(ptr3++) = (T)b; } | |
24903 | } | |
24904 | first_time = false; | |
24905 | } | |
24906 | return res; | |
24907 | } | |
24908 | }; | |
24909 | template<typename T> struct CImgList { | |
24910 | unsigned int size; | |
24911 | unsigned int allocsize; | |
24912 | CImg<T> *data; | |
24913 | typedef CImg<T>* iterator; | |
24914 | typedef const CImg<T>* const_iterator; | |
24915 | typedef T value_type; | |
24916 | CImgList(): | |
24917 | size(0),allocsize(0),data(0) {} | |
24918 | ~CImgList() { | |
24919 | if (data) delete[] data; | |
24920 | } | |
24921 | CImgList<T>& assign() { | |
24922 | if (data) delete[] data; | |
24923 | size = allocsize = 0; | |
24924 | data = 0; | |
24925 | return *this; | |
24926 | } | |
24927 | CImgList<T>& clear() { | |
24928 | return assign(); | |
24929 | } | |
24930 | template<typename t> CImgList(const CImgList<t>& list): | |
24931 | size(0),allocsize(0),data(0) { | |
24932 | assign(list); | |
24933 | } | |
24934 | CImgList(const CImgList<T>& list): | |
24935 | size(0),allocsize(0),data(0) { | |
24936 | assign(list.size); | |
24937 | for (unsigned int l=0; l<(*this).size; ++l) (*this)[l].assign(list[l],list[l].is_shared); | |
24938 | } | |
24939 | template<typename t> CImgList(const CImgList<t>& list, const bool shared): | |
24940 | size(0),allocsize(0),data(0) { | |
24941 | assign(list,shared?1:0); | |
24942 | } | |
24943 | CImgList(const CImgList<T>& list, const bool shared): | |
24944 | size(0),allocsize(0),data(0) { | |
24945 | assign(list,shared?1:0); | |
24946 | } | |
24947 | template<typename t> CImgList<T>& assign(const CImgList<t>& list, const int shared=0) { | |
24948 | assign(list.size); | |
24949 | if (shared>=0) for (unsigned int l=0; l<(*this).size; ++l) (*this)[l].assign(list[l],shared?true:false); | |
24950 | else for (unsigned int l=0; l<(*this).size; ++l) (*this)[l].assign(list[l],list[l].is_shared); | |
24951 | return *this; | |
24952 | } | |
24953 | explicit CImgList(const unsigned int n): | |
24954 | size(n) { | |
24955 | data = new CImg<T>[allocsize=cimg::nearest_pow2(n)]; | |
24956 | } | |
24957 | CImgList<T>& assign(const unsigned int n) { | |
24958 | if (n) { | |
24959 | if (allocsize<n || allocsize>(n<<2)) { | |
24960 | if (data) delete[] data; | |
24961 | data = new CImg<T>[allocsize=cimg::nearest_pow2(n)]; | |
24962 | } | |
24963 | size = n; | |
24964 | } else return assign(); | |
24965 | return *this; | |
24966 | } | |
24967 | CImgList(const unsigned int n, const unsigned int width, const unsigned int height=1, | |
24968 | const unsigned int depth=1, const unsigned int dim=1): | |
24969 | size(0),allocsize(0),data(0) { | |
24970 | assign(n,width,height,depth,dim); | |
24971 | } | |
24972 | CImgList<T>& assign(const unsigned int n, const unsigned int width, const unsigned int height=1, | |
24973 | const unsigned int depth=1, const unsigned int dim=1) { | |
24974 | const unsigned int siz = width*height*depth*dim; | |
24975 | if (n && siz) { assign(n); for (unsigned int l=0; l<(*this).size; ++l) data[l].assign(width,height,depth,dim); } | |
24976 | else return assign(); | |
24977 | return *this; | |
24978 | } | |
24979 | CImgList(const unsigned int n, const unsigned int width, const unsigned int height, | |
24980 | const unsigned int depth, const unsigned int dim, const T val): | |
24981 | size(0),allocsize(0),data(0) { | |
24982 | assign(n,width,height,depth,dim,val); | |
24983 | } | |
24984 | CImgList<T>& assign(const unsigned int n, const unsigned int width, const unsigned int height, | |
24985 | const unsigned int depth, const unsigned int dim, const T val) { | |
24986 | assign(n,width,height,depth,dim); | |
24987 | for (unsigned int l=0; l<(*this).size; ++l) data[l].fill(val); | |
24988 | return *this; | |
24989 | } | |
24990 | CImgList(const unsigned int n, const unsigned int width, const unsigned int height, | |
24991 | const unsigned int depth, const unsigned int dim, const int val0, const int val1, ...): | |
24992 | size(0),allocsize(0),data(0) { | |
24993 | assign(n,width,height,depth,dim); const unsigned int siz = width*height*depth*dim, nsiz = siz*n; T *ptrd = data->data; va_list ap; __builtin_va_start(ap,val1); for (unsigned int l=0, s=0, i=0; i<nsiz; ++i) { *(ptrd++) = (T)(i==0?val0:(i==1?val1:__builtin_va_arg(ap,int))); if ((++s)==siz) { ptrd = data[++l].data; s=0; } } __builtin_va_end(ap);; | |
24994 | } | |
24995 | CImgList<T>& assign(const unsigned int n, const unsigned int width, const unsigned int height, | |
24996 | const unsigned int depth, const unsigned int dim, const int val0, const int val1, ...) { | |
24997 | assign(n,width,height,depth,dim); const unsigned int siz = width*height*depth*dim, nsiz = siz*n; T *ptrd = data->data; va_list ap; __builtin_va_start(ap,val1); for (unsigned int l=0, s=0, i=0; i<nsiz; ++i) { *(ptrd++) = (T)(i==0?val0:(i==1?val1:__builtin_va_arg(ap,int))); if ((++s)==siz) { ptrd = data[++l].data; s=0; } } __builtin_va_end(ap);; | |
24998 | return *this; | |
24999 | } | |
25000 | CImgList(const unsigned int n, const unsigned int width, const unsigned int height, | |
25001 | const unsigned int depth, const unsigned int dim, const double val0, const double val1, ...): | |
25002 | size(0),allocsize(0),data(0) { | |
25003 | assign(n,width,height,depth,dim); const unsigned int siz = width*height*depth*dim, nsiz = siz*n; T *ptrd = data->data; va_list ap; __builtin_va_start(ap,val1); for (unsigned int l=0, s=0, i=0; i<nsiz; ++i) { *(ptrd++) = (T)(i==0?val0:(i==1?val1:__builtin_va_arg(ap,double))); if ((++s)==siz) { ptrd = data[++l].data; s=0; } } __builtin_va_end(ap);; | |
25004 | } | |
25005 | CImgList<T>& assign(const unsigned int n, const unsigned int width, const unsigned int height, | |
25006 | const unsigned int depth, const unsigned int dim, const double val0, const double val1, ...) { | |
25007 | assign(n,width,height,depth,dim); const unsigned int siz = width*height*depth*dim, nsiz = siz*n; T *ptrd = data->data; va_list ap; __builtin_va_start(ap,val1); for (unsigned int l=0, s=0, i=0; i<nsiz; ++i) { *(ptrd++) = (T)(i==0?val0:(i==1?val1:__builtin_va_arg(ap,double))); if ((++s)==siz) { ptrd = data[++l].data; s=0; } } __builtin_va_end(ap);; | |
25008 | return *this; | |
25009 | } | |
25010 | template<typename t> CImgList(const unsigned int n, const CImg<t>& img, const bool shared=false): | |
25011 | size(0),allocsize(0),data(0) { | |
25012 | assign(n,img,shared); | |
25013 | } | |
25014 | template<typename t> CImgList<T>& assign(const unsigned int n, const CImg<t>& img, const bool shared=false) { | |
25015 | assign(n); | |
25016 | for (unsigned int l=0; l<(*this).size; ++l) data[l].assign(img,shared); | |
25017 | return *this; | |
25018 | } | |
25019 | template<typename t> explicit CImgList(const CImg<t>& img, const bool shared=false): | |
25020 | size(0),allocsize(0),data(0) { | |
25021 | assign(img,shared); | |
25022 | } | |
25023 | template<typename t> CImgList<T>& assign(const CImg<t>& img, const bool shared=false) { | |
25024 | return assign(1,img,shared); | |
25025 | } | |
25026 | template<typename t1, typename t2> CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const bool shared=false): | |
25027 | size(0),allocsize(0),data(0) { | |
25028 | assign(img1,img2,shared); | |
25029 | } | |
25030 | template<typename t1, typename t2> CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const bool shared=false) { | |
25031 | assign(2); | |
25032 | data[0].assign(img1,shared); data[1].assign(img2,shared); | |
25033 | return *this; | |
25034 | } | |
25035 | template<typename t1, typename t2, typename t3> CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const bool shared=false): | |
25036 | size(0),allocsize(0),data(0) { | |
25037 | assign(img1,img2,img3,shared); | |
25038 | } | |
25039 | template<typename t1, typename t2, typename t3> CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const bool shared=false) { | |
25040 | assign(3); | |
25041 | data[0].assign(img1,shared); data[1].assign(img2,shared); data[2].assign(img3,shared); | |
25042 | return *this; | |
25043 | } | |
25044 | template<typename t1, typename t2, typename t3, typename t4> | |
25045 | CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const bool shared=false): | |
25046 | size(0),allocsize(0),data(0) { | |
25047 | assign(img1,img2,img3,img4,shared); | |
25048 | } | |
25049 | template<typename t1, typename t2, typename t3, typename t4> | |
25050 | CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const bool shared=false) { | |
25051 | assign(4); | |
25052 | data[0].assign(img1,shared); data[1].assign(img2,shared); data[2].assign(img3,shared); data[3].assign(img4,shared); | |
25053 | return *this; | |
25054 | } | |
25055 | template<typename t1, typename t2, typename t3, typename t4, typename t5> | |
25056 | CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, const bool shared=false): | |
25057 | size(0),allocsize(0),data(0) { | |
25058 | assign(img1,img2,img3,img4,img5,shared); | |
25059 | } | |
25060 | template<typename t1, typename t2, typename t3, typename t4, typename t5> | |
25061 | CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25062 | const bool shared=false) { | |
25063 | assign(5); | |
25064 | data[0].assign(img1,shared); data[1].assign(img2,shared); data[2].assign(img3,shared); data[3].assign(img4,shared); | |
25065 | data[4].assign(img5,shared); | |
25066 | return *this; | |
25067 | } | |
25068 | template<typename t1, typename t2, typename t3, typename t4, typename t5, typename t6> | |
25069 | CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25070 | const CImg<t6>& img6, const bool shared=false): | |
25071 | size(0),allocsize(0),data(0) { | |
25072 | assign(img1,img2,img3,img4,img5,img6,shared); | |
25073 | } | |
25074 | template<typename t1, typename t2, typename t3, typename t4, typename t5, typename t6> | |
25075 | CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25076 | const CImg<t6>& img6, const bool shared=false) { | |
25077 | assign(6); | |
25078 | data[0].assign(img1,shared); data[1].assign(img2,shared); data[2].assign(img3,shared); data[3].assign(img4,shared); | |
25079 | data[4].assign(img5,shared); data[5].assign(img6,shared); | |
25080 | return *this; | |
25081 | } | |
25082 | template<typename t1, typename t2, typename t3, typename t4, typename t5, typename t6, typename t7> | |
25083 | CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25084 | const CImg<t6>& img6, const CImg<t7>& img7, const bool shared=false): | |
25085 | size(0),allocsize(0),data(0) { | |
25086 | assign(img1,img2,img3,img4,img5,img6,img7,shared); | |
25087 | } | |
25088 | template<typename t1, typename t2, typename t3, typename t4, typename t5, typename t6, typename t7> | |
25089 | CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25090 | const CImg<t6>& img6, const CImg<t7>& img7, const bool shared=false) { | |
25091 | assign(7); | |
25092 | data[0].assign(img1,shared); data[1].assign(img2,shared); data[2].assign(img3,shared); data[3].assign(img4,shared); | |
25093 | data[4].assign(img5,shared); data[5].assign(img6,shared); data[6].assign(img7,shared); | |
25094 | return *this; | |
25095 | } | |
25096 | template<typename t1, typename t2, typename t3, typename t4, typename t5, typename t6, typename t7, typename t8> | |
25097 | CImgList(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25098 | const CImg<t6>& img6, const CImg<t7>& img7, const CImg<t8>& img8, const bool shared=false): | |
25099 | size(0),allocsize(0),data(0) { | |
25100 | assign(img1,img2,img3,img4,img5,img6,img7,img8,shared); | |
25101 | } | |
25102 | template<typename t1, typename t2, typename t3, typename t4, typename t5, typename t6, typename t7, typename t8> | |
25103 | CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, | |
25104 | const CImg<t6>& img6, const CImg<t7>& img7, const CImg<t8>& img8, const bool shared=false) { | |
25105 | assign(8); | |
25106 | data[0].assign(img1,shared); data[1].assign(img2,shared); data[2].assign(img3,shared); data[3].assign(img4,shared); | |
25107 | data[4].assign(img5,shared); data[5].assign(img6,shared); data[6].assign(img7,shared); data[7].assign(img8,shared); | |
25108 | return *this; | |
25109 | } | |
25110 | CImgList(const char *const filename): | |
25111 | size(0),allocsize(0),data(0) { | |
25112 | assign(filename); | |
25113 | } | |
25114 | CImgList<T>& assign(const char *const filename) { | |
25115 | return load(filename); | |
25116 | } | |
25117 | CImgList<T>& swap(CImgList<T>& list) { | |
25118 | cimg::swap(size,list.size); | |
25119 | cimg::swap(allocsize,list.allocsize); | |
25120 | cimg::swap(data,list.data); | |
25121 | return list; | |
25122 | } | |
25123 | CImgList<T>& transfer_to(CImgList<T>& list) { | |
25124 | return swap(list); | |
25125 | } | |
25126 | template<typename t> CImgList<T>& transfer_to(CImgList<t>& list) { | |
25127 | return list.assign(*this); | |
25128 | } | |
25129 | static const char* pixel_type() { | |
25130 | return cimg::type<T>::string(); | |
25131 | } | |
25132 | bool is_empty() const { | |
25133 | return (!data || !size); | |
25134 | } | |
25135 | operator bool() const { | |
25136 | return !is_empty(); | |
25137 | } | |
25138 | bool contains(const int k) const { | |
25139 | return data && k<(int)size; | |
25140 | } | |
25141 | bool contains(const int k, const int x, const int y=0, const int z=0, const int v=0) const { | |
25142 | return contains(k) && data[k].contains(x,y,z,v); | |
25143 | } | |
25144 | template<typename t> bool contains(const T& pixel, t& l, t& x, t&y, t& z, t& v) const { | |
25145 | const T *ptr = &pixel; | |
25146 | for (unsigned int i=0; i<(*this).size; ++i) if (data[i].contains(pixel,x,y,z,v)) { l = (t)i; return true; } | |
25147 | return false; | |
25148 | } | |
25149 | template<typename t> bool contains(const T& pixel, t& l, t& x, t&y, t& z) const { | |
25150 | t v; | |
25151 | return contains(pixel,l,x,y,z,v); | |
25152 | } | |
25153 | template<typename t> bool contains(const T& pixel, t& l, t& x, t&y) const { | |
25154 | t z,v; | |
25155 | return contains(pixel,l,x,y,z,v); | |
25156 | } | |
25157 | template<typename t> bool contains(const T& pixel, t& l, t& x) const { | |
25158 | t y,z,v; | |
25159 | return contains(pixel,l,x,y,z,v); | |
25160 | } | |
25161 | template<typename t> bool contains(const T& pixel, t& l) const { | |
25162 | t x,y,z,v; | |
25163 | return contains(pixel,l,x,y,z,v); | |
25164 | } | |
25165 | template<typename t> bool contains(const T& pixel) const { | |
25166 | t l,x,y,z,v; | |
25167 | return contains(pixel,l,x,y,z,v); | |
25168 | } | |
25169 | template<typename t> CImgList<T>& operator=(const CImgList<t>& list) { | |
25170 | return assign(list); | |
25171 | } | |
25172 | CImgList<T>& operator=(const CImgList<T>& list) { | |
25173 | return assign(list); | |
25174 | } | |
25175 | template<typename t> CImgList<T>& operator=(const CImg<t>& img) { | |
25176 | for (unsigned int l=0; l<(*this).size; ++l) data[l]=img; | |
25177 | return *this; | |
25178 | } | |
25179 | CImgList<T>& operator=(const T val) { | |
25180 | for (unsigned int l=0; l<(*this).size; ++l) data[l].fill(val); | |
25181 | return *this; | |
25182 | } | |
25183 | CImgList<T> operator+() const { | |
25184 | return CImgList<T>(*this); | |
25185 | } | |
25186 | template<typename t> CImgList<T>& operator+=(const t val) { | |
25187 | for (unsigned int l=0; l<(*this).size; ++l) (*this)[l]+=val; | |
25188 | return *this; | |
25189 | } | |
25190 | template<typename t> CImgList<T>& operator+=(const CImgList<t>& list) { | |
25191 | const unsigned int sizemax = cimg::min(size,list.size); | |
25192 | for (unsigned int l=0; l<sizemax; ++l) (*this)[l]+=list[l]; | |
25193 | return *this; | |
25194 | } | |
25195 | CImgList<T>& operator++() { | |
25196 | for (unsigned int l=0; l<(*this).size; ++l) ++(*this)[l]; | |
25197 | return *this; | |
25198 | } | |
25199 | CImgList<T> operator++(int) { | |
25200 | CImgList<T> copy(*this); | |
25201 | ++*this; | |
25202 | return copy; | |
25203 | } | |
25204 | CImgList<T> operator-() const { | |
25205 | CImgList<T> res(size); | |
25206 | for (unsigned int l=0; l<(res).size; ++l) res[l].assign(-data[l]); | |
25207 | return res; | |
25208 | } | |
25209 | template<typename t> CImgList<T>& operator-=(const t val) { | |
25210 | for (unsigned int l=0; l<(*this).size; ++l) (*this)[l]-=val; | |
25211 | return *this; | |
25212 | } | |
25213 | template<typename t> CImgList<T>& operator-=(const CImgList<t>& list) { | |
25214 | const unsigned int sizemax = min(size,list.size); | |
25215 | for (unsigned int l=0; l<sizemax; ++l) (*this)[l]-=list[l]; | |
25216 | return *this; | |
25217 | } | |
25218 | CImgList<T>& operator--() { | |
25219 | for (unsigned int l=0; l<(*this).size; ++l) --(*this)[l]; | |
25220 | return *this; | |
25221 | } | |
25222 | CImgList<T> operator--(int) { | |
25223 | CImgList<T> copy(*this); | |
25224 | --*this; | |
25225 | return copy; | |
25226 | } | |
25227 | template<typename t> CImgList<T>& operator*=(const t val) { | |
25228 | for (unsigned int l=0; l<(*this).size; ++l) (*this)[l]*=val; | |
25229 | return *this; | |
25230 | } | |
25231 | template<typename t> CImgList<T>& operator*=(const CImgList<t>& list) { | |
25232 | const unsigned int N = cimg::min(size,list.size); | |
25233 | for (unsigned int l=0; l<N; ++l) (*this)[l]*=list[l]; | |
25234 | return this; | |
25235 | } | |
25236 | template<typename t> CImgList<T>& operator/=(const t val) { | |
25237 | for (unsigned int l=0; l<(*this).size; ++l) (*this)[l]/=val; | |
25238 | return *this; | |
25239 | } | |
25240 | template<typename t> CImgList<T>& operator/=(const CImgList<t>& list) { | |
25241 | const unsigned int N = cimg::min(size,list.size); | |
25242 | for (unsigned int l=0; l<N; ++l) (*this)[l]/=list[l]; | |
25243 | return this; | |
25244 | } | |
25245 | const T& max() const { | |
25246 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::max() : Instance image list is empty.",pixel_type()); | |
25247 | const T *ptrmax = data->data; | |
25248 | T max_value = *ptrmax; | |
25249 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25250 | const CImg<T>& img = data[l]; | |
25251 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) if ((*ptr)>max_value) max_value = *(ptrmax=ptr); | |
25252 | } | |
25253 | return *ptrmax; | |
25254 | } | |
25255 | T& max() { | |
25256 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::max() : Instance image list is empty.",pixel_type()); | |
25257 | T *ptrmax = data->data; | |
25258 | T max_value = *ptrmax; | |
25259 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25260 | const CImg<T>& img = data[l]; | |
25261 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) if ((*ptr)>max_value) max_value = *(ptrmax=ptr); | |
25262 | } | |
25263 | return *ptrmax; | |
25264 | } | |
25265 | const T& min() const { | |
25266 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::min() : Instance image list is empty.",pixel_type()); | |
25267 | const T *ptrmin = data->data; | |
25268 | T min_value = *ptrmin; | |
25269 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25270 | const CImg<T>& img = data[l]; | |
25271 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) if ((*ptr)<min_value) min_value = *(ptrmin=ptr); | |
25272 | } | |
25273 | return *ptrmin; | |
25274 | } | |
25275 | T& min() { | |
25276 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::min() : Instance image list is empty.",pixel_type()); | |
25277 | T *ptrmin = data->data; | |
25278 | T min_value = *ptrmin; | |
25279 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25280 | const CImg<T>& img = data[l]; | |
25281 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) if ((*ptr)<min_value) min_value = *(ptrmin=ptr); | |
25282 | } | |
25283 | return *ptrmin; | |
25284 | } | |
25285 | template<typename t> const T& minmax(t& max_val) const { | |
25286 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::minmax() : Instance image list is empty.",pixel_type()); | |
25287 | const T *ptrmin = data->data; | |
25288 | T min_value = *ptrmin, max_value = min_value; | |
25289 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25290 | const CImg<T>& img = data[l]; | |
25291 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) { | |
25292 | const T val = *ptr; | |
25293 | if (val<min_value) { min_value = val; ptrmin = ptr; } | |
25294 | if (val>max_value) max_value = val; | |
25295 | } | |
25296 | } | |
25297 | max_val = (t)max_value; | |
25298 | return *ptrmin; | |
25299 | } | |
25300 | template<typename t> T& minmax(t& max_val) { | |
25301 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::minmax() : Instance image list is empty.",pixel_type()); | |
25302 | T *ptrmin = data->data; | |
25303 | T min_value = *ptrmin, max_value = min_value; | |
25304 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25305 | const CImg<T>& img = data[l]; | |
25306 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) { | |
25307 | const T val = *ptr; | |
25308 | if (val<min_value) { min_value = val; ptrmin = ptr; } | |
25309 | if (val>max_value) max_value = val; | |
25310 | } | |
25311 | } | |
25312 | max_val = (t)max_value; | |
25313 | return *ptrmin; | |
25314 | } | |
25315 | template<typename t> const T& maxmin(t& min_val) const { | |
25316 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::maxmin() : Instance image list is empty.",pixel_type()); | |
25317 | const T *ptrmax = data->data; | |
25318 | T min_value = *ptrmax, max_value = min_value; | |
25319 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25320 | const CImg<T>& img = data[l]; | |
25321 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) { | |
25322 | const T val = *ptr; | |
25323 | if (val>max_value) { max_value = val; ptrmax = ptr; } | |
25324 | if (val<min_value) min_value = val; | |
25325 | } | |
25326 | } | |
25327 | min_val = (t)min_value; | |
25328 | return *ptrmax; | |
25329 | } | |
25330 | template<typename t> T& maxmin(t& min_val) { | |
25331 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::maxmin() : Instance image list is empty.",pixel_type()); | |
25332 | T *ptrmax = data->data; | |
25333 | T min_value = *ptrmax, max_value = min_value; | |
25334 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25335 | const CImg<T>& img = data[l]; | |
25336 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) { | |
25337 | const T val = *ptr; | |
25338 | if (val>max_value) { max_value = val; ptrmax = ptr; } | |
25339 | if (val<min_value) min_value = val; | |
25340 | } | |
25341 | } | |
25342 | min_val = (t)min_value; | |
25343 | return *ptrmax; | |
25344 | } | |
25345 | double mean() const { | |
25346 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::mean() : Instance image list is empty.",pixel_type()); | |
25347 | double val = 0; | |
25348 | unsigned int siz = 0; | |
25349 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25350 | const CImg<T>& img = data[l]; | |
25351 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) val+=(double)*ptr; | |
25352 | siz+=img.size(); | |
25353 | } | |
25354 | return val/siz; | |
25355 | } | |
25356 | double variance() { | |
25357 | if (is_empty()) | |
25358 | throw CImgInstanceException("CImgList<%s>::variance() : Instance image list is empty.",pixel_type()); | |
25359 | double res = 0; | |
25360 | unsigned int siz = 0; | |
25361 | double S = 0, S2 = 0; | |
25362 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25363 | const CImg<T>& img = data[l]; | |
25364 | for (T *ptr = (img).data + (img).size(); (ptr--)>(img).data; ) { const double val = (double)*ptr; S+=val; S2+=val*val; } | |
25365 | siz+=img.size(); | |
25366 | } | |
25367 | res = (S2 - S*S/siz)/siz; | |
25368 | return res; | |
25369 | } | |
25370 | CImg<T>& operator[](const unsigned int pos) { | |
25371 | return data[pos]; | |
25372 | } | |
25373 | const CImg<T>& operator[](const unsigned int pos) const { | |
25374 | return data[pos]; | |
25375 | } | |
25376 | CImg<T>& operator()(const unsigned int pos) { | |
25377 | return (*this)[pos]; | |
25378 | } | |
25379 | const CImg<T>& operator()(const unsigned int pos) const { | |
25380 | return (*this)[pos]; | |
25381 | } | |
25382 | T& operator()(const unsigned int pos, const unsigned int x, const unsigned int y=0, | |
25383 | const unsigned int z=0, const unsigned int v=0) { | |
25384 | return (*this)[pos](x,y,z,v); | |
25385 | } | |
25386 | const T& operator()(const unsigned int pos, const unsigned int x, const unsigned int y=0, | |
25387 | const unsigned int z=0, const unsigned int v=0) const { | |
25388 | return (*this)[pos](x,y,z,v); | |
25389 | } | |
25390 | CImg<T>& at(const unsigned int pos) { | |
25391 | if (pos>=size) | |
25392 | throw CImgArgumentException("CImgList<%s>::at() : bad list position %u, in a list of %u images", | |
25393 | pixel_type(),pos,size); | |
25394 | return data[pos]; | |
25395 | } | |
25396 | const CImg<T>& at(const unsigned int pos) const { | |
25397 | if (pos>=size) | |
25398 | throw CImgArgumentException("CImgList<%s>::at() : bad list position %u, in a list of %u images", | |
25399 | pixel_type(),pos,size); | |
25400 | return data[pos]; | |
25401 | } | |
25402 | CImg<T>& back() { | |
25403 | return (*this)(size-1); | |
25404 | } | |
25405 | const CImg<T>& back() const { | |
25406 | return (*this)(size-1); | |
25407 | } | |
25408 | CImg<T>& front() { | |
25409 | return *data; | |
25410 | } | |
25411 | const CImg<T>& front() const { | |
25412 | return *data; | |
25413 | } | |
25414 | iterator begin() { | |
25415 | return data; | |
25416 | } | |
25417 | const_iterator begin() const { | |
25418 | return data; | |
25419 | } | |
25420 | iterator end() { | |
25421 | return data + size; | |
25422 | } | |
25423 | const_iterator end() const { | |
25424 | return data + size; | |
25425 | } | |
25426 | template<typename t> CImgList<typename cimg::superset<T,t>::type> | |
25427 | get_insert(const CImg<t>& img, const unsigned int pos=~0U, const bool shared=false) const { | |
25428 | typedef typename cimg::superset<T,t>::type restype; | |
25429 | return CImgList<restype>(*this).insert(img,pos,shared); | |
25430 | } | |
25431 | template<typename t> CImgList<T>& insert(const CImg<t>& img, const unsigned int pos, const bool shared) { | |
25432 | const unsigned int npos = pos==~0U?size:pos; | |
25433 | if (npos>size) | |
25434 | throw CImgArgumentException("CImgList<%s>::insert() : Cannot insert at position %u into a list with %u elements", | |
25435 | pixel_type(),npos,size); | |
25436 | if (shared) | |
25437 | throw CImgArgumentException("CImgList<%s>::insert(): Cannot insert a shared image CImg<%s> into a CImgList<%s>", | |
25438 | pixel_type(),img.pixel_type(),pixel_type()); | |
25439 | CImg<T> *new_data = (++size>allocsize)?new CImg<T>[allocsize?(allocsize<<=1):(allocsize=1)]:0; | |
25440 | if (!size || !data) { | |
25441 | data = new_data; | |
25442 | *data = img; | |
25443 | } else { | |
25444 | if (new_data) { | |
25445 | if (npos) std::memcpy(new_data,data,sizeof(CImg<T>)*npos); | |
25446 | if (npos!=size-1) std::memcpy(new_data+npos+1,data+npos,sizeof(CImg<T>)*(size-1-npos)); | |
25447 | std::memset(data,0,sizeof(CImg<T>)*(size-1)); | |
25448 | delete[] data; | |
25449 | data = new_data; | |
25450 | } | |
25451 | else if (npos!=size-1) std::memmove(data+npos+1,data+npos,sizeof(CImg<T>)*(size-1-npos)); | |
25452 | data[npos].width = data[npos].height = data[npos].depth = data[npos].dim = 0; data[npos].data = 0; | |
25453 | data[npos] = img; | |
25454 | } | |
25455 | return *this; | |
25456 | } | |
25457 | CImgList<T>& insert(const CImg<T>& img, const unsigned int pos, const bool shared) { | |
25458 | const unsigned int npos = pos==~0U?size:pos; | |
25459 | if (npos>size) | |
25460 | throw CImgArgumentException("CImgList<%s>::insert() : Can't insert at position %u into a list with %u elements", | |
25461 | pixel_type(),npos,size); | |
25462 | CImg<T> *new_data = (++size>allocsize)?new CImg<T>[allocsize?(allocsize<<=1):(allocsize=1)]:0; | |
25463 | if (!size || !data) { | |
25464 | data = new_data; | |
25465 | if (shared && img) { | |
25466 | data->width = img.width; data->height = img.height; data->depth = img.depth; data->dim = img.dim; | |
25467 | data->is_shared = true; data->data = img.data; | |
25468 | } else *data = img; | |
25469 | } | |
25470 | else { | |
25471 | if (new_data) { | |
25472 | if (npos) std::memcpy(new_data,data,sizeof(CImg<T>)*npos); | |
25473 | if (npos!=size-1) std::memcpy(new_data+npos+1,data+npos,sizeof(CImg<T>)*(size-1-npos)); | |
25474 | if (shared && img) { | |
25475 | new_data[npos].width = img.width; new_data[npos].height = img.height; new_data[npos].depth = img.depth; | |
25476 | new_data[npos].dim = img.dim; new_data[npos].is_shared = true; new_data[npos].data = img.data; | |
25477 | } else { | |
25478 | new_data[npos].width = new_data[npos].height = new_data[npos].depth = new_data[npos].dim = 0; new_data[npos].data = 0; | |
25479 | new_data[npos] = img; | |
25480 | } | |
25481 | std::memset(data,0,sizeof(CImg<T>)*(size-1)); | |
25482 | delete[] data; | |
25483 | data = new_data; | |
25484 | } else { | |
25485 | if (npos!=size-1) std::memmove(data+npos+1,data+npos,sizeof(CImg<T>)*(size-1-npos)); | |
25486 | if (shared && img) { | |
25487 | data[npos].width = img.width; data[npos].height = img.height; data[npos].depth = img.depth; data[npos].dim = img.dim; | |
25488 | data[npos].is_shared = true; data[npos].data = img.data; | |
25489 | } else { | |
25490 | data[npos].width = data[npos].height = data[npos].depth = data[npos].dim = 0; data[npos].data = 0; | |
25491 | data[npos] = img; | |
25492 | } | |
25493 | } | |
25494 | } | |
25495 | return *this; | |
25496 | } | |
25497 | template<typename t> CImgList<T>& insert(const CImg<t>& img, const unsigned int pos) { | |
25498 | return insert(img,pos,false); | |
25499 | } | |
25500 | template<typename t> CImgList<T>& insert(const CImg<t>& img) { | |
25501 | return insert(img,~0U,false); | |
25502 | } | |
25503 | template<typename t> CImgList<typename cimg::superset<T,t>::type> | |
25504 | get_insert(const unsigned int n, const CImg<t>& img, const unsigned int pos=~0U, const bool shared=false) const { | |
25505 | typedef typename cimg::superset<T,t>::type restype; | |
25506 | return CImgList<restype>(*this).insert(n,img,pos,shared); | |
25507 | } | |
25508 | template<typename t> CImgList<T>& insert(const unsigned int n, const CImg<t>& img, const unsigned int pos=~0U, const bool shared=false) { | |
25509 | const unsigned int npos = pos==~0U?size:pos; | |
25510 | insert(img,npos,shared); | |
25511 | for (unsigned int i=1; i<n; ++i) insert(data[npos],npos+i,shared); | |
25512 | return *this; | |
25513 | } | |
25514 | template<typename t> CImgList<typename cimg::superset<T,t>::type> | |
25515 | get_insert(const CImgList<t>& list, const unsigned int pos=~0U, int shared=0) const { | |
25516 | typedef typename cimg::superset<T,t>::type restype; | |
25517 | return CImgList<restype>(*this).insert(list,pos,shared); | |
25518 | } | |
25519 | template<typename t> CImgList<T>& insert(const CImgList<t>& list, const unsigned int pos=~0U, const int shared=0) { | |
25520 | const unsigned int npos = pos==~0U?size:pos; | |
25521 | if ((void*)this!=(void*)&list) { | |
25522 | if (shared>=0) for (unsigned int l=0; l<(list).size; ++l) insert(list[l],npos+l,shared?true:false); | |
25523 | else for (unsigned int l=0; l<(list).size; ++l) insert(list[l],npos+l,list[l].is_shared); | |
25524 | } else insert(CImgList<T>(list),npos,shared); | |
25525 | return *this; | |
25526 | } | |
25527 | template<typename t> CImgList<typename cimg::superset<T,t>::type> | |
25528 | get_insert(const unsigned int n, const CImgList<t>& list, const unsigned int pos=~0U, const int shared=0) const { | |
25529 | typedef typename cimg::superset<T,t>::type restype; | |
25530 | return CImgList<restype>(*this).insert(n,list,pos,shared); | |
25531 | } | |
25532 | template<typename t> CImgList<T>& insert(const unsigned int n, const CImgList<t>& list, const unsigned int pos=~0U, const int shared=0) { | |
25533 | const unsigned int npos = pos==~0U?size:pos; | |
25534 | for (unsigned int i=0; i<n; ++i) insert(list,npos,shared); | |
25535 | return *this; | |
25536 | } | |
25537 | CImgList<T> get_remove(const unsigned int pos1, const unsigned int pos2) const { | |
25538 | return (+*this).remove(pos1,pos2); | |
25539 | } | |
25540 | CImgList<T>& remove(const unsigned int pos1, const unsigned int pos2) { | |
25541 | const unsigned int | |
25542 | npos1 = pos1<pos2?pos1:pos2, | |
25543 | tpos2 = pos1<pos2?pos2:pos1, | |
25544 | npos2 = tpos2<size?tpos2:size-1; | |
25545 | if (npos1>=size) | |
25546 | cimg::warn("CImgList<%s>::remove() : Cannot remove images from a list (%p,%u), at positions %u->%u.", | |
25547 | pixel_type(),data,size,npos1,tpos2); | |
25548 | else { | |
25549 | if (tpos2>=size) | |
25550 | cimg::warn("CImgList<%s>::remove() : Cannot remove all images from a list (%p,%u), at positions %u->%u.", | |
25551 | pixel_type(),data,size,npos1,tpos2); | |
25552 | for (unsigned int k = npos1; k<=npos2; ++k) data[k].assign(); | |
25553 | const unsigned int nb = 1 + npos2 - npos1; | |
25554 | if (!(size-=nb)) return assign(); | |
25555 | if (size>(allocsize>>2) || allocsize<=8) { | |
25556 | if (npos1!=size) std::memmove(data+npos1,data+npos2+1,sizeof(CImg<T>)*(size-npos1)); | |
25557 | std::memset(data+size,0,sizeof(CImg<T>)*nb); | |
25558 | } else { | |
25559 | allocsize>>=2; | |
25560 | while (allocsize>8 && size<(allocsize>>1)) allocsize>>=1; | |
25561 | CImg<T> *new_data = new CImg<T>[allocsize]; | |
25562 | if (npos1) std::memcpy(new_data,data,sizeof(CImg<T>)*npos1); | |
25563 | if (npos1!=size) std::memcpy(new_data+npos1,data+npos2+1,sizeof(CImg<T>)*(size-npos1)); | |
25564 | if (size!=allocsize) std::memset(new_data+size,0,sizeof(allocsize-size)); | |
25565 | std::memset(data,0,sizeof(CImg<T>)*(size+nb)); | |
25566 | delete[] data; | |
25567 | data = new_data; | |
25568 | } | |
25569 | } | |
25570 | return *this; | |
25571 | } | |
25572 | CImgList<T> get_remove(const unsigned int pos) const { | |
25573 | return (+*this).remove(pos); | |
25574 | } | |
25575 | CImgList<T>& remove(const unsigned int pos) { | |
25576 | return remove(pos,pos); | |
25577 | } | |
25578 | CImgList<T> get_remove() const { | |
25579 | return (+*this).remove(); | |
25580 | } | |
25581 | CImgList<T>& remove() { | |
25582 | if (size) return remove(size-1); | |
25583 | else cimg::warn("CImgList<%s>::remove() : List is empty",pixel_type()); | |
25584 | return *this; | |
25585 | } | |
25586 | CImgList<T> get_reverse() const { | |
25587 | return (+*this).reverse(); | |
25588 | } | |
25589 | CImgList<T>& reverse() { | |
25590 | for (unsigned int l=0; l<size/2; ++l) (*this)[l].swap((*this)[size-1-l]); | |
25591 | return *this; | |
25592 | } | |
25593 | CImgList<T> get_crop(const unsigned int i0, const unsigned int i1, const bool shared=false) const { | |
25594 | if (i0>i1 || i1>=size) | |
25595 | throw CImgArgumentException("CImgList<%s>::crop() : Cannot crop a sub-list (%u->%u) from a list (%u,%p)", | |
25596 | pixel_type(),i0,i1,size,data); | |
25597 | CImgList<T> res(i1-i0+1); | |
25598 | for (unsigned int l=0; l<(res).size; ++l) res[l].assign((*this)[i0+l],shared); | |
25599 | return res; | |
25600 | } | |
25601 | CImgList<T>& crop(const unsigned int i0, const unsigned int i1, const bool shared=false) { | |
25602 | return get_crop(i0,i1,shared).transfer_to(*this); | |
25603 | } | |
25604 | CImgList<T> get_crop(const unsigned int i0, const unsigned int i1, | |
25605 | const int x0, const int y0, const int z0, const int v0, | |
25606 | const int x1, const int y1, const int z1, const int v1) const { | |
25607 | if (i0>i1 || i1>=size) | |
25608 | throw CImgArgumentException("CImgList<%s>::crop() : Cannot crop a sub-list (%u->%u) from a list (%u,%p)", | |
25609 | pixel_type(),i0,i1,size,data); | |
25610 | CImgList<T> res(i1-i0+1); | |
25611 | for (unsigned int l=0; l<(res).size; ++l) res[l] = (*this)[i0+l].get_crop(x0,y0,z0,v0,x1,y1,z1,v1); | |
25612 | return res; | |
25613 | } | |
25614 | CImgList<T>& crop(const unsigned int i0, const unsigned int i1, | |
25615 | const int x0, const int y0, const int z0, const int v0, | |
25616 | const int x1, const int y1, const int z1, const int v1) { | |
25617 | return get_crop(i0,i1,x0,y0,z0,v0,x1,y1,z1,v1).transfer_to(*this); | |
25618 | } | |
25619 | CImgList<T> get_crop(const unsigned int i0, const unsigned int i1, | |
25620 | const int x0, const int y0, const int z0, | |
25621 | const int x1, const int y1, const int z1) const { | |
25622 | if (i0>i1 || i1>=size) | |
25623 | throw CImgArgumentException("CImgList<%s>::crop() : Cannot crop a sub-list (%u->%u) from a list (%u,%p)", | |
25624 | pixel_type(),i0,i1,size,data); | |
25625 | CImgList<T> res(i1-i0+1); | |
25626 | for (unsigned int l=0; l<(res).size; ++l) res[l] = (*this)[i0+l].get_crop(x0,y0,z0,x1,y1,z1); | |
25627 | return res; | |
25628 | } | |
25629 | CImgList<T>& crop(const unsigned int i0, const unsigned int i1, | |
25630 | const int x0, const int y0, const int z0, | |
25631 | const int x1, const int y1, const int z1) { | |
25632 | return get_crop(i0,i1,x0,y0,z0,x1,y1,z1).transfer_to(*this); | |
25633 | } | |
25634 | CImgList<T> get_crop(const unsigned int i0, const unsigned int i1, | |
25635 | const int x0, const int y0, | |
25636 | const int x1, const int y1) const { | |
25637 | if (i0>i1 || i1>=size) | |
25638 | throw CImgArgumentException("CImgList<%s>::crop() : Cannot crop a sub-list (%u->%u) from a list (%u,%p)", | |
25639 | pixel_type(),i0,i1,size,data); | |
25640 | CImgList<T> res(i1-i0+1); | |
25641 | for (unsigned int l=0; l<(res).size; ++l) res[l] = (*this)[i0+l].get_crop(x0,y0,x1,y1); | |
25642 | return res; | |
25643 | } | |
25644 | CImgList<T>& crop(const unsigned int i0, const unsigned int i1, | |
25645 | const int x0, const int y0, | |
25646 | const int x1, const int y1) { | |
25647 | return get_crop(i0,i1,x0,y0,x1,y1).transfer_to(*this); | |
25648 | } | |
25649 | CImgList<T> get_crop(const unsigned int i0, const unsigned int i1, | |
25650 | const int x0, const int x1) const { | |
25651 | if (i0>i1 || i1>=size) | |
25652 | throw CImgArgumentException("CImgList<%s>::crop() : Cannot crop a sub-list (%u->%u) from a list (%u,%p)", | |
25653 | pixel_type(),i0,i1,size,data); | |
25654 | CImgList<T> res(i1-i0+1); | |
25655 | for (unsigned int l=0; l<(res).size; ++l) res[l] = (*this)[i0+l].get_crop(x0,x1); | |
25656 | return res; | |
25657 | } | |
25658 | CImgList<T>& crop(const unsigned int i0, const unsigned int i1, | |
25659 | const int x0, const int x1) { | |
25660 | return get_crop(i0,i1,x0,x1).transfer_to(*this); | |
25661 | } | |
25662 | template<typename t> CImgList<T>& operator<<(const CImg<t>& img) { | |
25663 | return insert(img); | |
25664 | } | |
25665 | template<typename t> CImgList<T>& operator<<(const CImgList<t>& list) { | |
25666 | return insert(list); | |
25667 | } | |
25668 | template<typename t> CImgList<T>& operator>>(CImg<t>& img) const { | |
25669 | typedef typename cimg::superset<T,t>::type restype; | |
25670 | return CImgList<restype>(*this).insert(img); | |
25671 | } | |
25672 | template<typename t> CImgList<T>& operator>>(CImgList<t>& list) const { | |
25673 | return list.insert(*this,0); | |
25674 | } | |
25675 | const CImgList<T>& operator>>(CImgDisplay& disp) const { | |
25676 | return display(disp); | |
25677 | } | |
25678 | template<typename t> CImgList<T>& push_back(const CImg<t>& img) { | |
25679 | return insert(img); | |
25680 | } | |
25681 | template<typename t> CImgList<T>& push_front(const CImg<t>& img) { | |
25682 | return insert(img,0); | |
25683 | } | |
25684 | template<typename t> CImgList<T>& push_back(const CImgList<t>& list) { | |
25685 | return insert(list); | |
25686 | } | |
25687 | template<typename t> CImgList<T>& push_front(const CImgList<t>& list) { | |
25688 | return insert(list,0); | |
25689 | } | |
25690 | CImgList<T>& pop_back() { | |
25691 | return remove(size-1); | |
25692 | } | |
25693 | CImgList<T>& pop_front() { | |
25694 | return remove(0); | |
25695 | } | |
25696 | CImgList<T>& erase(const iterator iter) { | |
25697 | return remove(iter-data); | |
25698 | } | |
25699 | CImgList<typename cimg::superset<T,float>::type> get_FFT(const char axe, const bool invert=false) const { | |
25700 | typedef typename cimg::superset<T,float>::type restype; | |
25701 | return CImgList<restype>(*this).FFT(axe,invert); | |
25702 | } | |
25703 | CImgList<T>& FFT(const char axe, const bool invert=false) { | |
25704 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::FFT() : Instance list (%u,%p) is empty",pixel_type(),size,data); | |
25705 | if (!data[0]) throw CImgInstanceException("CImgList<%s>::FFT() : Real part (%u,%u,%u,%u,%p) is empty", | |
25706 | pixel_type(),data[0].width,data[0].height,data[0].depth,data[0].dim,data[0].data); | |
25707 | if (size>2) cimg::warn("CImgList<%s>::FFT() : Instance list (%u,%p) have more than 2 images",pixel_type(),size,data); | |
25708 | if (size==1) insert(CImg<T>(data[0].width,data[0].height,data[0].depth,data[0].dim,0)); | |
25709 | CImg<T> &Ir = data[0], &Ii = data[1]; | |
25710 | if (Ir.width!=Ii.width || Ir.height!=Ii.height || Ir.depth!=Ii.depth || Ir.dim!=Ii.dim) | |
25711 | throw CImgInstanceException("CImgList<%s>::FFT() : Real part (%u,%u,%u,%u,%p) and imaginary part (%u,%u,%u,%u,%p)" | |
25712 | "have different dimensions",pixel_type(), | |
25713 | Ir.width,Ir.height,Ir.depth,Ir.dim,Ir.data,Ii.width,Ii.height,Ii.depth,Ii.dim,Ii.data); | |
25714 | switch (cimg::uncase(axe)) { | |
25715 | case 'x': { | |
25716 | const unsigned int N = Ir.width, N2 = (N>>1); | |
25717 | if (((N-1)&N) && N!=1) throw CImgInstanceException("CImgList<%s>::FFT() : Dimension of instance image along 'x' is %d != 2^N", | |
25718 | pixel_type(),N); | |
25719 | for (unsigned int i=0, j=0; i<N2; ++i) { | |
25720 | if (j>i) for (int v = 0; v<(int)((Ir).dim); ++v) for (int z = 0; z<(int)((Ir).depth); ++z) for (int y = 0; y<(int)((Ir).height); ++y) { cimg::swap(Ir(i,y,z,v),Ir(j,y,z,v)); cimg::swap(Ii(i,y,z,v),Ii(j,y,z,v)); | |
25721 | if (j<N2) { | |
25722 | const unsigned int ri = N-1-i, rj = N-1-j; | |
25723 | cimg::swap(Ir(ri,y,z,v),Ir(rj,y,z,v)); cimg::swap(Ii(ri,y,z,v),Ii(rj,y,z,v)); | |
25724 | }} | |
25725 | for (unsigned int m=N, n=N2; (j+=n)>=m; j-=m, m=n, n>>=1); | |
25726 | } | |
25727 | for (unsigned int delta=2; delta<=N; delta<<=1) { | |
25728 | const unsigned int delta2 = (delta>>1); | |
25729 | for (unsigned int i=0; i<N; i+=delta) { | |
25730 | float wr = 1, wi = 0; | |
25731 | const float angle = (float)((invert?+1:-1)*2*cimg::valuePI/delta), | |
25732 | ca = (float)std::cos(angle), | |
25733 | sa = (float)std::sin(angle); | |
25734 | for (unsigned int k=0; k<delta2; ++k) { | |
25735 | const unsigned int j = i + k, nj = j + delta2; | |
25736 | for (int k = 0; k<(int)((Ir).dim); ++k) for (int z = 0; z<(int)((Ir).depth); ++z) for (int y = 0; y<(int)((Ir).height); ++y) { | |
25737 | T &ir = Ir(j,y,z,k), &ii = Ii(j,y,z,k), &nir = Ir(nj,y,z,k), &nii = Ii(nj,y,z,k); | |
25738 | const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir); | |
25739 | nir = (T)(ir - tmpr); | |
25740 | nii = (T)(ii - tmpi); | |
25741 | ir += (T)tmpr; | |
25742 | ii += (T)tmpi; | |
25743 | } | |
25744 | const float nwr = wr*ca-wi*sa; | |
25745 | wi = wi*ca + wr*sa; | |
25746 | wr = nwr; | |
25747 | } | |
25748 | } | |
25749 | } | |
25750 | if (invert) (*this)/=N; | |
25751 | } break; | |
25752 | case 'y': { | |
25753 | const unsigned int N = Ir.height, N2 = (N>>1); | |
25754 | if (((N-1)&N) && N!=1) throw CImgInstanceException("CImgList<%s>::FFT() : Dimension of instance image(s) along 'y' is %d != 2^N", | |
25755 | pixel_type(),N); | |
25756 | for (unsigned int i=0, j=0; i<N2; ++i) { | |
25757 | if (j>i) for (int v = 0; v<(int)((Ir).dim); ++v) for (int z = 0; z<(int)((Ir).depth); ++z) for (int x = 0; x<(int)((Ir).width); ++x) { cimg::swap(Ir(x,i,z,v),Ir(x,j,z,v)); cimg::swap(Ii(x,i,z,v),Ii(x,j,z,v)); | |
25758 | if (j<N2) { | |
25759 | const unsigned int ri = N-1-i, rj = N-1-j; | |
25760 | cimg::swap(Ir(x,ri,z,v),Ir(x,rj,z,v)); cimg::swap(Ii(x,ri,z,v),Ii(x,rj,z,v)); | |
25761 | }} | |
25762 | for (unsigned int m=N, n=N2; (j+=n)>=m; j-=m, m=n, n>>=1); | |
25763 | } | |
25764 | for (unsigned int delta=2; delta<=N; delta<<=1) { | |
25765 | const unsigned int delta2 = (delta>>1); | |
25766 | for (unsigned int i=0; i<N; i+=delta) { | |
25767 | float wr = 1, wi = 0; | |
25768 | const float angle = (float)((invert?+1:-1)*2*cimg::valuePI/delta), | |
25769 | ca = (float)std::cos(angle), sa = (float)std::sin(angle); | |
25770 | for (unsigned int k=0; k<delta2; ++k) { | |
25771 | const unsigned int j = i + k, nj = j + delta2; | |
25772 | for (int k = 0; k<(int)((Ir).dim); ++k) for (int z = 0; z<(int)((Ir).depth); ++z) for (int x = 0; x<(int)((Ir).width); ++x) { | |
25773 | T &ir = Ir(x,j,z,k), &ii = Ii(x,j,z,k), &nir = Ir(x,nj,z,k), &nii = Ii(x,nj,z,k); | |
25774 | const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir); | |
25775 | nir = (T)(ir - tmpr); | |
25776 | nii = (T)(ii - tmpi); | |
25777 | ir += (T)tmpr; | |
25778 | ii += (T)tmpi; | |
25779 | } | |
25780 | const float nwr = wr*ca-wi*sa; | |
25781 | wi = wi*ca + wr*sa; | |
25782 | wr = nwr; | |
25783 | } | |
25784 | } | |
25785 | } | |
25786 | if (invert) (*this)/=N; | |
25787 | } break; | |
25788 | case 'z': { | |
25789 | const unsigned int N = Ir.depth, N2 = (N>>1); | |
25790 | if (((N-1)&N) && N!=1) throw CImgInstanceException("CImgList<%s>::FFT() : Dimension of instance image(s) along 'z' is %d != 2^N", | |
25791 | pixel_type(),N); | |
25792 | for (unsigned int i=0, j=0; i<N2; ++i) { | |
25793 | if (j>i) for (int v = 0; v<(int)((Ir).dim); ++v) for (int y = 0; y<(int)((Ir).height); ++y) for (int x = 0; x<(int)((Ir).width); ++x) { cimg::swap(Ir(x,y,i,v),Ir(x,y,j,v)); cimg::swap(Ii(x,y,i,v),Ii(x,y,j,v)); | |
25794 | if (j<N2) { | |
25795 | const unsigned int ri = N-1-i, rj = N-1-j; | |
25796 | cimg::swap(Ir(x,y,ri,v),Ir(x,y,rj,v)); cimg::swap(Ii(x,y,ri,v),Ii(x,y,rj,v)); | |
25797 | }} | |
25798 | for (unsigned int m=N, n=N2; (j+=n)>=m; j-=m, m=n, n>>=1); | |
25799 | } | |
25800 | for (unsigned int delta=2; delta<=N; delta<<=1) { | |
25801 | const unsigned int delta2 = (delta>>1); | |
25802 | for (unsigned int i=0; i<N; i+=delta) { | |
25803 | float wr = 1, wi = 0; | |
25804 | const float angle = (float)((invert?+1:-1)*2*cimg::valuePI/delta), | |
25805 | ca = (float)std::cos(angle), sa = (float)std::sin(angle); | |
25806 | for (unsigned int k=0; k<delta2; ++k) { | |
25807 | const unsigned int j = i + k, nj = j + delta2; | |
25808 | for (int k = 0; k<(int)((Ir).dim); ++k) for (int y = 0; y<(int)((Ir).height); ++y) for (int x = 0; x<(int)((Ir).width); ++x) { | |
25809 | T &ir = Ir(x,y,j,k), &ii = Ii(x,y,j,k), &nir = Ir(x,y,nj,k), &nii = Ii(x,y,nj,k); | |
25810 | const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir); | |
25811 | nir = (T)(ir - tmpr); | |
25812 | nii = (T)(ii - tmpi); | |
25813 | ir += (T)tmpr; | |
25814 | ii += (T)tmpi; | |
25815 | } | |
25816 | const float nwr = wr*ca-wi*sa; | |
25817 | wi = wi*ca + wr*sa; | |
25818 | wr = nwr; | |
25819 | } | |
25820 | } | |
25821 | } | |
25822 | if (invert) (*this)/=N; | |
25823 | } break; | |
25824 | default: throw CImgArgumentException("CImgList<%s>::FFT() : unknown axe '%c', must be 'x','y' or 'z'"); | |
25825 | } | |
25826 | return *this; | |
25827 | } | |
25828 | CImgList<typename cimg::superset<T,float>::type> get_FFT(const bool invert=false) const { | |
25829 | typedef typename cimg::superset<T,float>::type restype; | |
25830 | return CImgList<restype>(*this).FFT(invert); | |
25831 | } | |
25832 | CImgList<T>& FFT(const bool invert=false) { | |
25833 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::FFT() : Instance list (%u,%p) is empty",pixel_type(),size,data); | |
25834 | if (size>2) cimg::warn("CImgList<%s>::FFT() : Instance list (%u,%p) have more than 2 images",pixel_type(),size,data); | |
25835 | if (size==1) insert(CImg<T>(data->width,data->height,data->depth,data->dim,0)); | |
25836 | CImg<T> &Ir = data[0], &Ii = data[1]; | |
25837 | if (Ii.width!=Ir.width || Ii.height!=Ir.height || Ii.depth!=Ir.depth || Ii.dim!=Ir.dim) | |
25838 | throw CImgInstanceException("CImgList<%s>::FFT() : Real (%u,%u,%u,%u,%p) and Imaginary (%u,%u,%u,%u,%p) parts " | |
25839 | "of the instance image have different dimensions", | |
25840 | pixel_type(),Ir.width,Ir.height,Ir.depth,Ir.dim,Ir.data, | |
25841 | Ii.width,Ii.height,Ii.depth,Ii.dim,Ii.data); | |
25842 | if (Ir.depth>1) FFT('z',invert); | |
25843 | if (Ir.height>1) FFT('y',invert); | |
25844 | if (Ir.width>1) FFT('x',invert); | |
25845 | return *this; | |
25846 | } | |
25847 | const CImgList<T>& print(const char* title=0, const int print_flag=1) const { | |
25848 | if (print_flag>=0) { | |
25849 | char tmp[1024]; | |
25850 | std::fprintf(stderr,"%-8s(this=%p) : { size=%u, data=%p }\n",title?title:"CImgList", | |
25851 | (void*)this,size,(void*)data); | |
25852 | switch (print_flag) { | |
25853 | case 1: { | |
25854 | for (unsigned int l=0; l<(*this).size; ++l) | |
25855 | if (l<4 || l>=size-4) { | |
25856 | std::sprintf(tmp,"%s[%d]",title?title:"CImgList",l); | |
25857 | data[l].print(tmp,print_flag); | |
25858 | } else { | |
25859 | if (l==4) std::fprintf(stderr,"...\n"); | |
25860 | } | |
25861 | } break; | |
25862 | default: { | |
25863 | for (unsigned int l=0; l<(*this).size; ++l) { | |
25864 | std::sprintf(tmp,"%s[%d]",title?title:"CImgList",l); | |
25865 | data[l].print(tmp,print_flag); | |
25866 | } | |
25867 | } break; | |
25868 | } | |
25869 | } | |
25870 | return *this; | |
25871 | } | |
25872 | const CImgList<T>& print(const int print_flag) const { | |
25873 | return print(0,print_flag); | |
25874 | } | |
25875 | static CImgList<T> get_load(const char *const filename) { | |
25876 | return CImgList<T>().load(filename); | |
25877 | } | |
25878 | CImgList<T>& load(const char *const filename) { | |
25879 | const char *ext = cimg::filename_split(filename); | |
25880 | if (!cimg::strncasecmp(ext,"tif",3) || !cimg::strncasecmp(ext,"tiff",4)) return load_tiff(filename); | |
25881 | if (!cimg::strncasecmp(ext,"cimg",4) || !ext[0]) return load_cimg(filename); | |
25882 | if (!cimg::strncasecmp(ext,"rec",3) || | |
25883 | !cimg::strncasecmp(ext,"par",3)) return load_parrec(filename); | |
25884 | if (!cimg::strncasecmp(ext,"avi",3) || | |
25885 | !cimg::strncasecmp(ext,"mov",3) || | |
25886 | !cimg::strncasecmp(ext,"mpg",3) || | |
25887 | !cimg::strncasecmp(ext,"mpeg",4)) return load_ffmpeg(filename); | |
25888 | assign(1); | |
25889 | data->load(filename); | |
25890 | return *this; | |
25891 | } | |
25892 | static CImgList<T> get_load_cimg(std::FILE *const file, const char *const filename=0) { | |
25893 | return CImgList<T>().load_cimg(file,filename); | |
25894 | } | |
25895 | CImgList<T>& load_cimg(std::FILE *const file, const char *const filename=0) { | |
25896 | typedef unsigned char uchar; | |
25897 | typedef unsigned short ushort; | |
25898 | typedef unsigned int uint; | |
25899 | typedef unsigned long ulong; | |
25900 | const int cimg_iobuffer = 12*1024*1024; | |
25901 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
25902 | bool loaded = false, endian = cimg::endian(); | |
25903 | char tmp[256], str_pixeltype[256], str_endian[256]; | |
25904 | unsigned int j, err, N=0, W, H, D, V; | |
25905 | int i; | |
25906 | j = 0; while((i=std::fgetc(nfile))!='\n' && i!=(-1) && j<256) tmp[j++] = (char)i; tmp[j] = '\0'; | |
25907 | err = std::sscanf(tmp,"%u%*c%255[A-Za-z_]%*c%255[sA-Za-z_ ]",&N,str_pixeltype,str_endian); | |
25908 | if (err<2) { | |
25909 | if (!file) cimg::fclose(nfile); | |
25910 | throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Unknow CImg RAW header.", | |
25911 | pixel_type(),filename?filename:"(FILE*)"); | |
25912 | } | |
25913 | if (!cimg::strncasecmp("little",str_endian,6)) endian = false; | |
25914 | else if (!cimg::strncasecmp("big",str_endian,3)) endian = true; | |
25915 | assign(N); | |
25916 | if (!loaded && !cimg::strcasecmp("bool",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<bool> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const bool *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25917 | if (!loaded && !cimg::strcasecmp("unsigned_char",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<uchar> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const uchar *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25918 | if (!loaded && !cimg::strcasecmp("uchar",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<uchar> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const uchar *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25919 | if (!loaded && !cimg::strcasecmp("char",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<char> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const char *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25920 | if (!loaded && !cimg::strcasecmp("unsigned_short",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<ushort> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const ushort *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25921 | if (!loaded && !cimg::strcasecmp("ushort",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<ushort> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const ushort *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25922 | if (!loaded && !cimg::strcasecmp("short",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<short> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const short *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25923 | if (!loaded && !cimg::strcasecmp("unsigned_int",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<uint> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const uint *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25924 | if (!loaded && !cimg::strcasecmp("uint",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<uint> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const uint *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25925 | if (!loaded && !cimg::strcasecmp("int",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<int> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const int *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25926 | if (!loaded && !cimg::strcasecmp("unsigned_long",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<ulong> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const ulong *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25927 | if (!loaded && !cimg::strcasecmp("ulong",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<ulong> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const ulong *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25928 | if (!loaded && !cimg::strcasecmp("long",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<long> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const long *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25929 | if (!loaded && !cimg::strcasecmp("float",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<float> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const float *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25930 | if (!loaded && !cimg::strcasecmp("double",str_pixeltype)) { for (unsigned int l=0; l<N; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++] = (char)i; tmp[j] = '\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { CImg<double> raw; CImg<T> &img = data[l]; img.assign(W,H,D,V); T *ptrd = img.data; for (int toread = (int)img.size(); toread>0; ) { raw.assign(cimg::min(toread,cimg_iobuffer)); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); toread-=raw.width; const double *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); } } } loaded = true; }; | |
25931 | if (!loaded) { | |
25932 | if (!file) cimg::fclose(nfile); | |
25933 | throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', cannot read images of pixels coded as '%s'.", | |
25934 | pixel_type(),filename?filename:"(FILE*)",str_pixeltype); | |
25935 | } | |
25936 | if (!file) cimg::fclose(nfile); | |
25937 | return *this; | |
25938 | } | |
25939 | static CImgList<T> get_load_cimg(const char *const filename) { | |
25940 | return CImgList<T>().load_cimg(0,filename); | |
25941 | } | |
25942 | CImgList<T>& load_cimg(const char *const filename) { | |
25943 | return load_cimg(0,filename); | |
25944 | } | |
25945 | static CImgList<T> get_load_cimg(std::FILE *const file, | |
25946 | const unsigned int n0, const unsigned int n1, | |
25947 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
25948 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1) { | |
25949 | return CImgList<T>().load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
25950 | } | |
25951 | CImgList<T>& load_cimg(std::FILE *const file, | |
25952 | const unsigned int n0, const unsigned int n1, | |
25953 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
25954 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1) { | |
25955 | return load_cimg(file,0,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
25956 | } | |
25957 | static CImgList<T> get_load_cimg(const char *const filename, | |
25958 | const unsigned int n0, const unsigned int n1, | |
25959 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
25960 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1) { | |
25961 | return CImgList<T>().load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
25962 | } | |
25963 | CImgList<T>& load_cimg(const char *const filename, | |
25964 | const unsigned int n0, const unsigned int n1, | |
25965 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
25966 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1) { | |
25967 | return load_cimg(0,filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
25968 | } | |
25969 | CImgList<T>& load_cimg(std::FILE *const file, const char *const filename, | |
25970 | const unsigned int n0, const unsigned int n1, | |
25971 | const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int v0, | |
25972 | const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1) { | |
25973 | typedef unsigned char uchar; | |
25974 | typedef unsigned short ushort; | |
25975 | typedef unsigned int uint; | |
25976 | typedef unsigned long ulong; | |
25977 | if (n1<n0 || x1<x0 || y1<y0 || z1<z0 || v1<v0) | |
25978 | throw CImgArgumentException("CImgList<%s>::load_cimg() : File '%s', Bad sub-region coordinates [%u->%u] " | |
25979 | "(%u,%u,%u,%u)->(%u,%u,%u,%u).",pixel_type(),filename?filename:"(FILE*)", | |
25980 | n0,n1,x0,y0,z0,v0,x1,y1,z1,v1); | |
25981 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
25982 | bool loaded = false, endian = cimg::endian(); | |
25983 | char tmp[256], str_pixeltype[256], str_endian[256]; | |
25984 | unsigned int j, err, N, W, H, D, V; | |
25985 | int i; | |
25986 | j = 0; while((i=std::fgetc(nfile))!='\n' && i!=(-1) && j<256) tmp[j++] = (char)i; tmp[j] = '\0'; | |
25987 | err = std::sscanf(tmp,"%u%*c%255[A-Za-z_]%*c%255[sA-Za-z_ ]",&N,str_pixeltype,str_endian); | |
25988 | if (err<2) { | |
25989 | if (!file) cimg::fclose(nfile); | |
25990 | throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Unknow CImg RAW header.", | |
25991 | pixel_type(),filename?filename:"(FILE*)"); | |
25992 | } | |
25993 | if (!cimg::strncasecmp("little",str_endian,6)) endian = false; | |
25994 | else if (!cimg::strncasecmp("big",str_endian,3)) endian = true; | |
25995 | const unsigned int nn1 = n1>=N?N-1:n1; | |
25996 | assign(1+nn1-n0); | |
25997 | if (!loaded && !cimg::strcasecmp("bool",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(bool),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<bool> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(bool); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(bool); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(bool); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(bool); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const bool *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(bool); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(bool); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(bool); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(bool); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
25998 | if (!loaded && !cimg::strcasecmp("unsigned_char",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uchar),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uchar> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(uchar); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uchar); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uchar); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uchar); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const uchar *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(uchar); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uchar); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uchar); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uchar); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
25999 | if (!loaded && !cimg::strcasecmp("uchar",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uchar),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uchar> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(uchar); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uchar); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uchar); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uchar); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const uchar *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(uchar); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uchar); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uchar); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uchar); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26000 | if (!loaded && !cimg::strcasecmp("char",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(char),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<char> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(char); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(char); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(char); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(char); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const char *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(char); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(char); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(char); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(char); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26001 | if (!loaded && !cimg::strcasecmp("unsigned_short",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ushort),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ushort> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(ushort); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ushort); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ushort); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ushort); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const ushort *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(ushort); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ushort); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ushort); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ushort); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26002 | if (!loaded && !cimg::strcasecmp("ushort",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ushort),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ushort> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(ushort); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ushort); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ushort); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ushort); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const ushort *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(ushort); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ushort); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ushort); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ushort); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26003 | if (!loaded && !cimg::strcasecmp("short",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(short),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<short> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(short); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(short); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(short); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(short); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const short *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(short); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(short); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(short); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(short); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26004 | if (!loaded && !cimg::strcasecmp("unsigned_int",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uint),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uint> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(uint); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uint); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uint); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uint); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const uint *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(uint); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uint); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uint); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uint); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26005 | if (!loaded && !cimg::strcasecmp("uint",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uint),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uint> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(uint); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uint); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uint); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uint); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const uint *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(uint); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uint); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uint); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uint); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26006 | if (!loaded && !cimg::strcasecmp("int",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(int),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<int> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(int); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(int); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(int); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(int); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const int *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(int); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(int); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(int); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(int); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26007 | if (!loaded && !cimg::strcasecmp("unsigned_long",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ulong),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ulong> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(ulong); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ulong); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ulong); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ulong); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const ulong *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(ulong); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ulong); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ulong); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ulong); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26008 | if (!loaded && !cimg::strcasecmp("ulong",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ulong),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ulong> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(ulong); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ulong); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ulong); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ulong); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const ulong *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(ulong); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ulong); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ulong); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ulong); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26009 | if (!loaded && !cimg::strcasecmp("long",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(long),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<long> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(long); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(long); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(long); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(long); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const long *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(long); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(long); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(long); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(long); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26010 | if (!loaded && !cimg::strcasecmp("float",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(float),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<float> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(float); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(float); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(float); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(float); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const float *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(float); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(float); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(float); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(float); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26011 | if (!loaded && !cimg::strcasecmp("double",str_pixeltype)) { for (unsigned int l=0; l<=nn1; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(double),1); else { const unsigned int nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<double> raw(1+nx1-x0); CImg<T> &img = data[l-n0]; img.assign(1+nx1-x0,1+ny1-y0,1+nz1-z0,1+nv1-v0); T *ptrd = img.data; const unsigned int skipvb = v0*W*H*D*sizeof(double); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(double); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(double); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(double); if (skipxb) std::fseek(nfile,skipxb,1); cimg::fread(raw.data,raw.width,nfile); if (endian!=cimg::endian()) cimg::endian_swap(raw.data,raw.width); const double *ptrs = raw.data; for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++); const unsigned int skipxe = (W-1-nx1)*sizeof(double); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(double); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(double); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(double); if (skipve) std::fseek(nfile,skipve,1); } } } loaded = true; }; | |
26012 | if (!loaded) { | |
26013 | if (!file) cimg::fclose(nfile); | |
26014 | throw CImgIOException("CImgList<%s>::load_cimg() : File '%s', cannot read images of pixels coded as '%s'.", | |
26015 | pixel_type(),filename?filename:"(FILE*)",str_pixeltype); | |
26016 | } | |
26017 | if (!file) cimg::fclose(nfile); | |
26018 | return *this; | |
26019 | } | |
26020 | static CImgList<T> get_load_parrec(const char *const filename) { | |
26021 | return CImgList<T>().load_parrec(filename); | |
26022 | } | |
26023 | CImgList<T>& load_parrec(const char *const filename) { | |
26024 | char body[1024], filenamepar[1024], filenamerec[1024]; | |
26025 | const char *ext = cimg::filename_split(filename,body); | |
26026 | if (!cimg::strncmp(ext,"par",3)) { std::strcpy(filenamepar,filename); std::sprintf(filenamerec,"%s.rec",body); } | |
26027 | if (!cimg::strncmp(ext,"PAR",3)) { std::strcpy(filenamepar,filename); std::sprintf(filenamerec,"%s.REC",body); } | |
26028 | if (!cimg::strncmp(ext,"rec",3)) { std::strcpy(filenamerec,filename); std::sprintf(filenamepar,"%s.par",body); } | |
26029 | if (!cimg::strncmp(ext,"REC",3)) { std::strcpy(filenamerec,filename); std::sprintf(filenamepar,"%s.PAR",body); } | |
26030 | std::FILE *file = cimg::fopen(filenamepar,"r"); | |
26031 | CImgList<float> st_slices; | |
26032 | CImgList<unsigned int> st_global; | |
26033 | int err; | |
26034 | char line[256] = { 0 }; | |
26035 | do { err=std::fscanf(file,"%255[^\n]%*c",line); } while (err!=(-1) && (line[0]=='#' || line[0]=='.')); | |
26036 | do { | |
26037 | unsigned int sn,sizex,sizey,pixsize; | |
26038 | float rs,ri,ss; | |
26039 | err=std::fscanf(file,"%u%*u%*u%*u%*u%*u%*u%u%*u%u%u%g%g%g%*[^\n]",&sn,&pixsize,&sizex,&sizey,&ri,&rs,&ss); | |
26040 | if (err==7) { | |
26041 | st_slices.insert(CImg<float>::vector((float)sn,(float)pixsize,(float)sizex,(float)sizey,ri,rs,ss,0)); | |
26042 | unsigned int i; for (i=0; i<st_global.size && sn<=st_global[i][2]; ++i); | |
26043 | if (i==st_global.size) st_global.insert(CImg<unsigned int>::vector(sizex,sizey,sn)); | |
26044 | else { | |
26045 | CImg<unsigned int> &vec = st_global[i]; | |
26046 | if (sizex>vec[0]) vec[0] = sizex; | |
26047 | if (sizey>vec[1]) vec[1] = sizey; | |
26048 | vec[2] = sn; | |
26049 | } | |
26050 | st_slices[st_slices.size-1][7] = (float)i; | |
26051 | } | |
26052 | } while (err==7); | |
26053 | std::FILE *file2 = cimg::fopen(filenamerec,"rb"); | |
26054 | { for (unsigned int l=0; l<(st_global).size; ++l) { | |
26055 | const CImg<unsigned int>& vec = st_global[l]; | |
26056 | insert(CImg<T>(vec[0],vec[1],vec[2])); | |
26057 | }} | |
26058 | for (unsigned int l=0; l<(st_slices).size; ++l) { | |
26059 | const CImg<float>& vec = st_slices[l]; | |
26060 | const unsigned int | |
26061 | sn = (unsigned int)vec[0]-1, | |
26062 | pixsize = (unsigned int)vec[1], | |
26063 | sizex = (unsigned int)vec[2], | |
26064 | sizey = (unsigned int)vec[3], | |
26065 | imn = (unsigned int)vec[7]; | |
26066 | const float ri = vec[4], rs = vec[5], ss = vec[6]; | |
26067 | switch (pixsize) { | |
26068 | case 8: { | |
26069 | CImg<unsigned char> buf(sizex,sizey); | |
26070 | cimg::fread(buf.data,sizex*sizey,file2); | |
26071 | if (cimg::endian()) cimg::endian_swap(buf.data,sizex*sizey); | |
26072 | CImg<T>& img = (*this)[imn]; | |
26073 | for (int y = 0; y<(int)((img).height); ++y) for (int x = 0; x<(int)((img).width); ++x) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss)); | |
26074 | } break; | |
26075 | case 16: { | |
26076 | CImg<unsigned short> buf(sizex,sizey); | |
26077 | cimg::fread(buf.data,sizex*sizey,file2); | |
26078 | if (cimg::endian()) cimg::endian_swap(buf.data,sizex*sizey); | |
26079 | CImg<T>& img = (*this)[imn]; | |
26080 | for (int y = 0; y<(int)((img).height); ++y) for (int x = 0; x<(int)((img).width); ++x) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss)); | |
26081 | } break; | |
26082 | case 32: { | |
26083 | CImg<unsigned int> buf(sizex,sizey); | |
26084 | cimg::fread(buf.data,sizex*sizey,file2); | |
26085 | if (cimg::endian()) cimg::endian_swap(buf.data,sizex*sizey); | |
26086 | CImg<T>& img = (*this)[imn]; | |
26087 | for (int y = 0; y<(int)((img).height); ++y) for (int x = 0; x<(int)((img).width); ++x) img(x,y,sn) = (T)(( buf(x,y)*rs + ri )/(rs*ss)); | |
26088 | } break; | |
26089 | default: | |
26090 | cimg::fclose(file); | |
26091 | cimg::fclose(file2); | |
26092 | throw CImgIOException("CImg<%s>::load_parrec() : File '%s', cannot handle image with pixsize = %d bits.", | |
26093 | pixel_type(),filename,pixsize); | |
26094 | break; | |
26095 | } | |
26096 | } | |
26097 | cimg::fclose(file); | |
26098 | cimg::fclose(file2); | |
26099 | if (!size) | |
26100 | throw CImgIOException("CImg<%s>::load_parrec() : File '%s' does not appear to be a valid PAR-REC file.", | |
26101 | pixel_type(),filename); | |
26102 | return *this; | |
26103 | } | |
26104 | static CImgList<T> get_load_yuv(std::FILE *const file, const char *const filename, | |
26105 | const unsigned int sizex, const unsigned int sizey=1, | |
26106 | const unsigned int first_frame=0, const int last_frame=-1, | |
26107 | const bool yuv2rgb=false) { | |
26108 | return CImgList<T>().load_yuv(file,filename,sizex,sizey,first_frame,last_frame,yuv2rgb); | |
26109 | } | |
26110 | CImgList<T>& load_yuv(std::FILE *const file, const char *const filename, | |
26111 | const unsigned int sizex, const unsigned int sizey=1, | |
26112 | const unsigned int first_frame=0, const int last_frame=-1, | |
26113 | const bool yuv2rgb=false) { | |
26114 | if (sizex%2 || sizey%2) | |
26115 | throw CImgArgumentException("CImgList<%s>::load_yuv() : File '%s', image dimensions along X and Y must be " | |
26116 | "even numbers (given are %ux%u)\n",pixel_type(),filename?filename:"(unknown)",sizex,sizey); | |
26117 | if (!sizex || !sizey) | |
26118 | throw CImgArgumentException("CImgList<%s>::load_yuv() : File '%s', given image sequence size (%u,%u) is invalid", | |
26119 | pixel_type(),filename?filename:"(unknown)",sizex,sizey); | |
26120 | if (last_frame>0 && first_frame>(unsigned int)last_frame) | |
26121 | throw CImgArgumentException("CImgList<%s>::load_yuv() : File '%s', given first frame %u is posterior to last frame %d.", | |
26122 | pixel_type(),filename?filename:"(unknown)",first_frame,last_frame); | |
26123 | if (!sizex || !sizey) | |
26124 | throw CImgArgumentException("CImgList<%s>::load_yuv() : File '%s', given frame size (%u,%u) is invalid.", | |
26125 | pixel_type(),filename?filename:"(unknown)",sizex,sizey); | |
26126 | CImg<unsigned char> tmp(sizex,sizey,1,3), UV(sizex/2,sizey/2,1,2); | |
26127 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb"); | |
26128 | bool stopflag = false; | |
26129 | int err; | |
26130 | if (first_frame) { | |
26131 | err = std::fseek(nfile,first_frame*(sizex*sizey + sizex*sizey/2),1); | |
26132 | if (err) { | |
26133 | if (!file) cimg::fclose(nfile); | |
26134 | throw CImgIOException("CImgList<%s>::load_yuv() : File '%s' doesn't contain frame number %u " | |
26135 | "(out of range error).",pixel_type(),filename?filename:"(FILE*)",first_frame); | |
26136 | } | |
26137 | } | |
26138 | unsigned int frame; | |
26139 | for (frame = first_frame; !stopflag && (last_frame<0 || frame<=(unsigned int)last_frame); ++frame) { | |
26140 | tmp.fill(0); | |
26141 | err = (int)std::fread((void*)(tmp.data),1,(size_t)(tmp.width*tmp.height),nfile); | |
26142 | if (err!=(int)(tmp.width*tmp.height)) { | |
26143 | stopflag = true; | |
26144 | if (err>0) cimg::warn("CImgList<%s>::load_yuv() : File '%s' contains incomplete data," | |
26145 | " or given image dimensions (%u,%u) are incorrect.", | |
26146 | pixel_type(),filename?filename:"(unknown)",sizex,sizey); | |
26147 | } else { | |
26148 | UV.fill(0); | |
26149 | err = (int)std::fread((void*)(UV.data),1,(size_t)(UV.size()),nfile); | |
26150 | if (err!=(int)(UV.size())) { | |
26151 | stopflag = true; | |
26152 | if (err>0) cimg::warn("CImgList<%s>::load_yuv() : File '%s' contains incomplete data," | |
26153 | " or given image dimensions (%u,%u) are incorrect.", | |
26154 | pixel_type(),filename?filename:"(unknown)",sizex,sizey); | |
26155 | } else { | |
26156 | for (int y = 0; y<(int)((UV).height); ++y) for (int x = 0; x<(int)((UV).width); ++x) { | |
26157 | const int x2=2*x, y2=2*y; | |
26158 | tmp(x2,y2,1) = tmp(x2+1,y2,1) = tmp(x2,y2+1,1) = tmp(x2+1,y2+1,1) = UV(x,y,0); | |
26159 | tmp(x2,y2,2) = tmp(x2+1,y2,2) = tmp(x2,y2+1,2) = tmp(x2+1,y2+1,2) = UV(x,y,1); | |
26160 | } | |
26161 | if (yuv2rgb) tmp.YCbCrtoRGB(); | |
26162 | insert(tmp); | |
26163 | } | |
26164 | } | |
26165 | } | |
26166 | if (stopflag && last_frame>=0 && frame!=(unsigned int)last_frame) | |
26167 | cimg::warn("CImgList<%s>::load_yuv() : File '%s', frame %d not reached since only %u frames were found in the file.", | |
26168 | pixel_type(),filename?filename:"(unknown)",last_frame,frame-1,filename); | |
26169 | if (!file) cimg::fclose(nfile); | |
26170 | return *this; | |
26171 | } | |
26172 | static CImgList<T> get_load_yuv(const char *const filename, | |
26173 | const unsigned int sizex, const unsigned int sizey=1, | |
26174 | const unsigned int first_frame=0, const int last_frame=-1, | |
26175 | const bool yuv2rgb=false) { | |
26176 | return CImgList<T>().load_yuv(0,filename,sizex,sizey,first_frame,last_frame,yuv2rgb); | |
26177 | } | |
26178 | CImgList<T>& load_yuv(const char *const filename, | |
26179 | const unsigned int sizex, const unsigned int sizey, | |
26180 | const unsigned int first_frame=0, const int last_frame=-1, | |
26181 | const bool yuv2rgb=false) { | |
26182 | return load_yuv(0,filename,sizex,sizey,first_frame,last_frame,yuv2rgb); | |
26183 | } | |
26184 | static CImgList<T> get_load_ffmpeg(const char *const filename) { | |
26185 | return CImgList<T>().load_ffmpeg(filename); | |
26186 | } | |
26187 | CImgList<T>& load_ffmpeg(const char *const filename) { | |
26188 | char command[1024], filetmp[512], filetmp2[512]; | |
26189 | std::FILE *file = 0; | |
26190 | do { | |
26191 | std::sprintf(filetmp,"%s%s%s",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
26192 | std::sprintf(filetmp2,"%s_000001.ppm",filetmp); | |
26193 | if ((file=std::fopen(filetmp2,"rb"))!=0) std::fclose(file); | |
26194 | } while (file); | |
26195 | std::sprintf(filetmp2,"%s_%%6d.ppm",filetmp); | |
26196 | std::sprintf(command,"ffmpeg -i \"%s\" %s >/dev/null 2>&1",filename,filetmp2); | |
26197 | cimg::system(command,0); | |
26198 | const unsigned int odebug = cimg::exception_mode(); | |
26199 | cimg::exception_mode() = 0; | |
26200 | assign(); | |
26201 | unsigned int i = 1; | |
26202 | for (bool stopflag = false; !stopflag; ++i) { | |
26203 | std::sprintf(filetmp2,"%s_%.6u.ppm",filetmp,i); | |
26204 | CImg<T> img; | |
26205 | try { img.load_pnm(filetmp2); } | |
26206 | catch (CImgException&) { stopflag = true; } | |
26207 | if (img) { insert(img); std::remove(filetmp2); } | |
26208 | } | |
26209 | cimg::exception_mode() = odebug; | |
26210 | if (is_empty()) | |
26211 | throw CImgIOException("CImgList<%s>::load_ffmpeg() : Failed to open image sequence '%s'.\n" | |
26212 | "Check the filename and if the 'ffmpeg' tool is installed on your system.", | |
26213 | pixel_type(),filename); | |
26214 | return *this; | |
26215 | } | |
26216 | template<typename tf, typename tc> | |
26217 | static CImgList<T> get_load_off(std::FILE *const file, const char *const filename, | |
26218 | CImgList<tf>& primitives, CImgList<tc>& colors, | |
26219 | const bool invert_faces=false) { | |
26220 | return CImgList<T>().load_off(file,filename,primitives,colors,invert_faces); | |
26221 | } | |
26222 | template<typename tf, typename tc> | |
26223 | CImgList<T>& load_off(std::FILE *const file, const char *const filename, | |
26224 | CImgList<tf>& primitives, CImgList<tc>& colors, | |
26225 | const bool invert_faces=false) { | |
26226 | return assign(CImg<T>::get_load_off(file,filename,primitives,colors,invert_faces).get_split('x')); | |
26227 | } | |
26228 | template<typename tf, typename tc> | |
26229 | static CImgList<T> get_load_off(const char *const filename, | |
26230 | CImgList<tf>& primitives, CImgList<tc>& colors, | |
26231 | const bool invert_faces=false) { | |
26232 | return CImgList<T>().load_off(0,filename,primitives,colors,invert_faces); | |
26233 | } | |
26234 | template<typename tf, typename tc> | |
26235 | CImgList<T>& load_off(const char *const filename, CImgList<tf>& primitives, CImgList<tc>& colors, | |
26236 | const bool invert_faces=false) { | |
26237 | return load_off(0,filename,primitives,colors,invert_faces); | |
26238 | } | |
26239 | CImgList<T> get_load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U) const { | |
26240 | return CImgList<T>().load_tiff(filename,first_frame,last_frame); | |
26241 | } | |
26242 | CImgList<T>& load_tiff(const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U) { | |
26243 | if (first_frame>last_frame) | |
26244 | throw CImgArgumentException("CImg<%s>::load_tiff() : File '%s', specified first frame = %u is higher than last frame = %u.", | |
26245 | pixel_type(),first_frame,last_frame); | |
26246 | if (first_frame || last_frame!=~0U) | |
26247 | throw CImgArgumentException("CImgList<%s>::load_tiff() : File '%s', reading sub-images from a tiff file requires the use of libtiff.\n" | |
26248 | "('cimg_use_tiff' must be defined).",pixel_type(),filename); | |
26249 | return assign(CImg<T>::get_load_tiff(filename)); | |
26250 | } | |
26251 | const CImgList<T>& save(const char *const filename, const int number=-1) const { | |
26252 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::save() : Instance list (%u,%p) is empty (file '%s').", | |
26253 | pixel_type(),size,data,filename); | |
26254 | if (!filename) throw CImgArgumentException("CImg<%s>::save() : Instance list (%u,%p), specified filename is (null).", | |
26255 | pixel_type(),size,data); | |
26256 | const char *ext = cimg::filename_split(filename); | |
26257 | char nfilename[1024]; | |
26258 | const char *const fn = (number>=0)?cimg::filename_number(filename,number,6,nfilename):filename; | |
26259 | if (!cimg::strncasecmp(ext,"cimg",4) || !ext[0]) return save_cimg(fn); | |
26260 | if (!cimg::strncasecmp(ext,"yuv",3)) return save_yuv(fn,true); | |
26261 | if (!cimg::strncasecmp(ext,"avi",3) || | |
26262 | !cimg::strncasecmp(ext,"mov",3) || | |
26263 | !cimg::strncasecmp(ext,"mpg",3) || | |
26264 | !cimg::strncasecmp(ext,"mpeg",4)) return save_ffmpeg(fn); | |
26265 | if (size==1) data[0].save(fn,-1); | |
26266 | else for (unsigned int l=0; l<(*this).size; ++l) data[l].save(fn,l); | |
26267 | return *this; | |
26268 | } | |
26269 | const CImgList<T>& save_yuv(std::FILE *const file, const char *const filename=0, const bool rgb2yuv=true) const { | |
26270 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::save_yuv() : Instance list (%u,%p) is empty (file '%s').", | |
26271 | pixel_type(),size,data,filename?filename:"(unknown)"); | |
26272 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_yuv() : Instance list (%u,%p), specified file is (null).", | |
26273 | pixel_type(),size,data); | |
26274 | if ((*this)[0].dimx()%2 || (*this)[0].dimy()%2) | |
26275 | throw CImgInstanceException("CImgList<%s>::save_yuv() : Image dimensions must be even numbers (current are %ux%u, file '%s').", | |
26276 | pixel_type(),(*this)[0].dimx(),(*this)[0].dimy(),filename?filename:"(unknown)"); | |
26277 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
26278 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26279 | CImg<unsigned char> YCbCr((*this)[l]); | |
26280 | if (rgb2yuv) YCbCr.RGBtoYCbCr(); | |
26281 | cimg::fwrite(YCbCr.data,YCbCr.width*YCbCr.height,nfile); | |
26282 | cimg::fwrite(YCbCr.get_resize(YCbCr.width/2, YCbCr.height/2,1,3,3).ptr(0,0,0,1), | |
26283 | YCbCr.width*YCbCr.height/2,nfile); | |
26284 | } | |
26285 | if (!file) cimg::fclose(nfile); | |
26286 | return *this; | |
26287 | } | |
26288 | const CImgList<T>& save_yuv(const char *const filename=0, const bool rgb2yuv=true) const { | |
26289 | return save_yuv(0,filename,rgb2yuv); | |
26290 | } | |
26291 | const CImgList<T>& save_ffmpeg(const char *const filename, const char *const codec="mpeg2video") const { | |
26292 | char command[1024], filetmp[512], filetmp2[512]; | |
26293 | std::FILE *file = 0; | |
26294 | for (unsigned int ll=0; ll<(*this).size; ++ll) if (!data[ll].is_sameXYZ(data[0])) | |
26295 | throw CImgInstanceException("CImgList<%s>::save_ffmpeg() : All images of the sequence must be of the same dimension (file '%s').", | |
26296 | pixel_type(),filename); | |
26297 | do { | |
26298 | std::sprintf(filetmp,"%s%s%s",cimg::temporary_path(),1==2?"\\":"/",cimg::filenamerand()); | |
26299 | std::sprintf(filetmp2,"%s_000001.ppm",filetmp); | |
26300 | if ((file=std::fopen(filetmp2,"rb"))!=0) std::fclose(file); | |
26301 | } while (file); | |
26302 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26303 | std::sprintf(filetmp2,"%s_%.6u.ppm",filetmp,l+1); | |
26304 | if (data[l].depth>1 || data[l].dim!=3) data[l].get_resize(-100,-100,1,3).save_pnm(filetmp2); | |
26305 | else data[l].save_pnm(filetmp2); | |
26306 | } | |
26307 | std::sprintf(command,"ffmpeg -i %s_%%6d.ppm -vcodec %s -sameq -y \"%s\" >/dev/null 2>&1",filetmp,codec,filename); | |
26308 | cimg::system(command); | |
26309 | file = std::fopen(filename,"rb"); | |
26310 | if (!file) throw CImgIOException("CImg<%s>::save_ffmpeg() : Failed to save image sequence '%s'.\n\n", | |
26311 | pixel_type(),filename); | |
26312 | else cimg::fclose(file); | |
26313 | for (unsigned int lll=0; lll<(*this).size; ++lll) { std::sprintf(filetmp2,"%s_%.6u.ppm",filetmp,lll+1); std::remove(filetmp2); } | |
26314 | return *this; | |
26315 | } | |
26316 | const CImgList<T>& save_cimg(std::FILE *const file, const char *const filename=0) const { | |
26317 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::save_cimg() : Instance list (%u,%p) is empty (file '%s').", | |
26318 | pixel_type(),size,data,filename?filename:"(unknown)"); | |
26319 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_cimg() : Instance list (%u,%p), specified file is (null).", | |
26320 | pixel_type(),size,data); | |
26321 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
26322 | const char *const ptype = pixel_type(), *const etype = cimg::endian()?"big":"little"; | |
26323 | if (!cimg::strncmp(ptype,"unsigned",8)) std::fprintf(nfile,"%u unsigned_%s %s_endian\n",size,ptype+9,etype); | |
26324 | else std::fprintf(nfile,"%u %s %s_endian\n",size,ptype,etype); | |
26325 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26326 | const CImg<T>& img = data[l]; | |
26327 | std::fprintf(nfile,"%u %u %u %u\n",img.width,img.height,img.depth,img.dim); | |
26328 | if (img.data) { | |
26329 | if (cimg::endian()) { | |
26330 | CImg<T> tmp(img); | |
26331 | cimg::endian_swap(tmp.data,tmp.size()); | |
26332 | cimg::fwrite(tmp.data,img.width*img.height*img.depth*img.dim,nfile); | |
26333 | } else cimg::fwrite(img.data,img.width*img.height*img.depth*img.dim,nfile); | |
26334 | } | |
26335 | } | |
26336 | if (!file) cimg::fclose(nfile); | |
26337 | return *this; | |
26338 | } | |
26339 | const CImgList<T>& save_cimg(const char *const filename) const { | |
26340 | return save_cimg(0,filename); | |
26341 | } | |
26342 | const CImgList<T>& save_cimg(std::FILE *const file, const char *const filename, | |
26343 | const unsigned int n0, | |
26344 | const unsigned int x0, const unsigned int y0, | |
26345 | const unsigned int z0, const unsigned int v0) const { | |
26346 | if (is_empty()) throw CImgInstanceException("CImgList<%s>::save_cimg() : Instance list (%u,%p) is empty (file '%s').", | |
26347 | pixel_type(),size,data,filename?filename:"(unknown)"); | |
26348 | if (!file && !filename) throw CImgArgumentException("CImg<%s>::save_cimg() : Instance list (%u,%p), specified file is (null).", | |
26349 | pixel_type(),size,data); | |
26350 | typedef unsigned char uchar; | |
26351 | typedef unsigned short ushort; | |
26352 | typedef unsigned int uint; | |
26353 | typedef unsigned long ulong; | |
26354 | std::FILE *const nfile = file?file:cimg::fopen(filename,"rb+"); | |
26355 | bool saved = false, endian = cimg::endian(); | |
26356 | char tmp[256], str_pixeltype[256], str_endian[256]; | |
26357 | unsigned int j, err, N, W, H, D, V; | |
26358 | int i; | |
26359 | j = 0; while((i=std::fgetc(nfile))!='\n' && i!=(-1) && j<256) tmp[j++] = (char)i; tmp[j] = '\0'; | |
26360 | err = std::sscanf(tmp,"%u%*c%255[A-Za-z_]%*c%255[sA-Za-z_ ]",&N,str_pixeltype,str_endian); | |
26361 | if (err<2) { | |
26362 | if (!file) cimg::fclose(nfile); | |
26363 | throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Unknow CImg RAW header.", | |
26364 | pixel_type(),filename?filename:"(FILE*)"); | |
26365 | } | |
26366 | if (!cimg::strncasecmp("little",str_endian,6)) endian = false; | |
26367 | else if (!cimg::strncasecmp("big",str_endian,3)) endian = true; | |
26368 | const unsigned int lmax = cimg::min(N,n0+size); | |
26369 | if (!saved && !cimg::strcasecmp("bool",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(bool),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<bool> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(bool); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(bool); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(bool); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(bool); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(bool); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(bool); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(bool); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(bool); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26370 | if (!saved && !cimg::strcasecmp("unsigned_char",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uchar),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uchar> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(uchar); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uchar); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uchar); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uchar); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(uchar); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uchar); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uchar); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uchar); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26371 | if (!saved && !cimg::strcasecmp("uchar",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uchar),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uchar> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(uchar); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uchar); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uchar); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uchar); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(uchar); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uchar); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uchar); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uchar); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26372 | if (!saved && !cimg::strcasecmp("char",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(char),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<char> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(char); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(char); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(char); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(char); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(char); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(char); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(char); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(char); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26373 | if (!saved && !cimg::strcasecmp("unsigned_short",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ushort),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ushort> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(ushort); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ushort); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ushort); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ushort); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(ushort); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ushort); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ushort); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ushort); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26374 | if (!saved && !cimg::strcasecmp("ushort",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ushort),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ushort> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(ushort); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ushort); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ushort); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ushort); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(ushort); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ushort); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ushort); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ushort); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26375 | if (!saved && !cimg::strcasecmp("short",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(short),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<short> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(short); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(short); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(short); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(short); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(short); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(short); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(short); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(short); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26376 | if (!saved && !cimg::strcasecmp("unsigned_int",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uint),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uint> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(uint); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uint); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uint); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uint); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(uint); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uint); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uint); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uint); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26377 | if (!saved && !cimg::strcasecmp("uint",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(uint),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<uint> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(uint); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(uint); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(uint); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(uint); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(uint); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(uint); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(uint); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(uint); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26378 | if (!saved && !cimg::strcasecmp("int",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(int),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<int> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(int); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(int); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(int); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(int); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(int); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(int); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(int); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(int); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26379 | if (!saved && !cimg::strcasecmp("unsigned_long",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ulong),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ulong> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(ulong); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ulong); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ulong); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ulong); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(ulong); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ulong); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ulong); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ulong); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26380 | if (!saved && !cimg::strcasecmp("ulong",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(ulong),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<ulong> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(ulong); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(ulong); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(ulong); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(ulong); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(ulong); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(ulong); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(ulong); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(ulong); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26381 | if (!saved && !cimg::strcasecmp("long",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(long),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<long> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(long); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(long); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(long); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(long); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(long); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(long); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(long); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(long); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26382 | if (!saved && !cimg::strcasecmp("float",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(float),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<float> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(float); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(float); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(float); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(float); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(float); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(float); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(float); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(float); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26383 | if (!saved && !cimg::strcasecmp("double",str_pixeltype)) { for (unsigned int l=0; l<lmax; ++l) { j = 0; while((i=std::fgetc(nfile))!='\n') tmp[j++]=(char)i; tmp[j]='\0'; W = H = D = V = 0; if (std::sscanf(tmp,"%u %u %u %u",&W,&H,&D,&V)!=4) throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', Image %u has an invalid size (%u,%u,%u,%u)\n", pixel_type(), filename?filename:("(FILE*)"), W, H, D, V); if (W*H*D*V>0) { if (l<n0 || x0>=W || y0>=H || z0>=D || v0>=D) std::fseek(nfile,W*H*D*V*sizeof(double),1); else { const CImg<T>& img = (*this)[l-n0]; const T *ptrs = img.data; const unsigned int x1 = x0 + img.width - 1, y1 = y0 + img.height - 1, z1 = z0 + img.depth - 1, v1 = v0 + img.dim - 1, nx1 = x1>=W?W-1:x1, ny1 = y1>=H?H-1:y1, nz1 = z1>=D?D-1:z1, nv1 = v1>=V?V-1:v1; CImg<double> raw(1+nx1-x0); const unsigned int skipvb = v0*W*H*D*sizeof(double); if (skipvb) std::fseek(nfile,skipvb,1); for (unsigned int v=1+nv1-v0; v; --v) { const unsigned int skipzb = z0*W*H*sizeof(double); if (skipzb) std::fseek(nfile,skipzb,1); for (unsigned int z=1+nz1-z0; z; --z) { const unsigned int skipyb = y0*W*sizeof(double); if (skipyb) std::fseek(nfile,skipyb,1); for (unsigned int y=1+ny1-y0; y; --y) { const unsigned int skipxb = x0*sizeof(double); if (skipxb) std::fseek(nfile,skipxb,1); raw.assign(ptrs, raw.width); ptrs+=img.width; if (endian) cimg::endian_swap(raw.data,raw.width); cimg::fwrite(raw.data,raw.width,nfile); const unsigned int skipxe = (W-1-nx1)*sizeof(double); if (skipxe) std::fseek(nfile,skipxe,1); } const unsigned int skipye = (H-1-ny1)*W*sizeof(double); if (skipye) std::fseek(nfile,skipye,1); } const unsigned int skipze = (D-1-nz1)*W*H*sizeof(double); if (skipze) std::fseek(nfile,skipze,1); } const unsigned int skipve = (V-1-nv1)*W*H*D*sizeof(double); if (skipve) std::fseek(nfile,skipve,1); } } } saved = true; }; | |
26384 | if (!saved) { | |
26385 | if (!file) cimg::fclose(nfile); | |
26386 | throw CImgIOException("CImgList<%s>::save_cimg() : File '%s', cannot save images of pixels coded as '%s'.", | |
26387 | pixel_type(),filename?filename:"(FILE*)",str_pixeltype); | |
26388 | } | |
26389 | if (!file) cimg::fclose(nfile); | |
26390 | return *this; | |
26391 | } | |
26392 | const CImgList<T>& save_cimg(std::FILE *const file, | |
26393 | const unsigned int n0, | |
26394 | const unsigned int x0, const unsigned int y0, | |
26395 | const unsigned int z0, const unsigned int v0) const { | |
26396 | return save_cimg(file,0,n0,x0,y0,z0,v0); | |
26397 | } | |
26398 | const CImgList<T>& save_cimg(const char *const filename, | |
26399 | const unsigned int n0, | |
26400 | const unsigned int x0, const unsigned int y0, | |
26401 | const unsigned int z0, const unsigned int v0) const { | |
26402 | return save_cimg(0,filename,n0,x0,y0,z0,v0); | |
26403 | } | |
26404 | static void save_empty_cimg(std::FILE *const file, const char *const filename, | |
26405 | const unsigned int nb, | |
26406 | const unsigned int dx, const unsigned int dy=1, | |
26407 | const unsigned int dz=1, const unsigned int dv=1) { | |
26408 | std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); | |
26409 | const unsigned int siz = dx*dy*dz*dv*sizeof(T); | |
26410 | std::fprintf(nfile,"%u %s\n",nb,pixel_type()); | |
26411 | for (unsigned int i=nb; i; --i) { | |
26412 | std::fprintf(nfile,"%u %u %u %u\n",dx,dy,dz,dv); | |
26413 | for (unsigned int off=siz; off; --off) std::fputc(0,nfile); | |
26414 | } | |
26415 | if (!file) cimg::fclose(nfile); | |
26416 | } | |
26417 | static void save_empty_cimg(std::FILE *const file, | |
26418 | const unsigned int nb, | |
26419 | const unsigned int dx, const unsigned int dy=1, | |
26420 | const unsigned int dz=1, const unsigned int dv=1) { | |
26421 | return save_empty_cimg(file,0,nb,dx,dy,dz,dv); | |
26422 | } | |
26423 | static void save_empty_cimg(const char *const filename, | |
26424 | const unsigned int nb, | |
26425 | const unsigned int dx, const unsigned int dy=1, | |
26426 | const unsigned int dz=1, const unsigned int dv=1) { | |
26427 | return save_empty_cimg(0,filename,nb,dx,dy,dz,dv); | |
26428 | } | |
26429 | template<typename tf, typename tc> | |
26430 | const CImgList<T>& save_off(std::FILE *const file, const char *const filename, | |
26431 | const CImgList<tf>& primitives, const CImgList<tc>& colors, const bool invert_faces=false) const { | |
26432 | get_append('x','y').save_off(file,filename,primitives,colors,invert_faces); | |
26433 | return *this; | |
26434 | } | |
26435 | template<typename tf, typename tc> | |
26436 | const CImgList<T>& save_off(const char *const filename, | |
26437 | const CImgList<tf>& primitives, const CImgList<tc>& colors, const bool invert_faces=false) const { | |
26438 | return save_off(0,filename,primitives,colors,invert_faces); | |
26439 | } | |
26440 | CImgList<T> get_split(const char axe='x') const { | |
26441 | CImgList<T> res; | |
26442 | for (unsigned int l=0; l<(*this).size; ++l) res.insert(data[l].get_split(axe)); | |
26443 | return res; | |
26444 | } | |
26445 | CImgList<T>& split(const char axe='x') { | |
26446 | return get_split(axe).transfer_to(*this); | |
26447 | } | |
26448 | CImg<T> get_append(const char axe='x', const char align='c') const { | |
26449 | if (is_empty()) return CImg<T>(); | |
26450 | if (size==1) return +((*this)[0]); | |
26451 | unsigned int dx = 0, dy = 0, dz = 0, dv = 0, pos = 0; | |
26452 | CImg<T> res; | |
26453 | switch(cimg::uncase(axe)) { | |
26454 | case 'x': { | |
26455 | switch (cimg::uncase(align)) { | |
26456 | case 'x': { dy = dz = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dx+=(*this)[l].size(); } break; | |
26457 | case 'y': { dx = size; dz = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dy = cimg::max(dy,(unsigned int)(*this)[l].size()); } break; | |
26458 | case 'z': { dx = size; dy = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dz = cimg::max(dz,(unsigned int)(*this)[l].size()); } break; | |
26459 | case 'v': { dx = size; dy = dz = 1; for (unsigned int l=0; l<(*this).size; ++l) dv = cimg::max(dz,(unsigned int)(*this)[l].size()); } break; | |
26460 | default: | |
26461 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26462 | const CImg<T>& img = (*this)[l]; | |
26463 | dx += img.width; | |
26464 | dy = cimg::max(dy,img.height); | |
26465 | dz = cimg::max(dz,img.depth); | |
26466 | dv = cimg::max(dv,img.dim); | |
26467 | } | |
26468 | } | |
26469 | res.assign(dx,dy,dz,dv,0); | |
26470 | switch (cimg::uncase(align)) { | |
26471 | case 'x': { | |
26472 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image(CImg<T>((*this)[l],true).unroll('x'),pos,0,0,0); pos+=(*this)[l].size(); } | |
26473 | } break; | |
26474 | case 'y': { | |
26475 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('y'),pos++,0,0,0); | |
26476 | } break; | |
26477 | case 'z': { | |
26478 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('z'),pos++,0,0,0); | |
26479 | } break; | |
26480 | case 'v': { | |
26481 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('v'),pos++,0,0,0); | |
26482 | } break; | |
26483 | case 'p': { | |
26484 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],pos,0,0,0); pos+=(*this)[l].width; } | |
26485 | } break; | |
26486 | case 'n': { | |
26487 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],pos,dy-(*this)[l].height,dz-(*this)[l].depth,dv-(*this)[l].dim); pos+=(*this)[l].width; } | |
26488 | } break; | |
26489 | default : { | |
26490 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],pos,(dy-(*this)[l].height)/2,(dz-(*this)[l].depth)/2,(dv-(*this)[l].dim)/2); pos+=(*this)[l].width; } | |
26491 | } break; | |
26492 | } | |
26493 | } break; | |
26494 | case 'y': { | |
26495 | switch (cimg::uncase(align)) { | |
26496 | case 'x': { dy = size; dz = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dx = cimg::max(dx,(unsigned int)(*this)[l].size()); } break; | |
26497 | case 'y': { dx = dz = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dy+=(*this)[l].size(); } break; | |
26498 | case 'z': { dy = size; dx = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dz = cimg::max(dz,(unsigned int)(*this)[l].size()); } break; | |
26499 | case 'v': { dy = size; dx = dz = 1; for (unsigned int l=0; l<(*this).size; ++l) dv = cimg::max(dv,(unsigned int)(*this)[l].size()); } break; | |
26500 | default: | |
26501 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26502 | const CImg<T>& img = (*this)[l]; | |
26503 | dx = cimg::max(dx,img.width); | |
26504 | dy += img.height; | |
26505 | dz = cimg::max(dz,img.depth); | |
26506 | dv = cimg::max(dv,img.dim); | |
26507 | } | |
26508 | } | |
26509 | res.assign(dx,dy,dz,dv,0); | |
26510 | switch (cimg::uncase(align)) { | |
26511 | case 'x': { | |
26512 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('x'),0,pos++,0,0); | |
26513 | } break; | |
26514 | case 'y': { | |
26515 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image(CImg<T>((*this)[l],true).unroll('y'),0,pos,0,0); pos+=(*this)[l].size(); } | |
26516 | } break; | |
26517 | case 'z': { | |
26518 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('z'),0,pos++,0,0); | |
26519 | } break; | |
26520 | case 'v': { | |
26521 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('v'),0,pos++,0,0); | |
26522 | } break; | |
26523 | case 'p': { | |
26524 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],0,pos,0,0); pos+=(*this)[l].height; } | |
26525 | } break; | |
26526 | case 'n': { | |
26527 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],dx-(*this)[l].width,pos,dz-(*this)[l].depth,dv-(*this)[l].dim); pos+=(*this)[l].height; } | |
26528 | } break; | |
26529 | default : { | |
26530 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],(dx-(*this)[l].width)/2,pos,(dz-(*this)[l].depth)/2,(dv-(*this)[l].dim)/2); | |
26531 | pos+=(*this)[l].height; } | |
26532 | } break; | |
26533 | } | |
26534 | } break; | |
26535 | case 'z': { | |
26536 | switch (cimg::uncase(align)) { | |
26537 | case 'x': { dz = size; dy = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dx = cimg::max(dx,(unsigned int)(*this)[l].size()); } break; | |
26538 | case 'y': { dz = size; dx = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dy = cimg::max(dz,(unsigned int)(*this)[l].size()); } break; | |
26539 | case 'z': { dx = dy = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dz+=(*this)[l].size(); } break; | |
26540 | case 'v': { dz = size; dx = dz = 1; for (unsigned int l=0; l<(*this).size; ++l) dv = cimg::max(dv,(unsigned int)(*this)[l].size()); } break; | |
26541 | default : | |
26542 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26543 | const CImg<T>& img = (*this)[l]; | |
26544 | dx = cimg::max(dx,img.width); | |
26545 | dy = cimg::max(dy,img.height); | |
26546 | dz += img.depth; | |
26547 | dv = cimg::max(dv,img.dim); | |
26548 | } | |
26549 | } | |
26550 | res.assign(dx,dy,dz,dv,0); | |
26551 | switch (cimg::uncase(align)) { | |
26552 | case 'x': { | |
26553 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('x'),0,0,pos++,0); | |
26554 | } break; | |
26555 | case 'y': { | |
26556 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('y'),0,0,pos++,0); | |
26557 | } break; | |
26558 | case 'z': { | |
26559 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image(CImg<T>((*this)[l],true).unroll('z'),0,0,pos,0); pos+=(*this)[l].size(); } | |
26560 | } break; | |
26561 | case 'v': { | |
26562 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('v'),0,0,pos++,0); | |
26563 | } break; | |
26564 | case 'p': { | |
26565 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],0,0,pos,0); pos+=(*this)[l].depth; } | |
26566 | } break; | |
26567 | case 'n': { | |
26568 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],dx-(*this)[l].width,dy-(*this)[l].height,pos,dv-(*this)[l].dim); pos+=(*this)[l].depth; } | |
26569 | } break; | |
26570 | case 'c': { | |
26571 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],(dx-(*this)[l].width)/2,(dy-(*this)[l].height)/2,pos,(dv-(*this)[l].dim)/2); | |
26572 | pos+=(*this)[l].depth; } | |
26573 | } break; | |
26574 | } | |
26575 | } break; | |
26576 | case 'v': { | |
26577 | switch (cimg::uncase(align)) { | |
26578 | case 'x': { dv = size; dy = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dx = cimg::max(dx,(unsigned int)(*this)[l].size()); } break; | |
26579 | case 'y': { dv = size; dx = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dy = cimg::max(dz,(unsigned int)(*this)[l].size()); } break; | |
26580 | case 'z': { dv = size; dx = dv = 1; for (unsigned int l=0; l<(*this).size; ++l) dz = cimg::max(dv,(unsigned int)(*this)[l].size()); } break; | |
26581 | case 'v': { dx = dy = dz = 1; for (unsigned int l=0; l<(*this).size; ++l) dv+=(*this)[l].size(); } break; | |
26582 | default : | |
26583 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26584 | const CImg<T>& img = (*this)[l]; | |
26585 | dx = cimg::max(dx,img.width); | |
26586 | dy = cimg::max(dy,img.height); | |
26587 | dz = cimg::max(dz,img.depth); | |
26588 | dv += img.dim; | |
26589 | } | |
26590 | } | |
26591 | res.assign(dx,dy,dz,dv,0); | |
26592 | switch (cimg::uncase(align)) { | |
26593 | case 'x': { | |
26594 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('x'),0,0,0,pos++); | |
26595 | } break; | |
26596 | case 'y': { | |
26597 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('y'),0,0,0,pos++); | |
26598 | } break; | |
26599 | case 'z': { | |
26600 | for (unsigned int l=0; l<(*this).size; ++l) res.draw_image(CImg<T>((*this)[l],true).unroll('v'),0,0,0,pos++); | |
26601 | } break; | |
26602 | case 'v': { | |
26603 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image(CImg<T>((*this)[l],true).unroll('z'),0,0,0,pos); pos+=(*this)[l].size(); } | |
26604 | } break; | |
26605 | case 'p': { | |
26606 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],0,0,0,pos); pos+=(*this)[l].dim; } | |
26607 | } break; | |
26608 | case 'n': { | |
26609 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],dx-(*this)[l].width,dy-(*this)[l].height,dz-(*this)[l].depth,pos); pos+=(*this)[l].dim; } | |
26610 | } break; | |
26611 | case 'c': { | |
26612 | for (unsigned int l=0; l<(*this).size; ++l) { res.draw_image((*this)[l],(dx-(*this)[l].width)/2,(dy-(*this)[l].height)/2,(dz-(*this)[l].depth)/2,pos); | |
26613 | pos+=(*this)[l].dim; } | |
26614 | } break; | |
26615 | } | |
26616 | } break; | |
26617 | default: throw CImgArgumentException("CImgList<%s>::get_append() : unknow axe '%c', must be 'x','y','z' or 'v'",pixel_type(),axe); | |
26618 | } | |
26619 | return res; | |
26620 | } | |
26621 | CImgList<T> get_crop_font() const { | |
26622 | CImgList<T> res; | |
26623 | for (unsigned int l=0; l<(*this).size; ++l) { | |
26624 | const CImg<T>& letter = (*this)[l]; | |
26625 | int xmin = letter.width, xmax = 0; | |
26626 | for (int y = 0; y<(int)((letter).height); ++y) for (int x = 0; x<(int)((letter).width); ++x) if (letter(x,y)) { if (x<xmin) xmin=x; if (x>xmax) xmax=x; } | |
26627 | if (xmin>xmax) res.insert(CImg<T>(letter.width,letter.height,1,letter.dim,0)); | |
26628 | else res.insert(letter.get_crop(xmin,0,xmax,letter.height-1)); | |
26629 | } | |
26630 | res[' '].resize(res['f'].width); | |
26631 | res[' '+256].resize(res['f'].width); | |
26632 | return res; | |
26633 | } | |
26634 | CImgList<T>& crop_font() { | |
26635 | return get_crop_font().transfer_to(*this); | |
26636 | } | |
26637 | static CImgList<T> get_font(const unsigned int *const font, const unsigned int w, const unsigned int h, | |
26638 | const unsigned int paddingx, const unsigned int paddingy, const bool variable_size=true) { | |
26639 | CImgList<T> res = CImgList<T>(256,w,h,1,3).insert(CImgList<T>(256,w,h,1,1)); | |
26640 | const unsigned int *ptr = font; | |
26641 | unsigned int m = 0, val = 0; | |
26642 | for (unsigned int y=0; y<h; ++y) | |
26643 | for (unsigned int x=0; x<256*w; ++x) { | |
26644 | m>>=1; if (!m) { m = 0x80000000; val = *(ptr++); } | |
26645 | CImg<T>& img = res[x/w], &mask = res[x/w+256]; | |
26646 | unsigned int xm = x%w; | |
26647 | img(xm,y,0) = img(xm,y,1) = img(xm,y,2) = mask(xm,y,0) = (T)((val&m)?1:0); | |
26648 | } | |
26649 | if (variable_size) res.crop_font(); | |
26650 | if (paddingx || paddingy) for (unsigned int l=0; l<(res).size; ++l) res[l].resize(res[l].dimx()+paddingx, res[l].dimy()+paddingy,1,-100,0); | |
26651 | return res; | |
26652 | } | |
26653 | CImgList<T>& font(const unsigned int *const font, const unsigned int w, const unsigned int h, | |
26654 | const unsigned int paddingx, const unsigned int paddingy, const bool variable_size=true) { | |
26655 | return get_font(font,w,h,paddingx,paddingy,variable_size).transfer_to(*this); | |
26656 | } | |
26657 | static CImgList<T> get_font(const unsigned int font_width, const bool variable_size=true) { | |
26658 | if (font_width<=11) { | |
26659 | static CImgList<T> font7x11, nfont7x11; | |
26660 | if (!variable_size && !font7x11) font7x11 = get_font(cimg::font7x11,7,11,1,0,false); | |
26661 | if (variable_size && !nfont7x11) nfont7x11 = get_font(cimg::font7x11,7,11,1,0,true); | |
26662 | return variable_size?nfont7x11:font7x11; | |
26663 | } | |
26664 | if (font_width<=13) { | |
26665 | static CImgList<T> font10x13, nfont10x13; | |
26666 | if (!variable_size && !font10x13) font10x13 = get_font(cimg::font10x13,10,13,1,0,false); | |
26667 | if (variable_size && !nfont10x13) nfont10x13 = get_font(cimg::font10x13,10,13,1,0,true); | |
26668 | return variable_size?nfont10x13:font10x13; | |
26669 | } | |
26670 | if (font_width<=17) { | |
26671 | static CImgList<T> font8x17, nfont8x17; | |
26672 | if (!variable_size && !font8x17) font8x17 = get_font(cimg::font8x17,8,17,1,0,false); | |
26673 | if (variable_size && !nfont8x17) nfont8x17 = get_font(cimg::font8x17,8,17,1,0,true); | |
26674 | return variable_size?nfont8x17:font8x17; | |
26675 | } | |
26676 | if (font_width<=19) { | |
26677 | static CImgList<T> font10x19, nfont10x19; | |
26678 | if (!variable_size && !font10x19) font10x19 = get_font(cimg::font10x19,10,19,2,0,false); | |
26679 | if (variable_size && !nfont10x19) nfont10x19 = get_font(cimg::font10x19,10,19,2,0,true); | |
26680 | return variable_size?nfont10x19:font10x19; | |
26681 | } | |
26682 | if (font_width<=24) { | |
26683 | static CImgList<T> font12x24, nfont12x24; | |
26684 | if (!variable_size && !font12x24) font12x24 = get_font(cimg::font12x24,12,24,2,0,false); | |
26685 | if (variable_size && !nfont12x24) nfont12x24 = get_font(cimg::font12x24,12,24,2,0,true); | |
26686 | return variable_size?nfont12x24:font12x24; | |
26687 | } | |
26688 | if (font_width<=32) { | |
26689 | static CImgList<T> font16x32, nfont16x32; | |
26690 | if (!variable_size && !font16x32) font16x32 = get_font(cimg::font16x32,16,32,2,0,false); | |
26691 | if (variable_size && !nfont16x32) nfont16x32 = get_font(cimg::font16x32,16,32,2,0,true); | |
26692 | return variable_size?nfont16x32:font16x32; | |
26693 | } | |
26694 | if (font_width<=38) { | |
26695 | static CImgList<T> font19x38, nfont19x38; | |
26696 | if (!variable_size && !font19x38) font19x38 = get_font(cimg::font19x38,19,38,3,0,false); | |
26697 | if (variable_size && !nfont19x38) nfont19x38 = get_font(cimg::font19x38,19,38,3,0,true); | |
26698 | return variable_size?nfont19x38:font19x38; | |
26699 | } | |
26700 | static CImgList<T> font29x57, nfont29x57; | |
26701 | if (!variable_size && !font29x57) font29x57 = get_font(cimg::font29x57,29,57,5,0,false); | |
26702 | if (variable_size && !nfont29x57) nfont29x57 = get_font(cimg::font29x57,29,57,5,0,true); | |
26703 | return variable_size?nfont29x57:font29x57; | |
26704 | } | |
26705 | CImgList<T>& font(const unsigned int font_width, const bool variable_size=true) { | |
26706 | return get_font(font_width,variable_size).transfer_to(*this); | |
26707 | } | |
26708 | const CImgList<T>& display(CImgDisplay& disp, const char axe='x', const char align='c') const { | |
26709 | get_append(axe,align).display(disp); | |
26710 | return *this; | |
26711 | } | |
26712 | const CImgList<T>& display(const char* title, const char axe='x', const char align='c', | |
26713 | const int min_size=128, const int max_size=1024, const int print_flag=1) const { | |
26714 | if (is_empty()) | |
26715 | throw CImgInstanceException("CImgList<%s>::display() : Instance list (%u,%u) is empty.", | |
26716 | pixel_type(),size,data); | |
26717 | const CImg<T> visu = get_append(axe,align); | |
26718 | CImgDisplay disp; | |
26719 | unsigned int w = visu.width+(visu.depth>1?visu.depth:0), h = visu.height+(visu.depth>1?visu.depth:0), XYZ[3]; | |
26720 | print(title,print_flag); | |
26721 | const unsigned int dmin = cimg::min(w,h), minsiz = min_size>=0?min_size:(-min_size)*dmin/100; | |
26722 | if (dmin<minsiz) { w=w*minsiz/dmin; w+=(w==0); h=h*minsiz/dmin; h+=(h==0); } | |
26723 | const unsigned int dmax = cimg::max(w,h), maxsiz = max_size>=0?max_size:(-max_size)*dmax/100; | |
26724 | if (dmax>maxsiz) { w=w*maxsiz/dmax; w+=(w==0); h=h*maxsiz/dmax; h+=(h==0); } | |
26725 | disp.assign(w,h,title,1,3); | |
26726 | XYZ[0] = visu.width/2; XYZ[1] = visu.height/2; XYZ[2] = visu.depth/2; | |
26727 | while (!disp.is_closed && !disp.key) visu.get_coordinates(1,disp,XYZ); | |
26728 | return *this; | |
26729 | } | |
26730 | const CImgList<T>& display(const char axe='x', const char align='c', | |
26731 | const int min_size=128, const int max_size=1024, const int print_flag=1) const { | |
26732 | char title[256] = { 0 }; | |
26733 | std::sprintf(title,"CImgList<%s>",pixel_type()); | |
26734 | return display(title,axe,align,min_size,max_size,print_flag); | |
26735 | } | |
26736 | }; | |
26737 | namespace cimg { | |
26738 | template<typename t> | |
26739 | inline int dialog(const char *title, const char *msg, | |
26740 | const char *button1_txt, const char *button2_txt, | |
26741 | const char *button3_txt, const char *button4_txt, | |
26742 | const char *button5_txt, const char *button6_txt, | |
26743 | const CImg<t>& logo, const bool centering = false) { | |
26744 | const unsigned char | |
26745 | black[] = { 0,0,0 }, white[] = { 255,255,255 }, gray[] = { 200,200,200 }, gray2[] = { 150,150,150 }; | |
26746 | CImgList<unsigned char> buttons, cbuttons, sbuttons; | |
26747 | if (button1_txt) { buttons.insert(CImg<unsigned char>().draw_text(button1_txt,0,0,black,gray,13)); | |
26748 | if (button2_txt) { buttons.insert(CImg<unsigned char>().draw_text(button2_txt,0,0,black,gray,13)); | |
26749 | if (button3_txt) { buttons.insert(CImg<unsigned char>().draw_text(button3_txt,0,0,black,gray,13)); | |
26750 | if (button4_txt) { buttons.insert(CImg<unsigned char>().draw_text(button4_txt,0,0,black,gray,13)); | |
26751 | if (button5_txt) { buttons.insert(CImg<unsigned char>().draw_text(button5_txt,0,0,black,gray,13)); | |
26752 | if (button6_txt) { buttons.insert(CImg<unsigned char>().draw_text(button6_txt,0,0,black,gray,13)); | |
26753 | }}}}}} | |
26754 | if (!buttons.size) throw CImgArgumentException("cimg::dialog() : No buttons have been defined. At least one is necessary"); | |
26755 | unsigned int bw = 0, bh = 0; | |
26756 | for (unsigned int l=0; l<(buttons).size; ++l) { bw = cimg::max(bw,buttons[l].width); bh = cimg::max(bh,buttons[l].height); } | |
26757 | bw+=8; bh+=8; | |
26758 | if (bw<64) bw=64; | |
26759 | if (bw>128) bw=128; | |
26760 | if (bh<24) bh=24; | |
26761 | if (bh>48) bh=48; | |
26762 | CImg<unsigned char> button(bw,bh,1,3); | |
26763 | button.draw_rectangle(0,0,bw-1,bh-1,gray); | |
26764 | button.draw_line(0,0,bw-1,0,white).draw_line(0,bh-1,0,0,white); | |
26765 | button.draw_line(bw-1,0,bw-1,bh-1,black).draw_line(bw-1,bh-1,0,bh-1,black); | |
26766 | button.draw_line(1,bh-2,bw-2,bh-2,gray2).draw_line(bw-2,bh-2,bw-2,1,gray2); | |
26767 | CImg<unsigned char> sbutton(bw,bh,1,3); | |
26768 | sbutton.draw_rectangle(0,0,bw-1,bh-1,gray); | |
26769 | sbutton.draw_line(0,0,bw-1,0,black).draw_line(bw-1,0,bw-1,bh-1,black); | |
26770 | sbutton.draw_line(bw-1,bh-1,0,bh-1,black).draw_line(0,bh-1,0,0,black); | |
26771 | sbutton.draw_line(1,1,bw-2,1,white).draw_line(1,bh-2,1,1,white); | |
26772 | sbutton.draw_line(bw-2,1,bw-2,bh-2,black).draw_line(bw-2,bh-2,1,bh-2,black); | |
26773 | sbutton.draw_line(2,bh-3,bw-3,bh-3,gray2).draw_line(bw-3,bh-3,bw-3,2,gray2); | |
26774 | sbutton.draw_line(4,4,bw-5,4,black,1.0f,0xAAAAAAAA,true).draw_line(bw-5,4,bw-5,bh-5,black,1.0f,0xAAAAAAAA,false); | |
26775 | sbutton.draw_line(bw-5,bh-5,4,bh-5,black,1.0f,0xAAAAAAAA,false).draw_line(4,bh-5,4,4,black,1.0f,0xAAAAAAAA,false); | |
26776 | CImg<unsigned char> cbutton(bw,bh,1,3); | |
26777 | cbutton.draw_rectangle(0,0,bw-1,bh-1,black).draw_rectangle(1,1,bw-2,bh-2,gray2).draw_rectangle(2,2,bw-3,bh-3,gray); | |
26778 | cbutton.draw_line(4,4,bw-5,4,black,1.0f,0xAAAAAAAA,true).draw_line(bw-5,4,bw-5,bh-5,black,1.0f,0xAAAAAAAA,false); | |
26779 | cbutton.draw_line(bw-5,bh-5,4,bh-5,black,1.0f,0xAAAAAAAA,false).draw_line(4,bh-5,4,4,black,1.0f,0xAAAAAAAA,false); | |
26780 | for (unsigned int ll=0; ll<(buttons).size; ++ll) { | |
26781 | cbuttons.insert(CImg<unsigned char>(cbutton).draw_image(buttons[ll],1+(bw-buttons[ll].dimx())/2,1+(bh-buttons[ll].dimy())/2)); | |
26782 | sbuttons.insert(CImg<unsigned char>(sbutton).draw_image(buttons[ll],(bw-buttons[ll].dimx())/2,(bh-buttons[ll].dimy())/2)); | |
26783 | buttons[ll] = CImg<unsigned char>(button).draw_image(buttons[ll],(bw-buttons[ll].dimx())/2,(bh-buttons[ll].dimy())/2); | |
26784 | } | |
26785 | CImg<unsigned char> canvas; | |
26786 | if (msg) canvas = CImg<unsigned char>().draw_text(msg,0,0,black,gray,13); | |
26787 | const unsigned int | |
26788 | bwall = (buttons.size-1)*(12+bw) + bw, | |
26789 | w = cimg::max(196U,36+logo.width+canvas.width, 24+bwall), | |
26790 | h = cimg::max(96U,36+canvas.height+bh,36+logo.height+bh), | |
26791 | lx = 12 + (canvas.data?0:((w-24-logo.width)/2)), | |
26792 | ly = (h-12-bh-logo.height)/2, | |
26793 | tx = lx+logo.width+12, | |
26794 | ty = (h-12-bh-canvas.height)/2, | |
26795 | bx = (w-bwall)/2, | |
26796 | by = h-12-bh; | |
26797 | if (canvas.data) | |
26798 | canvas = CImg<unsigned char>(w,h,1,3). | |
26799 | draw_rectangle(0,0,w-1,h-1,gray). | |
26800 | draw_line(0,0,w-1,0,white).draw_line(0,h-1,0,0,white). | |
26801 | draw_line(w-1,0,w-1,h-1,black).draw_line(w-1,h-1,0,h-1,black). | |
26802 | draw_image(canvas,tx,ty); | |
26803 | else | |
26804 | canvas = CImg<unsigned char>(w,h,1,3). | |
26805 | draw_rectangle(0,0,w-1,h-1,gray). | |
26806 | draw_line(0,0,w-1,0,white).draw_line(0,h-1,0,0,white). | |
26807 | draw_line(w-1,0,w-1,h-1,black).draw_line(w-1,h-1,0,h-1,black); | |
26808 | if (logo.data) canvas.draw_image(logo,lx,ly); | |
26809 | unsigned int xbuttons[6]; | |
26810 | for (unsigned int lll=0; lll<(buttons).size; ++lll) { xbuttons[lll] = bx+(bw+12)*lll; canvas.draw_image(buttons[lll],xbuttons[lll],by); } | |
26811 | CImgDisplay disp(canvas,title?title:" ",0,3,false,centering?true:false); | |
26812 | if (centering) disp.move((CImgDisplay::screen_dimx()-disp.dimx())/2, | |
26813 | (CImgDisplay::screen_dimy()-disp.dimy())/2); | |
26814 | bool stopflag = false, refresh = false; | |
26815 | int oselected = -1, oclicked = -1, selected = -1, clicked = -1; | |
26816 | while (!disp.is_closed && !stopflag) { | |
26817 | if (refresh) { | |
26818 | if (clicked>=0) CImg<unsigned char>(canvas).draw_image(cbuttons[clicked],xbuttons[clicked],by).display(disp); | |
26819 | else { | |
26820 | if (selected>=0) CImg<unsigned char>(canvas).draw_image(sbuttons[selected],xbuttons[selected],by).display(disp); | |
26821 | else canvas.display(disp); | |
26822 | } | |
26823 | refresh = false; | |
26824 | } | |
26825 | disp.wait(15); | |
26826 | if (disp.is_resized) disp.resize(disp); | |
26827 | if (disp.button&1) { | |
26828 | oclicked = clicked; | |
26829 | clicked = -1; | |
26830 | for (unsigned int l=0; l<(buttons).size; ++l) | |
26831 | if (disp.mouse_y>=(int)by && disp.mouse_y<(int)(by+bh) && | |
26832 | disp.mouse_x>=(int)xbuttons[l] && disp.mouse_x<(int)(xbuttons[l]+bw)) { | |
26833 | clicked = selected = l; | |
26834 | refresh = true; | |
26835 | } | |
26836 | if (clicked!=oclicked) refresh = true; | |
26837 | } else if (clicked>=0) stopflag = true; | |
26838 | if (disp.key) { | |
26839 | oselected = selected; | |
26840 | switch (disp.key) { | |
26841 | case cimg::keyESC: selected=-1; stopflag=true; break; | |
26842 | case cimg::keyENTER: if (selected<0) selected = 0; stopflag = true; break; | |
26843 | case cimg::keyTAB: | |
26844 | case cimg::keyARROWRIGHT: | |
26845 | case cimg::keyARROWDOWN: selected = (selected+1)%buttons.size; break; | |
26846 | case cimg::keyARROWLEFT: | |
26847 | case cimg::keyARROWUP: selected = (selected+buttons.size-1)%buttons.size; break; | |
26848 | } | |
26849 | disp.key = 0; | |
26850 | if (selected!=oselected) refresh = true; | |
26851 | } | |
26852 | } | |
26853 | if (!disp) selected = -1; | |
26854 | return selected; | |
26855 | } | |
26856 | inline int dialog(const char *title, const char *msg, | |
26857 | const char *button1_txt, const char *button2_txt, const char *button3_txt, | |
26858 | const char *button4_txt, const char *button5_txt, const char *button6_txt, | |
26859 | const bool centering) { | |
26860 | return dialog(title,msg,button1_txt,button2_txt,button3_txt,button4_txt,button5_txt,button6_txt, | |
26861 | CImg<unsigned char>::get_logo40x38(),centering); | |
26862 | } | |
26863 | template<typename t> inline int _marching_cubes_indice(const unsigned int edge, const CImg<t>& indices1, const CImg<t>& indices2, | |
26864 | const unsigned int x, const unsigned int y, const unsigned int nx, const unsigned int ny) { | |
26865 | switch (edge) { | |
26866 | case 0: return indices1(x,y,0); | |
26867 | case 1: return indices1(nx,y,1); | |
26868 | case 2: return indices1(x,ny,0); | |
26869 | case 3: return indices1(x,y,1); | |
26870 | case 4: return indices2(x,y,0); | |
26871 | case 5: return indices2(nx,y,1); | |
26872 | case 6: return indices2(x,ny,0); | |
26873 | case 7: return indices2(x,y,1); | |
26874 | case 8: return indices1(x,y,2); | |
26875 | case 9: return indices1(nx,y,2); | |
26876 | case 10: return indices1(nx,ny,2); | |
26877 | case 11: return indices1(x,ny,2); | |
26878 | } | |
26879 | return 0; | |
26880 | } | |
26881 | template<typename tfunc, typename tp, typename tf> | |
26882 | inline void marching_cubes(const tfunc& func, const float isovalue, | |
26883 | const float x0, const float y0, const float z0, | |
26884 | const float x1, const float y1, const float z1, | |
26885 | const float resx, const float resy, const float resz, | |
26886 | CImgList<tp>& points, CImgList<tf>& primitives, | |
26887 | const bool invert_faces) { | |
26888 | static unsigned int edges[256] = { | |
26889 | 0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, | |
26890 | 0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, | |
26891 | 0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, | |
26892 | 0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, | |
26893 | 0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, | |
26894 | 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, | |
26895 | 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, | |
26896 | 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc , 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, | |
26897 | 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, | |
26898 | 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, | |
26899 | 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, | |
26900 | 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460, | |
26901 | 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0, | |
26902 | 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230, | |
26903 | 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190, | |
26904 | 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000 }; | |
26905 | static int triangles[256][16] = | |
26906 | {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26907 | {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26908 | {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26909 | {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1}, | |
26910 | {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26911 | {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1}, | |
26912 | {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1}, | |
26913 | {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26914 | {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26915 | {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1}, | |
26916 | {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1}, | |
26917 | {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1}, | |
26918 | {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1}, | |
26919 | {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1}, | |
26920 | {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1}, | |
26921 | {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1}, | |
26922 | {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26923 | {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1}, | |
26924 | {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, | |
26925 | {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1}, | |
26926 | {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, | |
26927 | {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1}, | |
26928 | {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1}, | |
26929 | {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1}, | |
26930 | {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1}, | |
26931 | {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26932 | {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1}, | |
26933 | {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1}, {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1}, | |
26934 | {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1}, | |
26935 | {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1}, {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1}, | |
26936 | {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1}, {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1}, | |
26937 | {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1}, {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26938 | {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26939 | {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, | |
26940 | {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1}, | |
26941 | {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1}, | |
26942 | {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, | |
26943 | {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1}, | |
26944 | {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1}, | |
26945 | {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1}, {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1}, | |
26946 | {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1}, | |
26947 | {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1}, | |
26948 | {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1}, | |
26949 | {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1}, {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1}, | |
26950 | {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1}, | |
26951 | {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1}, {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1}, | |
26952 | {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1}, | |
26953 | {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1}, {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1}, | |
26954 | {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1}, | |
26955 | {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1}, | |
26956 | {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1}, | |
26957 | {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1}, | |
26958 | {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1}, | |
26959 | {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1}, | |
26960 | {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1}, {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1}, | |
26961 | {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26962 | {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1}, | |
26963 | {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1}, {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1}, | |
26964 | {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1}, | |
26965 | {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26966 | {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1}, | |
26967 | {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1}, {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1}, | |
26968 | {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1}, {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26969 | {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1}, {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26970 | {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26971 | {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, | |
26972 | {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, | |
26973 | {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1}, | |
26974 | {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1}, | |
26975 | {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1}, | |
26976 | {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1}, | |
26977 | {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1}, {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1}, | |
26978 | {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1}, | |
26979 | {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1}, {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1}, | |
26980 | {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1}, | |
26981 | {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1}, {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1}, | |
26982 | {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26983 | {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1}, {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1}, | |
26984 | {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1}, {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1}, | |
26985 | {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1}, {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
26986 | {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, | |
26987 | {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1}, | |
26988 | {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1}, | |
26989 | {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1}, {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1}, | |
26990 | {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1}, | |
26991 | {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1}, {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1}, | |
26992 | {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1}, {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1}, | |
26993 | {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1}, {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1}, | |
26994 | {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1}, | |
26995 | {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1}, {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1}, | |
26996 | {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1}, {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1}, | |
26997 | {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1}, {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1}, | |
26998 | {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1}, {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1}, | |
26999 | {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1}, {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27000 | {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1}, {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1}, | |
27001 | {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27002 | {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1}, | |
27003 | {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1}, | |
27004 | {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1}, | |
27005 | {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1}, {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1}, | |
27006 | {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1}, | |
27007 | {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1}, {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1}, | |
27008 | {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1}, | |
27009 | {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27010 | {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1}, | |
27011 | {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1}, {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1}, | |
27012 | {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1}, {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1}, | |
27013 | {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1}, {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27014 | {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1}, {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1}, | |
27015 | {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1}, {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1}, | |
27016 | {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27017 | {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1}, {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27018 | {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1}, | |
27019 | {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1}, {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1}, | |
27020 | {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1}, {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1}, | |
27021 | {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1}, | |
27022 | {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1}, {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1}, | |
27023 | {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1}, {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27024 | {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1}, | |
27025 | {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27026 | {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1}, | |
27027 | {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27028 | {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1}, | |
27029 | {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27030 | {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27031 | {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1}, {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27032 | {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, | |
27033 | {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}}; | |
27034 | const unsigned int | |
27035 | nx = (unsigned int)((x1-x0+1)/resx), nxm1 = nx-1, | |
27036 | ny = (unsigned int)((y1-y0+1)/resy), nym1 = ny-1, | |
27037 | nz = (unsigned int)((z1-z0+1)/resz), nzm1 = nz-1; | |
27038 | if (!nxm1 || !nym1 || !nzm1) return; | |
27039 | CImg<int> indices1(nx,ny,1,3,-1), indices2(indices1); | |
27040 | CImg<float> values1(nx,ny), values2(nx,ny); | |
27041 | float X = 0, Y = 0, Z = 0, nX = 0, nY = 0, nZ = 0; | |
27042 | Y=y0; | |
27043 | for (int y = 0; y<(int)((values1).height); ++y) { | |
27044 | X = x0; | |
27045 | for (int x = 0; x<(int)((values1).width); ++x) { values1(x,y) = (float)func(X,Y,z0); X+=resx; } | |
27046 | Y+=resy; | |
27047 | } | |
27048 | Z = z0; nZ = Z + resz; | |
27049 | for (unsigned int zi=0; zi<nzm1; ++zi, Z=nZ, nZ+=resz) { | |
27050 | Y = y0; nY = Y + resy; | |
27051 | indices2.fill(-1); | |
27052 | for (unsigned int yi=0, nyi=1; yi<nym1; ++yi, ++nyi, Y=nY, nY+=resy) { | |
27053 | X = x0; nX = X + resx; | |
27054 | for (unsigned int xi=0, nxi=1; xi<nxm1; ++xi, ++nxi, X=nX, nX+=resx) { | |
27055 | const float | |
27056 | val0 = values1(xi,yi), val1 = values1(nxi,yi), val2 = values1(nxi,nyi), val3 = values1(xi,nyi), | |
27057 | val4 = values2(xi,yi) = (float)func(X,Y,nZ), | |
27058 | val5 = values2(nxi,yi) = (float)func(nX,Y,nZ), | |
27059 | val6 = values2(nxi,nyi) = (float)func(nX,nY,nZ), | |
27060 | val7 = values2(xi,nyi) = (float)func(X,nY,nZ); | |
27061 | const unsigned int configuration = | |
27062 | (val0<isovalue?1:0) | (val1<isovalue?2:0) | (val2<isovalue?4:0) | (val3<isovalue?8:0) | | |
27063 | (val4<isovalue?16:0) | (val5<isovalue?32:0) | (val6<isovalue?64:0) | (val7<isovalue?128:0), | |
27064 | edge = edges[configuration]; | |
27065 | if (edge) { | |
27066 | if ((edge&1) && indices1(xi,yi,0)<0) { | |
27067 | const float Xi = X + (isovalue-val0)*resx/(val1-val0); | |
27068 | indices1(xi,yi,0) = points.size; | |
27069 | points.insert(CImg<tp>::vector(Xi,Y,Z)); | |
27070 | } | |
27071 | if ((edge&2) && indices1(nxi,yi,1)<0) { | |
27072 | const float Yi = Y + (isovalue-val1)*resy/(val2-val1); | |
27073 | indices1(nxi,yi,1) = points.size; | |
27074 | points.insert(CImg<tp>::vector(nX,Yi,Z)); | |
27075 | } | |
27076 | if ((edge&4) && indices1(xi,nyi,0)<0) { | |
27077 | const float Xi = X + (isovalue-val3)*resx/(val2-val3); | |
27078 | indices1(xi,nyi,0) = points.size; | |
27079 | points.insert(CImg<tp>::vector(Xi,nY,Z)); | |
27080 | } | |
27081 | if ((edge&8) && indices1(xi,yi,1)<0) { | |
27082 | const float Yi = Y + (isovalue-val0)*resy/(val3-val0); | |
27083 | indices1(xi,yi,1) = points.size; | |
27084 | points.insert(CImg<tp>::vector(X,Yi,Z)); | |
27085 | } | |
27086 | if ((edge&16) && indices2(xi,yi,0)<0) { | |
27087 | const float Xi = X + (isovalue-val4)*resx/(val5-val4); | |
27088 | indices2(xi,yi,0) = points.size; | |
27089 | points.insert(CImg<tp>::vector(Xi,Y,nZ)); | |
27090 | } | |
27091 | if ((edge&32) && indices2(nxi,yi,1)<0) { | |
27092 | const float Yi = Y + (isovalue-val5)*resy/(val6-val5); | |
27093 | indices2(nxi,yi,1) = points.size; | |
27094 | points.insert(CImg<tp>::vector(nX,Yi,nZ)); | |
27095 | } | |
27096 | if ((edge&64) && indices2(xi,nyi,0)<0) { | |
27097 | const float Xi = X + (isovalue-val7)*resx/(val6-val7); | |
27098 | indices2(xi,nyi,0) = points.size; | |
27099 | points.insert(CImg<tp>::vector(Xi,nY,nZ)); | |
27100 | } | |
27101 | if ((edge&128) && indices2(xi,yi,1)<0) { | |
27102 | const float Yi = Y + (isovalue-val4)*resy/(val7-val4); | |
27103 | indices2(xi,yi,1) = points.size; | |
27104 | points.insert(CImg<tp>::vector(X,Yi,nZ)); | |
27105 | } | |
27106 | if ((edge&256) && indices1(xi,yi,2)<0) { | |
27107 | const float Zi = Z+ (isovalue-val0)*resz/(val4-val0); | |
27108 | indices1(xi,yi,2) = points.size; | |
27109 | points.insert(CImg<tp>::vector(X,Y,Zi)); | |
27110 | } | |
27111 | if ((edge&512) && indices1(nxi,yi,2)<0) { | |
27112 | const float Zi = Z + (isovalue-val1)*resz/(val5-val1); | |
27113 | indices1(nxi,yi,2) = points.size; | |
27114 | points.insert(CImg<tp>::vector(nX,Y,Zi)); | |
27115 | } | |
27116 | if ((edge&1024) && indices1(nxi,nyi,2)<0) { | |
27117 | const float Zi = Z + (isovalue-val2)*resz/(val6-val2); | |
27118 | indices1(nxi,nyi,2) = points.size; | |
27119 | points.insert(CImg<tp>::vector(nX,nY,Zi)); | |
27120 | } | |
27121 | if ((edge&2048) && indices1(xi,nyi,2)<0) { | |
27122 | const float Zi = Z + (isovalue-val3)*resz/(val7-val3); | |
27123 | indices1(xi,nyi,2) = points.size; | |
27124 | points.insert(CImg<tp>::vector(X,nY,Zi)); | |
27125 | } | |
27126 | for (int *triangle=triangles[configuration]; *triangle!=-1; ) { | |
27127 | const unsigned int p0 = *(triangle++), p1 = *(triangle++), p2 = *(triangle++); | |
27128 | const tf | |
27129 | i0 = (tf)(_marching_cubes_indice(p0,indices1,indices2,xi,yi,nxi,nyi)), | |
27130 | i1 = (tf)(_marching_cubes_indice(p1,indices1,indices2,xi,yi,nxi,nyi)), | |
27131 | i2 = (tf)(_marching_cubes_indice(p2,indices1,indices2,xi,yi,nxi,nyi)); | |
27132 | if (invert_faces) primitives.insert(CImg<tf>::vector(i0,i1,i2)); | |
27133 | else primitives.insert(CImg<tf>::vector(i0,i2,i1)); | |
27134 | } | |
27135 | } | |
27136 | } | |
27137 | } | |
27138 | cimg::swap(values1,values2); | |
27139 | cimg::swap(indices1,indices2); | |
27140 | } | |
27141 | } | |
27142 | template<typename t> inline int _marching_squares_indice(const unsigned int edge, const CImg<t>& indices1, const CImg<t>& indices2, | |
27143 | const unsigned int x, const unsigned int nx) { | |
27144 | switch (edge) { | |
27145 | case 0: return (int)indices1(x,0); | |
27146 | case 1: return (int)indices1(nx,1); | |
27147 | case 2: return (int)indices2(x,0); | |
27148 | case 3: return (int)indices1(x,1); | |
27149 | } | |
27150 | return 0; | |
27151 | } | |
27152 | template<typename tfunc, typename tp, typename tf> | |
27153 | inline void marching_squares(const tfunc& func, const float isovalue, | |
27154 | const float x0, const float y0, | |
27155 | const float x1, const float y1, | |
27156 | const float resx, const float resy, | |
27157 | CImgList<tp>& points, CImgList<tf>& primitives) { | |
27158 | static unsigned int edges[16] = { 0x0, 0x9, 0x3, 0xa, 0x6, 0xf, 0x5, 0xc, 0xc, 0x5, 0xf, 0x6, 0xa, 0x3, 0x9, 0x0 }; | |
27159 | static int segments[16][4] = { { -1,-1,-1,-1 }, { 0,3,-1,-1 }, { 0,1,-1,-1 }, { 1,3,-1,-1 }, | |
27160 | { 1,2,-1,-1 }, { 0,1,2,3 }, { 0,2,-1,-1 }, { 2,3,-1,-1 }, | |
27161 | { 2,3,-1,-1 }, { 0,2,-1,-1}, { 0,3,1,2 }, { 1,2,-1,-1 }, | |
27162 | { 1,3,-1,-1 }, { 0,1,-1,-1}, { 0,3,-1,-1}, { -1,-1,-1,-1 } }; | |
27163 | const unsigned int | |
27164 | nx = (unsigned int)((x1-x0+1)/resx), nxm1 = nx-1, | |
27165 | ny = (unsigned int)((y1-y0+1)/resy), nym1 = ny-1; | |
27166 | if (!nxm1 || !nym1) return; | |
27167 | CImg<int> indices1(nx,1,1,2,-1), indices2(nx,1,1,2); | |
27168 | CImg<float> values1(nx), values2(nx); | |
27169 | float X = 0, Y = 0, nX = 0, nY = 0; | |
27170 | for (int x = 0; x<(int)((values1).width); ++x) { values1(x) = (float)func(X,Y); X+=resx; } | |
27171 | Y = y0; nY = Y + resy; | |
27172 | for (unsigned int yi=0, nyi=1; yi<nym1; ++yi, ++nyi, Y=nY, nY+=resy) { | |
27173 | X = x0; nX = X + resx; | |
27174 | indices2.fill(-1); | |
27175 | for (unsigned int xi=0, nxi=1; xi<nxm1; ++xi, ++nxi, X=nX, nX+=resx) { | |
27176 | const float | |
27177 | val0 = values1(xi), val1 = values1(nxi), | |
27178 | val2 = values2(nxi) = (float)func(nX,nY), | |
27179 | val3 = values2(xi) = (float)func(X,nY); | |
27180 | const unsigned int configuration = (val0<isovalue?1:0) | (val1<isovalue?2:0) | (val2<isovalue?4:0) | (val3<isovalue?8:0), | |
27181 | edge = edges[configuration]; | |
27182 | if (edge) { | |
27183 | if ((edge&1) && indices1(xi,0)<0) { | |
27184 | const float Xi = X + (isovalue-val0)*resx/(val1-val0); | |
27185 | indices1(xi,0) = points.size; | |
27186 | points.insert(CImg<tp>::vector(Xi,Y)); | |
27187 | } | |
27188 | if ((edge&2) && indices1(nxi,1)<0) { | |
27189 | const float Yi = Y + (isovalue-val1)*resy/(val2-val1); | |
27190 | indices1(nxi,1) = points.size; | |
27191 | points.insert(CImg<tp>::vector(nX,Yi)); | |
27192 | } | |
27193 | if ((edge&4) && indices2(xi,0)<0) { | |
27194 | const float Xi = X + (isovalue-val3)*resx/(val2-val3); | |
27195 | indices2(xi,0) = points.size; | |
27196 | points.insert(CImg<tp>::vector(Xi,nY)); | |
27197 | } | |
27198 | if ((edge&8) && indices1(xi,1)<0) { | |
27199 | const float Yi = Y + (isovalue-val0)*resy/(val3-val0); | |
27200 | indices1(xi,1) = points.size; | |
27201 | points.insert(CImg<tp>::vector(X,Yi)); | |
27202 | } | |
27203 | for (int *segment=segments[configuration]; *segment!=-1; ) { | |
27204 | const unsigned int p0 = *(segment++), p1 = *(segment++); | |
27205 | const tf | |
27206 | i0 = (tf)(_marching_squares_indice(p0,indices1,indices2,xi,nxi)), | |
27207 | i1 = (tf)(_marching_squares_indice(p1,indices1,indices2,xi,nxi)); | |
27208 | primitives.insert(CImg<tf>::vector(i0,i1)); | |
27209 | } | |
27210 | } | |
27211 | } | |
27212 | values1.swap(values2); | |
27213 | indices1.swap(indices2); | |
27214 | } | |
27215 | } | |
27216 | } | |
27217 | } | |
27218 | using namespace cimg_library; | |
27219 | void get_geom(const char *geom, int &geom_w, int &geom_h) { | |
27220 | char tmp[16]; | |
27221 | std::sscanf(geom,"%d%7[^0-9]%d%7[^0-9]",&geom_w,tmp,&geom_h,tmp+1); | |
27222 | if (tmp[0]=='%') geom_w=-geom_w; | |
27223 | if (tmp[1]=='%') geom_h=-geom_h; | |
27224 | } | |
27225 | template<typename T> void greycstoration(int argc, char **argv, T pixel_type) { | |
27226 | pixel_type = (T)0; | |
27227 | cimg_library::cimg::option((char*)0,argc,argv,(char*)0," Open Source Algorithms for Image Denoising and Interpolation."); | |
27228 | cimg_library::cimg::option((char*)0,argc,argv,"-------------------------------------------------------------------------\n" " GREYCstoration v2.8, by David Tschumperle. \n" " ------------------------------------------------------------------------\n" " This program allows to denoise, inpaint and resize 2D color images. \n" " It is the result of the research work done in the IMAGE group of the \n" " GREYC Lab (CNRS, UMR 6072) (http://www.greyc.ensicaen.fr/EquipeImage/) \n" " by David Tschumperle (http://www.greyc.ensicaen.fr/~dtschump/). This \n" " program has been primarily released to help people processing image data\n" " and to allow comparisons between regularization algorithms. This is an \n" " open source software, distributed within the CImg Library package \n" " (http://cimg.sourceforge.net), and submitted to the CeCILL License. If \n" " you are interested to distribute it in a closed-source product, please \n" " read the licence file carefully. If you are using 'GREYCstored' images \n" " in your own publications, be kind to reference the GREYCstoration web \n" " site or the related scientific papers. More informations available at : \n" " ** http://www.greyc.ensicaen.fr/~dtschump/greycstoration/ ** \n" "-------------------------------------------------------------------------\n",(char*)0); | |
27229 | cimg_library::cimg::option((char*)0,argc,argv," + Global parameters\n -----------------------",(char*)0); | |
27230 | const char *restore_mode = cimg_library::cimg::option("-restore",argc,argv,(char*)0,"Restore image specified after '-restore'"); | |
27231 | const char *inpaint_mode = cimg_library::cimg::option("-inpaint",argc,argv,(char*)0,"Inpaint image specified after '-inpaint'"); | |
27232 | const char *resize_mode = cimg_library::cimg::option("-resize",argc,argv,(char*)0,"Resize image specified after '-resize'"); | |
27233 | const char *clean_mode = cimg_library::cimg::option("-clean",argc,argv,(char*)0,"Clean image specified after '-clean'"); | |
27234 | const char *reference_image = cimg_library::cimg::option("-ref",argc,argv,(char*)0,"Reference image to compare with"); | |
27235 | cimg_library::cimg::option("-bits",argc,argv,8,"Define input value type (8='uchar', 16='ushort', 32='float')"); | |
27236 | const unsigned int value_factor = cimg_library::cimg::option("-fact",argc,argv,0,"Define input value factor (0=auto)"); | |
27237 | const float noise_g = cimg_library::cimg::option("-ng",argc,argv,0.0f,"Add Gaussian noise before denoising"); | |
27238 | const float noise_u = cimg_library::cimg::option("-nu",argc,argv,0.0f,"Add Uniform noise before denoising"); | |
27239 | const float noise_s = cimg_library::cimg::option("-ns",argc,argv,0.0f,"Add Salt&Pepper noise before denoising"); | |
27240 | const unsigned int color_base = cimg_library::cimg::option("-cbase",argc,argv,0,"Processed color base (0=RGB, 1=YCbCr)"); | |
27241 | const char *channel_range = cimg_library::cimg::option("-crange",argc,argv,(char*)0,"Processed channels (ex: '0-2')"); | |
27242 | const unsigned int saving_step = cimg_library::cimg::option("-save",argc,argv,0,"Iteration saving step (>=0)"); | |
27243 | const bool visu = cimg_library::cimg::option("-visu",argc,argv,1?true:false,"Enable/Disable visualization windows (0 or 1)"); | |
27244 | const char *file_o = cimg_library::cimg::option("-o",argc,argv,(char*)0,"Filename of output image"); | |
27245 | const bool append_result = cimg_library::cimg::option("-append",argc,argv,false,"Append images in output file"); | |
27246 | const bool verbose = cimg_library::cimg::option("-verbose",argc,argv,true,"Verbose mode"); | |
27247 | const unsigned int jpg_quality = cimg_library::cimg::option("-quality",argc,argv,100,"Output compression quality (if JPEG format)"); | |
27248 | unsigned int nb_iterations = cimg_library::cimg::option("-iter",argc,argv,(restore_mode||clean_mode)?1:(inpaint_mode?1000:3),"Number of iterations (>0)"); | |
27249 | const float sdt = cimg_library::cimg::option("-sharp",argc,argv,(restore_mode||clean_mode)?0.0f:(inpaint_mode?0.0f:10.0f),"Sharpening strength (activate sharpening filter, >=0)"); | |
27250 | const float sp = cimg_library::cimg::option("-se",argc,argv,(restore_mode||clean_mode)?0.5f:(inpaint_mode?0.5f:3.0f),"Sharpening edge threshold (>=0)"); | |
27251 | const unsigned int tile_size = cimg_library::cimg::option("-tile",argc,argv,512,"Activate tiled mode and set tile size (>=0)"); | |
27252 | const unsigned int tile_border = cimg_library::cimg::option("-btile",argc,argv,4,"Size of tile borders (>=0)"); | |
27253 | const unsigned int nb_threads = cimg_library::cimg::option("-threads",argc,argv,1,"Number of threads used (*experimental*, tile mode only, >0)"); | |
27254 | const bool fast_approx = cimg_library::cimg::option("-fast",argc,argv,true,"Try faster algorithm (true or false)"); | |
27255 | float amplitude = 0, sharpness = 0, anisotropy = 0, alpha = 0, sigma = 0, gauss_prec = 0, dl = 0, da = 0, sigma_s = 0, sigma_p = 0; | |
27256 | unsigned int interpolation = 0, patch_size = 0, lookup_size = 0; | |
27257 | if (argc==1 || | |
27258 | (!restore_mode && !inpaint_mode && !resize_mode && !clean_mode) || | |
27259 | (restore_mode && inpaint_mode) || (restore_mode && resize_mode) || (restore_mode && clean_mode) || | |
27260 | (inpaint_mode && resize_mode) || (inpaint_mode && clean_mode)) { | |
27261 | std::fprintf(stderr,"\n%s : You must specify (only) one of the '-restore', '-inpaint', '-resize' or '-clean' options.\n" | |
27262 | "(try option '-h', '-h -restore','-h -inpaint', '-h -resize' or '-h -clean' to get options relative to specific actions\n\n", | |
27263 | cimg::basename(argv[0])); | |
27264 | std::exit(0); | |
27265 | } | |
27266 | CImg<T> img0, img, imgr; | |
27267 | CImg<unsigned char> mask; | |
27268 | CImgDisplay disp; | |
27269 | if (restore_mode) { | |
27270 | cimg_library::cimg::option((char*)0,argc,argv,"\n + Restoration mode parameters\n ---------------------------",(char*)0); | |
27271 | amplitude = cimg_library::cimg::option("-dt",argc,argv,40.0f,"Regularization strength per iteration (>=0)"); | |
27272 | sharpness = cimg_library::cimg::option("-p",argc,argv,0.9f,"Contour preservation (>=0)"); | |
27273 | anisotropy = cimg_library::cimg::option("-a",argc,argv,0.15f,"Smoothing anisotropy (0<=a<=1)"); | |
27274 | alpha = cimg_library::cimg::option("-alpha",argc,argv,0.6f,"Noise scale (>=0)"); | |
27275 | sigma = cimg_library::cimg::option("-sigma",argc,argv,1.1f,"Geometry regularity (>=0)"); | |
27276 | gauss_prec = cimg_library::cimg::option("-prec",argc,argv,2.0f,"Computation precision (>0)"); | |
27277 | dl = cimg_library::cimg::option("-dl",argc,argv,0.8f,"Spatial integration step (0<=dl<=1)"); | |
27278 | da = cimg_library::cimg::option("-da",argc,argv,30.0f,"Angular integration step (0<=da<=90)"); | |
27279 | interpolation = cimg_library::cimg::option("-interp",argc,argv,0,"Interpolation type (0=Nearest-neighbor, 1=Linear, 2=Runge-Kutta)"); | |
27280 | if (verbose) std::fprintf(stderr,"- Image Restoration mode\n"); | |
27281 | if (!cimg::strcmp("-restore",restore_mode)) { | |
27282 | std::fprintf(stderr,"%s : You must specify a valid input image filename after the '-restore' flag.\n\n",cimg::basename(argv[0])); | |
27283 | std::exit(0); | |
27284 | } | |
27285 | if (verbose) std::fprintf(stderr,"- Load input image '%s'...",cimg::basename(restore_mode)); | |
27286 | img.load(restore_mode); | |
27287 | if (verbose) std::fprintf(stderr,"\r- Input image : '%s' (size %dx%d, value range [%g,%g])\n", | |
27288 | cimg::basename(restore_mode),img.dimx(),img.dimy(),(double)img.min(),(double)img.max()); | |
27289 | if (noise_g || noise_u || noise_s) { | |
27290 | img0 = img; | |
27291 | img.noise(noise_g,0).noise(noise_u,1).noise(noise_s,2); | |
27292 | if (verbose) std::fprintf(stderr,"\r- Noisy image : value range [%g,%g], PSNR Noisy / Original : %g\n",(double)img.min(),(double)img.max(),img.PSNR(img0)); | |
27293 | } | |
27294 | } | |
27295 | if (inpaint_mode) { | |
27296 | cimg_library::cimg::option((char*)0,argc,argv,"\n + Inpainting mode parameters\n --------------------------",(char*)0); | |
27297 | const char *file_m = cimg_library::cimg::option("-m",argc,argv,(char*)0,"Input inpainting mask"); | |
27298 | const unsigned int dilate = cimg_library::cimg::option("-dilate",argc,argv,0,"Inpainting mask dilatation (>=0)"); | |
27299 | const unsigned int init = cimg_library::cimg::option("-init",argc,argv,4,"Inpainting init (0=black, 1=white, 2=noise, 3=unchanged, 4=smart)"); | |
27300 | amplitude = cimg_library::cimg::option("-dt",argc,argv,20.0f,"Regularization strength per iteration (>=0)"); | |
27301 | sharpness = cimg_library::cimg::option("-p",argc,argv,0.3f,"Contour preservation (>=0)"); | |
27302 | anisotropy = cimg_library::cimg::option("-a",argc,argv,1.0f,"Smoothing anisotropy (0<=a<=1)"); | |
27303 | alpha = cimg_library::cimg::option("-alpha",argc,argv,0.8f,"Noise scale (>=0)"); | |
27304 | sigma = cimg_library::cimg::option("-sigma",argc,argv,2.0f,"Geometry regularity (>=0)"); | |
27305 | gauss_prec = cimg_library::cimg::option("-prec",argc,argv,2.0f,"Computation precision (>0)"); | |
27306 | dl = cimg_library::cimg::option("-dl",argc,argv,0.8f,"Spatial integration step (0<=dl<=1)"); | |
27307 | da = cimg_library::cimg::option("-da",argc,argv,30.0f,"Angular integration step (0<=da<=90)"); | |
27308 | interpolation = cimg_library::cimg::option("-interp",argc,argv,0,"Interpolation type (0=Nearest-neighbor, 1=Linear, 2=Runge-Kutta)"); | |
27309 | if (verbose) std::fprintf(stderr,"- Image Inpainting mode\n"); | |
27310 | if (!cimg::strcmp("-inpaint",inpaint_mode)) { | |
27311 | std::fprintf(stderr,"%s : You must specify a valid input image filename after the '-inpaint' flag.\n\n",cimg::basename(argv[0])); | |
27312 | std::exit(0); | |
27313 | } | |
27314 | if (verbose) std::fprintf(stderr,"- Load input image '%s'...",cimg::basename(inpaint_mode)); | |
27315 | img.load(inpaint_mode); | |
27316 | if (verbose) std::fprintf(stderr,"\r- Input image : '%s' (size %dx%d, value range [%g,%g])\n", | |
27317 | cimg::basename(inpaint_mode),img.dimx(),img.dimy(),(double)img.min(),(double)img.max()); | |
27318 | if (noise_g || noise_u || noise_s) { | |
27319 | img0 = img; | |
27320 | img.noise(noise_g,0).noise(noise_u,1).noise(noise_s,2); | |
27321 | if (verbose) std::fprintf(stderr,"\r- Noisy image : value range [%g,%g], PSNR Noisy / Original : %g\n",(double)img.min(),(double)img.max(),img.PSNR(img0)); | |
27322 | } | |
27323 | if (!file_m) { | |
27324 | std::fprintf(stderr,"%s : You need to specify a valid inpainting mask filename after the '-m' flag.\n\n",cimg::basename(argv[0])); | |
27325 | std::exit(0); | |
27326 | } | |
27327 | if (cimg::strncasecmp("block",file_m,5)) { | |
27328 | if (verbose) std::fprintf(stderr,"- Load inpainting mask '%s'...",cimg::basename(file_m)); | |
27329 | mask.load(file_m); | |
27330 | if (verbose) std::fprintf(stderr,"\r- Inpainting mask : '%s' (size %dx%d)\n",cimg::basename(file_m),mask.dimx(),mask.dimy()); | |
27331 | } | |
27332 | else { | |
27333 | unsigned int l = 16; std::sscanf(file_m,"block%u",&l); | |
27334 | mask.assign(img.dimx()/l,img.dimy()/l); | |
27335 | for (int y = 0; y<(int)((mask).height); ++y) for (int x = 0; x<(int)((mask).width); ++x) mask(x,y) = (x+y)%2; | |
27336 | img0 = img; | |
27337 | } | |
27338 | mask.resize(img.dimx(),img.dimy(),1,1); | |
27339 | if (dilate) mask.dilate(dilate); | |
27340 | switch (init) { | |
27341 | case 0 : { for (int k = 0; k<(int)((img).dim); ++k) for (int y = 0; y<(int)((img).height); ++y) for (int x = 0; x<(int)((img).width); ++x) if (mask(x,y)) img(x,y,k) = 0; } break; | |
27342 | case 1 : { for (int k = 0; k<(int)((img).dim); ++k) for (int y = 0; y<(int)((img).height); ++y) for (int x = 0; x<(int)((img).width); ++x) if (mask(x,y)) img(x,y,k) = 255; } break; | |
27343 | case 2 : { for (int k = 0; k<(int)((img).dim); ++k) for (int y = 0; y<(int)((img).height); ++y) for (int x = 0; x<(int)((img).width); ++x) if (mask(x,y)) img(x,y,k) = (T)(255*cimg::rand()); } break; | |
27344 | case 3 : break; | |
27345 | default: { | |
27346 | typedef unsigned char uchar; | |
27347 | CImg<unsigned char> tmask(mask), ntmask(tmask); | |
27348 | uchar M[9]; uchar& Mpp = M[0]; uchar& Mcp = M[1]; uchar& Mnp = M[2]; uchar& Mpc = M[3]; uchar& Mcc = M[4]; uchar& Mnc = M[5]; uchar& Mpn = M[6]; uchar& Mcn = M[7]; uchar& Mnn = M[8]; Mpp = Mcp = Mnp = Mpc = Mcc = Mnc = Mpn = Mcn = Mnn = 0; Mpp = Mnp = Mpn = Mnn = 0; | |
27349 | T I[9]; T& Ipp = I[0]; T& Icp = I[1]; T& Inp = I[2]; T& Ipc = I[3]; T& Icc = I[4]; T& Inc = I[5]; T& Ipn = I[6]; T& Icn = I[7]; T& Inn = I[8]; Ipp = Icp = Inp = Ipc = Icc = Inc = Ipn = Icn = Inn = 0; Ipp = Inp = Icc = Ipn = Inn = 0; | |
27350 | while (ntmask.max()>0) { | |
27351 | for (int y = 0, _p1y = 0, _n1y = 1>=((tmask).height)?(int)((tmask).height)-1:1; _n1y<(int)((tmask).height) || y==--_n1y; _p1y = y++, ++_n1y) for (int x = 0, _p1x = 0, _n1x = (int)( (M[0] = M[1] = (tmask)(0,_p1y,0,0)), (M[3] = M[4] = (tmask)(0,y,0,0)), (M[6] = M[7] = (tmask)(0,_n1y,0,0)), 1>=(tmask).width?(int)((tmask).width)-1:1); (_n1x<(int)((tmask).width) && ( (M[2] = (tmask)(_n1x,_p1y,0,0)), (M[5] = (tmask)(_n1x,y,0,0)), (M[8] = (tmask)(_n1x,_n1y,0,0)),1)) || x==--_n1x; M[0] = M[1], M[1] = M[2], M[3] = M[4], M[4] = M[5], M[6] = M[7], M[7] = M[8], _p1x = x++, ++_n1x) if (Mcc && (!Mpc || !Mnc || !Mcp || !Mcn)) { | |
27352 | const float | |
27353 | ccp = Mcp?0.0f:1.0f, cpc = Mpc?0.0f:1.0f, | |
27354 | cnc = Mnc?0.0f:1.0f, ccn = Mcn?0.0f:1.0f, | |
27355 | csum = ccp + cpc + cnc + ccn; | |
27356 | for (int k = 0; k<(int)((img).dim); ++k) { | |
27357 | I[0] = (img)(_p1x,_p1y,0,k), I[1] = (img)(x,_p1y,0,k), I[2] = (img)(_n1x,_p1y,0,k), I[3] = (img)(_p1x, y,0,k), I[4] = (img)(x, y,0,k), I[5] = (img)(_n1x, y,0,k), I[6] = (img)(_p1x,_n1y,0,k), I[7] = (img)(x,_n1y,0,k), I[8] = (img)(_n1x,_n1y,0,k); | |
27358 | img(x,y,k) = (T)((ccp*Icp + cpc*Ipc + cnc*Inc + ccn*Icn)/csum); | |
27359 | } | |
27360 | ntmask(x,y) = 0; | |
27361 | } | |
27362 | tmask = ntmask; | |
27363 | } | |
27364 | } break; | |
27365 | } | |
27366 | } | |
27367 | if (resize_mode) { | |
27368 | cimg_library::cimg::option((char*)0,argc,argv,"\n + Resizing mode parameters\n ------------------------",(char*)0); | |
27369 | const char *geom0 = cimg_library::cimg::option("-g0",argc,argv,(char*)0,"Input image geometry"); | |
27370 | const char *geom = cimg_library::cimg::option("-g",argc,argv,(char*)0,"Output image geometry"); | |
27371 | const bool anchor = cimg_library::cimg::option("-anchor",argc,argv,true,"Anchor original pixels (keep their original values)"); | |
27372 | const unsigned int init = cimg_library::cimg::option("-init",argc,argv,3,"Initial estimate (1=block, 3=linear, 4=Moving average, 5=bicubic)"); | |
27373 | amplitude = cimg_library::cimg::option("-dt",argc,argv,20.0f,"Regularization strength per iteration (>=0)"); | |
27374 | sharpness = cimg_library::cimg::option("-p",argc,argv,0.2f,"Contour preservation (>=0)"); | |
27375 | anisotropy = cimg_library::cimg::option("-a",argc,argv,0.9f,"Smoothing anisotropy (0<=a<=1)"); | |
27376 | alpha = cimg_library::cimg::option("-alpha",argc,argv,0.1f,"Noise scale (>=0)"); | |
27377 | sigma = cimg_library::cimg::option("-sigma",argc,argv,1.5f,"Geometry regularity (>=0)"); | |
27378 | gauss_prec = cimg_library::cimg::option("-prec",argc,argv,2.0f,"Computation precision (>0)"); | |
27379 | dl = cimg_library::cimg::option("-dl",argc,argv,0.8f,"Spatial integration step (0<=dl<=1)"); | |
27380 | da = cimg_library::cimg::option("-da",argc,argv,30.0f,"Angular integration step (0<=da<=90)"); | |
27381 | interpolation = cimg_library::cimg::option("-interp",argc,argv,0,"Interpolation type (0=Nearest-neighbor, 1=Linear, 2=Runge-Kutta)"); | |
27382 | if (verbose) std::fprintf(stderr,"- Image Resizing mode\n"); | |
27383 | if (!geom && !geom0) { | |
27384 | std::fprintf(stderr,"%s : You need to specify an output geometry or an input geometry (option -g or -g0).\n\n",cimg::basename(argv[0])); | |
27385 | std::exit(0); | |
27386 | } | |
27387 | if (!cimg::strcmp("-resize",resize_mode)) { | |
27388 | std::fprintf(stderr,"%s : You must specify a valid input image filename after the '-resize' flag.\n\n",cimg::basename(argv[0])); | |
27389 | std::exit(0); | |
27390 | } | |
27391 | if (verbose) std::fprintf(stderr,"- Load input image '%s'...",cimg::basename(resize_mode)); | |
27392 | img.load(resize_mode); | |
27393 | if (verbose) std::fprintf(stderr,"\r- Input image : '%s' (size %dx%d, value range [%g,%g])\n", | |
27394 | cimg::basename(resize_mode),img.dimx(),img.dimy(),(double)img.min(),(double)img.max()); | |
27395 | if (noise_g || noise_u || noise_s) { | |
27396 | img0 = img; | |
27397 | img.noise(noise_g,0).noise(noise_u,1).noise(noise_s,2); | |
27398 | if (verbose) std::fprintf(stderr,"\r- Noisy image : value range [%g,%g], PSNR Noisy / Original : %g\n",(double)img.min(),(double)img.max(),img.PSNR(img0)); | |
27399 | } | |
27400 | int w, h; | |
27401 | if (geom0) { | |
27402 | int w0, h0; | |
27403 | get_geom(geom0,w0,h0); | |
27404 | w0 = w0>0?w0:-w0*img.dimx()/100; | |
27405 | h0 = h0>0?h0:-h0*img.dimy()/100; | |
27406 | if (verbose) std::fprintf(stderr,"- Reducing geometry to %dx%d using %s interpolation.\n",w0,h0,init==1?"bloc":(init==3?"linear":(init==5?"bicubic":"moving average"))); | |
27407 | img0.assign(img); | |
27408 | w = img.dimx(); | |
27409 | h = img.dimy(); | |
27410 | img.resize(w0,h0,-100,-100,5); | |
27411 | } | |
27412 | if (geom) { | |
27413 | get_geom(geom,w,h); | |
27414 | w = w>0?w:-w*img.dimx()/100; | |
27415 | h = h>0?h:-h*img.dimy()/100; | |
27416 | } | |
27417 | mask.assign(img.dimx(),img.dimy(),1,1,255); | |
27418 | if (!anchor) mask.resize(w,h,1,1,1); else mask = !mask.resize(w,h,1,1,4); | |
27419 | img.resize(w,h,1,-100,init); | |
27420 | if (img0) { if (verbose) std::fprintf(stderr,"\r- PSNR Original / Thumbnail : %g\n",img.PSNR(img0)); } | |
27421 | } | |
27422 | if (clean_mode) { | |
27423 | cimg_library::cimg::option((char*)0,argc,argv,"\n + Cleaning mode parameters\n ------------------------",(char*)0); | |
27424 | patch_size = cimg_library::cimg::option("-p",argc,argv,4,"Patch size (>0)"); | |
27425 | sigma_s = cimg_library::cimg::option("-ss",argc,argv,15.0f,"Spatial sigma (>0)"); | |
27426 | sigma_p = cimg_library::cimg::option("-sp",argc,argv,10.0f,"Patch sigma (>0)"); | |
27427 | lookup_size = cimg_library::cimg::option("-r",argc,argv,7,"Size of the lookup region (>0)"); | |
27428 | if (verbose) std::fprintf(stderr,"- Image Cleaning mode\n"); | |
27429 | if (!cimg::strcmp("-clean",clean_mode)) { | |
27430 | std::fprintf(stderr,"%s : You must specify a valid input image filename after the '-clean' flag.\n\n",cimg::basename(argv[0])); | |
27431 | std::exit(0); | |
27432 | } | |
27433 | if (verbose) std::fprintf(stderr,"- Load input image '%s'...",cimg::basename(clean_mode)); | |
27434 | img.load(clean_mode); | |
27435 | if (verbose) std::fprintf(stderr,"\r- Input image : '%s' (size %dx%d, value range [%g,%g])\n", | |
27436 | cimg::basename(clean_mode),img.dimx(),img.dimy(),(double)img.min(),(double)img.max()); | |
27437 | if (noise_g || noise_u || noise_s) { | |
27438 | img0 = img; | |
27439 | img.noise(noise_g,0).noise(noise_u,1).noise(noise_s,2); | |
27440 | if (verbose) std::fprintf(stderr,"\r- Noisy image : value range [%g,%g], PSNR Noisy / Original : %g\n",(double)img.min(),(double)img.max(),img.PSNR(img0)); | |
27441 | } | |
27442 | } | |
27443 | if (reference_image) { | |
27444 | if (verbose) std::fprintf(stderr,"- Load reference image '%s'...",cimg::basename(reference_image)); | |
27445 | imgr.load(reference_image); | |
27446 | if (verbose) std::fprintf(stderr,"\r- Reference image : '%s' (size %dx%d, value range [%g,%g])", | |
27447 | cimg::basename(reference_image),imgr.dimx(),imgr.dimy(),(double)imgr.min(),(double)imgr.max()); | |
27448 | if (img0) { imgr.resize(img0); if (verbose) std::fprintf(stderr,", PSNR Reference / Original : %g dB\n",imgr.PSNR(img0)); } | |
27449 | else { imgr.resize(img); if (verbose) std::fprintf(stderr,"\n"); } | |
27450 | } | |
27451 | CImg<T> dest(img); | |
27452 | unsigned int crange_beg = 0, crange_end = dest.dimv()-1U; | |
27453 | if (color_base) dest.RGBtoYCbCr(); | |
27454 | if (channel_range) std::sscanf(channel_range,"%u%*c%u",&crange_beg,&crange_end); | |
27455 | if (verbose) std::fprintf(stderr,"- Color base : %s, Channels range : %u-%u\n",color_base?"YCbCr":"RGB",crange_beg,crange_end); | |
27456 | if (!visu && !append_result) img.assign(); | |
27457 | if (visu) { | |
27458 | const int sx = 2*CImgDisplay::screen_dimx()/3, sy = 2*CImgDisplay::screen_dimy()/3; | |
27459 | int nwidth = dest.dimx(), nheight = dest.dimy(); | |
27460 | if (nwidth>sx) { nheight = nheight*sx/nwidth; nwidth = sx; } | |
27461 | if (nheight>sy) { nwidth = nwidth*sy/nheight; nheight = sy; } | |
27462 | disp.assign(nwidth,nheight,"GREYCstoration"); | |
27463 | if (color_base) dest.get_YCbCrtoRGB().display(disp); | |
27464 | else dest.display(disp); | |
27465 | } | |
27466 | const float gfact = (value_factor>0)?value_factor:((sizeof(T)==2)?1.0f/256:1.0f); | |
27467 | bool stop_all = false; | |
27468 | for (unsigned int iter=0; iter<nb_iterations && !stop_all; iter++) { | |
27469 | bool stop_iteration = false; | |
27470 | CImg<T> dest_range = dest.get_shared_channels(crange_beg,crange_end); | |
27471 | if (restore_mode) | |
27472 | dest_range.greycstoration_run(amplitude,sharpness,anisotropy,alpha,sigma,gfact,dl,da,gauss_prec, | |
27473 | interpolation,fast_approx,tile_size,tile_border,nb_threads); | |
27474 | if (clean_mode) | |
27475 | dest_range.greycstoration_patch_run(patch_size,sigma_s,sigma_p,lookup_size, | |
27476 | tile_size,tile_border,nb_threads,fast_approx); | |
27477 | if (inpaint_mode || resize_mode) | |
27478 | dest_range.greycstoration_run(mask,amplitude,sharpness,anisotropy,alpha,sigma,gfact,dl,da,gauss_prec, | |
27479 | interpolation,fast_approx,tile_size,tile_border,nb_threads); | |
27480 | do { | |
27481 | const unsigned int progress = (unsigned int)dest_range.greycstoration_progress(); | |
27482 | if (verbose) std::fprintf(stderr,"\r- Processing : Iteration %u/%u (%u%%)\t\t",1+iter,nb_iterations,progress); | |
27483 | if (disp) { | |
27484 | if (disp.is_resized) disp.resize(); | |
27485 | disp.set_title("Processing : Iteration %u/%u (%u%%)",1+iter,nb_iterations,progress); | |
27486 | if (disp.is_closed || disp.key==cimg::keyQ || disp.key==cimg::keyESC) { | |
27487 | dest_range.greycstoration_stop(); | |
27488 | stop_iteration = true; | |
27489 | iter = nb_iterations-1; | |
27490 | } | |
27491 | } | |
27492 | cimg::wait(200); | |
27493 | } while (dest_range.greycstoration_is_running()); | |
27494 | if (!stop_iteration && sdt>0) dest_range.sharpen(sdt,sp,alpha/3,sigma/3); | |
27495 | dest_range.cut(cimg::type<T>::min(),cimg::type<T>::max()); | |
27496 | CImg<T> tmp_rgb = color_base?dest.get_YCbCrtoRGB():CImg<T>(), &dest_rgb = color_base?tmp_rgb:dest; | |
27497 | if (disp && visu) dest_rgb.display(disp); | |
27498 | if (file_o && saving_step && !(iter%saving_step)) dest_rgb.save(file_o,iter); | |
27499 | if (iter==nb_iterations-1) { | |
27500 | if (verbose) std::fprintf(stderr,"\r- Processing : Done ! \n"); | |
27501 | if (img0) { if (verbose) std::fprintf(stderr,"- PSNR Restored / Original : %g dB\n",dest_rgb.PSNR(img0)); } | |
27502 | if (disp) { | |
27503 | static bool first_time = true; | |
27504 | if (first_time) { | |
27505 | first_time = false; | |
27506 | if (verbose) std::fprintf(stderr, | |
27507 | "- GREYCstoration interface :\n" | |
27508 | " > You can now zoom to a particular rectangular region,\n" | |
27509 | " or press one of the following key on the display window :\n" | |
27510 | " SPACE : Swap views.\n" | |
27511 | " S : Save a snapshot of the current image.\n" | |
27512 | " I : Run another iteration.\n" | |
27513 | " Q : Quit GREYCstoration.\n"); | |
27514 | } | |
27515 | CImgList<T> visu; | |
27516 | visu.insert(img0,~0,true).insert(img,~0,true).insert(dest_rgb,~0,true).insert(imgr,~0U,true); | |
27517 | const char *titles[4] = { "original", "noisy", "restored", "reference"}; | |
27518 | unsigned int visupos = 2; | |
27519 | CImgDisplay dispz; | |
27520 | CImg<T> zoom; | |
27521 | int snb = 0; | |
27522 | bool stop_interact = false; | |
27523 | while (!stop_interact) { | |
27524 | disp.show().set_title("GREYCstoration (%s)",titles[visupos]); | |
27525 | const CImg<int> s = visu(visupos).get_coordinates(2,disp); | |
27526 | if (disp.is_closed) stop_interact = true; | |
27527 | switch (disp.key) { | |
27528 | case cimg::keySPACE: do { visupos = (visupos+1)%visu.size; } while (!visu(visupos)); break; | |
27529 | case cimg::keyBACKSPACE: do { visupos = (visupos-1+visu.size)%visu.size; } while (!visu(visupos)); break; | |
27530 | case cimg::keyQ: stop_interact = stop_all = true; break; | |
27531 | case cimg::keyI: | |
27532 | stop_interact = true; | |
27533 | if (verbose) std::fprintf(stderr,"- Perform iteration %u...\n",++nb_iterations); | |
27534 | dest_rgb.display(disp); | |
27535 | break; | |
27536 | case cimg::keyS: | |
27537 | if (!snb) { | |
27538 | if (!append_result) dest_rgb.save(file_o?file_o:"GREYCstoration.bmp"); | |
27539 | else CImgList<T>(img,dest_rgb).get_append('x').save(file_o?file_o:"GREYCstoration.bmp"); | |
27540 | } | |
27541 | if (zoom) zoom.save(file_o?file_o:"GREYCstoration.bmp",snb); | |
27542 | if (verbose) std::fprintf(stderr,"- Snapshot %u : '%s' saved\n",snb++,file_o?file_o:"GREYCstoration.bmp"); | |
27543 | break; | |
27544 | } | |
27545 | disp.key = 0; | |
27546 | if (disp.is_resized) disp.resize().display(visu(visupos)); | |
27547 | if (dispz && dispz.is_resized) dispz.resize().display(zoom); | |
27548 | if (dispz && dispz.is_closed) dispz.assign(); | |
27549 | if (s[0]>=0 && s[1]>=0 && s[3]>=0 && s[4]>=0) { | |
27550 | const int x0 = s[0], y0 = s[1], x1 = s[3], y1 = s[4]; | |
27551 | if (cimg::abs(x0-x1)>4 && cimg::abs(y0-y1)>4) { | |
27552 | CImgList<T> tmp(img.get_crop(x0,y0,x1,y1), dest_rgb.get_crop(x0,y0,x1,y1)); | |
27553 | if (img0) tmp.insert(img0.get_crop(x0,y0,x1,y1),0); | |
27554 | if (imgr) tmp.insert(imgr.get_crop(x0,y0,x1,y1)); | |
27555 | zoom = tmp.get_append('x','c'); | |
27556 | if (!dispz) { | |
27557 | const int sx = 5*CImgDisplay::screen_dimx()/6, sy = 5*CImgDisplay::screen_dimy()/6; | |
27558 | int nwidth = zoom.dimx(), nheight = zoom.dimy(); | |
27559 | if (nwidth>nheight) { nheight = nheight*sx/nwidth; nwidth = sx; } | |
27560 | else { nwidth = nwidth*sy/nheight; nheight = sy; } | |
27561 | dispz.assign(zoom.get_resize(nwidth,nheight)); | |
27562 | dispz.set_title("GREYCstoration (zoom) : - %s %s %s %s", | |
27563 | img0?"original -":"", | |
27564 | img?"noisy -":"", | |
27565 | dest?"restored -":"", | |
27566 | imgr?"reference -":""); | |
27567 | } else dispz.resize(dispz.dimx(),dispz.dimx()*zoom.dimy()/zoom.dimx(),false); | |
27568 | dispz.display(zoom).show(); | |
27569 | } | |
27570 | } | |
27571 | } | |
27572 | } | |
27573 | } | |
27574 | } | |
27575 | if (file_o) { | |
27576 | CImg<T> tmp_rgb = color_base?dest.get_YCbCrtoRGB():CImg<T>(), &dest_rgb = color_base?tmp_rgb:dest; | |
27577 | if (jpg_quality) { | |
27578 | if (verbose) std::fprintf(stderr,"\n- Saving output image '%s' (JPEG quality = %u%%)\n",file_o,jpg_quality); | |
27579 | if (!append_result) dest_rgb.save_jpeg(file_o,jpg_quality); | |
27580 | else CImgList<T>(img,dest_rgb).get_append('x').save_jpeg(file_o,jpg_quality); | |
27581 | } else { | |
27582 | if (verbose) std::fprintf(stderr,"\n- Saving output image '%s'\n",file_o); | |
27583 | if (!append_result) dest_rgb.save(file_o); | |
27584 | else CImgList<T>(img,dest_rgb).get_append('x').save(file_o); | |
27585 | } | |
27586 | } | |
27587 | if (verbose) std::fprintf(stderr,"\n- Quit\n\n"); | |
27588 | } | |
27589 | int main(int argc,char **argv) { | |
27590 | switch (cimg_library::cimg::option("-bits",argc,argv,8,0)) { | |
27591 | case 32: { | |
27592 | float pixel_type = 0; | |
27593 | greycstoration(argc,argv,pixel_type); | |
27594 | } break; | |
27595 | case 16: { | |
27596 | unsigned short pixel_type = 0; | |
27597 | greycstoration(argc,argv,pixel_type); | |
27598 | } break; | |
27599 | default: { | |
27600 | unsigned char pixel_type = 0; | |
27601 | greycstoration(argc,argv,pixel_type); | |
27602 | } break; | |
27603 | } | |
27604 | return 0; | |
27605 | } |