Changeset 1897
- Timestamp:
- Sep 24, 2004, 4:06:12 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 15 edited
-
psLib.kdevelop.pcs (modified) ( previous)
-
psLib.kdevses (modified) (1 diff)
-
src/collections/psVector.c (modified) (2 diffs)
-
src/collections/psVector.h (modified) (2 diffs)
-
src/image/psImage.c (modified) (8 diffs)
-
src/image/psImage.h (modified) (4 diffs)
-
src/image/psImageErrors.dat (modified) (1 diff)
-
src/image/psImageErrors.h (modified) (2 diffs)
-
src/image/psImageExtraction.c (modified) (4 diffs)
-
src/image/psImageExtraction.h (modified) (2 diffs)
-
src/image/psImageManip.c (modified) (4 diffs)
-
src/mathtypes/psImage.c (modified) (8 diffs)
-
src/mathtypes/psImage.h (modified) (4 diffs)
-
src/mathtypes/psVector.c (modified) (2 diffs)
-
src/mathtypes/psVector.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevses
r1865 r1897 2 2 <!DOCTYPE KDevPrjSession> 3 3 <KDevPrjSession> 4 <DocsAndViews NumberOfDocuments="0" /> 4 <DocsAndViews NumberOfDocuments="7" > 5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageExtraction.c" > 6 <View0 line="723" Type="???" > 7 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="738" Left="1" MinMaxMode="0" /> 8 </View0> 9 </Doc0> 10 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" > 11 <View0 line="27" Type="???" > 12 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="736" Left="1" MinMaxMode="0" /> 13 </View0> 14 </Doc1> 15 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageExtraction.h" > 16 <View0 line="146" Type="???" > 17 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="738" Left="1" MinMaxMode="0" /> 18 </View0> 19 </Doc2> 20 <Doc3 context="" NumberOfViews="1" URL="man:/hypot" > 21 <View0 Type="???" > 22 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="736" Left="1" MinMaxMode="0" /> 23 </View0> 24 </Doc3> 25 <Doc4 context="" NumberOfViews="1" URL="man:/usr/share/man/man3/hypot.3.gz" > 26 <View0 Type="???" > 27 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="736" Left="1" MinMaxMode="0" /> 28 </View0> 29 </Doc4> 30 <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImage.c" > 31 <View0 line="482" Type="???" > 32 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="738" Left="1" MinMaxMode="0" /> 33 </View0> 34 </Doc5> 35 <Doc6 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImage.h" > 36 <View0 line="177" Type="???" > 37 <AdditionalSettings Top="1" Width="1123" Attach="1" Height="738" Left="1" MinMaxMode="0" /> 38 </View0> 39 </Doc6> 40 </DocsAndViews> 5 41 <pluginList> 6 42 <kdevbookmarks> -
trunk/psLib/src/collections/psVector.c
r1820 r1897 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09- 16 23:47:43$12 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 } 111 111 112 psVector* psVectorCopy(psVector* out, const psVector* in, psElemType type) 113 { 114 if (in == NULL) { 115 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 116 PS_ERR_BAD_PARAMETER_NULL, true, 117 PS_ERRORTEXT_psVector_SORT_NULL); 118 psFree(out); 119 return NULL; 120 } 121 122 int nElements = in->n; 123 124 out = psVectorRecycle(out, nElements, type); 125 126 #define PSVECTOR_COPY(INTYPE,OUTTYPE) { \ 127 ps##INTYPE *inVec = in->data.INTYPE; \ 128 ps##OUTTYPE *outVec = out->data.OUTTYPE; \ 129 for (int col=0;col<nElements;col++) { \ 130 *(outVec++) = *(inVec++); \ 131 } \ 132 } 133 134 #define PSVECTOR_COPY_CASE(OUTTYPE) \ 135 case PS_TYPE_##OUTTYPE: { \ 136 switch (in->type.type) { \ 137 case PS_TYPE_S8: \ 138 PSVECTOR_COPY(S8,OUTTYPE); \ 139 break; \ 140 case PS_TYPE_S16: \ 141 PSVECTOR_COPY(S16,OUTTYPE); \ 142 break; \ 143 case PS_TYPE_S32: \ 144 PSVECTOR_COPY(S32,OUTTYPE); \ 145 break; \ 146 case PS_TYPE_S64: \ 147 PSVECTOR_COPY(S64,OUTTYPE); \ 148 break; \ 149 case PS_TYPE_U8: \ 150 PSVECTOR_COPY(U8,OUTTYPE); \ 151 break; \ 152 case PS_TYPE_U16: \ 153 PSVECTOR_COPY(U16,OUTTYPE); \ 154 break; \ 155 case PS_TYPE_U32: \ 156 PSVECTOR_COPY(U32,OUTTYPE); \ 157 break; \ 158 case PS_TYPE_U64: \ 159 PSVECTOR_COPY(U64,OUTTYPE); \ 160 break; \ 161 case PS_TYPE_F32: \ 162 PSVECTOR_COPY(F32,OUTTYPE); \ 163 break; \ 164 case PS_TYPE_F64: \ 165 PSVECTOR_COPY(F64,OUTTYPE); \ 166 break; \ 167 case PS_TYPE_C32: \ 168 PSVECTOR_COPY(C32,OUTTYPE); \ 169 break; \ 170 case PS_TYPE_C64: \ 171 PSVECTOR_COPY(C64,OUTTYPE); \ 172 break; \ 173 default: { \ 174 char* typeStr; \ 175 PS_TYPE_NAME(typeStr,type); \ 176 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \ 177 PS_ERR_BAD_PARAMETER_TYPE, true, \ 178 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \ 179 typeStr); \ 180 psFree(out); \ 181 } \ 182 } \ 183 break; \ 184 } 185 186 switch (type) { 187 PSVECTOR_COPY_CASE(S8); 188 PSVECTOR_COPY_CASE(S16); 189 PSVECTOR_COPY_CASE(S32); 190 PSVECTOR_COPY_CASE(S64); 191 PSVECTOR_COPY_CASE(U8); 192 PSVECTOR_COPY_CASE(U16); 193 PSVECTOR_COPY_CASE(U32); 194 PSVECTOR_COPY_CASE(U64); 195 PSVECTOR_COPY_CASE(F32); 196 PSVECTOR_COPY_CASE(F64); 197 PSVECTOR_COPY_CASE(C32); 198 PSVECTOR_COPY_CASE(C64); 199 default: { 200 char* typeStr; 201 PS_TYPE_NAME(typeStr,type); 202 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 203 PS_ERR_BAD_PARAMETER_TYPE, true, 204 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 205 typeStr); 206 psFree(out); 207 208 break; 209 } 210 } 211 return out; 212 213 214 } 215 112 216 psVector* psVectorSort(psVector* restrict outVector, const psVector* restrict inVector) 113 217 { -
trunk/psLib/src/collections/psVector.h
r1478 r1897 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-11 20:17:35$14 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-25 02:06:12 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 105 105 ); 106 106 107 /** Copy a vector, converting types. 108 * 109 * Performs a deep copy of the elements of one psVector to a new psVector, 110 * converting numeric types to a specified type. 111 * 112 * @return psVector* Pointer to resulting psVector. 113 * 114 */ 115 psVector* psVectorCopy( 116 psVector* out, ///< if non-NULL, a psVector to recycle 117 const psVector* in, ///< the vector to copy. 118 psElemType type ///< the data type of the resulting psVector 119 ); 120 107 121 /** Sort an array of floats. 108 122 * -
trunk/psLib/src/image/psImage.c
r1841 r1897 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 1 23:15:04$12 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 199 199 float x, 200 200 float y, 201 const psImage* mask, 202 unsigned int maskVal, 201 203 psC64 unexposedValue, 202 204 psImageInterpolateMode mode) … … 214 216 switch (mode) { \ 215 217 case PS_INTERPOLATE_FLAT: \ 216 return p_psImagePixelInterpolateFLAT_##TYPE(input, x, y, \ 218 return p_psImagePixelInterpolateFLAT_##TYPE( \ 219 input, \ 220 x, \ 221 y, \ 222 mask, \ 223 maskVal, \ 217 224 unexposedValue); \ 218 225 break; \ 219 226 case PS_INTERPOLATE_BILINEAR: \ 220 return p_psImagePixelInterpolateBILINEAR_##TYPE(input,x,y, \ 227 return p_psImagePixelInterpolateBILINEAR_##TYPE( \ 228 input, \ 229 x, \ 230 y, \ 231 mask, \ 232 maskVal, \ 221 233 unexposedValue); \ 222 234 break; \ … … 259 271 float x, \ 260 272 float y, \ 273 const psImage* mask, \ 274 unsigned int maskVal, \ 261 275 psF64 unexposedValue) \ 262 276 { \ … … 269 283 (intX > lastX) || \ 270 284 (intY < 0) || \ 271 (intY > lastY)) { \ 285 (intY > lastY) || \ 286 ( (mask!=NULL) && \ 287 ((mask->data.PS_TYPE_MASK_DATA[intY][intX] & maskVal) != 0) ) ) { \ 272 288 return unexposedValue; \ 273 289 } \ … … 280 296 float x, \ 281 297 float y, \ 298 const psImage* mask, \ 299 unsigned int maskVal, \ 282 300 psC64 unexposedValue) \ 283 301 { \ … … 290 308 (intX > lastX) || \ 291 309 (intY < 0) || \ 292 (intY > lastY)) { \ 310 (intY > lastY) || \ 311 ( (mask!=NULL) && \ 312 ((mask->data.PS_TYPE_MASK_DATA[intY][intX] & maskVal) != 0) ) ) { \ 293 313 return unexposedValue; \ 294 314 } \ … … 314 334 float x, \ 315 335 float y, \ 336 const psImage* mask, \ 337 unsigned int maskVal, \ 316 338 psF64 unexposedValue) \ 317 339 { \ 318 340 double floorX = floor((psF64)(x) - 0.5); \ 319 341 double floorY = floor((psF64)(y) - 0.5); \ 320 doublefracX = x - 0.5 - floorX; \321 doublefracY = y - 0.5 - floorY; \342 psF64 fracX = x - 0.5 - floorX; \ 343 psF64 fracY = y - 0.5 - floorY; \ 322 344 int intFloorX = (int) floorX; \ 323 345 int intFloorY = (int) floorY; \ 324 346 int lastX = input->numCols - 1; \ 325 347 int lastY = input->numRows - 1; \ 326 double rx = 0.0; \ 327 psF64 pixel = 0.0; \ 328 ps##TYPE* currentRow; \ 329 ps##TYPE* nextRow; \ 330 \ 331 if ((intFloorX < 0) || \ 332 (intFloorX > lastX) || \ 333 (intFloorY < 0) || \ 334 (intFloorY > lastY)) { \ 335 return unexposedValue; \ 336 } \ 337 \ 338 currentRow = input->data.TYPE[intFloorY]; \ 339 if (intFloorY == lastY) { \ 340 pixel = currentRow[intFloorX]; \ 341 if (intFloorX < lastX) { \ 342 pixel+= fracY * ((psF64)currentRow[intFloorX+1] - \ 343 (psF64)currentRow[intFloorX]); \ 344 } \ 345 return(pixel); \ 346 } \ 347 nextRow = input->data.TYPE[intFloorY+1]; \ 348 if (intFloorX == lastX) { \ 349 pixel = currentRow[intFloorX]; \ 350 if (intFloorY < lastY) { \ 351 pixel+= fracX * ((psF64)nextRow[intFloorX] - \ 352 (psF64)currentRow[intFloorX]); \ 353 } \ 354 return(pixel); \ 355 } \ 356 \ 357 rx = currentRow[intFloorX] + \ 358 fracX * ((psF64)currentRow[intFloorX+1] - \ 359 (psF64)currentRow[intFloorX]); \ 360 \ 361 pixel = rx + fracY * ((psF64)nextRow[intFloorX] + \ 362 fracX * ((psF64)nextRow[intFloorX+1] - \ 363 (psF64)nextRow[intFloorX]) - rx); \ 364 \ 365 return(pixel); \ 366 } 348 ps##TYPE V00; \ 349 ps##TYPE V01; \ 350 ps##TYPE V10; \ 351 ps##TYPE V11; \ 352 bool valid00 = false; \ 353 bool valid01 = false; \ 354 bool valid10 = false; \ 355 bool valid11 = false; \ 356 \ 357 if (intFloorY >= 0 && intFloorY <= lastY) { \ 358 if (intFloorX >= 0 && intFloorX <= lastX) { \ 359 V00 = input->data.TYPE[intFloorY][intFloorX]; \ 360 valid00 = (mask == NULL) || \ 361 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX] & maskVal) == 0); \ 362 } \ 363 if (intFloorX >= -1 && intFloorX < lastX) { \ 364 V10 = input->data.TYPE[intFloorY][intFloorX+1]; \ 365 valid10 = (mask == NULL) || \ 366 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX+1] & maskVal) == 0); \ 367 } \ 368 } \ 369 if (intFloorY >= -1 && intFloorY < lastY) { \ 370 if (intFloorX >= 0 && intFloorX <= lastX) { \ 371 V01 = input->data.TYPE[intFloorY+1][intFloorX]; \ 372 valid01 = (mask == NULL) || \ 373 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX] & maskVal) == 0); \ 374 } \ 375 if (intFloorX >= -1 && intFloorX < lastX) { \ 376 V11 = input->data.TYPE[intFloorY+1][intFloorX+1]; \ 377 valid11 = (mask == NULL) || \ 378 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX+1] & maskVal) == 0); \ 379 } \ 380 } \ 381 \ 382 /* cover likely case of all pixels being valid more efficiently */ \ 383 if (valid00 && valid10 && valid01 && valid11) { \ 384 /* formula from the ADD */ \ 385 psF64 rx = V00 + (V10-V00)*fracX; \ 386 return (rx + (V01 + (V11 - V01) * fracX - rx) * fracY); \ 387 } \ 388 \ 389 /* OK, at least one pixel is not valid - need to do it piecemeal */ \ 390 \ 391 psF64 V0; \ 392 bool valid0 = true; \ 393 if (valid00 && valid10) { \ 394 V0 = V00*(1-fracX)+V10*fracX; \ 395 } else if (valid00) { \ 396 V0 = V00; \ 397 } else if (valid10) { \ 398 V0 = V10; \ 399 } else { \ 400 valid0 = false; \ 401 } \ 402 \ 403 psF64 V1; \ 404 bool valid1 = true; \ 405 if (valid01 && valid11) { \ 406 V0 = V01*(1-fracX)+V11*fracX; \ 407 } else if (valid01) { \ 408 V0 = V01; \ 409 } else if (valid11) { \ 410 V0 = V11; \ 411 } else { \ 412 valid1 = false; \ 413 } \ 414 \ 415 if (valid0 && valid1) { \ 416 return ( V0*(1-fracY) + V1*fracY ); \ 417 } else if (valid0) { \ 418 return V0; \ 419 } else if (valid1) { \ 420 return V1; \ 421 } \ 422 \ 423 return unexposedValue; \ 424 } 425 367 426 #define PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(TYPE) \ 368 427 inline psC64 p_psImagePixelInterpolateBILINEAR_##TYPE(const psImage* input, \ 369 428 float x, \ 370 429 float y, \ 430 const psImage* mask, \ 431 unsigned int maskVal, \ 371 432 psC64 unexposedValue) \ 372 433 { \ 373 434 double floorX = floor((psF64)(x) - 0.5); \ 374 435 double floorY = floor((psF64)(y) - 0.5); \ 375 doublefracX = x - 0.5 - floorX; \376 doublefracY = y - 0.5 - floorY; \436 psF64 fracX = x - 0.5 - floorX; \ 437 psF64 fracY = y - 0.5 - floorY; \ 377 438 int intFloorX = (int) floorX; \ 378 439 int intFloorY = (int) floorY; \ 379 440 int lastX = input->numCols - 1; \ 380 441 int lastY = input->numRows - 1; \ 381 double rx = 0.0; \ 382 psC64 pixel = 0.0; \ 383 ps##TYPE* currentRow; \ 384 ps##TYPE* nextRow; \ 385 \ 386 if ((intFloorX < 0) || \ 387 (intFloorX > lastX) || \ 388 (intFloorY < 0) || \ 389 (intFloorY > lastY)) { \ 390 return unexposedValue; \ 391 } \ 392 \ 393 currentRow = input->data.TYPE[intFloorY]; \ 394 if (intFloorY == lastY) { \ 395 pixel = currentRow[intFloorX]; \ 396 if (intFloorX < lastX) { \ 397 pixel+= fracY * (currentRow[intFloorX+1] - \ 398 currentRow[intFloorX]); \ 399 } \ 400 return(pixel); \ 401 } \ 402 nextRow = input->data.TYPE[intFloorY+1]; \ 403 if (intFloorX == lastX) { \ 404 pixel = currentRow[intFloorX]; \ 405 if (intFloorY < lastY) { \ 406 pixel+= fracX * (nextRow[intFloorX] - \ 407 currentRow[intFloorX]); \ 408 } \ 409 return(pixel); \ 410 } \ 411 \ 412 rx = currentRow[intFloorX] + \ 413 fracX * (currentRow[intFloorX+1] - \ 414 currentRow[intFloorX]); \ 415 \ 416 pixel = rx + fracY * ((psF64)nextRow[intFloorX] + \ 417 fracX * (nextRow[intFloorX+1] - \ 418 nextRow[intFloorX]) - rx); \ 419 \ 420 return(pixel); \ 442 ps##TYPE V00; \ 443 ps##TYPE V01; \ 444 ps##TYPE V10; \ 445 ps##TYPE V11; \ 446 bool valid00 = false; \ 447 bool valid01 = false; \ 448 bool valid10 = false; \ 449 bool valid11 = false; \ 450 \ 451 if (intFloorY >= 0 && intFloorY <= lastY) { \ 452 if (intFloorX >= 0 && intFloorX <= lastX) { \ 453 V00 = input->data.TYPE[intFloorY][intFloorX]; \ 454 valid00 = (mask == NULL) || \ 455 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX] & maskVal) == 0); \ 456 } \ 457 if (intFloorX >= -1 && intFloorX < lastX) { \ 458 V10 = input->data.TYPE[intFloorY][intFloorX+1]; \ 459 valid10 = (mask == NULL) || \ 460 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX+1] & maskVal) == 0); \ 461 } \ 462 } \ 463 if (intFloorY >= -1 && intFloorY < lastY) { \ 464 if (intFloorX >= 0 && intFloorX <= lastX) { \ 465 V01 = input->data.TYPE[intFloorY+1][intFloorX]; \ 466 valid01 = (mask == NULL) || \ 467 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX] & maskVal) == 0); \ 468 } \ 469 if (intFloorX >= -1 && intFloorX < lastX) { \ 470 V11 = input->data.TYPE[intFloorY+1][intFloorX+1]; \ 471 valid11 = (mask == NULL) || \ 472 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX+1] & maskVal) == 0); \ 473 } \ 474 } \ 475 \ 476 /* cover likely case of all pixels being valid */ \ 477 if (valid00 && valid10 && valid01 && valid11) { \ 478 /* formula from the ADD */ \ 479 psC64 rx = V00 + (V10-V00)*fracX; \ 480 return (rx + (V01 + (V11 - V01) * fracX - rx) * fracY); \ 481 } \ 482 \ 483 /* OK, at least one pixel is not valid - need to do it piecemeal */ \ 484 \ 485 psC64 V0; \ 486 bool valid0 = true; \ 487 if (valid00 && valid10) { \ 488 V0 = V00*(1-fracX)+V10*fracX; \ 489 } else if (valid00) { \ 490 V0 = V00; \ 491 } else if (valid10) { \ 492 V0 = V10; \ 493 } else { \ 494 valid0 = false; \ 495 } \ 496 \ 497 psC64 V1; \ 498 bool valid1 = true; \ 499 if (valid01 && valid11) { \ 500 V0 = V01*(1-fracX)+V11*fracX; \ 501 } else if (valid01) { \ 502 V0 = V01; \ 503 } else if (valid11) { \ 504 V0 = V11; \ 505 } else { \ 506 valid1 = false; \ 507 } \ 508 \ 509 if (valid0 && valid1) { \ 510 return ( V0*(1-fracY) + V1*fracY ); \ 511 } else if (valid0) { \ 512 return V0; \ 513 } else if (valid1) { \ 514 return V1; \ 515 } \ 516 \ 517 return unexposedValue; \ 421 518 } 422 519 -
trunk/psLib/src/image/psImage.h
r1839 r1897 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-09-2 1 19:51:41$13 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-09-25 02:06:12 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 118 118 float x, ///< column location to derive value of 119 119 float y, ///< row location ot derive value of 120 const psImage* mask, ///< if not NULL, the mask of the input image 121 unsigned int maskVal, ///< the mask value 120 122 psC64 unexposedValue, ///< return value if x,y location is not in image. 121 123 psImageInterpolateMode mode ///< interpolation mode … … 124 126 #define p_psImagePixelInterpolateFcns(TYPE) \ 125 127 inline psF64 p_psImagePixelInterpolateFLAT_##TYPE( \ 126 const psImage* input, \ 127 float x, \ 128 float y, \ 129 psF64 unexposedValue \ 128 const psImage* input, /**< input image for interpolation */ \ 129 float x, /**< column location to derive value of */ \ 130 float y, /**< row location ot derive value of */ \ 131 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 132 unsigned int maskVal, /**< the mask value */ \ 133 psF64 unexposedValue /**< return value if x,y location is not in image. */ \ 130 134 ); \ 131 135 inline psF64 p_psImagePixelInterpolateBILINEAR_##TYPE( \ 132 const psImage* input, \ 133 float x, \ 134 float y, \ 135 psF64 unexposedValue \ 136 const psImage* input, /**< input image for interpolation */ \ 137 float x, /**< column location to derive value of */ \ 138 float y, /**< row location ot derive value of */ \ 139 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 140 unsigned int maskVal, /**< the mask value */ \ 141 psF64 unexposedValue /**< return value if x,y location is not in image. */ \ 136 142 ); 137 143 138 144 #define p_psImagePixelInterpolateComplexFcns(TYPE) \ 139 145 inline psC64 p_psImagePixelInterpolateFLAT_##TYPE( \ 140 const psImage* input, \ 141 float x, \ 142 float y, \ 143 psC64 unexposedValue \ 146 const psImage* input, /**< input image for interpolation */ \ 147 float x, /**< column location to derive value of */ \ 148 float y, /**< row location ot derive value of */ \ 149 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 150 unsigned int maskVal, /**< the mask value */ \ 151 psC64 unexposedValue /**< return value if x,y location is not in image. */ \ 144 152 ); \ 145 153 inline psC64 p_psImagePixelInterpolateBILINEAR_##TYPE( \ 146 const psImage* input, \ 147 float x, \ 148 float y, \ 149 psC64 unexposedValue \ 154 const psImage* input, /**< input image for interpolation */ \ 155 float x, /**< column location to derive value of */ \ 156 float y, /**< row location ot derive value of */ \ 157 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 158 unsigned int maskVal, /**< the mask value */ \ 159 psC64 unexposedValue /**< return value if x,y location is not in image. */ \ 150 160 ); 151 161 … … 162 172 p_psImagePixelInterpolateComplexFcns(C32) 163 173 p_psImagePixelInterpolateComplexFcns(C64) 174 164 175 /// @} 176 165 177 #endif -
trunk/psLib/src/image/psImageErrors.dat
r1864 r1897 26 26 psImage_SLICE_DIRECTION_INVALID Specified slice direction, %d, is invalid. 27 27 psImage_PARAMETER_OUTOF_TYPERANGE Specified %s value, %g, is outside of psImage type's range (%s: %g to %g). 28 psImage_nSamples_TOOSMALL Specified number of samples, %d, must be greater than 1 to make a line. 29 psImage_LINE_NOT_IN_IMAGE Specified line, (%f,%f)->(%f,%f), does not entirely lie in psImage's boundaries, [0:%d,0:%d]. 30 psImage_RADII_VECTOR_NULL Specified radii vector can not be NULL. 31 psImage_CENTER_NOT_IN_IMAGE Specified center, (%d,%d), is outside of the psImage boundaries, [0:%d,0:%d]. 32 psImage_RADII_VECTOR_TOOSMALL Input radii vector size, %d, can not be less than 2. 28 33 # 29 34 psImageFFT_IMAGE_TYPE_UNSUPPORTED Input psImage type (%s) is not supported. Valid image types are psF32 and psC32. -
trunk/psLib/src/image/psImageErrors.h
r1864 r1897 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 3 18:31:49$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-25 02:06:12 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 #define PS_ERRORTEXT_psImage_SLICE_DIRECTION_INVALID "Specified slice direction, %d, is invalid." 49 49 #define PS_ERRORTEXT_psImage_PARAMETER_OUTOF_TYPERANGE "Specified %s value, %g, is outside of psImage type's range (%s: %g to %g)." 50 #define PS_ERRORTEXT_psImage_nSamples_TOOSMALL "Specified number of samples, %d, must be greater than 1 to make a line." 51 #define PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE "Specified line, (%f,%f)->(%f,%f), does not entirely lie in psImage's boundaries, [0:%d,0:%d]." 52 #define PS_ERRORTEXT_psImage_RADII_VECTOR_NULL "Specified radii vector can not be NULL." 53 #define PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE "Specified center, (%d,%d), is outside of the psImage boundaries, [0:%d,0:%d]." 54 #define PS_ERRORTEXT_psImage_RADII_VECTOR_TOOSMALL "Input radii vector size, %d, can not be less than 2." 50 55 #define PS_ERRORTEXT_psImageFFT_IMAGE_TYPE_UNSUPPORTED "Input psImage type (%s) is not supported. Valid image types are psF32 and psC32." 51 56 #define PS_ERRORTEXT_psImageFFT_REVERSE_NOT_COMPLEX "Input psImage (%s) is not complex. Reverse FFT operation requires a complex psImage input." -
trunk/psLib/src/image/psImageExtraction.c
r1864 r1897 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 3 18:31:49$12 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 609 609 610 610 psVector* psImageCut(psVector* out, 611 psVector* coords, 612 const psImage* input, 611 psVector* cutCols, 612 psVector* cutRows, 613 const psImage* in, 613 614 const psImage* restrict mask, 614 615 unsigned int maskVal, … … 620 621 psImageInterpolateMode mode) 621 622 { 622 623 return NULL; 623 if (in == NULL || in->data.V == NULL) { 624 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 625 PS_ERR_BAD_PARAMETER_NULL, true, 626 PS_ERRORTEXT_psImage_IMAGE_NULL); 627 psFree(out); 628 return NULL; 629 } 630 int numCols = in->numCols; 631 int numRows = in->numRows; 632 633 if (nSamples < 2) { 634 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 635 PS_ERR_BAD_PARAMETER_VALUE, true, 636 PS_ERRORTEXT_psImage_nSamples_TOOSMALL, 637 nSamples); 638 psFree(out); 639 return NULL; 640 } 641 642 if (startCol < 0 || startCol >= numCols || 643 startRow < 0 || startRow >= numRows || 644 endCol < 0 || endCol >= numCols || 645 endRow < 0 || endRow >= numRows) { 646 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 647 PS_ERR_BAD_PARAMETER_VALUE, true, 648 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 649 startCol,startRow,endCol,endRow, 650 numCols,numRows); 651 psFree(out); 652 } 653 654 if (mask != NULL) { 655 if (numRows != mask->numRows || numCols != mask->numCols) { 656 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 657 PS_ERR_BAD_PARAMETER_VALUE, true, 658 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 659 mask->numCols,mask->numRows, 660 numCols, numRows); 661 psFree(out); 662 } 663 if (mask->type.type != PS_TYPE_MASK) { 664 char* typeStr; 665 PS_TYPE_NAME(typeStr,mask->type.type); 666 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 667 PS_ERR_BAD_PARAMETER_TYPE, true, 668 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 669 typeStr, PS_TYPE_MASK_NAME); 670 psFree(out); 671 } 672 } 673 674 //resize the vectors for the coordinate output 675 psF32* cutColsData = NULL; 676 psF32* cutRowsData = NULL; 677 if (cutCols != NULL) { 678 (void)psVectorRecycle(cutCols, nSamples, PS_TYPE_F32); 679 cutColsData = cutCols->data.F32; 680 } 681 if (cutRows != NULL) { 682 (void)psVectorRecycle(cutRows, nSamples, PS_TYPE_F32); 683 cutRowsData = cutRows->data.F32; 684 } 685 686 out = psVectorRecycle(out,nSamples,in->type.type); 687 688 float dX = (endCol - startCol) / (nSamples-1); 689 float dY = (endRow - startRow) / (nSamples-1); 690 691 float x = startCol; 692 float y = startRow; 693 694 #define LINEAR_CUT_CASE(TYPE) \ 695 case PS_TYPE_##TYPE: { \ 696 ps##TYPE* outData = out->data.TYPE; \ 697 for (int i = 0; i < nSamples; i++) { \ 698 /* store off the location of the sample. */ \ 699 if (cutColsData != NULL) { \ 700 cutColsData[i] = x; \ 701 } \ 702 if (cutRowsData != NULL) { \ 703 cutRowsData[i] = y; \ 704 } \ 705 outData[i] = psImagePixelInterpolate(in,x,y,mask,maskVal,0,mode); \ 706 x += dX; \ 707 y += dY; \ 708 } \ 709 } \ 710 break; 711 712 713 switch (in->type.type) { 714 LINEAR_CUT_CASE(U8); 715 LINEAR_CUT_CASE(U16); 716 LINEAR_CUT_CASE(U32); 717 LINEAR_CUT_CASE(U64); 718 LINEAR_CUT_CASE(S8); 719 LINEAR_CUT_CASE(S16); 720 LINEAR_CUT_CASE(S32); 721 LINEAR_CUT_CASE(S64); 722 LINEAR_CUT_CASE(F32); 723 LINEAR_CUT_CASE(F64); 724 LINEAR_CUT_CASE(C32); 725 LINEAR_CUT_CASE(C64); 726 727 default: { 728 char* typeStr; 729 PS_TYPE_NAME(typeStr,in->type.type); 730 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCut", 731 PS_ERR_BAD_PARAMETER_TYPE, true, 732 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 733 typeStr); 734 psFree(out); 735 out = NULL; 736 } 737 } 738 739 return out; 624 740 } 625 741 626 742 psVector* psImageRadialCut(psVector* out, 627 const psImage* in put,743 const psImage* in, 628 744 const psImage* restrict mask, 629 745 unsigned int maskVal, … … 633 749 const psStats* stats) 634 750 { 635 636 return NULL; 751 double statVal; 752 753 /* check the parameters */ 754 755 if (in == NULL || in->data.V == NULL) { 756 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 757 PS_ERR_BAD_PARAMETER_NULL, true, 758 PS_ERRORTEXT_psImage_IMAGE_NULL); 759 psFree(out); 760 return NULL; 761 } 762 int numCols = in->numCols; 763 int numRows = in->numRows; 764 765 if (mask != NULL) { 766 if (numRows != mask->numRows || numCols != mask->numCols) { 767 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 768 PS_ERR_BAD_PARAMETER_VALUE, true, 769 PS_ERRORTEXT_psImage_IMAGE_MASK_SIZE, 770 mask->numCols,mask->numRows, 771 numCols, numRows); 772 psFree(out); 773 } 774 if (mask->type.type != PS_TYPE_MASK) { 775 char* typeStr; 776 PS_TYPE_NAME(typeStr,mask->type.type); 777 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 778 PS_ERR_BAD_PARAMETER_TYPE, true, 779 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, 780 typeStr, PS_TYPE_MASK_NAME); 781 psFree(out); 782 } 783 } 784 785 if (centerCol < 0 || centerCol >= numCols || 786 centerRow < 0 || centerRow >= numRows) { 787 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 788 PS_ERR_BAD_PARAMETER_VALUE, true, 789 PS_ERRORTEXT_psImage_CENTER_NOT_IN_IMAGE, 790 centerCol, centerRow, 791 numCols, numRows); 792 psFree(out); 793 } 794 795 if (radii == NULL) { 796 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 797 PS_ERR_BAD_PARAMETER_NULL, true, 798 PS_ERRORTEXT_psImage_RADII_VECTOR_NULL); 799 psFree(out); 800 return NULL; 801 } 802 803 if (radii->n < 2) { 804 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 805 PS_ERR_BAD_PARAMETER_VALUE, true, 806 PS_ERRORTEXT_psImage_RADII_VECTOR_TOOSMALL, 807 radii->n); 808 psFree(out); 809 return NULL; 810 } 811 812 if (stats == NULL) { 813 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 814 PS_ERR_BAD_PARAMETER_NULL, true, 815 PS_ERRORTEXT_psImage_STAT_NULL); 816 psFree(out); 817 return NULL; 818 } 819 820 // verify that the stats struct specifies a 821 // single stats operation 822 if (p_psGetStatValue(stats, &statVal) == false) { 823 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageRadialCut", 824 PS_ERR_BAD_PARAMETER_VALUE, false, 825 PS_ERRORTEXT_psImage_BAD_STAT); 826 psFree(out); 827 return NULL; 828 } 829 830 /* completed checking the parameters */ 831 832 // size the output vector to proper size. 833 int numOut = radii->n - 1; 834 out = psVectorRecycle(out, numOut, PS_TYPE_F64); 835 psF64* outData = out->data.F64; 836 837 // sort the radii by value 838 psVector* rSqVec = psVectorCopy(NULL, radii, PS_TYPE_F32); 839 psVectorSort(rSqVec,rSqVec); 840 psF32* rSq = rSqVec->data.F32; 841 842 int startRow = centerRow - rSq[numOut]; 843 int endRow = centerRow + rSq[numOut]; 844 int startCol = centerCol - rSq[numOut]; 845 int endCol = centerCol + rSq[numOut]; 846 847 if (startRow < 0) { 848 startRow = 0; 849 } 850 851 if (startCol < 0) { 852 startCol = 0; 853 } 854 855 if (endRow >= numRows) { 856 endRow = numRows - 1; 857 } 858 859 if (endCol >= numCols) { 860 endCol = numCols - 1; 861 } 862 863 // Square the data 864 for (int d = 0; d <= numOut; d++) { 865 rSq[d] *= rSq[d]; 866 } 867 868 // create temporary vectors for the data binning step 869 psVector** buffer = psAlloc(sizeof(psVector*)*numOut); 870 psVector** bufferMask = psAlloc(sizeof(psVector*)*numOut); 871 for (int lcv = 0; lcv < numOut; lcv++) { 872 // n.b. alloc enough for the data by making the vectors slightly larger 873 // than the area of the region of interest. 874 buffer[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]), 875 in->type.type); 876 buffer[lcv]->n = 0; 877 878 bufferMask[lcv] = NULL; 879 if (mask != NULL) { 880 bufferMask[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]), 881 PS_TYPE_MASK); 882 bufferMask[lcv]->n = 0; 883 } 884 } 885 886 float dX; 887 float dY; 888 float dist; 889 for (int row=startRow; row <= endRow; row++) { 890 psF32* inRow = in->data.F32[row]; 891 psMaskType* maskRow = NULL; 892 if (mask != NULL) { 893 maskRow = mask->data.PS_TYPE_MASK_DATA[row]; 894 } 895 for (int col=startCol; col <= endCol; col++) { 896 dX = centerCol - (float)col - 0.5f; 897 dY = centerRow - (float)row - 0.5f; 898 dist = dX*dX+dY*dY; 899 for (int r = 0; r < numOut;) { 900 if (rSq[r] < dist && dist < rSq[++r]) { 901 int n = buffer[r]->n; 902 if (n == buffer[r]->nalloc) { // in case buffers already full, expand 903 buffer[r] = psVectorRealloc(n*2, buffer[r]); 904 if (bufferMask[r] != NULL) { 905 bufferMask[r] = psVectorRealloc(n*2, bufferMask[r]); 906 } 907 } 908 909 buffer[r]->data.F32[n] = inRow[col]; 910 buffer[r]->n = n+1; 911 912 if (maskRow != NULL) { 913 bufferMask[r]->data.PS_TYPE_MASK_DATA[n] = maskRow[col]; 914 bufferMask[r]->n = n+1; 915 } 916 917 break; 918 } 919 } 920 } 921 } 922 923 psStats* myStats = psAlloc(sizeof(psStats)); 924 *myStats = *stats; 925 926 for (int r = 0; r < numOut; r++) { 927 myStats = psVectorStats(myStats,buffer[r], bufferMask[r],maskVal); 928 (void)p_psGetStatValue(myStats,&statVal); 929 outData[r] = statVal; 930 } 931 932 psFree(myStats); 933 934 for (int lcv = 0; lcv < numOut; lcv++) { 935 psFree(buffer[lcv]); 936 psFree(bufferMask[lcv]); 937 } 938 psFree(buffer); 939 psFree(bufferMask); 940 941 return out; 637 942 } -
trunk/psLib/src/image/psImageExtraction.h
r1864 r1897 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 3 18:31:49$12 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 145 145 psVector* psImageCut( 146 146 psVector* out, ///< psVector to recycle, or NULL. 147 psVector* coords, ///< if not NULL, the calculated coordinates along the slice (output) 147 psVector* cutCols, ///< if not NULL, the calculated column values along the slice (output) 148 psVector* cutRows, ///< if not NULL, the calculated row values along the slice (output) 148 149 const psImage* input, ///< the input image in which to perform the cut 149 150 const psImage* restrict mask, ///< the mask for the input image. -
trunk/psLib/src/image/psImageManip.c
r1894 r1897 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-25 0 0:47:54$12 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 580 580 float inRow = (float)row * invScale; \ 581 581 for (int col=0;col<outCols;col++) { \ 582 rowData[col] = psImagePixelInterpolate(in,inRow,(float)col*invScale, 0,mode); \582 rowData[col] = psImagePixelInterpolate(in,inRow,(float)col*invScale,NULL,0,0,mode); \ 583 583 } \ 584 584 } \ … … 889 889 outRow = out->data.TYPE[y]; \ 890 890 for (int x = 0; x < outCols; x++) { \ 891 outRow[x] = p_psImagePixelInterpolate##MODE##_##TYPE(in,inX,inY, unexposedValue); \891 outRow[x] = p_psImagePixelInterpolate##MODE##_##TYPE(in,inX,inY,NULL,0,unexposedValue); \ 892 892 inX += cosT; \ 893 893 inY -= sinT; \ … … 1013 1013 for (int col=0;col<outCols;col++) { \ 1014 1014 outRow[col] = p_psImagePixelInterpolate##MODE##_##TYPE( \ 1015 in,dx+(float)col,y, unexposedValue); \1015 in,dx+(float)col,y,NULL,0,unexposedValue); \ 1016 1016 } \ 1017 1017 } \ -
trunk/psLib/src/mathtypes/psImage.c
r1841 r1897 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 1 23:15:04$12 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 199 199 float x, 200 200 float y, 201 const psImage* mask, 202 unsigned int maskVal, 201 203 psC64 unexposedValue, 202 204 psImageInterpolateMode mode) … … 214 216 switch (mode) { \ 215 217 case PS_INTERPOLATE_FLAT: \ 216 return p_psImagePixelInterpolateFLAT_##TYPE(input, x, y, \ 218 return p_psImagePixelInterpolateFLAT_##TYPE( \ 219 input, \ 220 x, \ 221 y, \ 222 mask, \ 223 maskVal, \ 217 224 unexposedValue); \ 218 225 break; \ 219 226 case PS_INTERPOLATE_BILINEAR: \ 220 return p_psImagePixelInterpolateBILINEAR_##TYPE(input,x,y, \ 227 return p_psImagePixelInterpolateBILINEAR_##TYPE( \ 228 input, \ 229 x, \ 230 y, \ 231 mask, \ 232 maskVal, \ 221 233 unexposedValue); \ 222 234 break; \ … … 259 271 float x, \ 260 272 float y, \ 273 const psImage* mask, \ 274 unsigned int maskVal, \ 261 275 psF64 unexposedValue) \ 262 276 { \ … … 269 283 (intX > lastX) || \ 270 284 (intY < 0) || \ 271 (intY > lastY)) { \ 285 (intY > lastY) || \ 286 ( (mask!=NULL) && \ 287 ((mask->data.PS_TYPE_MASK_DATA[intY][intX] & maskVal) != 0) ) ) { \ 272 288 return unexposedValue; \ 273 289 } \ … … 280 296 float x, \ 281 297 float y, \ 298 const psImage* mask, \ 299 unsigned int maskVal, \ 282 300 psC64 unexposedValue) \ 283 301 { \ … … 290 308 (intX > lastX) || \ 291 309 (intY < 0) || \ 292 (intY > lastY)) { \ 310 (intY > lastY) || \ 311 ( (mask!=NULL) && \ 312 ((mask->data.PS_TYPE_MASK_DATA[intY][intX] & maskVal) != 0) ) ) { \ 293 313 return unexposedValue; \ 294 314 } \ … … 314 334 float x, \ 315 335 float y, \ 336 const psImage* mask, \ 337 unsigned int maskVal, \ 316 338 psF64 unexposedValue) \ 317 339 { \ 318 340 double floorX = floor((psF64)(x) - 0.5); \ 319 341 double floorY = floor((psF64)(y) - 0.5); \ 320 doublefracX = x - 0.5 - floorX; \321 doublefracY = y - 0.5 - floorY; \342 psF64 fracX = x - 0.5 - floorX; \ 343 psF64 fracY = y - 0.5 - floorY; \ 322 344 int intFloorX = (int) floorX; \ 323 345 int intFloorY = (int) floorY; \ 324 346 int lastX = input->numCols - 1; \ 325 347 int lastY = input->numRows - 1; \ 326 double rx = 0.0; \ 327 psF64 pixel = 0.0; \ 328 ps##TYPE* currentRow; \ 329 ps##TYPE* nextRow; \ 330 \ 331 if ((intFloorX < 0) || \ 332 (intFloorX > lastX) || \ 333 (intFloorY < 0) || \ 334 (intFloorY > lastY)) { \ 335 return unexposedValue; \ 336 } \ 337 \ 338 currentRow = input->data.TYPE[intFloorY]; \ 339 if (intFloorY == lastY) { \ 340 pixel = currentRow[intFloorX]; \ 341 if (intFloorX < lastX) { \ 342 pixel+= fracY * ((psF64)currentRow[intFloorX+1] - \ 343 (psF64)currentRow[intFloorX]); \ 344 } \ 345 return(pixel); \ 346 } \ 347 nextRow = input->data.TYPE[intFloorY+1]; \ 348 if (intFloorX == lastX) { \ 349 pixel = currentRow[intFloorX]; \ 350 if (intFloorY < lastY) { \ 351 pixel+= fracX * ((psF64)nextRow[intFloorX] - \ 352 (psF64)currentRow[intFloorX]); \ 353 } \ 354 return(pixel); \ 355 } \ 356 \ 357 rx = currentRow[intFloorX] + \ 358 fracX * ((psF64)currentRow[intFloorX+1] - \ 359 (psF64)currentRow[intFloorX]); \ 360 \ 361 pixel = rx + fracY * ((psF64)nextRow[intFloorX] + \ 362 fracX * ((psF64)nextRow[intFloorX+1] - \ 363 (psF64)nextRow[intFloorX]) - rx); \ 364 \ 365 return(pixel); \ 366 } 348 ps##TYPE V00; \ 349 ps##TYPE V01; \ 350 ps##TYPE V10; \ 351 ps##TYPE V11; \ 352 bool valid00 = false; \ 353 bool valid01 = false; \ 354 bool valid10 = false; \ 355 bool valid11 = false; \ 356 \ 357 if (intFloorY >= 0 && intFloorY <= lastY) { \ 358 if (intFloorX >= 0 && intFloorX <= lastX) { \ 359 V00 = input->data.TYPE[intFloorY][intFloorX]; \ 360 valid00 = (mask == NULL) || \ 361 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX] & maskVal) == 0); \ 362 } \ 363 if (intFloorX >= -1 && intFloorX < lastX) { \ 364 V10 = input->data.TYPE[intFloorY][intFloorX+1]; \ 365 valid10 = (mask == NULL) || \ 366 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX+1] & maskVal) == 0); \ 367 } \ 368 } \ 369 if (intFloorY >= -1 && intFloorY < lastY) { \ 370 if (intFloorX >= 0 && intFloorX <= lastX) { \ 371 V01 = input->data.TYPE[intFloorY+1][intFloorX]; \ 372 valid01 = (mask == NULL) || \ 373 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX] & maskVal) == 0); \ 374 } \ 375 if (intFloorX >= -1 && intFloorX < lastX) { \ 376 V11 = input->data.TYPE[intFloorY+1][intFloorX+1]; \ 377 valid11 = (mask == NULL) || \ 378 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX+1] & maskVal) == 0); \ 379 } \ 380 } \ 381 \ 382 /* cover likely case of all pixels being valid more efficiently */ \ 383 if (valid00 && valid10 && valid01 && valid11) { \ 384 /* formula from the ADD */ \ 385 psF64 rx = V00 + (V10-V00)*fracX; \ 386 return (rx + (V01 + (V11 - V01) * fracX - rx) * fracY); \ 387 } \ 388 \ 389 /* OK, at least one pixel is not valid - need to do it piecemeal */ \ 390 \ 391 psF64 V0; \ 392 bool valid0 = true; \ 393 if (valid00 && valid10) { \ 394 V0 = V00*(1-fracX)+V10*fracX; \ 395 } else if (valid00) { \ 396 V0 = V00; \ 397 } else if (valid10) { \ 398 V0 = V10; \ 399 } else { \ 400 valid0 = false; \ 401 } \ 402 \ 403 psF64 V1; \ 404 bool valid1 = true; \ 405 if (valid01 && valid11) { \ 406 V0 = V01*(1-fracX)+V11*fracX; \ 407 } else if (valid01) { \ 408 V0 = V01; \ 409 } else if (valid11) { \ 410 V0 = V11; \ 411 } else { \ 412 valid1 = false; \ 413 } \ 414 \ 415 if (valid0 && valid1) { \ 416 return ( V0*(1-fracY) + V1*fracY ); \ 417 } else if (valid0) { \ 418 return V0; \ 419 } else if (valid1) { \ 420 return V1; \ 421 } \ 422 \ 423 return unexposedValue; \ 424 } 425 367 426 #define PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(TYPE) \ 368 427 inline psC64 p_psImagePixelInterpolateBILINEAR_##TYPE(const psImage* input, \ 369 428 float x, \ 370 429 float y, \ 430 const psImage* mask, \ 431 unsigned int maskVal, \ 371 432 psC64 unexposedValue) \ 372 433 { \ 373 434 double floorX = floor((psF64)(x) - 0.5); \ 374 435 double floorY = floor((psF64)(y) - 0.5); \ 375 doublefracX = x - 0.5 - floorX; \376 doublefracY = y - 0.5 - floorY; \436 psF64 fracX = x - 0.5 - floorX; \ 437 psF64 fracY = y - 0.5 - floorY; \ 377 438 int intFloorX = (int) floorX; \ 378 439 int intFloorY = (int) floorY; \ 379 440 int lastX = input->numCols - 1; \ 380 441 int lastY = input->numRows - 1; \ 381 double rx = 0.0; \ 382 psC64 pixel = 0.0; \ 383 ps##TYPE* currentRow; \ 384 ps##TYPE* nextRow; \ 385 \ 386 if ((intFloorX < 0) || \ 387 (intFloorX > lastX) || \ 388 (intFloorY < 0) || \ 389 (intFloorY > lastY)) { \ 390 return unexposedValue; \ 391 } \ 392 \ 393 currentRow = input->data.TYPE[intFloorY]; \ 394 if (intFloorY == lastY) { \ 395 pixel = currentRow[intFloorX]; \ 396 if (intFloorX < lastX) { \ 397 pixel+= fracY * (currentRow[intFloorX+1] - \ 398 currentRow[intFloorX]); \ 399 } \ 400 return(pixel); \ 401 } \ 402 nextRow = input->data.TYPE[intFloorY+1]; \ 403 if (intFloorX == lastX) { \ 404 pixel = currentRow[intFloorX]; \ 405 if (intFloorY < lastY) { \ 406 pixel+= fracX * (nextRow[intFloorX] - \ 407 currentRow[intFloorX]); \ 408 } \ 409 return(pixel); \ 410 } \ 411 \ 412 rx = currentRow[intFloorX] + \ 413 fracX * (currentRow[intFloorX+1] - \ 414 currentRow[intFloorX]); \ 415 \ 416 pixel = rx + fracY * ((psF64)nextRow[intFloorX] + \ 417 fracX * (nextRow[intFloorX+1] - \ 418 nextRow[intFloorX]) - rx); \ 419 \ 420 return(pixel); \ 442 ps##TYPE V00; \ 443 ps##TYPE V01; \ 444 ps##TYPE V10; \ 445 ps##TYPE V11; \ 446 bool valid00 = false; \ 447 bool valid01 = false; \ 448 bool valid10 = false; \ 449 bool valid11 = false; \ 450 \ 451 if (intFloorY >= 0 && intFloorY <= lastY) { \ 452 if (intFloorX >= 0 && intFloorX <= lastX) { \ 453 V00 = input->data.TYPE[intFloorY][intFloorX]; \ 454 valid00 = (mask == NULL) || \ 455 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX] & maskVal) == 0); \ 456 } \ 457 if (intFloorX >= -1 && intFloorX < lastX) { \ 458 V10 = input->data.TYPE[intFloorY][intFloorX+1]; \ 459 valid10 = (mask == NULL) || \ 460 ((mask->data.PS_TYPE_MASK_DATA[intFloorY][intFloorX+1] & maskVal) == 0); \ 461 } \ 462 } \ 463 if (intFloorY >= -1 && intFloorY < lastY) { \ 464 if (intFloorX >= 0 && intFloorX <= lastX) { \ 465 V01 = input->data.TYPE[intFloorY+1][intFloorX]; \ 466 valid01 = (mask == NULL) || \ 467 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX] & maskVal) == 0); \ 468 } \ 469 if (intFloorX >= -1 && intFloorX < lastX) { \ 470 V11 = input->data.TYPE[intFloorY+1][intFloorX+1]; \ 471 valid11 = (mask == NULL) || \ 472 ((mask->data.PS_TYPE_MASK_DATA[intFloorY+1][intFloorX+1] & maskVal) == 0); \ 473 } \ 474 } \ 475 \ 476 /* cover likely case of all pixels being valid */ \ 477 if (valid00 && valid10 && valid01 && valid11) { \ 478 /* formula from the ADD */ \ 479 psC64 rx = V00 + (V10-V00)*fracX; \ 480 return (rx + (V01 + (V11 - V01) * fracX - rx) * fracY); \ 481 } \ 482 \ 483 /* OK, at least one pixel is not valid - need to do it piecemeal */ \ 484 \ 485 psC64 V0; \ 486 bool valid0 = true; \ 487 if (valid00 && valid10) { \ 488 V0 = V00*(1-fracX)+V10*fracX; \ 489 } else if (valid00) { \ 490 V0 = V00; \ 491 } else if (valid10) { \ 492 V0 = V10; \ 493 } else { \ 494 valid0 = false; \ 495 } \ 496 \ 497 psC64 V1; \ 498 bool valid1 = true; \ 499 if (valid01 && valid11) { \ 500 V0 = V01*(1-fracX)+V11*fracX; \ 501 } else if (valid01) { \ 502 V0 = V01; \ 503 } else if (valid11) { \ 504 V0 = V11; \ 505 } else { \ 506 valid1 = false; \ 507 } \ 508 \ 509 if (valid0 && valid1) { \ 510 return ( V0*(1-fracY) + V1*fracY ); \ 511 } else if (valid0) { \ 512 return V0; \ 513 } else if (valid1) { \ 514 return V1; \ 515 } \ 516 \ 517 return unexposedValue; \ 421 518 } 422 519 -
trunk/psLib/src/mathtypes/psImage.h
r1839 r1897 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-09-2 1 19:51:41$13 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-09-25 02:06:12 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 118 118 float x, ///< column location to derive value of 119 119 float y, ///< row location ot derive value of 120 const psImage* mask, ///< if not NULL, the mask of the input image 121 unsigned int maskVal, ///< the mask value 120 122 psC64 unexposedValue, ///< return value if x,y location is not in image. 121 123 psImageInterpolateMode mode ///< interpolation mode … … 124 126 #define p_psImagePixelInterpolateFcns(TYPE) \ 125 127 inline psF64 p_psImagePixelInterpolateFLAT_##TYPE( \ 126 const psImage* input, \ 127 float x, \ 128 float y, \ 129 psF64 unexposedValue \ 128 const psImage* input, /**< input image for interpolation */ \ 129 float x, /**< column location to derive value of */ \ 130 float y, /**< row location ot derive value of */ \ 131 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 132 unsigned int maskVal, /**< the mask value */ \ 133 psF64 unexposedValue /**< return value if x,y location is not in image. */ \ 130 134 ); \ 131 135 inline psF64 p_psImagePixelInterpolateBILINEAR_##TYPE( \ 132 const psImage* input, \ 133 float x, \ 134 float y, \ 135 psF64 unexposedValue \ 136 const psImage* input, /**< input image for interpolation */ \ 137 float x, /**< column location to derive value of */ \ 138 float y, /**< row location ot derive value of */ \ 139 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 140 unsigned int maskVal, /**< the mask value */ \ 141 psF64 unexposedValue /**< return value if x,y location is not in image. */ \ 136 142 ); 137 143 138 144 #define p_psImagePixelInterpolateComplexFcns(TYPE) \ 139 145 inline psC64 p_psImagePixelInterpolateFLAT_##TYPE( \ 140 const psImage* input, \ 141 float x, \ 142 float y, \ 143 psC64 unexposedValue \ 146 const psImage* input, /**< input image for interpolation */ \ 147 float x, /**< column location to derive value of */ \ 148 float y, /**< row location ot derive value of */ \ 149 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 150 unsigned int maskVal, /**< the mask value */ \ 151 psC64 unexposedValue /**< return value if x,y location is not in image. */ \ 144 152 ); \ 145 153 inline psC64 p_psImagePixelInterpolateBILINEAR_##TYPE( \ 146 const psImage* input, \ 147 float x, \ 148 float y, \ 149 psC64 unexposedValue \ 154 const psImage* input, /**< input image for interpolation */ \ 155 float x, /**< column location to derive value of */ \ 156 float y, /**< row location ot derive value of */ \ 157 const psImage* mask, /**< if not NULL, the mask of the input image */ \ 158 unsigned int maskVal, /**< the mask value */ \ 159 psC64 unexposedValue /**< return value if x,y location is not in image. */ \ 150 160 ); 151 161 … … 162 172 p_psImagePixelInterpolateComplexFcns(C32) 163 173 p_psImagePixelInterpolateComplexFcns(C64) 174 164 175 /// @} 176 165 177 #endif -
trunk/psLib/src/mathtypes/psVector.c
r1820 r1897 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09- 16 23:47:43$12 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-25 02:06:12 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 110 110 } 111 111 112 psVector* psVectorCopy(psVector* out, const psVector* in, psElemType type) 113 { 114 if (in == NULL) { 115 psErrorMsg(PS_ERRORNAME_DOMAIN "psVectorSort", 116 PS_ERR_BAD_PARAMETER_NULL, true, 117 PS_ERRORTEXT_psVector_SORT_NULL); 118 psFree(out); 119 return NULL; 120 } 121 122 int nElements = in->n; 123 124 out = psVectorRecycle(out, nElements, type); 125 126 #define PSVECTOR_COPY(INTYPE,OUTTYPE) { \ 127 ps##INTYPE *inVec = in->data.INTYPE; \ 128 ps##OUTTYPE *outVec = out->data.OUTTYPE; \ 129 for (int col=0;col<nElements;col++) { \ 130 *(outVec++) = *(inVec++); \ 131 } \ 132 } 133 134 #define PSVECTOR_COPY_CASE(OUTTYPE) \ 135 case PS_TYPE_##OUTTYPE: { \ 136 switch (in->type.type) { \ 137 case PS_TYPE_S8: \ 138 PSVECTOR_COPY(S8,OUTTYPE); \ 139 break; \ 140 case PS_TYPE_S16: \ 141 PSVECTOR_COPY(S16,OUTTYPE); \ 142 break; \ 143 case PS_TYPE_S32: \ 144 PSVECTOR_COPY(S32,OUTTYPE); \ 145 break; \ 146 case PS_TYPE_S64: \ 147 PSVECTOR_COPY(S64,OUTTYPE); \ 148 break; \ 149 case PS_TYPE_U8: \ 150 PSVECTOR_COPY(U8,OUTTYPE); \ 151 break; \ 152 case PS_TYPE_U16: \ 153 PSVECTOR_COPY(U16,OUTTYPE); \ 154 break; \ 155 case PS_TYPE_U32: \ 156 PSVECTOR_COPY(U32,OUTTYPE); \ 157 break; \ 158 case PS_TYPE_U64: \ 159 PSVECTOR_COPY(U64,OUTTYPE); \ 160 break; \ 161 case PS_TYPE_F32: \ 162 PSVECTOR_COPY(F32,OUTTYPE); \ 163 break; \ 164 case PS_TYPE_F64: \ 165 PSVECTOR_COPY(F64,OUTTYPE); \ 166 break; \ 167 case PS_TYPE_C32: \ 168 PSVECTOR_COPY(C32,OUTTYPE); \ 169 break; \ 170 case PS_TYPE_C64: \ 171 PSVECTOR_COPY(C64,OUTTYPE); \ 172 break; \ 173 default: { \ 174 char* typeStr; \ 175 PS_TYPE_NAME(typeStr,type); \ 176 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", \ 177 PS_ERR_BAD_PARAMETER_TYPE, true, \ 178 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, \ 179 typeStr); \ 180 psFree(out); \ 181 } \ 182 } \ 183 break; \ 184 } 185 186 switch (type) { 187 PSVECTOR_COPY_CASE(S8); 188 PSVECTOR_COPY_CASE(S16); 189 PSVECTOR_COPY_CASE(S32); 190 PSVECTOR_COPY_CASE(S64); 191 PSVECTOR_COPY_CASE(U8); 192 PSVECTOR_COPY_CASE(U16); 193 PSVECTOR_COPY_CASE(U32); 194 PSVECTOR_COPY_CASE(U64); 195 PSVECTOR_COPY_CASE(F32); 196 PSVECTOR_COPY_CASE(F64); 197 PSVECTOR_COPY_CASE(C32); 198 PSVECTOR_COPY_CASE(C64); 199 default: { 200 char* typeStr; 201 PS_TYPE_NAME(typeStr,type); 202 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageCopy", 203 PS_ERR_BAD_PARAMETER_TYPE, true, 204 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, 205 typeStr); 206 psFree(out); 207 208 break; 209 } 210 } 211 return out; 212 213 214 } 215 112 216 psVector* psVectorSort(psVector* restrict outVector, const psVector* restrict inVector) 113 217 { -
trunk/psLib/src/mathtypes/psVector.h
r1478 r1897 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-11 20:17:35$14 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-25 02:06:12 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 105 105 ); 106 106 107 /** Copy a vector, converting types. 108 * 109 * Performs a deep copy of the elements of one psVector to a new psVector, 110 * converting numeric types to a specified type. 111 * 112 * @return psVector* Pointer to resulting psVector. 113 * 114 */ 115 psVector* psVectorCopy( 116 psVector* out, ///< if non-NULL, a psVector to recycle 117 const psVector* in, ///< the vector to copy. 118 psElemType type ///< the data type of the resulting psVector 119 ); 120 107 121 /** Sort an array of floats. 108 122 *
Note:
See TracChangeset
for help on using the changeset viewer.
