Changeset 1226
- Timestamp:
- Jul 15, 2004, 9:58:37 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
image/psImageManip.c (modified) (5 diffs)
-
image/psImageManip.h (modified) (2 diffs)
-
sys/psType.h (modified) (2 diffs)
-
sysUtils/psType.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r1216 r1226 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-1 4 23:22:49$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-15 19:58:37 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include <stdlib.h> 19 19 #include <stdbool.h> 20 #include <string.h> // for memcpy, etc. 20 21 21 22 #include "psError.h" … … 50 51 if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \ 51 52 psError(__func__, "Specified vmin (%g) is outside of image's " \ 52 typename " pixel range ", \53 vmin ); \53 typename " pixel range (%g to %g)", \ 54 vmin,(psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 54 55 } \ 55 56 if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \ 56 57 psError(__func__, "Specified vmax (%g) is outside of image's " \ 57 typename " pixel range", \ 58 vmax); \ 59 } \ 60 ps##type minimum = (ps##type) min; \ 61 ps##type maximum = (ps##type) max; \ 58 typename " pixel range (%g to %g)", \ 59 vmax,(psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 60 } \ 62 61 for (unsigned int row = 0;row<numRows;row++) { \ 63 62 ps##type* inputRow = input->data.type[row]; \ 64 63 for (unsigned int col = 0; col < numCols; col++) { \ 65 if ( inputRow[col] < minimum) { \64 if ((psF64)inputRow[col] < min) { \ 66 65 inputRow[col] = (ps##type)vmin; \ 67 66 numClipped++; \ 68 } else if ( inputRow[col] > maximum) { \67 } else if ((psF64)inputRow[col] > max) { \ 69 68 inputRow[col] = (ps##type)vmax; \ 70 69 numClipped++; \ … … 341 340 342 341 switch (stats->options & 343 !(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {342 ~ (PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) { 344 343 case PS_STAT_SAMPLE_MEAN: 345 344 *value = stats->sampleMean; … … 484 483 return out; 485 484 } 485 486 psImage* psImageRoll(psImage* out, const psImage* in, int dx, int dy) 487 { 488 int outRows; 489 int outCols; 490 int elementSize; 491 492 if (in == NULL) { 493 psError(__func__,"Input image can not be NULL."); 494 return NULL; 495 } 496 497 // create an output image of the same size and type 498 outRows = in->numRows; 499 outCols = in->numCols; 500 elementSize = PSELEMTYPE_SIZEOF(in->type.type); 501 out = psImageRecycle(out,outCols, outRows, in->type.type); 502 503 // make dx and dy between 0 and outCols or outRows, respectively 504 dx = dx % outCols; 505 dy = dy % outRows; 506 if (dx < 0) { 507 dx += outCols; 508 } 509 if (dy < 0) { 510 dy += outRows; 511 } 512 513 int segment1Size = elementSize*(outCols-dx); 514 int segment2Size = elementSize*dx; 515 516 for (int row=0;row<outRows;row++) { 517 int inRowNumber = row+dy; 518 if (inRowNumber >= outRows) { 519 inRowNumber -= outRows; 520 } 521 psU8* inRow = in->data.U8[inRowNumber]; // to allow byte arithmetic, but for all types 522 psU8* outRow = out->data.U8[row]; 523 memcpy(outRow,inRow+segment2Size,segment1Size); 524 memcpy(outRow+segment1Size,inRow,segment2Size); 525 } 526 527 return out; 528 } -
trunk/psLib/src/image/psImageManip.h
r1216 r1226 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-1 4 23:22:49$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-15 19:58:37 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 104 104 ); 105 105 106 /** Roll image by an integer number of pixels in either direction. 107 * 108 * The output image is the same dimensions as the input image. Edge pixels 109 * wrap to the other side (no values are lost). This function is 110 * defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64. 111 * 112 * @return psImage* the rolled version of the input image. 113 */ 114 psImage* psImageRoll( 115 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 116 const psImage* in, ///< input image 117 int dx, ///< number of pixels to roll in the x-dimension 118 int dy ///< number of pixels to roll in the y-dimension 119 ); 120 106 121 #endif 107 122 -
trunk/psLib/src/sys/psType.h
r1216 r1226 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-1 4 23:22:49$12 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-15 19:58:37 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 79 79 #define PS_MIN_U32 0 80 80 #define PS_MIN_U64 0 81 #define PS_MIN_F32 FLT_MIN82 #define PS_MIN_F64 DBL_MIN83 #define PS_MIN_C32 FLT_MIN84 #define PS_MIN_C64 DBL_MIN81 #define PS_MIN_F32 -FLT_MAX 82 #define PS_MIN_F64 -DBL_MAX 83 #define PS_MIN_C32 -FLT_MAX 84 #define PS_MIN_C64 -DBL_MAX 85 85 86 86 #define PS_MAX_S8 INT8_MAX -
trunk/psLib/src/sysUtils/psType.h
r1216 r1226 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-1 4 23:22:49$12 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-15 19:58:37 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 79 79 #define PS_MIN_U32 0 80 80 #define PS_MIN_U64 0 81 #define PS_MIN_F32 FLT_MIN82 #define PS_MIN_F64 DBL_MIN83 #define PS_MIN_C32 FLT_MIN84 #define PS_MIN_C64 DBL_MIN81 #define PS_MIN_F32 -FLT_MAX 82 #define PS_MIN_F64 -DBL_MAX 83 #define PS_MIN_C32 -FLT_MAX 84 #define PS_MIN_C64 -DBL_MAX 85 85 86 86 #define PS_MAX_S8 INT8_MAX
Note:
See TracChangeset
for help on using the changeset viewer.
