Changeset 12431 for trunk/psLib/src/imageops/psImagePixelManip.c
- Timestamp:
- Mar 13, 2007, 2:39:51 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImagePixelManip.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImagePixelManip.c
r12256 r12431 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-03- 06 03:09:58$12 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-03-14 00:39:50 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 #endif 21 21 22 #include <complex.h>23 22 #include <math.h> // for isfinite(), etc. 24 23 #include <stdlib.h> … … 90 89 break; 91 90 92 #define psImageClipCaseComplex(type,absfcn)\93 case PS_TYPE_##type: { \94 if (vmin < PS_MIN_##type || vmin > PS_MAX_##type) { \95 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \96 _("Specified %s value, %g, is outside of psImage type's range (%s: %g to %g)."), \97 "vmin",vmin, PS_TYPE_##type##_NAME, \98 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \99 } \100 if (vmax > PS_MAX_##type || vmax < PS_MIN_##type) { \101 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \102 _("Specified %s value, %g, is outside of psImage type's range (%s: %g to %g)."), \103 "vmax",vmax, PS_TYPE_##type##_NAME, \104 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \105 } \106 for (psU32 row = 0;row<numRows;row++) { \107 ps##type* inputRow = input->data.type[row]; \108 for (psU32 col = 0; col < numCols; col++) { \109 if (absfcn(inputRow[col]) < min) { \110 inputRow[col] = (ps##type)vmin; \111 numClipped++; \112 } else if (absfcn(inputRow[col]) > max) { \113 inputRow[col] = (ps##type)vmax; \114 numClipped++; \115 } \116 } \117 } \118 } \119 break;120 121 91 psImageClipCase(S8) 122 92 psImageClipCase(S16) … … 129 99 psImageClipCase(F32) 130 100 psImageClipCase(F64) 131 psImageClipCaseComplex(C32, cabsf)132 psImageClipCaseComplex(C64, cabs)133 101 134 102 default: { … … 174 142 psImageClipNaNCase(F32) 175 143 psImageClipNaNCase(F64) 176 psImageClipNaNCase(C32)177 psImageClipNaNCase(C64)178 144 179 145 default: { … … 331 297 psImageOverlayCase(F32,NAN); 332 298 psImageOverlayCase(F64,NAN); 333 psImageOverlayCase(C32,NAN);334 psImageOverlayCase(C64,NAN);335 299 336 300 default: { … … 347 311 } 348 312 349 int psImageClipComplexRegion(psImage* input,350 double complex min,351 double complex vmin,352 double complex max,353 double complex vmax)354 {355 psS32 numClipped = 0;356 psU32 numRows;357 psU32 numCols;358 psF64 realMin = creal(min);359 psF64 imagMin = cimag(min);360 psF64 realMax = creal(max);361 psF64 imagMax = cimag(max);362 363 if (input == NULL) {364 psError(PS_ERR_BAD_PARAMETER_NULL, true,365 _("Can not operate on a NULL psImage."));366 return 0;367 }368 369 if (realMax < realMin) {370 psError(PS_ERR_BAD_PARAMETER_VALUE, true,371 _("Specified real-portion of min value, %g, can not be greater than the real-portion of max value, %g."),372 (double)realMin, (double)realMax);373 return 0;374 }375 if (imagMax < imagMin) {376 psError(PS_ERR_BAD_PARAMETER_VALUE, true,377 _("Specified imaginary-portion of min value, %g, can not be greater than the imaginary-portion of max value, %g."),378 (double)imagMin, (double)imagMax);379 return 0;380 }381 382 numRows = input->numRows;383 numCols = input->numCols;384 385 #define psImageClipComplexRegionCase(type,realfcn,imagfcn) \386 case PS_TYPE_##type: { \387 if (realfcn(vmin) < PS_MIN_##type || imagfcn(vmin) < PS_MIN_##type || \388 realfcn(vmin) > PS_MAX_##type || imagfcn(vmin) > PS_MAX_##type ) { \389 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \390 _("Specified %s value, %g%+gi, is not the the range of input psImage's valid pixel values (%s), i.e. [%g:%g]."), \391 "vmin", creal(vmin), cimag(vmin), \392 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \393 break; \394 } \395 if (realfcn(vmax) > PS_MAX_##type || imagfcn(vmax) > PS_MAX_##type || \396 realfcn(vmax) < PS_MIN_##type || imagfcn(vmax) < PS_MIN_##type ) { \397 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \398 _("Specified %s value, %g%+gi, is not the the range of input psImage's valid pixel values (%s), i.e. [%g:%g]."), \399 "vmax", creal(vmax), cimag(vmax), \400 PS_TYPE_##type##_NAME, PS_MIN_##type, PS_MAX_##type); \401 break; \402 } \403 for (psU32 row = 0;row<numRows;row++) { \404 ps##type* inputRow = input->data.type[row]; \405 for (psU32 col = 0; col < numCols; col++) { \406 if ( (realfcn(inputRow[col]) > realMax) || (imagfcn(inputRow[col]) > imagMax) ) { \407 inputRow[col] = (ps##type)vmax; \408 numClipped++; \409 } else if ( (realfcn(inputRow[col]) < realMin) || (imagfcn(inputRow[col]) < imagMin) ){ \410 inputRow[col] = (ps##type)vmin; \411 numClipped++; \412 } \413 } \414 } \415 } \416 break;417 418 switch (input->type.type) {419 420 psImageClipComplexRegionCase(C32, crealf, cimagf)421 psImageClipComplexRegionCase(C64, creal, cimag)422 423 default: {424 char* typeStr;425 PS_TYPE_NAME(typeStr,input->type.type);426 psError(PS_ERR_BAD_PARAMETER_TYPE, true,427 _("Specified psImage type, %s, is not supported."),428 typeStr);429 }430 }431 432 return numClipped;433 }
Note:
See TracChangeset
for help on using the changeset viewer.
