Changeset 2911 for trunk/psLib/src/imageops/psImageConvolve.c
- Timestamp:
- Jan 5, 2005, 11:16:15 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageConvolve.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageConvolve.c
r2411 r2911 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 200 4-11-24 00:05:54 $7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-01-05 21:16:14 $ 9 9 * 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 11 11 */ 12 12 … … 130 130 } 131 131 132 // determine the usable length of the shift vector132 // sizes match? 133 133 length = xShifts->n; 134 134 if (length != yShifts->n || 135 135 length != tShifts->n) { 136 psLogMsg(__func__,PS_LOG_WARN,"Shift vectors found to be different sizes."); 137 if (yShifts->n < length) { 138 length = yShifts->n; 139 } 140 if (tShifts->n < length) { 141 length = tShifts->n; 142 } 136 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 137 "Shift vectors can not be of different sizes."); 138 return NULL; 139 } 140 141 // if no shifts, the kernel is just a 1 at 0,0 142 if (length < 1) { 143 result = psKernelAlloc(0,0,0,0); 144 result->kernel[0][0] = 1; 145 return result; 143 146 } 144 147 … … 148 151 ps##TYPE *xShiftData = xShifts->data.TYPE; \ 149 152 ps##TYPE *yShiftData = yShifts->data.TYPE; \ 150 lastX = xShiftData[length-1]; \ 151 lastY = yShiftData[length-1]; \ 153 lastX = xShiftData[length-1]; \ 154 lastY = yShiftData[length-1]; \ 155 lastT = tShiftData[length-1]; \ 152 156 \ 153 157 for (int lcv = 0; lcv < length; lcv++) { \ … … 167 171 } \ 168 172 \ 169 normalizeTime = 1.0 / (psKernelType)( lastT - tShiftData[0]); \173 normalizeTime = 1.0 / (psKernelType)(tShiftData[length-1]); \ 170 174 result = psKernelAlloc(xMin,xMax,yMin,yMax); \ 171 175 kernel = result->kernel; \ 172 176 \ 173 lastT = 0; \177 psS32 prevT = 0; \ 174 178 for (int i = 0; i < length; i++) { \ 175 t = tShiftData[i] - lastT; \179 t = tShiftData[i] - prevT; \ 176 180 x = lastX - xShiftData[i]; \ 177 181 y = lastY - yShiftData[i]; \ 178 182 \ 179 kernel[y][x] += (psKernelType)t * normalizeTime; \180 lastT = t; \183 kernel[y][x] += (psKernelType)t / (psKernelType)lastT; \ 184 prevT = tShiftData[i]; \ 181 185 } \ 182 186 break; \ … … 206 210 yMax = y; \ 207 211 } \ 208 x += xShiftData[lcv]; \209 y += yShiftData[lcv]; \212 x -= xShiftData[lcv]; \ 213 y -= yShiftData[lcv]; \ 210 214 \ 211 215 } \ … … 218 222 for (psS32 i = length-1; i >= 0; i--) { \ 219 223 kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \ 220 x += xShiftData[i]; \221 y += yShiftData[i]; \224 x -= xShiftData[i]; \ 225 y -= yShiftData[i]; \ 222 226 \ 223 227 } \
Note:
See TracChangeset
for help on using the changeset viewer.
