Changeset 2911
- Timestamp:
- Jan 5, 2005, 11:16:15 AM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 edited
-
psLib.kdevelop.pcs (modified) ( previous)
-
psLib.kdevses (modified) (2 diffs)
-
src/image/psImageConvolve.c (modified) (6 diffs)
-
src/image/psImageIO.c (modified) (5 diffs)
-
src/imageops/psImageConvolve.c (modified) (6 diffs)
-
test/image/tst_psImageConvolve.c (modified) (8 diffs)
-
test/image/verified/tst_psImageConvolve.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevses
r2860 r2911 2 2 <!DOCTYPE KDevPrjSession> 3 3 <KDevPrjSession> 4 <DocsAndViews NumberOfDocuments=" 3" >5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/ test/image/tst_psImageManip.c" >6 <View0 line="1 514" Type="Source" />4 <DocsAndViews NumberOfDocuments="1" > 5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageConvolve.c" > 6 <View0 line="132" Type="Source" /> 7 7 </Doc0> 8 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageManip.c" >9 <View0 line="770" Type="Source" />10 </Doc1>11 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/dataManip/psConstants.h" >12 <View0 line="0" Type="Source" />13 </Doc2>14 8 </DocsAndViews> 15 9 <pluginList> … … 21 15 </bookmarks> 22 16 </kdevbookmarks> 23 <kdevsubversion>24 <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" />25 </kdevsubversion>26 17 <kdevvalgrind> 27 18 <executable path="" params="" /> -
trunk/psLib/src/image/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 } \ -
trunk/psLib/src/image/psImageIO.c
r2273 r2911 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 200 4-11-04 01:05:00$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-01-05 21:16:14 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 { 34 34 fitsfile *fptr = NULL; /* Pointer to the FITS file */ 35 psS32 status = 0; /* CFITSIO file vars */35 psS32 status = 0; /* CFITSIO file vars */ 36 36 psS32 nAxis = 0; 37 37 psS32 anynull = 0; 38 psS32 bitPix = 0; /* Pixel type */38 psS32 bitPix = 0; /* Pixel type */ 39 39 long nAxes[3]; 40 40 long firstPixel[3]; /* lower-left corner of image subset */ … … 160 160 fitsDatatype = TBYTE; 161 161 break; 162 /* case SBYTE_IMG: Not a requirement163 datatype = PS_TYPE_S8;164 fitsDatatype = TSBYTE;165 break; */166 /* case USHORT_IMG: Not a requirement167 datatype = PS_TYPE_U16;168 fitsDatatype = TUSHORT;169 break; */162 case SBYTE_IMG: 163 datatype = PS_TYPE_S8; 164 fitsDatatype = TSBYTE; 165 break; 166 case USHORT_IMG: 167 datatype = PS_TYPE_U16; 168 fitsDatatype = TUSHORT; 169 break; 170 170 case SHORT_IMG: 171 171 datatype = PS_TYPE_S16; 172 172 fitsDatatype = TSHORT; 173 173 break; 174 /* case ULONG_IMG: Not a requirement175 datatype = PS_TYPE_U32;176 fitsDatatype = TUINT;177 break; */174 case ULONG_IMG: 175 datatype = PS_TYPE_U32; 176 fitsDatatype = TUINT; 177 break; 178 178 case LONG_IMG: 179 179 datatype = PS_TYPE_S32; 180 180 fitsDatatype = TINT; 181 181 break; 182 /* case LONGLONG_IMG: Not a requirement183 datatype = PS_TYPE_S64;184 fitsDatatype = TLONGLONG;185 break; */182 case LONGLONG_IMG: 183 datatype = PS_TYPE_S64; 184 fitsDatatype = TLONGLONG; 185 break; 186 186 case FLOAT_IMG: 187 187 datatype = PS_TYPE_F32; … … 256 256 datatype = TBYTE; 257 257 break; 258 /* case PS_TYPE_S8: Not a requirement259 bitPix = BYTE_IMG;260 bzero = INT8_MIN;261 datatype = TSBYTE;262 break; */263 /* case PS_TYPE_U16: Not a requirement264 bitPix = SHORT_IMG;265 bzero = -1.0f * INT16_MIN;266 datatype = TUSHORT;267 break; */258 case PS_TYPE_S8: 259 bitPix = BYTE_IMG; 260 bzero = INT8_MIN; 261 datatype = TSBYTE; 262 break; 263 case PS_TYPE_U16: 264 bitPix = SHORT_IMG; 265 bzero = -1.0f * INT16_MIN; 266 datatype = TUSHORT; 267 break; 268 268 case PS_TYPE_S16: 269 269 bitPix = SHORT_IMG; 270 270 datatype = TSHORT; 271 271 break; 272 /* case PS_TYPE_U32: Not a requirement273 bitPix = LONG_IMG;274 bzero = -1.0f * INT32_MIN;275 datatype = TUINT;276 break; */272 case PS_TYPE_U32: 273 bitPix = LONG_IMG; 274 bzero = -1.0f * INT32_MIN; 275 datatype = TUINT; 276 break; 277 277 case PS_TYPE_S32: 278 278 bitPix = LONG_IMG; … … 344 344 } 345 345 346 } else { // file 347 // does 348 // not 349 // exist 346 } else { 347 // file does not exist 350 348 351 349 (void)fits_create_file(&fptr, filename, &status); -
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 } \ -
trunk/psLib/test/image/tst_psImageConvolve.c
r2273 r2911 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $8 * @date $Date: 200 4-11-04 01:05:00$7 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-01-05 21:16:15 $ 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 … … 117 117 static psS32 testKernelGenerate(void) 118 118 { 119 psS32 size = 4;120 psS32 t[] = { 1, 2, 8, 10 };121 psS32 x[] = { 0, 1, 0, -1 };122 psS32 y[] = { 2, 1, -1, -2 };119 psS32 size = 5; 120 psS32 t[] = { 1, 2, 8, 9, 10 }; 121 psS32 x[] = { 0, 1, 0, -1, 0 }; 122 psS32 y[] = { 2, 1, -1, -2, 0 }; 123 123 psKernelType sum; 124 124 … … 142 142 if (result->xMin != -1 || result->xMax != 1 || 143 143 result->yMin != -2 || result->yMax != 2) { 144 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result had a range of [%d:%d,%d:%d]. Suppose to be [ 0:1,1:2].",144 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result had a range of [%d:%d,%d:%d]. Suppose to be [-2:2,-1:1].", 145 145 result->xMin, result->xMax, result->yMin, result->yMax); 146 146 return 2; … … 148 148 149 149 sum = 0.0; 150 printf("Resulting kernel:\n"); 150 151 for (psS32 y = result->yMin; y <= result->yMax; y++) { 151 152 for (psS32 x = result->xMin; x <= result->xMax; x++) { 153 printf(" %6.2f ", result->kernel[y][x]); 152 154 sum += result->kernel[y][x]; 153 155 } 156 printf("\n"); 154 157 } 155 158 if (fabsf(1.0 - sum) > FLT_EPSILON) { … … 161 164 } 162 165 163 if (fabsf(result->kernel[2][0] - 1.0/10.0) > FLT_EPSILON || 164 fabsf(result->kernel[ 1][ 1] - 6.0/10.0) > FLT_EPSILON || 165 fabsf(result->kernel[ 0][ 0] - 1.0/10.0) > FLT_EPSILON || 166 fabsf(result->kernel[-1][ 0] - 2.0/10.0) > FLT_EPSILON || 167 fabsf(result->kernel[-2][-1] - 0.0/10.0) > FLT_EPSILON) { 168 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.", 169 result->kernel[-1][0], result->kernel[1][1], 170 result->kernel[2][0], result->kernel[-2][-1]); 166 if (fabsf(result->kernel[-2][0] - 0.1) > FLT_EPSILON || 167 fabsf(result->kernel[ -1][ -1] - 0.1) > FLT_EPSILON || 168 fabsf(result->kernel[ 1][ 0] - 0.6) > FLT_EPSILON || 169 fabsf(result->kernel[2][1] - 0.1) > FLT_EPSILON) { 170 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g,%g,%g, are wrong. Suppose to be 0.1,0.1,0.6,0.1", 171 result->kernel[-2][0], result->kernel[-1][-1], 172 result->kernel[1][0], result->kernel[2][1]); 171 173 172 174 return 4; … … 203 205 204 206 sum = 0.0; 207 printf("Resulting kernel (relative=true):\n"); 205 208 for (psS32 y = result->yMin; y <= result->yMax; y++) { 206 209 for (psS32 x = result->xMin; x <= result->xMax; x++) { 210 printf(" %6.2f ", result->kernel[y][x]); 207 211 sum += result->kernel[y][x]; 208 212 } 213 printf("\n"); 209 214 } 210 215 if (fabsf(1.0 - sum) > FLT_EPSILON) { … … 216 221 } 217 222 218 if (fabsf(result->kernel[0][0] - 1 .0/21.0) > FLT_EPSILON ||219 fabsf(result->kernel[2][0] - 2.0/21.0) > FLT_EPSILON ||220 fabsf(result->kernel[ 3][1] - 8.0/21.0) > FLT_EPSILON ||221 fabsf(result->kernel[ 2][1] - 10.0/21.0) > FLT_EPSILON) {223 if (fabsf(result->kernel[0][0] - 19.0/30.0) > FLT_EPSILON || 224 fabsf(result->kernel[2][0] - 1.0/30.0) > FLT_EPSILON || 225 fabsf(result->kernel[2][1] - 8.0/30.0) > FLT_EPSILON || 226 fabsf(result->kernel[3][1] - 2.0/30.0) > FLT_EPSILON) { 222 227 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values, %g,%g;%g,%g, are wrong. Suppose to be 2,6;1,0.", 223 result->kernel[ 1][0], result->kernel[1][1],224 result->kernel[2][ 0], result->kernel[2][1]);228 result->kernel[0][0], result->kernel[2][0], 229 result->kernel[2][1], result->kernel[3][1]); 225 230 226 231 return 8; … … 243 248 244 249 tVec->n--; // decrease size by one to make vectors unequal in length. 245 psLogMsg(__func__,PS_LOG_INFO, "Following should be a warning - not automatically tested.");250 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error."); 246 251 result = psKernelGenerate(tVec, xVec, yVec, false); 247 if (result == NULL) {248 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned NULL.");252 if (result != NULL) { 253 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate returned non-NULL given differing sized vectors."); 249 254 return 9; 250 }251 252 // make sure last sample is not used253 if (fabsf(result->kernel[2][0] - 1.0/8.0) > FLT_EPSILON ||254 fabsf(result->kernel[ 1][ 1] - 6.0/8.0) > FLT_EPSILON ||255 fabsf(result->kernel[ 0][ 0] - 1.0/8.0) > FLT_EPSILON) {256 psError(PS_ERR_UNKNOWN, true,"psKernelGenerate result values wrong for truncated time vector.");257 258 return 10;259 255 } 260 256 -
trunk/psLib/test/image/verified/tst_psImageConvolve.stderr
r2279 r2911 23 23 24 24 <DATE><TIME>|<HOST>|I|testKernelGenerate 25 Following should be a warning - not automatically tested.26 <DATE><TIME>|<HOST>| W|psKernelGenerate27 Shift vectors found to bedifferent sizes.25 Following should be an error. 26 <DATE><TIME>|<HOST>|E|psKernelGenerate (psImageConvolve.c:<LINENO>) 27 Shift vectors can not be of different sizes. 28 28 <DATE><TIME>|<HOST>|I|testKernelGenerate 29 29 Following should be a error (time vector NULL).
Note:
See TracChangeset
for help on using the changeset viewer.
