! * \brief kernelInvert() * * \param[in] kels source kel, to be inverted * \return keld spatially inverted, about the origin, or NULL on error * * * Notes: * (1) For convolution, the kernel is spatially inverted before * a "correlation" operation is done between the kernel and the image. * */
| 453 | * </pre> |
| 454 | */ |
| 455 | L_KERNEL * |
| 456 | kernelInvert(L_KERNEL *kels) |
| 457 | { |
| 458 | l_int32 i, j, sx, sy, cx, cy; |
| 459 | L_KERNEL *keld; |
| 460 | |
| 461 | PROCNAME("kernelInvert"); |
| 462 | |
| 463 | if (!kels) |
| 464 | return (L_KERNEL *)ERROR_PTR("kels not defined", procName, NULL); |
| 465 | |
| 466 | kernelGetParameters(kels, &sy, &sx, &cy, &cx); |
| 467 | if ((keld = kernelCreate(sy, sx)) == NULL) |
| 468 | return (L_KERNEL *)ERROR_PTR("keld not made", procName, NULL); |
| 469 | keld->cy = sy - 1 - cy; |
| 470 | keld->cx = sx - 1 - cx; |
| 471 | |
| 472 | for (i = 0; i < sy; i++) |
| 473 | for (j = 0; j < sx; j++) |
| 474 | keld->data[i][j] = kels->data[sy - 1 - i][sx - 1 - j]; |
| 475 | |
| 476 | return keld; |
| 477 | } |
| 478 | |
| 479 | |
| 480 | /*----------------------------------------------------------------------* |
no test coverage detected