Changeset 12745 for trunk/psLib/src/imageops/psImageGeomManip.c
- Timestamp:
- Apr 4, 2007, 2:17:29 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageGeomManip.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageGeomManip.c
r12741 r12745 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-04-0 4 22:42:02$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-04-05 00:17:29 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 568 568 } 569 569 570 // XXX this function seems to work (except for edge pixels and masked pixels571 // but the function below does not define the right 3x3 kernels. look this572 // up573 psImage *p_psImageShiftKernel_F32(574 psImage *out,575 const psImage *input,576 const psImage *kernel)577 {578 579 PS_ASSERT_IMAGE_NON_NULL(input, NULL);580 PS_ASSERT_IMAGE_NON_NULL(kernel, NULL);581 582 if ((kernel->numCols % 2 == 0) || (kernel->numRows % 2 == 0)) {583 psError(PS_ERR_BAD_PARAMETER_NULL, true,584 _("kernel must have odd dimensions"));585 return NULL;586 }587 int Xk = (kernel->numCols - 1) / 2;588 int Yk = (kernel->numRows - 1) / 2;589 590 int outRows = input->numRows;591 int outCols = input->numCols;592 out = psImageRecycle(out, outCols, outRows, input->type.type);593 psImageInit (out, 0.0);594 595 // need to handle the edge cases...596 for (int row = 1; row < outRows-1; row++) {597 psF32 *outRow = out->data.F32[row];598 psF32 **inValue = input->data.F32;599 for (int col = 1; col < outCols-1; col++) {600 double value = 0;601 double norm = 0;602 psF32 **kernValue = kernel->data.F32;603 for (int yi = -Yk; yi <= Yk; yi++) {604 for (int xi = -Xk; xi <= Xk; xi++) {605 value += inValue[row+yi][col+xi]*kernValue[yi+Yk][xi+Xk];606 norm += kernValue[yi+Yk][xi+Xk];607 }608 }609 // include the mask tests and divide-by-zero test610 outRow[col] = value / norm;611 }612 }613 614 return (out);615 }616 617 // XXX fix the definition of the interpolation kernels and add integer shifts618 psImage *psImageShiftKernel (619 psImage *out,620 const psImage *input,621 float dx, float dy, psImageInterpolateMode mode)622 {623 624 psImage *kernel = NULL;625 626 switch (mode) {627 case PS_INTERPOLATE_BICUBE:628 kernel = psImageAlloc (3, 3, PS_TYPE_F32);629 for (int iy = -1; iy <= +1; iy++) {630 for (int ix = -1; ix <= +1; ix++) {631 kernel->data.F32[iy+1][ix+1] = 5 - 3*PS_SQR(ix+dx) - 3*PS_SQR(iy+dy);632 }633 }634 out = p_psImageShiftKernel_F32 (out, input, kernel);635 break;636 637 case PS_INTERPOLATE_GAUSS:638 kernel = psImageAlloc (3, 3, PS_TYPE_F32);639 for (int iy = -1; iy <= +1; iy++) {640 for (int ix = -1; ix <= +1; ix++) {641 kernel->data.F32[iy+1][ix+1] = exp(-0.5*PS_SQR(ix+dx) -0.5*PS_SQR(iy+dy));642 }643 }644 out = p_psImageShiftKernel_F32 (out, input, kernel);645 break;646 647 default:648 psError(PS_ERR_BAD_PARAMETER_NULL, true,649 _("shift kernel for %d not defined"), mode);650 return NULL;651 }652 psFree (kernel);653 return (out);654 }655 656 570 psImage* psImageShift(psImage* out, 657 571 const psImage* input,
Note:
See TracChangeset
for help on using the changeset viewer.
