IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 13, 2005, 2:16:46 PM (21 years ago)
Author:
desonia
Message:

added initial implementation of psImageTransform -- untested!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImageManip.c

    r3887 r3935  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-05-12 00:54:49 $
     12 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-05-14 00:16:46 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    10791079    }
    10801080
    1081     // find the input image domain in the output image
     1081    int row0 = region.y0;
     1082    int row1 = region.y1;
     1083    int col0 = region.x0;
     1084    int col1 = region.x1;
     1085    if (col1 < 1) {
     1086        col1 += input->numCols;
     1087    }
     1088
     1089    if (row1 < 1) {
     1090        row1 += input->numRows;
     1091    }
     1092
     1093    int numRows = row1 - row0;
     1094    int numCols = col1 - col0;
     1095
     1096    if (numRows < 1 || numCols < 1) {
     1097        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     1098                "The specified region is invalid.");
     1099        psFree(output);
     1100        return NULL;
     1101    }
     1102
     1103    // create the output image.
     1104    output = psImageRecycle(output, numCols, numRows, input->type.type);
     1105    *(psS32*)&output->col0 = region.x0;
     1106    *(psS32*)&output->row0 = region.y0;
     1107
    10821108
    10831109    // loop through the output image using the domain above and transform
    10841110    // each output pixel to input coordinates and use psImagePixelInterpolate
    10851111    // to determine the pixel value.
    1086 
    1087 
    1088     return NULL;
     1112    psPlane outPosition;
     1113    psPlane* inPosition = NULL;
     1114    for (int row = 0; row < numRows; row++) {
     1115        outPosition.y = row+row0;
     1116        psF32* outputData=output->data.F32[row];
     1117        for (int col = 0; col < numCols; col++) {
     1118            outPosition.x = col+col0;
     1119            // apply the transform to get the position in the input image
     1120            inPosition = psPlaneTransformApply(inPosition, outToIn, inPosition);
     1121
     1122            if (inPosition == NULL) {
     1123                psError(PS_ERR_UNKNOWN, false,
     1124                        "Failed to apply the transform");
     1125                psFree(output);
     1126                return NULL;
     1127            }
     1128            // interpolate the cooresponding input pixel to get the output pixel value.
     1129            outputData[col] = (psF32)psImagePixelInterpolate(input,
     1130                              inPosition->x, inPosition->y,
     1131                              inputMask, inputMaskVal, exposedValue,
     1132                              mode);
     1133
     1134        }
     1135    }
     1136
     1137    return output;
    10891138}
    10901139
Note: See TracChangeset for help on using the changeset viewer.