Changeset 4954 for trunk/psphot/src/psLibUtils.c
- Timestamp:
- Sep 6, 2005, 5:33:01 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psLibUtils.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psLibUtils.c
r4946 r4954 1 # include "psphot.h" 1 # include <strings.h> // for strncasecmp 2 # include <pslib.h> 3 4 // XXX EAM : this is NOT included in the C99 headers ?? 5 FILE *fdopen(int fildes, const char *mode); 2 6 3 7 // XXX EAM : these utility functions should be added back into PSLib … … 29 33 if (timers == NULL) timers = psHashAlloc (16); 30 34 31 start = psTimeGet Time(PS_TIME_UTC);35 start = psTimeGetNow (PS_TIME_UTC); 32 36 psHashAdd (timers, name, start); 33 37 psFree (start); … … 47 51 if (start == NULL) return (0); 48 52 49 mark = psTimeGet Time(PS_TIME_UTC);53 mark = psTimeGetNow (PS_TIME_UTC); 50 54 delta = psTimeDelta (mark, start); 51 55 psFree (mark); … … 53 57 54 58 return (delta); 59 } 60 61 // find the location of the specified argument 62 int psArgumentGet (int argc, char **argv, char *arg) { 63 64 int i; 65 66 for (i = 0; i < argc; i++) { 67 if (!strcmp(argv[i], arg)) 68 return (i); 69 } 70 71 return ((int)NULL); 72 } 73 74 // remove the specified argument (by location) 75 int psArgumentRemove (int N, int *argc, char **argv) { 76 77 int i; 78 79 if ((N != (int)NULL) && (N != 0)) { 80 (*argc)--; 81 for (i = N; i < *argc; i++) { 82 argv[i] = argv[i+1]; 83 } 84 } 85 86 return (N); 55 87 } 56 88 … … 114 146 } 115 147 116 // find the location of the specified argument117 int psArgumentGet (int argc, char **argv, char *arg) {118 119 int i;120 121 for (i = 0; i < argc; i++) {122 if (!strcmp(argv[i], arg))123 return (i);124 }125 126 return ((int)NULL);127 }128 129 // remove the specified argument (by location)130 int psArgumentRemove (int N, int *argc, char **argv) {131 132 int i;133 134 if ((N != (int)NULL) && (N != 0)) {135 (*argc)--;136 for (i = N; i < *argc; i++) {137 argv[i] = argv[i+1];138 }139 }140 141 return (N);142 }143 144 148 // alternate implementation of this function from pmObjects.c 149 // XXX EAM : move this to pmObjects_EAM.c 145 150 psVector *psGetRowVectorFromImage(psImage *image, 146 151 psU32 row) 147 152 { 148 PS_ IMAGE_CHECK_NULL(image, NULL);149 PS_ IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL);153 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 154 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL); 150 155 151 156 psVector *tmpVector = psVectorAlloc(image->numCols, PS_TYPE_F32); … … 201 206 } 202 207 203 void psImageSmooth (psImage *image, float sigma, float Nsigma) { 208 // XXX EAM : this is now in psLib 209 void psImageSmooth_EAM (psImage *image, float sigma, float Nsigma) { 204 210 205 211 int Nx, Ny, Npixel, Nrange; … … 314 320 } 315 321 322 // count number of pixels with given mask value 323 int psImageCountPixelMask (psImage *mask, psU8 value) 324 { 325 int Npixels = 0; 326 327 for (int i = 0; i < mask->numRows; i++) { 328 for (int j = 0; j < mask->numCols; j++) { 329 if (mask->data.U8[i][j] & value) { 330 Npixels ++; 331 } 332 } 333 } 334 return (Npixels); 335 } 336 316 337 // define a square region centered on the given coordinate 338 // XXX EAM : this is now in psLib 339 # if (0) 317 340 psRegion *psRegionSquare (psF32 x, psF32 y, psF32 radius) { 318 341 psRegion *region; … … 321 344 return (region); 322 345 } 346 # endif 323 347 324 348 // set actual region based on image parameters: … … 327 351 // frame, which means the negative values should subtract from Nx,Ny of 328 352 // the parent, not the child. but, we don't carry the dimensions of the 329 // parent in the psImage container. for now, us the child Nx,Ny 330 // force range to be on this subimage 331 // XXX EAM : this needs to be changes to use psRegion rather than psRegion* 353 // parent in the psImage container. for now, use the child Nx,Ny 354 // force range to be on this subimage 355 // XXX EAM : this needs to be changed to use psRegion rather than psRegion* 356 // XXX EAM : this is now in psLib 357 # if (0) 332 358 psRegion *psRegionForImage (psRegion *out, psImage *image, psRegion *in) { 333 359 … … 356 382 return (out); 357 383 } 384 # endif 358 385 359 386 // mask the area contained by the region 360 387 // the region is defined wrt the parent image 388 // XXX EAM : this is now in psLib 389 # if (0) 361 390 void psImageMaskRegion (psImage *image, psRegion *region, bool logical_and, int maskValue) { 362 391 … … 375 404 } 376 405 } 406 # endif 377 407 378 408 // mask the area not contained by the region 379 409 // the region is defined wrt the parent image 410 // XXX EAM : this is now in psLib 411 # if (0) 380 412 void psImageKeepRegion (psImage *image, psRegion *region, bool logical_and, int maskValue) { 381 413 … … 396 428 } 397 429 } 430 # endif 398 431 399 432 // mask the area contained by the region 400 433 // the region is defined wrt the parent image 434 // XXX EAM : this is now in psLib 435 # if (0) 401 436 void psImageMaskCircle (psImage *image, double x, double y, double radius, bool logical_and, int maskValue) { 402 437 … … 419 454 } 420 455 } 456 # endif 421 457 422 458 // mask the area contained by the region 423 459 // the region is defined wrt the parent image 460 // XXX EAM : this is now in psLib 461 # if (0) 424 462 void psImageKeepCircle (psImage *image, double x, double y, double radius, bool logical_and, int maskValue) { 425 463 … … 442 480 } 443 481 } 482 # endif 444 483 445 484 psVector *psVectorCreate (double lower, double upper, double delta, psElemType type) { … … 455 494 return (out); 456 495 } 496 497 // XXX EAM a utility function 498 bool p_psVectorPrintRow (int fd, psVector *a, char *name) 499 { 500 501 FILE *f; 502 f = fdopen(fd, "a+"); 503 fprintf (f, "vector: %s\n", name); 504 505 for (int i = 0; i < a[0].n; i++) { 506 fprintf (f, "%f ", p_psVectorGetElementF64(a, i)); 507 } 508 fprintf (f, "\n"); 509 fclose(f); 510 return (true); 511 } 512 // XXX EAM is the use of fdopen here a good way to do this?
Note:
See TracChangeset
for help on using the changeset viewer.
