Changeset 821 for soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2.c
- Timestamp:
- May 6, 2016, 3:06:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2.c
r772 r821 17 17 #include <malloc.h> 18 18 #include <math.h> // fabs 19 // #include <memory.h> // memcpy 20 19 20 #include "nrc_os_config.h" 21 21 #include "mypredef.h" 22 22 #include "nrtype.h" … … 25 25 #include "nrkernel.h" 26 26 27 #include "nrarith1.h"28 27 #include "nrarith2.h" 29 28 … … 32 31 /* ------------------ */ 33 32 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 } 33 #undef min_type_matrix 34 #define min_type_matrix(t) \ 35 t short_name(t,min_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 36 { \ 37 t minimum = m[nrl][nrh]; \ 38 for (int32_t i = nrl; i <= nrh; i++) { \ 39 for (int32_t j = ncl; j <= nch; j++) { \ 40 if (m[i][j] < minimum) { \ 41 minimum = m[i][j]; \ 42 } \ 43 } \ 44 } \ 45 return minimum; \ 46 } 47 48 min_type_matrix(int8_t); 49 min_type_matrix(uint8_t); 50 min_type_matrix(int16_t); 51 min_type_matrix(uint16_t); 52 min_type_matrix(int32_t); 53 min_type_matrix(uint32_t); 54 min_type_matrix(int64_t); 55 min_type_matrix(uint64_t); 56 min_type_matrix(float); 57 min_type_matrix(double); 58 174 59 175 60 /* ------------------ */ … … 177 62 /* ------------------ */ 178 63 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 } 64 #undef max_type_matrix 65 #define max_type_matrix(t) \ 66 t short_name(t,max_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ 67 { \ 68 t maximum = m[nrl][nrh]; \ 69 for (int32_t i = nrl; i <= nrh; i++) { \ 70 for (int32_t j = ncl; j <= nch; j++) { \ 71 if (m[i][j] > maximum) { \ 72 maximum = m[i][j]; \ 73 } \ 74 } \ 75 } \ 76 return maximum; \ 77 } 78 79 max_type_matrix(int8_t); 80 max_type_matrix(uint8_t); 81 max_type_matrix(int16_t); 82 max_type_matrix(uint16_t); 83 max_type_matrix(int32_t); 84 max_type_matrix(uint32_t); 85 max_type_matrix(int64_t); 86 max_type_matrix(uint64_t); 87 max_type_matrix(float); 88 max_type_matrix(double); 89 90 332 91 333 92 /* ------------------ */ … … 335 94 /* ------------------ */ 336 95 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 } 96 97 #undef add_type_matrix 98 #define add_type_matrix(t) \ 99 void short_name(t,add_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \ 100 { \ 101 for (int32_t i = nrl; i <= nrh; i++) { \ 102 for (int32_t j = ncl; j <= nch; j++) { \ 103 Z[i][j] = X[i][j] + Y[i][j]; \ 104 } \ 105 } \ 106 } 107 108 add_type_matrix(int8_t); 109 add_type_matrix(uint8_t); 110 add_type_matrix(int16_t); 111 add_type_matrix(uint16_t); 112 add_type_matrix(int32_t); 113 add_type_matrix(uint32_t); 114 add_type_matrix(int64_t); 115 add_type_matrix(uint64_t); 116 add_type_matrix(float); 117 add_type_matrix(double); 118 119 445 120 /* ----------------------------------------------------------------------------------------------- */ 446 IMAGE_EXPORT(void) add_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)121 void add_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** Y, rgb8 ** Z) 447 122 /* ----------------------------------------------------------------------------------------------- */ 448 123 { 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 } 124 for (int32_t i = nrl; i <= nrh; i++) { 125 for (int32_t j = ncl; j <= nch; j++) { 126 //z = x + y; 127 RGB8_ADD(X[i][j], Y[i][j], Z[i][j]); 128 } 129 } 130 } 131 462 132 /* --------------------------------------------------------------------------------------------------- */ 463 IMAGE_EXPORT(void) add_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)133 void add_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 ** Y, rgbx8 ** Z) 464 134 /* --------------------------------------------------------------------------------------------------- */ 465 135 { 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 } 136 for (int32_t i = nrl; i <= nrh; i++) { 137 for (int32_t j = ncl; j <= nch; j++) { 138 //z = x + y; 139 RGBX8_ADD(X[i][j], Y[i][j], Z[i][j]); 140 } 141 } 478 142 } 479 143 … … 482 146 /* -------------------- */ 483 147 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 } 148 #undef addc_type_matrix 149 #define addc_type_matrix(t) \ 150 void short_name(t,addc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 151 { \ 152 for (int32_t i = nrl; i <= nrh; i++) { \ 153 for (int32_t j = ncl; j <= nch; j++) { \ 154 Z[i][j] = X[i][j] + y; \ 155 } \ 156 } \ 157 } 158 159 addc_type_matrix(int8_t); 160 addc_type_matrix(uint8_t); 161 addc_type_matrix(int16_t); 162 addc_type_matrix(uint16_t); 163 addc_type_matrix(int32_t); 164 addc_type_matrix(uint32_t); 165 addc_type_matrix(int64_t); 166 addc_type_matrix(uint64_t); 167 addc_type_matrix(float); 168 addc_type_matrix(double); 169 170 171 172 /* ---------------------------------------------------------------------------------------------- */ 173 void addc_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z) 174 /* ---------------------------------------------------------------------------------------------- */ 175 { 176 for (int32_t i = nrl; i <= nrh; i++) { 177 for (int32_t j = ncl; j <= nch; j++) { 178 RGB8_ADD(X[i][j], y, Z[i][j]); 179 } 180 } 181 } 182 183 /* -------------------------------------------------------------------------------------------------- */ 184 void addc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z) 185 /* -------------------------------------------------------------------------------------------------- */ 186 { 187 for (int32_t i = nrl; i <= nrh; i++) { 188 for (int32_t j = ncl; j <= nch; j++) { 189 RGBX8_ADD(X[i][j], y, Z[i][j]); 190 } 191 } 192 } 193 194 195 /* ------------------ */ 196 /* --- Sub Matrix --- */ 197 /* ------------------ */ 198 199 #undef sub_type_matrix 200 #define sub_type_matrix(t) \ 201 void short_name(t,sub_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \ 202 { \ 203 for (int32_t i = nrl; i <= nrh; i++) { \ 204 for (int32_t j = ncl; j <= nch; j++) { \ 205 Z[i][j] = X[i][j] - Y[i][j]; \ 206 } \ 207 } \ 208 } 209 210 sub_type_matrix(int8_t); 211 sub_type_matrix(uint8_t); 212 sub_type_matrix(int16_t); 213 sub_type_matrix(uint16_t); 214 sub_type_matrix(int32_t); 215 sub_type_matrix(uint32_t); 216 sub_type_matrix(int64_t); 217 sub_type_matrix(uint64_t); 218 sub_type_matrix(float); 219 sub_type_matrix(double); 220 221 746 222 /* ----------------------------------------------------------------------------------------------- */ 747 IMAGE_EXPORT(void) sub_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)223 void sub_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 ** Y, rgb8 ** Z) 748 224 /* ----------------------------------------------------------------------------------------------- */ 749 225 { 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 } 226 for (int32_t i = nrl; i <= nrh; i++) { 227 for (int32_t j = ncl; j <= nch; j++) { 228 //z = x + y; 229 RGB8_SUB(X[i][j], Y[i][j], Z[i][j]); 230 } 231 } 232 } 233 762 234 /* --------------------------------------------------------------------------------------------------- */ 763 IMAGE_EXPORT(void) sub_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)235 void sub_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 ** Y, rgbx8 ** Z) 764 236 /* --------------------------------------------------------------------------------------------------- */ 765 237 { 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 } 238 for (int32_t i = nrl; i <= nrh; i++) { 239 for (int32_t j = ncl; j <= nch; j++) { 240 //z = x + y; 241 RGBX8_SUB(X[i][j], Y[i][j], Z[i][j]); 242 } 243 } 244 } 245 778 246 779 247 /* -------------------- */ … … 781 249 /* -------------------- */ 782 250 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 } 251 #undef subc_type_matrix 252 #define subc_type_matrix(t) \ 253 void short_name(t,subc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 254 { \ 255 for (int32_t i = nrl; i <= nrh; i++) { \ 256 for (int32_t j = ncl; j <= nch; j++) { \ 257 Z[i][j] = X[i][j] - y; \ 258 } \ 259 } \ 260 } 261 262 subc_type_matrix(int8_t); 263 subc_type_matrix(uint8_t); 264 subc_type_matrix(int16_t); 265 subc_type_matrix(uint16_t); 266 subc_type_matrix(int32_t); 267 subc_type_matrix(uint32_t); 268 subc_type_matrix(int64_t); 269 subc_type_matrix(uint64_t); 270 subc_type_matrix(float); 271 subc_type_matrix(double); 272 273 274 275 /* ---------------------------------------------------------------------------------------------- */ 276 void subc_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z) 277 /* ---------------------------------------------------------------------------------------------- */ 278 { 279 for (int32_t i = nrl; i <= nrh; i++) { 280 for (int32_t j = ncl; j <= nch; j++) { 281 RGB8_SUB(X[i][j], y, Z[i][j]); 282 } 283 } 284 } 285 286 /* -------------------------------------------------------------------------------------------------- */ 287 void subc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z) 288 /* -------------------------------------------------------------------------------------------------- */ 289 { 290 for (int32_t i = nrl; i <= nrh; i++) { 291 for (int32_t j = ncl; j <= nch; j++) { 292 RGBX8_SUB(X[i][j], y, Z[i][j]); 293 } 294 } 295 } 296 297 933 298 /* -------------------- */ 934 299 /* --- Mul constant --- */ 935 300 /* -------------------- */ 936 301 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 } 302 #undef mulc_type_matrix 303 #define mulc_type_matrix(t) \ 304 void short_name(t,mulc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \ 305 { \ 306 for (int32_t i = nrl; i <= nrh; i++) { \ 307 for (int32_t j = ncl; j <= nch; j++) { \ 308 Z[i][j] = X[i][j] * y; \ 309 } \ 310 } \ 311 } 312 313 mulc_type_matrix(int8_t); 314 mulc_type_matrix(uint8_t); 315 mulc_type_matrix(int16_t); 316 mulc_type_matrix(uint16_t); 317 mulc_type_matrix(int32_t); 318 mulc_type_matrix(uint32_t); 319 mulc_type_matrix(int64_t); 320 mulc_type_matrix(uint64_t); 321 mulc_type_matrix(float); 322 mulc_type_matrix(double); 323 324 325 326 /* ---------------------------------------------------------------------------------------------- */ 327 void mulc_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 y, rgb8 ** Z) 328 /* ---------------------------------------------------------------------------------------------- */ 329 { 330 for (int32_t i = nrl; i <= nrh; i++) { 331 for (int32_t j = ncl; j <= nch; j++) { 332 RGB8_MUL(X[i][j], y, Z[i][j]); 333 } 334 } 335 } 336 337 /* -------------------------------------------------------------------------------------------------- */ 338 void mulc_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 ** Z) 339 /* -------------------------------------------------------------------------------------------------- */ 340 { 341 for (int32_t i = nrl; i <= nrh; i++) { 342 for (int32_t j = ncl; j <= nch; j++) { 343 RGBX8_MUL(X[i][j], y, Z[i][j]); 344 } 345 } 346 } 347 348 1087 349 /* --------------- */ 1088 350 /* --- MulFrac --- */ 1089 351 /* --------------- */ 1090 352 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 } 353 // Y = (a * X) / b 354 355 #undef mulfrac_type_matrix 356 #define mulfrac_type_matrix(t) \ 357 void short_name(t,mulfrac_,matrix)(t ** X, int32_t nrl, int32_t nrh, \ 358 int32_t ncl, int32_t nch, int32_t a, int32_t b, t ** Y) \ 359 { \ 360 for (int32_t i = nrl; i <= nrh; i++) { \ 361 for (int32_t j = ncl; j <= nch; j++) { \ 362 Y[i][j] = (t) ((a * X[i][j]) / b); \ 363 } \ 364 } \ 365 } 366 367 mulfrac_type_matrix(int8_t); 368 mulfrac_type_matrix(uint8_t); 369 mulfrac_type_matrix(int16_t); 370 mulfrac_type_matrix(uint16_t); 371 mulfrac_type_matrix(int32_t); 372 mulfrac_type_matrix(uint32_t); 373 mulfrac_type_matrix(int64_t); 374 mulfrac_type_matrix(uint64_t); 375 mulfrac_type_matrix(float); 376 mulfrac_type_matrix(double); 377 378 379 /* ------------------------------------------------------------------------------------------------------------ */ 380 void mulfrac_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 a, rgb32 b, rgb8 ** Y) 381 /* ------------------------------------------------------------------------------------------------------------ */ 382 { 383 rgb32 y32; 384 rgb8 x8, y8; 385 for (int32_t i = nrl; i <= nrh; i++) { 386 for (int32_t j = ncl; j <= nch; j++) { 387 x8 = X[i][j]; 388 RGB8_MULFRAC(x8, a, b, y32); 389 RGB32CAST8(y32, y8); 390 Y[i][j] = y8; 391 } 392 } 393 } 394 1123 395 /* ----------------------------------------------------------------------------------------------------------------- */ 1124 IMAGE_EXPORT(void) mulfrac_si16matrix(sint16 **X, long nrl, long nrh, long ncl, long nch, int32 a, int32 b, sint16 **Y)396 void mulfrac_rgb8xmatrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx32 a, rgbx32 b, rgbx8 ** Y) 1125 397 /* ----------------------------------------------------------------------------------------------------------------- */ 1126 398 { 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 } 399 rgbx32 y32; 400 rgbx8 x8, y8; 401 for (int32_t i = nrl; i <= nrh; i++) { 402 for (int32_t j = ncl; j <= nch; j++) { 403 x8 = X[i][j]; 404 RGBX8_MULFRAC(x8, a, b, y32); 405 RGBX32CAST8(y32, y8); 406 Y[i][j] = y8; 407 } 408 } 409 } 410 1248 411 1249 412 /* ---------------- */ … … 1251 414 /* ---------------- */ 1252 415 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 } 416 // m3 = (a * m1) >> s 417 418 #undef mulshift_type_matrix 419 #define mulshift_type_matrix(t) \ 420 void short_name(t,mulshift_,matrix)(t ** X, int32_t nrl, int32_t nrh, \ 421 int32_t ncl, int32_t nch, int32_t a, int32_t s, t ** Y) \ 422 { \ 423 for (int32_t i = nrl; i <= nrh; i++) { \ 424 for (int32_t j = ncl; j <= nch; j++) { \ 425 Y[i][j] = (t) ((a * X[i][j]) >> s); \ 426 } \ 427 } \ 428 } 429 430 mulshift_type_matrix(int8_t); 431 mulshift_type_matrix(uint8_t); 432 mulshift_type_matrix(int16_t); 433 mulshift_type_matrix(uint16_t); 434 mulshift_type_matrix(int32_t); 435 mulshift_type_matrix(uint32_t); 436 mulshift_type_matrix(int64_t); 437 mulshift_type_matrix(uint64_t); 438 439 440 /* ---------------------------------------------------------------------------------------------------------------- */ 441 void mulshift_rgb8matrix(rgb8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 a, rgb32 s, rgb8 ** Y) 442 /* ---------------------------------------------------------------------------------------------------------------- */ 443 { 444 rgb32 y32; 445 rgb8 x8, y8; 446 for (int32_t i = nrl; i <= nrh; i++) { 447 for (int32_t j = ncl; j <= nch; j++) { 448 x8 = X[i][j]; 449 RGB8_MULSHIFT(x8, a, s, y32); 450 RGB32CAST8(y32, y8); 451 Y[i][j] = y8; 452 } 453 } 454 } 455 1285 456 /* ----------------------------------------------------------------------------------------------------------------- */ 1286 IMAGE_EXPORT(void) mulshift_si16matrix(sint16 **X, long nrl, long nrh,long ncl, long nch, int32 a, int32 s, sint16 **Y)457 void mulshift_rgbx8matrix(rgbx8 ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgbx32 a, rgbx32 s, rgbx8 ** Y) 1287 458 /* ----------------------------------------------------------------------------------------------------------------- */ 1288 459 { 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 } 460 rgbx32 y32; 461 rgbx8 x8, y8; 462 for (int32_t i = nrl; i <= nrh; i++) { 463 for (int32_t j = ncl; j <= nch; j++) { 464 x8 = X[i][j]; 465 RGBX8_MULSHIFT(x8, a, s, y32); 466 RGBX32CAST8(y32, y8); 467 Y[i][j] = y8; 468 } 469 } 470 } 471 472 // Local Variables: 473 // tab-width: 4 474 // c-basic-offset: 4 475 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 476 // indent-tabs-mode: nil 477 // End: 478 479 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 480
Note: See TracChangeset
for help on using the changeset viewer.