1 | /* ------------------ */ |
---|
2 | /* --- nrarith2.c --- */ |
---|
3 | /* ------------------ */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | * |
---|
9 | * Distributed under the Boost Software License, Version 1.0 |
---|
10 | * see accompanying file LICENSE.txt or copy it at |
---|
11 | * http://www.boost.org/LICENSE_1_0.txt |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <stddef.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <malloc.h> |
---|
18 | #include <math.h> // fabs |
---|
19 | // #include <memory.h> // memcpy |
---|
20 | |
---|
21 | #include "mypredef.h" |
---|
22 | #include "nrtype.h" |
---|
23 | #include "nrdef.h" |
---|
24 | #include "nrmacro.h" |
---|
25 | #include "nrkernel.h" |
---|
26 | |
---|
27 | #include "nrarith1.h" |
---|
28 | #include "nrarith2.h" |
---|
29 | |
---|
30 | /* ------------------ */ |
---|
31 | /* --- min_matrix --- */ |
---|
32 | /* ------------------ */ |
---|
33 | |
---|
34 | /* ----------------------------------------------------------------------------- */ |
---|
35 | IMAGE_EXPORT(sint8) min_si8matrix(sint8 **m, long nrl, long nrh, long ncl, long nch) |
---|
36 | /* ----------------------------------------------------------------------------- */ |
---|
37 | { |
---|
38 | int i, j; |
---|
39 | sint8 minimum = m[nrl][ncl]; |
---|
40 | |
---|
41 | for(i=nrl; i<=nrh; i++) { |
---|
42 | for(j=ncl; j<=nch; j++) { |
---|
43 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
44 | } |
---|
45 | } |
---|
46 | return minimum; |
---|
47 | } |
---|
48 | /* ------------------------------------------------------------------------------ */ |
---|
49 | IMAGE_EXPORT(uint8) min_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch) |
---|
50 | /* ------------------------------------------------------------------------------ */ |
---|
51 | { |
---|
52 | int i, j; |
---|
53 | uint8 minimum = m[nrl][ncl]; |
---|
54 | |
---|
55 | for(i=nrl; i<=nrh; i++) { |
---|
56 | for(j=ncl; j<=nch; j++) { |
---|
57 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
58 | } |
---|
59 | } |
---|
60 | return minimum; |
---|
61 | } |
---|
62 | /* --------------------------------------------------------------------------------- */ |
---|
63 | IMAGE_EXPORT(sint16) min_si16matrix(sint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
64 | /* --------------------------------------------------------------------------------- */ |
---|
65 | { |
---|
66 | int i, j; |
---|
67 | sint16 minimum = m[nrl][ncl]; |
---|
68 | |
---|
69 | for(i=nrl; i<=nrh; i++) { |
---|
70 | for(j=ncl; j<=nch; j++) { |
---|
71 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
72 | } |
---|
73 | } |
---|
74 | return minimum; |
---|
75 | } |
---|
76 | /* --------------------------------------------------------------------------------- */ |
---|
77 | IMAGE_EXPORT(uint16) min_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
78 | /* --------------------------------------------------------------------------------- */ |
---|
79 | { |
---|
80 | int i, j; |
---|
81 | uint16 minimum = m[nrl][ncl]; |
---|
82 | |
---|
83 | for(i=nrl; i<=nrh; i++) { |
---|
84 | for(j=ncl; j<=nch; j++) { |
---|
85 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
86 | } |
---|
87 | } |
---|
88 | return minimum; |
---|
89 | } |
---|
90 | /* --------------------------------------------------------------------------------- */ |
---|
91 | IMAGE_EXPORT(sint32) min_si32matrix(sint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
92 | /* --------------------------------------------------------------------------------- */ |
---|
93 | { |
---|
94 | int i, j; |
---|
95 | sint32 minimum = m[nrl][ncl]; |
---|
96 | |
---|
97 | for(i=nrl; i<=nrh; i++) { |
---|
98 | for(j=ncl; j<=nch; j++) { |
---|
99 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
100 | } |
---|
101 | } |
---|
102 | return minimum; |
---|
103 | } |
---|
104 | /* --------------------------------------------------------------------------------- */ |
---|
105 | IMAGE_EXPORT(uint32) min_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
106 | /* --------------------------------------------------------------------------------- */ |
---|
107 | { |
---|
108 | int i, j; |
---|
109 | uint32 minimum = m[nrl][ncl]; |
---|
110 | |
---|
111 | for(i=nrl; i<=nrh; i++) { |
---|
112 | for(j=ncl; j<=nch; j++) { |
---|
113 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
114 | } |
---|
115 | } |
---|
116 | return minimum; |
---|
117 | } |
---|
118 | /* --------------------------------------------------------------------------------- */ |
---|
119 | IMAGE_EXPORT(sint64) min_si64matrix(sint64 **m, long nrl, long nrh, long ncl, long nch) |
---|
120 | /* --------------------------------------------------------------------------------- */ |
---|
121 | { |
---|
122 | int i, j; |
---|
123 | sint64 minimum = m[nrl][ncl]; |
---|
124 | |
---|
125 | for(i=nrl; i<=nrh; i++) { |
---|
126 | for(j=ncl; j<=nch; j++) { |
---|
127 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
128 | } |
---|
129 | } |
---|
130 | return minimum; |
---|
131 | } |
---|
132 | /* --------------------------------------------------------------------------------- */ |
---|
133 | IMAGE_EXPORT(uint64) min_ui64matrix(uint64 **m, long nrl, long nrh, long ncl, long nch) |
---|
134 | /* --------------------------------------------------------------------------------- */ |
---|
135 | { |
---|
136 | int i, j; |
---|
137 | uint64 minimum = m[nrl][ncl]; |
---|
138 | |
---|
139 | for(i=nrl; i<=nrh; i++) { |
---|
140 | for(j=ncl; j<=nch; j++) { |
---|
141 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
142 | } |
---|
143 | } |
---|
144 | return minimum; |
---|
145 | } |
---|
146 | /* ---------------------------------------------------------------------------------- */ |
---|
147 | IMAGE_EXPORT(float32) min_f32matrix(float32 **m, long nrl, long nrh, long ncl, long nch) |
---|
148 | /* ---------------------------------------------------------------------------------- */ |
---|
149 | { |
---|
150 | int i, j; |
---|
151 | float32 minimum = m[nrl][ncl]; |
---|
152 | |
---|
153 | for(i=nrl; i<=nrh; i++) { |
---|
154 | for(j=ncl; j<=nch; j++) { |
---|
155 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
156 | } |
---|
157 | } |
---|
158 | return minimum; |
---|
159 | } |
---|
160 | /* ---------------------------------------------------------------------------------- */ |
---|
161 | IMAGE_EXPORT(float64) min_f64matrix(float64 **m, long nrl, long nrh, long ncl, long nch) |
---|
162 | /* ---------------------------------------------------------------------------------- */ |
---|
163 | { |
---|
164 | int i, j; |
---|
165 | float64 minimum = m[nrl][ncl]; |
---|
166 | |
---|
167 | for(i=nrl; i<=nrh; i++) { |
---|
168 | for(j=ncl; j<=nch; j++) { |
---|
169 | if(m[i][j]<minimum) minimum = m[i][j]; |
---|
170 | } |
---|
171 | } |
---|
172 | return minimum; |
---|
173 | } |
---|
174 | |
---|
175 | /* ------------------ */ |
---|
176 | /* --- max_matrix --- */ |
---|
177 | /* ------------------ */ |
---|
178 | |
---|
179 | /* ----------------------------------------------------------------------------- */ |
---|
180 | IMAGE_EXPORT(sint8) max_si8matrix(sint8 **m, long nrl, long nrh, long ncl, long nch) |
---|
181 | /* ----------------------------------------------------------------------------- */ |
---|
182 | { |
---|
183 | int i, j; |
---|
184 | sint8 minimum = m[nrl][ncl]; |
---|
185 | |
---|
186 | for(i=nrl; i<=nrh; i++) { |
---|
187 | for(j=ncl; j<=nch; j++) { |
---|
188 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
189 | } |
---|
190 | } |
---|
191 | return minimum; |
---|
192 | } |
---|
193 | /* ------------------------------------------------------------------------------ */ |
---|
194 | IMAGE_EXPORT(uint8) max_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch) |
---|
195 | /* ------------------------------------------------------------------------------ */ |
---|
196 | { |
---|
197 | int i, j; |
---|
198 | uint8 minimum = m[nrl][ncl]; |
---|
199 | |
---|
200 | for(i=nrl; i<=nrh; i++) { |
---|
201 | for(j=ncl; j<=nch; j++) { |
---|
202 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
203 | } |
---|
204 | } |
---|
205 | return minimum; |
---|
206 | } |
---|
207 | /* --------------------------------------------------------------------------------- */ |
---|
208 | IMAGE_EXPORT(sint16) max_si16matrix(sint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
209 | /* --------------------------------------------------------------------------------- */ |
---|
210 | { |
---|
211 | int i, j; |
---|
212 | sint16 minimum = m[nrl][ncl]; |
---|
213 | |
---|
214 | for(i=nrl; i<=nrh; i++) { |
---|
215 | for(j=ncl; j<=nch; j++) { |
---|
216 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
217 | } |
---|
218 | } |
---|
219 | return minimum; |
---|
220 | } |
---|
221 | /* --------------------------------------------------------------------------------- */ |
---|
222 | IMAGE_EXPORT(uint16) max_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
223 | /* --------------------------------------------------------------------------------- */ |
---|
224 | { |
---|
225 | int i, j; |
---|
226 | uint16 minimum = m[nrl][ncl]; |
---|
227 | |
---|
228 | for(i=nrl; i<=nrh; i++) { |
---|
229 | for(j=ncl; j<=nch; j++) { |
---|
230 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
231 | } |
---|
232 | } |
---|
233 | return minimum; |
---|
234 | } |
---|
235 | /* --------------------------------------------------------------------------------- */ |
---|
236 | IMAGE_EXPORT(sint32) max_si32matrix(sint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
237 | /* --------------------------------------------------------------------------------- */ |
---|
238 | { |
---|
239 | int i, j; |
---|
240 | sint32 minimum = m[nrl][ncl]; |
---|
241 | |
---|
242 | for(i=nrl; i<=nrh; i++) { |
---|
243 | for(j=ncl; j<=nch; j++) { |
---|
244 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
245 | } |
---|
246 | } |
---|
247 | return minimum; |
---|
248 | } |
---|
249 | /* --------------------------------------------------------------------------------- */ |
---|
250 | IMAGE_EXPORT(uint32) max_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
251 | /* --------------------------------------------------------------------------------- */ |
---|
252 | { |
---|
253 | int i, j; |
---|
254 | uint32 minimum = m[nrl][ncl]; |
---|
255 | |
---|
256 | for(i=nrl; i<=nrh; i++) { |
---|
257 | for(j=ncl; j<=nch; j++) { |
---|
258 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
259 | } |
---|
260 | } |
---|
261 | return minimum; |
---|
262 | } |
---|
263 | /* --------------------------------------------------------------------------------- */ |
---|
264 | IMAGE_EXPORT(sint64) max_si64matrix(sint64 **m, long nrl, long nrh, long ncl, long nch) |
---|
265 | /* --------------------------------------------------------------------------------- */ |
---|
266 | { |
---|
267 | int i, j; |
---|
268 | sint64 minimum = m[nrl][ncl]; |
---|
269 | |
---|
270 | for(i=nrl; i<=nrh; i++) { |
---|
271 | for(j=ncl; j<=nch; j++) { |
---|
272 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
273 | } |
---|
274 | } |
---|
275 | return minimum; |
---|
276 | } |
---|
277 | /* --------------------------------------------------------------------------------- */ |
---|
278 | IMAGE_EXPORT(uint64) max_ui64matrix(uint64 **m, long nrl, long nrh, long ncl, long nch) |
---|
279 | /* --------------------------------------------------------------------------------- */ |
---|
280 | { |
---|
281 | int i, j; |
---|
282 | uint64 minimum = m[nrl][ncl]; |
---|
283 | |
---|
284 | for(i=nrl; i<=nrh; i++) { |
---|
285 | for(j=ncl; j<=nch; j++) { |
---|
286 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
287 | } |
---|
288 | } |
---|
289 | return minimum; |
---|
290 | } |
---|
291 | /* ---------------------------------------------------------------------------------- */ |
---|
292 | IMAGE_EXPORT(float32) max_f32matrix(float32 **m, long nrl, long nrh, long ncl, long nch) |
---|
293 | /* ---------------------------------------------------------------------------------- */ |
---|
294 | { |
---|
295 | int i, j; |
---|
296 | float32 minimum = m[nrl][ncl]; |
---|
297 | |
---|
298 | for(i=nrl; i<=nrh; i++) { |
---|
299 | for(j=ncl; j<=nch; j++) { |
---|
300 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
301 | } |
---|
302 | } |
---|
303 | return minimum; |
---|
304 | } |
---|
305 | /* ---------------------------------------------------------------------------------- */ |
---|
306 | IMAGE_EXPORT(float64) max_f64matrix(float64 **m, long nrl, long nrh, long ncl, long nch) |
---|
307 | /* ---------------------------------------------------------------------------------- */ |
---|
308 | { |
---|
309 | int i, j; |
---|
310 | float64 minimum = m[nrl][ncl]; |
---|
311 | |
---|
312 | for(i=nrl; i<=nrh; i++) { |
---|
313 | for(j=ncl; j<=nch; j++) { |
---|
314 | if(m[i][j]>minimum) minimum = m[i][j]; |
---|
315 | } |
---|
316 | } |
---|
317 | return minimum; |
---|
318 | } |
---|
319 | |
---|
320 | /* -------------------------------------------------------------------------------------------------- */ |
---|
321 | IMAGE_EXPORT(void) add_si8matrix(sint8 **X, long nrl,long nrh, long ncl, long nch, sint8 **Y, sint8 **Z) |
---|
322 | /* -------------------------------------------------------------------------------------------------- */ |
---|
323 | { |
---|
324 | long i, j; |
---|
325 | |
---|
326 | for(i=nrl; i<=nrh; i++) { |
---|
327 | for(j=ncl; j<=nch; j++) { |
---|
328 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
329 | } |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | /* ------------------ */ |
---|
334 | /* --- Add Matrix --- */ |
---|
335 | /* ------------------ */ |
---|
336 | |
---|
337 | /* -------------------------------------------------------------------------------------------------- */ |
---|
338 | IMAGE_EXPORT(void) add_ui8matrix(uint8 **X, long nrl,long nrh, long ncl, long nch, uint8 **Y, uint8 **Z) |
---|
339 | /* -------------------------------------------------------------------------------------------------- */ |
---|
340 | { |
---|
341 | long i, j; |
---|
342 | |
---|
343 | for(i=nrl; i<=nrh; i++) { |
---|
344 | for(j=ncl; j<=nch; j++) { |
---|
345 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
346 | } |
---|
347 | } |
---|
348 | } |
---|
349 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
350 | IMAGE_EXPORT(void) add_si16matrix(sint16 **X, long nrl,long nrh, long ncl, long nch, sint16 **Y, sint16 **Z) |
---|
351 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
352 | { |
---|
353 | long i, j; |
---|
354 | |
---|
355 | for(i=nrl; i<=nrh; i++) { |
---|
356 | for(j=ncl; j<=nch; j++) { |
---|
357 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
358 | } |
---|
359 | } |
---|
360 | } |
---|
361 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
362 | IMAGE_EXPORT(void) add_ui16matrix(uint16 **X, long nrl,long nrh, long ncl, long nch, uint16 **Y, uint16 **Z) |
---|
363 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
364 | { |
---|
365 | long i, j; |
---|
366 | |
---|
367 | for(i=nrl; i<=nrh; i++) { |
---|
368 | for(j=ncl; j<=nch; j++) { |
---|
369 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
374 | IMAGE_EXPORT(void) add_si32matrix(sint32 **X, long nrl,long nrh, long ncl, long nch, sint32 **Y, sint32 **Z) |
---|
375 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
376 | { |
---|
377 | long i, j; |
---|
378 | |
---|
379 | for(i=nrl; i<=nrh; i++) { |
---|
380 | for(j=ncl; j<=nch; j++) { |
---|
381 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
382 | } |
---|
383 | } |
---|
384 | } |
---|
385 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
386 | IMAGE_EXPORT(void) add_ui32matrix(uint32 **X, long nrl,long nrh, long ncl, long nch, uint32 **Y, uint32 **Z) |
---|
387 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
388 | { |
---|
389 | long i, j; |
---|
390 | |
---|
391 | for(i=nrl; i<=nrh; i++) { |
---|
392 | for(j=ncl; j<=nch; j++) { |
---|
393 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
394 | } |
---|
395 | } |
---|
396 | } |
---|
397 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
398 | IMAGE_EXPORT(void) add_si64matrix(sint64 **X, long nrl,long nrh, long ncl, long nch, sint64 **Y, sint64 **Z) |
---|
399 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
400 | { |
---|
401 | long i, j; |
---|
402 | |
---|
403 | for(i=nrl; i<=nrh; i++) { |
---|
404 | for(j=ncl; j<=nch; j++) { |
---|
405 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
406 | } |
---|
407 | } |
---|
408 | } |
---|
409 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
410 | IMAGE_EXPORT(void) add_ui64matrix(uint64 **X, long nrl,long nrh, long ncl, long nch, uint64 **Y, uint64 **Z) |
---|
411 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
412 | { |
---|
413 | long i, j; |
---|
414 | |
---|
415 | for(i=nrl; i<=nrh; i++) { |
---|
416 | for(j=ncl; j<=nch; j++) { |
---|
417 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
418 | } |
---|
419 | } |
---|
420 | } |
---|
421 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
422 | IMAGE_EXPORT(void) add_f32matrix(float32 **X, long nrl,long nrh, long ncl, long nch, float32 **Y, float32 **Z) |
---|
423 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
424 | { |
---|
425 | long i, j; |
---|
426 | |
---|
427 | for(i=nrl; i<=nrh; i++) { |
---|
428 | for(j=ncl; j<=nch; j++) { |
---|
429 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
430 | } |
---|
431 | } |
---|
432 | } |
---|
433 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
434 | IMAGE_EXPORT(void) add_f64matrix(float64 **X, long nrl,long nrh, long ncl, long nch, float64 **Y, float64 **Z) |
---|
435 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
436 | { |
---|
437 | long i, j; |
---|
438 | |
---|
439 | for(i=nrl; i<=nrh; i++) { |
---|
440 | for(j=ncl; j<=nch; j++) { |
---|
441 | Z[i][j] = X[i][j] + Y[i][j]; |
---|
442 | } |
---|
443 | } |
---|
444 | } |
---|
445 | /* ----------------------------------------------------------------------------------------------- */ |
---|
446 | IMAGE_EXPORT(void) add_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z) |
---|
447 | /* ----------------------------------------------------------------------------------------------- */ |
---|
448 | { |
---|
449 | long i, j; |
---|
450 | rgb8 x, y, z; |
---|
451 | |
---|
452 | for(i=nrl; i<=nrh; i++) { |
---|
453 | for(j=ncl; j<=nch; j++) { |
---|
454 | x = X[i][j]; |
---|
455 | y = Y[i][j]; |
---|
456 | //z = x + y; |
---|
457 | RGB8_ADD(x,y,z); |
---|
458 | Z[i][j] = z; |
---|
459 | } |
---|
460 | } |
---|
461 | } |
---|
462 | /* --------------------------------------------------------------------------------------------------- */ |
---|
463 | IMAGE_EXPORT(void) add_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z) |
---|
464 | /* --------------------------------------------------------------------------------------------------- */ |
---|
465 | { |
---|
466 | long i, j; |
---|
467 | rgbx8 x, y, z; |
---|
468 | |
---|
469 | for(i=nrl; i<=nrh; i++) { |
---|
470 | for(j=ncl; j<=nch; j++) { |
---|
471 | x = X[i][j]; |
---|
472 | y = Y[i][j]; |
---|
473 | //z = x + y; |
---|
474 | RGBX8_ADD(x,y,z); |
---|
475 | Z[i][j] = z; |
---|
476 | } |
---|
477 | } |
---|
478 | } |
---|
479 | |
---|
480 | /* -------------------- */ |
---|
481 | /* --- Add constant --- */ |
---|
482 | /* -------------------- */ |
---|
483 | |
---|
484 | /* ------------------------------------------------------------------------------------------------ */ |
---|
485 | IMAGE_EXPORT(void) addc_si8matrix(sint8 **X,long nrl,long nrh, long ncl, long nch, sint8 y, sint8 **Z) |
---|
486 | /* ------------------------------------------------------------------------------------------------ */ |
---|
487 | { |
---|
488 | long i,j; |
---|
489 | |
---|
490 | for(i=nrl; i<=nrh; i++) { |
---|
491 | for(j=ncl; j<=nch; j++) { |
---|
492 | Z[i][j] = X[i][j] + y; |
---|
493 | } |
---|
494 | } |
---|
495 | } |
---|
496 | /* ------------------------------------------------------------------------------------------------ */ |
---|
497 | IMAGE_EXPORT(void) addc_ui8matrix(uint8 **X,long nrl,long nrh, long ncl, long nch, uint8 y, uint8 **Z) |
---|
498 | /* ------------------------------------------------------------------------------------------------ */ |
---|
499 | { |
---|
500 | long i,j; |
---|
501 | |
---|
502 | for(i=nrl; i<=nrh; i++) { |
---|
503 | for(j=ncl; j<=nch; j++) { |
---|
504 | Z[i][j] = X[i][j] + y; |
---|
505 | } |
---|
506 | } |
---|
507 | } |
---|
508 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
509 | IMAGE_EXPORT(void) addc_si16matrix(sint16 **X,long nrl,long nrh, long ncl, long nch, sint16 y, sint16 **Z) |
---|
510 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
511 | { |
---|
512 | long i,j; |
---|
513 | |
---|
514 | for(i=nrl; i<=nrh; i++) { |
---|
515 | for(j=ncl; j<=nch; j++) { |
---|
516 | Z[i][j] = X[i][j] + y; |
---|
517 | } |
---|
518 | } |
---|
519 | } |
---|
520 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
521 | IMAGE_EXPORT(void) addc_ui16matrix(uint16 **X,long nrl,long nrh, long ncl, long nch, uint16 y, uint16 **Z) |
---|
522 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
523 | { |
---|
524 | long i,j; |
---|
525 | |
---|
526 | for(i=nrl; i<=nrh; i++) { |
---|
527 | for(j=ncl; j<=nch; j++) { |
---|
528 | Z[i][j] = X[i][j] + y; |
---|
529 | } |
---|
530 | } |
---|
531 | } |
---|
532 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
533 | IMAGE_EXPORT(void) addc_si32matrix(sint32 **X,long nrl,long nrh, long ncl, long nch, sint32 y, sint32 **Z) |
---|
534 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
535 | { |
---|
536 | long i,j; |
---|
537 | |
---|
538 | for(i=nrl; i<=nrh; i++) { |
---|
539 | for(j=ncl; j<=nch; j++) { |
---|
540 | Z[i][j] = X[i][j] + y; |
---|
541 | } |
---|
542 | } |
---|
543 | } |
---|
544 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
545 | IMAGE_EXPORT(void) addc_ui32matrix(uint32 **X,long nrl,long nrh, long ncl, long nch, uint32 y, uint32 **Z) |
---|
546 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
547 | { |
---|
548 | long i,j; |
---|
549 | |
---|
550 | for(i=nrl; i<=nrh; i++) { |
---|
551 | for(j=ncl; j<=nch; j++) { |
---|
552 | Z[i][j] = X[i][j] + y; |
---|
553 | } |
---|
554 | } |
---|
555 | } |
---|
556 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
557 | IMAGE_EXPORT(void) addc_si64matrix(sint64 **X,long nrl,long nrh, long ncl, long nch, sint64 y, sint64 **Z) |
---|
558 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
559 | { |
---|
560 | long i,j; |
---|
561 | |
---|
562 | for(i=nrl; i<=nrh; i++) { |
---|
563 | for(j=ncl; j<=nch; j++) { |
---|
564 | Z[i][j] = X[i][j] + y; |
---|
565 | } |
---|
566 | } |
---|
567 | } |
---|
568 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
569 | IMAGE_EXPORT(void) addc_ui64matrix(uint64 **X,long nrl,long nrh, long ncl, long nch, uint64 y, uint64 **Z) |
---|
570 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
571 | { |
---|
572 | long i,j; |
---|
573 | |
---|
574 | for(i=nrl; i<=nrh; i++) { |
---|
575 | for(j=ncl; j<=nch; j++) { |
---|
576 | Z[i][j] = X[i][j] + y; |
---|
577 | } |
---|
578 | } |
---|
579 | } |
---|
580 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
581 | IMAGE_EXPORT(void) addc_f32matrix(float32 **X,long nrl,long nrh, long ncl, long nch, float32 y, float32 **Z) |
---|
582 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
583 | { |
---|
584 | long i,j; |
---|
585 | |
---|
586 | for(i=nrl; i<=nrh; i++) { |
---|
587 | for(j=ncl; j<=nch; j++) { |
---|
588 | Z[i][j] = X[i][j] + y; |
---|
589 | } |
---|
590 | } |
---|
591 | } |
---|
592 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
593 | IMAGE_EXPORT(void) addc_f64matrix(float64 **X,long nrl,long nrh, long ncl, long nch, float64 y, float64 **Z) |
---|
594 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
595 | { |
---|
596 | long i,j; |
---|
597 | |
---|
598 | for(i=nrl; i<=nrh; i++) { |
---|
599 | for(j=ncl; j<=nch; j++) { |
---|
600 | Z[i][j] = X[i][j] + y; |
---|
601 | } |
---|
602 | } |
---|
603 | } |
---|
604 | /* ---------------------------------------------------------------------------------------------- */ |
---|
605 | IMAGE_EXPORT(void) addc_rgb8matrix(rgb8 **X,long nrl,long nrh, long ncl, long nch, rgb8 y, rgb8 **Z) |
---|
606 | /* ---------------------------------------------------------------------------------------------- */ |
---|
607 | { |
---|
608 | long i,j; |
---|
609 | rgb8 x, z; |
---|
610 | |
---|
611 | for(i=nrl; i<=nrh; i++) { |
---|
612 | for(j=ncl; j<=nch; j++) { |
---|
613 | x = X[i][j]; |
---|
614 | RGB8_ADD(x,y,z); |
---|
615 | Z[i][j] = z; |
---|
616 | } |
---|
617 | } |
---|
618 | } |
---|
619 | /* -------------------------------------------------------------------------------------------------- */ |
---|
620 | IMAGE_EXPORT(void) addc_rgbx8matrix(rgbx8 **X,long nrl,long nrh, long ncl, long nch, rgbx8 y, rgbx8 **Z) |
---|
621 | /* -------------------------------------------------------------------------------------------------- */ |
---|
622 | { |
---|
623 | long i,j; |
---|
624 | rgbx8 x, z; |
---|
625 | |
---|
626 | for(i=nrl; i<=nrh; i++) { |
---|
627 | for(j=ncl; j<=nch; j++) { |
---|
628 | x = X[i][j]; |
---|
629 | RGBX8_ADD(x,y,z); |
---|
630 | Z[i][j] = z; |
---|
631 | } |
---|
632 | } |
---|
633 | } |
---|
634 | /* ------------------ */ |
---|
635 | /* --- Add Matrix --- */ |
---|
636 | /* ------------------ */ |
---|
637 | |
---|
638 | /* -------------------------------------------------------------------------------------------------- */ |
---|
639 | IMAGE_EXPORT(void) sub_ui8matrix(uint8 **X, long nrl,long nrh, long ncl, long nch, uint8 **Y, uint8 **Z) |
---|
640 | /* -------------------------------------------------------------------------------------------------- */ |
---|
641 | { |
---|
642 | long i, j; |
---|
643 | |
---|
644 | for(i=nrl; i<=nrh; i++) { |
---|
645 | for(j=ncl; j<=nch; j++) { |
---|
646 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
647 | } |
---|
648 | } |
---|
649 | } |
---|
650 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
651 | IMAGE_EXPORT(void) sub_si16matrix(sint16 **X, long nrl,long nrh, long ncl, long nch, sint16 **Y, sint16 **Z) |
---|
652 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
653 | { |
---|
654 | long i, j; |
---|
655 | |
---|
656 | for(i=nrl; i<=nrh; i++) { |
---|
657 | for(j=ncl; j<=nch; j++) { |
---|
658 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
659 | } |
---|
660 | } |
---|
661 | } |
---|
662 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
663 | IMAGE_EXPORT(void) sub_ui16matrix(uint16 **X, long nrl,long nrh, long ncl, long nch, uint16 **Y, uint16 **Z) |
---|
664 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
665 | { |
---|
666 | long i, j; |
---|
667 | |
---|
668 | for(i=nrl; i<=nrh; i++) { |
---|
669 | for(j=ncl; j<=nch; j++) { |
---|
670 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
671 | } |
---|
672 | } |
---|
673 | } |
---|
674 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
675 | IMAGE_EXPORT(void) sub_si32matrix(sint32 **X, long nrl,long nrh, long ncl, long nch, sint32 **Y, sint32 **Z) |
---|
676 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
677 | { |
---|
678 | long i, j; |
---|
679 | |
---|
680 | for(i=nrl; i<=nrh; i++) { |
---|
681 | for(j=ncl; j<=nch; j++) { |
---|
682 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
683 | } |
---|
684 | } |
---|
685 | } |
---|
686 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
687 | IMAGE_EXPORT(void) sub_ui32matrix(uint32 **X, long nrl,long nrh, long ncl, long nch, uint32 **Y, uint32 **Z) |
---|
688 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
689 | { |
---|
690 | long i, j; |
---|
691 | |
---|
692 | for(i=nrl; i<=nrh; i++) { |
---|
693 | for(j=ncl; j<=nch; j++) { |
---|
694 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
695 | } |
---|
696 | } |
---|
697 | } |
---|
698 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
699 | IMAGE_EXPORT(void) sub_si64matrix(sint64 **X, long nrl,long nrh, long ncl, long nch, sint64 **Y, sint64 **Z) |
---|
700 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
701 | { |
---|
702 | long i, j; |
---|
703 | |
---|
704 | for(i=nrl; i<=nrh; i++) { |
---|
705 | for(j=ncl; j<=nch; j++) { |
---|
706 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
707 | } |
---|
708 | } |
---|
709 | } |
---|
710 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
711 | IMAGE_EXPORT(void) sub_ui64matrix(uint64 **X, long nrl,long nrh, long ncl, long nch, uint64 **Y, uint64 **Z) |
---|
712 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
713 | { |
---|
714 | long i, j; |
---|
715 | |
---|
716 | for(i=nrl; i<=nrh; i++) { |
---|
717 | for(j=ncl; j<=nch; j++) { |
---|
718 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
719 | } |
---|
720 | } |
---|
721 | } |
---|
722 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
723 | IMAGE_EXPORT(void) sub_f32matrix(float32 **X, long nrl,long nrh, long ncl, long nch, float32 **Y, float32 **Z) |
---|
724 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
725 | { |
---|
726 | long i, j; |
---|
727 | |
---|
728 | for(i=nrl; i<=nrh; i++) { |
---|
729 | for(j=ncl; j<=nch; j++) { |
---|
730 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
731 | } |
---|
732 | } |
---|
733 | } |
---|
734 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
735 | IMAGE_EXPORT(void) sub_f64matrix(float64 **X, long nrl,long nrh, long ncl, long nch, float64 **Y, float64 **Z) |
---|
736 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
737 | { |
---|
738 | long i, j; |
---|
739 | |
---|
740 | for(i=nrl; i<=nrh; i++) { |
---|
741 | for(j=ncl; j<=nch; j++) { |
---|
742 | Z[i][j] = X[i][j] - Y[i][j]; |
---|
743 | } |
---|
744 | } |
---|
745 | } |
---|
746 | /* ----------------------------------------------------------------------------------------------- */ |
---|
747 | IMAGE_EXPORT(void) sub_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z) |
---|
748 | /* ----------------------------------------------------------------------------------------------- */ |
---|
749 | { |
---|
750 | long i, j; |
---|
751 | rgb8 x, y, z; |
---|
752 | |
---|
753 | for(i=nrl; i<=nrh; i++) { |
---|
754 | for(j=ncl; j<=nch; j++) { |
---|
755 | x = X[i][j]; |
---|
756 | y = Y[i][j]; |
---|
757 | RGB8_SUB(x,y,z); |
---|
758 | Z[i][j] = z; |
---|
759 | } |
---|
760 | } |
---|
761 | } |
---|
762 | /* --------------------------------------------------------------------------------------------------- */ |
---|
763 | IMAGE_EXPORT(void) sub_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z) |
---|
764 | /* --------------------------------------------------------------------------------------------------- */ |
---|
765 | { |
---|
766 | long i, j; |
---|
767 | rgbx8 x, y, z; |
---|
768 | |
---|
769 | for(i=nrl; i<=nrh; i++) { |
---|
770 | for(j=ncl; j<=nch; j++) { |
---|
771 | x = X[i][j]; |
---|
772 | y = Y[i][j]; |
---|
773 | RGBX8_SUB(x,y,z); |
---|
774 | Z[i][j] = z; |
---|
775 | } |
---|
776 | } |
---|
777 | } |
---|
778 | |
---|
779 | /* -------------------- */ |
---|
780 | /* --- Sub constant --- */ |
---|
781 | /* -------------------- */ |
---|
782 | |
---|
783 | /* ------------------------------------------------------------------------------------------------ */ |
---|
784 | IMAGE_EXPORT(void) subc_si8matrix(sint8 **X,long nrl,long nrh, long ncl, long nch, sint8 y, sint8 **Z) |
---|
785 | /* ------------------------------------------------------------------------------------------------ */ |
---|
786 | { |
---|
787 | long i,j; |
---|
788 | |
---|
789 | for(i=nrl; i<=nrh; i++) { |
---|
790 | for(j=ncl; j<=nch; j++) { |
---|
791 | Z[i][j] = X[i][j] - y; |
---|
792 | } |
---|
793 | } |
---|
794 | } |
---|
795 | /* ------------------------------------------------------------------------------------------------ */ |
---|
796 | IMAGE_EXPORT(void) subc_ui8matrix(uint8 **X,long nrl,long nrh, long ncl, long nch, uint8 y, uint8 **Z) |
---|
797 | /* ------------------------------------------------------------------------------------------------ */ |
---|
798 | { |
---|
799 | long i,j; |
---|
800 | |
---|
801 | for(i=nrl; i<=nrh; i++) { |
---|
802 | for(j=ncl; j<=nch; j++) { |
---|
803 | Z[i][j] = X[i][j] - y; |
---|
804 | } |
---|
805 | } |
---|
806 | } |
---|
807 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
808 | IMAGE_EXPORT(void) subc_si16matrix(sint16 **X,long nrl,long nrh, long ncl, long nch, sint16 y, sint16 **Z) |
---|
809 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
810 | { |
---|
811 | long i,j; |
---|
812 | |
---|
813 | for(i=nrl; i<=nrh; i++) { |
---|
814 | for(j=ncl; j<=nch; j++) { |
---|
815 | Z[i][j] = X[i][j] - y; |
---|
816 | } |
---|
817 | } |
---|
818 | } |
---|
819 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
820 | IMAGE_EXPORT(void) subc_ui16matrix(uint16 **X,long nrl,long nrh, long ncl, long nch, uint16 y, uint16 **Z) |
---|
821 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
822 | { |
---|
823 | long i,j; |
---|
824 | |
---|
825 | for(i=nrl; i<=nrh; i++) { |
---|
826 | for(j=ncl; j<=nch; j++) { |
---|
827 | Z[i][j] = X[i][j] - y; |
---|
828 | } |
---|
829 | } |
---|
830 | } |
---|
831 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
832 | IMAGE_EXPORT(void) subc_si32matrix(sint32 **X,long nrl,long nrh, long ncl, long nch, sint32 y, sint32 **Z) |
---|
833 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
834 | { |
---|
835 | long i,j; |
---|
836 | |
---|
837 | for(i=nrl; i<=nrh; i++) { |
---|
838 | for(j=ncl; j<=nch; j++) { |
---|
839 | Z[i][j] = X[i][j] - y; |
---|
840 | } |
---|
841 | } |
---|
842 | } |
---|
843 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
844 | IMAGE_EXPORT(void) subc_ui32matrix(uint32 **X,long nrl,long nrh, long ncl, long nch, uint32 y, uint32 **Z) |
---|
845 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
846 | { |
---|
847 | long i,j; |
---|
848 | |
---|
849 | for(i=nrl; i<=nrh; i++) { |
---|
850 | for(j=ncl; j<=nch; j++) { |
---|
851 | Z[i][j] = X[i][j] - y; |
---|
852 | } |
---|
853 | } |
---|
854 | } |
---|
855 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
856 | IMAGE_EXPORT(void) subc_si64matrix(sint64 **X,long nrl,long nrh, long ncl, long nch, sint64 y, sint64 **Z) |
---|
857 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
858 | { |
---|
859 | long i,j; |
---|
860 | |
---|
861 | for(i=nrl; i<=nrh; i++) { |
---|
862 | for(j=ncl; j<=nch; j++) { |
---|
863 | Z[i][j] = X[i][j] - y; |
---|
864 | } |
---|
865 | } |
---|
866 | } |
---|
867 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
868 | IMAGE_EXPORT(void) subc_ui64matrix(uint64 **X,long nrl,long nrh, long ncl, long nch, uint64 y, uint64 **Z) |
---|
869 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
870 | { |
---|
871 | long i,j; |
---|
872 | |
---|
873 | for(i=nrl; i<=nrh; i++) { |
---|
874 | for(j=ncl; j<=nch; j++) { |
---|
875 | Z[i][j] = X[i][j] - y; |
---|
876 | } |
---|
877 | } |
---|
878 | } |
---|
879 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
880 | IMAGE_EXPORT(void) subc_f32matrix(float32 **X,long nrl,long nrh, long ncl, long nch, float32 y, float32 **Z) |
---|
881 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
882 | { |
---|
883 | long i,j; |
---|
884 | |
---|
885 | for(i=nrl; i<=nrh; i++) { |
---|
886 | for(j=ncl; j<=nch; j++) { |
---|
887 | Z[i][j] = X[i][j] - y; |
---|
888 | } |
---|
889 | } |
---|
890 | } |
---|
891 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
892 | IMAGE_EXPORT(void) subc_f64matrix(float64 **X,long nrl,long nrh, long ncl, long nch, float64 y, float64 **Z) |
---|
893 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
894 | { |
---|
895 | long i,j; |
---|
896 | |
---|
897 | for(i=nrl; i<=nrh; i++) { |
---|
898 | for(j=ncl; j<=nch; j++) { |
---|
899 | Z[i][j] = X[i][j] - y; |
---|
900 | } |
---|
901 | } |
---|
902 | } |
---|
903 | /* ---------------------------------------------------------------------------------------------- */ |
---|
904 | IMAGE_EXPORT(void) subc_rgb8matrix(rgb8 **X,long nrl,long nrh, long ncl, long nch, rgb8 y, rgb8 **Z) |
---|
905 | /* ---------------------------------------------------------------------------------------------- */ |
---|
906 | { |
---|
907 | long i,j; |
---|
908 | rgb8 x, z; |
---|
909 | |
---|
910 | for(i=nrl; i<=nrh; i++) { |
---|
911 | for(j=ncl; j<=nch; j++) { |
---|
912 | x = X[i][j]; |
---|
913 | RGB8_SUB(x,y,z); |
---|
914 | Z[i][j] = z; |
---|
915 | } |
---|
916 | } |
---|
917 | } |
---|
918 | /* -------------------------------------------------------------------------------------------------- */ |
---|
919 | IMAGE_EXPORT(void) subc_rgbx8matrix(rgbx8 **X,long nrl,long nrh, long ncl, long nch, rgbx8 y, rgbx8 **Z) |
---|
920 | /* -------------------------------------------------------------------------------------------------- */ |
---|
921 | { |
---|
922 | long i,j; |
---|
923 | rgbx8 x, z; |
---|
924 | |
---|
925 | for(i=nrl; i<=nrh; i++) { |
---|
926 | for(j=ncl; j<=nch; j++) { |
---|
927 | x = X[i][j]; |
---|
928 | RGBX8_SUB(x,y,z); |
---|
929 | Z[i][j] = z; |
---|
930 | } |
---|
931 | } |
---|
932 | } |
---|
933 | /* -------------------- */ |
---|
934 | /* --- Mul constant --- */ |
---|
935 | /* -------------------- */ |
---|
936 | |
---|
937 | /* ------------------------------------------------------------------------------------------------ */ |
---|
938 | IMAGE_EXPORT(void) mulc_si8matrix(sint8 **X,long nrl,long nrh, long ncl, long nch, sint8 y, sint8 **Z) |
---|
939 | /* ------------------------------------------------------------------------------------------------ */ |
---|
940 | { |
---|
941 | long i,j; |
---|
942 | |
---|
943 | for(i=nrl; i<=nrh; i++) { |
---|
944 | for(j=ncl; j<=nch; j++) { |
---|
945 | Z[i][j] = X[i][j] * y; |
---|
946 | } |
---|
947 | } |
---|
948 | } |
---|
949 | /* ------------------------------------------------------------------------------------------------ */ |
---|
950 | IMAGE_EXPORT(void) mulc_ui8matrix(uint8 **X,long nrl,long nrh, long ncl, long nch, uint8 y, uint8 **Z) |
---|
951 | /* ------------------------------------------------------------------------------------------------ */ |
---|
952 | { |
---|
953 | long i,j; |
---|
954 | |
---|
955 | for(i=nrl; i<=nrh; i++) { |
---|
956 | for(j=ncl; j<=nch; j++) { |
---|
957 | Z[i][j] = X[i][j] * y; |
---|
958 | } |
---|
959 | } |
---|
960 | } |
---|
961 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
962 | IMAGE_EXPORT(void) mulc_si16matrix(sint16 **X,long nrl,long nrh, long ncl, long nch, sint16 y, sint16 **Z) |
---|
963 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
964 | { |
---|
965 | long i,j; |
---|
966 | |
---|
967 | for(i=nrl; i<=nrh; i++) { |
---|
968 | for(j=ncl; j<=nch; j++) { |
---|
969 | Z[i][j] = X[i][j] * y; |
---|
970 | } |
---|
971 | } |
---|
972 | } |
---|
973 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
974 | IMAGE_EXPORT(void) mulc_ui16matrix(uint16 **X,long nrl,long nrh, long ncl, long nch, uint16 y, uint16 **Z) |
---|
975 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
976 | { |
---|
977 | long i,j; |
---|
978 | |
---|
979 | for(i=nrl; i<=nrh; i++) { |
---|
980 | for(j=ncl; j<=nch; j++) { |
---|
981 | Z[i][j] = X[i][j] * y; |
---|
982 | } |
---|
983 | } |
---|
984 | } |
---|
985 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
986 | IMAGE_EXPORT(void) mulc_si32matrix(sint32 **X,long nrl,long nrh, long ncl, long nch, sint32 y, sint32 **Z) |
---|
987 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
988 | { |
---|
989 | long i,j; |
---|
990 | |
---|
991 | for(i=nrl; i<=nrh; i++) { |
---|
992 | for(j=ncl; j<=nch; j++) { |
---|
993 | Z[i][j] = X[i][j] * y; |
---|
994 | } |
---|
995 | } |
---|
996 | } |
---|
997 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
998 | IMAGE_EXPORT(void) mulc_ui32matrix(uint32 **X,long nrl,long nrh, long ncl, long nch, uint32 y, uint32 **Z) |
---|
999 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1000 | { |
---|
1001 | long i,j; |
---|
1002 | |
---|
1003 | for(i=nrl; i<=nrh; i++) { |
---|
1004 | for(j=ncl; j<=nch; j++) { |
---|
1005 | Z[i][j] = X[i][j] * y; |
---|
1006 | } |
---|
1007 | } |
---|
1008 | } |
---|
1009 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1010 | IMAGE_EXPORT(void) mulc_si64matrix(sint64 **X,long nrl,long nrh, long ncl, long nch, sint64 y, sint64 **Z) |
---|
1011 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1012 | { |
---|
1013 | long i,j; |
---|
1014 | |
---|
1015 | for(i=nrl; i<=nrh; i++) { |
---|
1016 | for(j=ncl; j<=nch; j++) { |
---|
1017 | Z[i][j] = X[i][j] * y; |
---|
1018 | } |
---|
1019 | } |
---|
1020 | } |
---|
1021 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1022 | IMAGE_EXPORT(void) mulc_ui64matrix(uint64 **X,long nrl,long nrh, long ncl, long nch, uint64 y, uint64 **Z) |
---|
1023 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1024 | { |
---|
1025 | long i,j; |
---|
1026 | |
---|
1027 | for(i=nrl; i<=nrh; i++) { |
---|
1028 | for(j=ncl; j<=nch; j++) { |
---|
1029 | Z[i][j] = X[i][j] * y; |
---|
1030 | } |
---|
1031 | } |
---|
1032 | } |
---|
1033 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1034 | IMAGE_EXPORT(void) mulc_f32matrix(float32 **X,long nrl,long nrh, long ncl, long nch, float32 y, float32 **Z) |
---|
1035 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1036 | { |
---|
1037 | long i,j; |
---|
1038 | |
---|
1039 | for(i=nrl; i<=nrh; i++) { |
---|
1040 | for(j=ncl; j<=nch; j++) { |
---|
1041 | Z[i][j] = X[i][j] * y; |
---|
1042 | } |
---|
1043 | } |
---|
1044 | } |
---|
1045 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1046 | IMAGE_EXPORT(void) mulc_f64matrix(float64 **X,long nrl,long nrh, long ncl, long nch, float64 y, float64 **Z) |
---|
1047 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1048 | { |
---|
1049 | long i,j; |
---|
1050 | |
---|
1051 | for(i=nrl; i<=nrh; i++) { |
---|
1052 | for(j=ncl; j<=nch; j++) { |
---|
1053 | Z[i][j] = X[i][j] * y; |
---|
1054 | } |
---|
1055 | } |
---|
1056 | } |
---|
1057 | /* ---------------------------------------------------------------------------------------------- */ |
---|
1058 | IMAGE_EXPORT(void) mulc_rgb8matrix(rgb8 **X,long nrl,long nrh, long ncl, long nch, rgb8 y, rgb8 **Z) |
---|
1059 | /* ---------------------------------------------------------------------------------------------- */ |
---|
1060 | { |
---|
1061 | long i,j; |
---|
1062 | rgb8 x, z; |
---|
1063 | |
---|
1064 | for(i=nrl; i<=nrh; i++) { |
---|
1065 | for(j=ncl; j<=nch; j++) { |
---|
1066 | x = X[i][j]; |
---|
1067 | RGB8_MUL(x,y,z); |
---|
1068 | Z[i][j] = z; |
---|
1069 | } |
---|
1070 | } |
---|
1071 | } |
---|
1072 | /* -------------------------------------------------------------------------------------------------- */ |
---|
1073 | IMAGE_EXPORT(void) mulc_rgbx8matrix(rgbx8 **X,long nrl,long nrh, long ncl, long nch, rgbx8 y, rgbx8 **Z) |
---|
1074 | /* -------------------------------------------------------------------------------------------------- */ |
---|
1075 | { |
---|
1076 | long i,j; |
---|
1077 | rgbx8 x, z; |
---|
1078 | |
---|
1079 | for(i=nrl; i<=nrh; i++) { |
---|
1080 | for(j=ncl; j<=nch; j++) { |
---|
1081 | x = X[i][j]; |
---|
1082 | RGBX8_MUL(x,y,z); |
---|
1083 | Z[i][j] = z; |
---|
1084 | } |
---|
1085 | } |
---|
1086 | } |
---|
1087 | /* --------------- */ |
---|
1088 | /* --- MulFrac --- */ |
---|
1089 | /* --------------- */ |
---|
1090 | |
---|
1091 | // Y=(a*X)/b |
---|
1092 | |
---|
1093 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
1094 | IMAGE_EXPORT(void) mulfrac_si8matrix(sint8 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint8 **Y) |
---|
1095 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
1096 | { |
---|
1097 | int i, j; |
---|
1098 | int32 x, y; |
---|
1099 | |
---|
1100 | for(i=nrl; i<=nrh; i++) { |
---|
1101 | for(j=ncl; j<=nch; j++) { |
---|
1102 | x = X[i][j]; |
---|
1103 | y = (a * x) / b; |
---|
1104 | Y[i][j] = (sint8) y; |
---|
1105 | } |
---|
1106 | } |
---|
1107 | } |
---|
1108 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
1109 | IMAGE_EXPORT(void) mulfrac_ui8matrix(uint8 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint8 **Y) |
---|
1110 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
1111 | { |
---|
1112 | int i, j; |
---|
1113 | int32 x, y; |
---|
1114 | |
---|
1115 | for(i=nrl; i<=nrh; i++) { |
---|
1116 | for(j=ncl; j<=nch; j++) { |
---|
1117 | x = X[i][j]; |
---|
1118 | y = (a * x) / b; |
---|
1119 | Y[i][j] = (uint8) y; |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1124 | IMAGE_EXPORT(void) mulfrac_si16matrix(sint16 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint16 **Y) |
---|
1125 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1126 | { |
---|
1127 | int i, j; |
---|
1128 | int32 x, y; |
---|
1129 | |
---|
1130 | for(i=nrl; i<=nrh; i++) { |
---|
1131 | for(j=ncl; j<=nch; j++) { |
---|
1132 | x = X[i][j]; |
---|
1133 | y = (a * x) / b; |
---|
1134 | Y[i][j] = (sint16) y; |
---|
1135 | } |
---|
1136 | } |
---|
1137 | } |
---|
1138 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1139 | IMAGE_EXPORT(void) mulfrac_ui16matrix(uint16 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint16 **Y) |
---|
1140 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1141 | { |
---|
1142 | int i, j; |
---|
1143 | int32 x, y; |
---|
1144 | |
---|
1145 | for(i=nrl; i<=nrh; i++) { |
---|
1146 | for(j=ncl; j<=nch; j++) { |
---|
1147 | x = X[i][j]; |
---|
1148 | y = (a * x) / b; |
---|
1149 | Y[i][j] = (uint16) y; |
---|
1150 | } |
---|
1151 | } |
---|
1152 | } |
---|
1153 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1154 | IMAGE_EXPORT(void) mulfrac_si32matrix(sint32 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint32 **Y) |
---|
1155 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1156 | { |
---|
1157 | int i, j; |
---|
1158 | int32 x, y; |
---|
1159 | |
---|
1160 | for(i=nrl; i<=nrh; i++) { |
---|
1161 | for(j=ncl; j<=nch; j++) { |
---|
1162 | x = X[i][j]; |
---|
1163 | y = (a * x) / b; |
---|
1164 | Y[i][j] = (sint16) y; |
---|
1165 | } |
---|
1166 | } |
---|
1167 | } |
---|
1168 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1169 | IMAGE_EXPORT(void) mulfrac_ui32matrix(uint32 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint32 **Y) |
---|
1170 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1171 | { |
---|
1172 | int i, j; |
---|
1173 | int32 x, y; |
---|
1174 | |
---|
1175 | for(i=nrl; i<=nrh; i++) { |
---|
1176 | for(j=ncl; j<=nch; j++) { |
---|
1177 | x = X[i][j]; |
---|
1178 | y = (a * x) / b; |
---|
1179 | Y[i][j] = (uint16) y; |
---|
1180 | } |
---|
1181 | } |
---|
1182 | } |
---|
1183 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1184 | IMAGE_EXPORT(void) mulfrac_si64matrix(sint64 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint64 **Y) |
---|
1185 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1186 | { |
---|
1187 | int i, j; |
---|
1188 | sint64 x, y; |
---|
1189 | |
---|
1190 | for(i=nrl; i<=nrh; i++) { |
---|
1191 | for(j=ncl; j<=nch; j++) { |
---|
1192 | x = X[i][j]; |
---|
1193 | y = (a * x) / b; |
---|
1194 | Y[i][j] = (sint64) y; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | } |
---|
1198 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1199 | IMAGE_EXPORT(void) mulfrac_ui64matrix(uint64 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, uint64 **Y) |
---|
1200 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1201 | { |
---|
1202 | int i, j; |
---|
1203 | uint64 x, y; |
---|
1204 | |
---|
1205 | for(i=nrl; i<=nrh; i++) { |
---|
1206 | for(j=ncl; j<=nch; j++) { |
---|
1207 | x = X[i][j]; |
---|
1208 | y = (a * x) / b; |
---|
1209 | Y[i][j] = (uint64) y; |
---|
1210 | } |
---|
1211 | } |
---|
1212 | } |
---|
1213 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
1214 | IMAGE_EXPORT(void) mulfrac_rgb8matrix(rgb8 **X, long nrl,long nrh, long ncl, long nch, rgb32 a, rgb32 b, rgb8 **Y) |
---|
1215 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
1216 | { |
---|
1217 | int i, j; |
---|
1218 | rgb32 y32; |
---|
1219 | rgb8 x8, y8; |
---|
1220 | |
---|
1221 | |
---|
1222 | for(i=nrl; i<=nrh; i++) { |
---|
1223 | for(j=ncl; j<=nch; j++) { |
---|
1224 | x8 = X[i][j]; |
---|
1225 | RGB8_MULFRAC(x8,a,b,y32); |
---|
1226 | RGB32CAST8(y32,y8); |
---|
1227 | Y[i][j] = y8; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | } |
---|
1231 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1232 | IMAGE_EXPORT(void) mulfrac_rgb8xmatrix(rgbx8 **X, long nrl,long nrh, long ncl, long nch, rgbx32 a, rgbx32 b, rgbx8 **Y) |
---|
1233 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1234 | { |
---|
1235 | int i, j; |
---|
1236 | rgbx32 y32; |
---|
1237 | rgbx8 x8, y8; |
---|
1238 | |
---|
1239 | for(i=nrl; i<=nrh; i++) { |
---|
1240 | for(j=ncl; j<=nch; j++) { |
---|
1241 | x8 = X[i][j]; |
---|
1242 | RGBX8_MULFRAC(x8,a,b,y32); |
---|
1243 | RGBX32CAST8(y32,y8); |
---|
1244 | Y[i][j] = y8; |
---|
1245 | } |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | /* ---------------- */ |
---|
1250 | /* --- MulShift --- */ |
---|
1251 | /* ---------------- */ |
---|
1252 | |
---|
1253 | // m3 = (a*m1)>>s |
---|
1254 | |
---|
1255 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
1256 | IMAGE_EXPORT(void) mulshift_si8matrix(sint8 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint8 **Y) |
---|
1257 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
1258 | { |
---|
1259 | int i, j; |
---|
1260 | int32 x, y; |
---|
1261 | |
---|
1262 | for(i=nrl; i<=nrh; i++) { |
---|
1263 | for(j=ncl; j<=nch; j++) { |
---|
1264 | x = X[i][j]; |
---|
1265 | y = (a * x) >> s; |
---|
1266 | Y[i][j] = (sint8) y; |
---|
1267 | } |
---|
1268 | } |
---|
1269 | } |
---|
1270 | /* --------------------------------------------------------------------------------------------------------------- */ |
---|
1271 | IMAGE_EXPORT(void) mulshift_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint8 **Y) |
---|
1272 | /* --------------------------------------------------------------------------------------------------------------- */ |
---|
1273 | { |
---|
1274 | int i, j; |
---|
1275 | int32 x, y; |
---|
1276 | |
---|
1277 | for(i=nrl; i<=nrh; i++) { |
---|
1278 | for(j=ncl; j<=nch; j++) { |
---|
1279 | x = X[i][j]; |
---|
1280 | y = (a * x) >> s; |
---|
1281 | Y[i][j] = (uint8) y; |
---|
1282 | } |
---|
1283 | } |
---|
1284 | } |
---|
1285 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1286 | IMAGE_EXPORT(void) mulshift_si16matrix(sint16 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint16 **Y) |
---|
1287 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1288 | { |
---|
1289 | int i, j; |
---|
1290 | int32 x, y; |
---|
1291 | |
---|
1292 | for(i=nrl; i<=nrh; i++) { |
---|
1293 | for(j=ncl; j<=nch; j++) { |
---|
1294 | x = X[i][j]; |
---|
1295 | y = (a * x) >> s; |
---|
1296 | Y[i][j] = (sint16) y; |
---|
1297 | } |
---|
1298 | } |
---|
1299 | } |
---|
1300 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1301 | IMAGE_EXPORT(void) mulshift_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint16 **Y) |
---|
1302 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1303 | { |
---|
1304 | int i, j; |
---|
1305 | int32 x, y; |
---|
1306 | |
---|
1307 | for(i=nrl; i<=nrh; i++) { |
---|
1308 | for(j=ncl; j<=nch; j++) { |
---|
1309 | x = X[i][j]; |
---|
1310 | y = (a * x) >> s; |
---|
1311 | Y[i][j] = (uint16) y; |
---|
1312 | } |
---|
1313 | } |
---|
1314 | } |
---|
1315 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1316 | IMAGE_EXPORT(void) mulshift_si32matrix(sint32 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint32 **Y) |
---|
1317 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1318 | { |
---|
1319 | int i, j; |
---|
1320 | int32 x, y; |
---|
1321 | |
---|
1322 | for(i=nrl; i<=nrh; i++) { |
---|
1323 | for(j=ncl; j<=nch; j++) { |
---|
1324 | x = X[i][j]; |
---|
1325 | y = (a * x) >> s; |
---|
1326 | Y[i][j] = (sint32) y; |
---|
1327 | } |
---|
1328 | } |
---|
1329 | } |
---|
1330 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1331 | IMAGE_EXPORT(void) mulshift_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, int32 a, int32 s, uint32 **Y) |
---|
1332 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
1333 | { |
---|
1334 | int i, j; |
---|
1335 | int32 x, y; |
---|
1336 | |
---|
1337 | for(i=nrl; i<=nrh; i++) { |
---|
1338 | for(j=ncl; j<=nch; j++) { |
---|
1339 | x = X[i][j]; |
---|
1340 | y = (a * x) >> s; |
---|
1341 | Y[i][j] = (uint32) y; |
---|
1342 | } |
---|
1343 | } |
---|
1344 | } |
---|
1345 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
1346 | IMAGE_EXPORT(void) mulshift_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb32 a, rgb32 s, rgb8 **Y) |
---|
1347 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
1348 | { |
---|
1349 | int i, j; |
---|
1350 | rgb32 y32; |
---|
1351 | rgb8 x8, y8; |
---|
1352 | |
---|
1353 | for(i=nrl; i<=nrh; i++) { |
---|
1354 | for(j=ncl; j<=nch; j++) { |
---|
1355 | x8 = X[i][j]; |
---|
1356 | RGB8_MULSHIFT(x8,a,s,y32); |
---|
1357 | RGB32CAST8(y32,y8); |
---|
1358 | Y[i][j] = y8; |
---|
1359 | } |
---|
1360 | } |
---|
1361 | } |
---|
1362 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1363 | IMAGE_EXPORT(void) mulshift_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx32 a, rgbx32 s, rgbx8 **Y) |
---|
1364 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
1365 | { |
---|
1366 | int i, j; |
---|
1367 | rgbx32 y32; |
---|
1368 | rgbx8 x8, y8; |
---|
1369 | |
---|
1370 | for(i=nrl; i<=nrh; i++) { |
---|
1371 | for(j=ncl; j<=nch; j++) { |
---|
1372 | x8 = X[i][j]; |
---|
1373 | RGBX8_MULSHIFT(x8,a,s,y32); |
---|
1374 | RGBX32CAST8(y32,y8); |
---|
1375 | Y[i][j] = y8; |
---|
1376 | } |
---|
1377 | } |
---|
1378 | } |
---|