Changeset 2204 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r2105 r2204 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-10- 14 01:22:59$12 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-27 00:57:31 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include <math.h> // for isfinite(), etc. 19 19 #include <stdlib.h> 20 #include <stdbool.h>21 20 #include <string.h> // for memcpy, etc. 22 21 … … 29 28 #include "psImageErrors.h" 30 29 31 intpsImageClip(psImage* input,32 psF64 min,33 psF64 vmin,34 psF64 max,35 psF64 vmax)30 psS32 psImageClip(psImage* input, 31 psF64 min, 32 psF64 vmin, 33 psF64 max, 34 psF64 vmax) 36 35 { 37 intnumClipped = 0;38 unsigned intnumRows;39 unsigned intnumCols;36 psS32 numClipped = 0; 37 psU32 numRows; 38 psU32 numCols; 40 39 41 40 if (input == NULL) { … … 72 71 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 73 72 } \ 74 for ( unsigned introw = 0;row<numRows;row++) { \73 for (psU32 row = 0;row<numRows;row++) { \ 75 74 ps##type* inputRow = input->data.type[row]; \ 76 for ( unsigned intcol = 0; col < numCols; col++) { \75 for (psU32 col = 0; col < numCols; col++) { \ 77 76 if ((psF64)inputRow[col] < min) { \ 78 77 inputRow[col] = (ps##type)vmin; \ … … 103 102 (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \ 104 103 } \ 105 for ( unsigned introw = 0;row<numRows;row++) { \104 for (psU32 row = 0;row<numRows;row++) { \ 106 105 ps##type* inputRow = input->data.type[row]; \ 107 for ( unsigned intcol = 0; col < numCols; col++) { \106 for (psU32 col = 0; col < numCols; col++) { \ 108 107 if (absfcn(inputRow[col]) < min) { \ 109 108 inputRow[col] = (ps##type)vmin; \ … … 144 143 } 145 144 146 intpsImageClipNaN(psImage* input,147 psF64 value)145 psS32 psImageClipNaN(psImage* input, 146 psF64 value) 148 147 { 149 intnumClipped = 0;150 unsigned intnumRows;151 unsigned intnumCols;148 psS32 numClipped = 0; 149 psU32 numRows; 150 psU32 numCols; 152 151 153 152 if (input == NULL) { … … 161 160 #define psImageClipNaNCase(type) \ 162 161 case PS_TYPE_##type: \ 163 for ( unsigned introw = 0;row<numRows;row++) { \162 for (psU32 row = 0;row<numRows;row++) { \ 164 163 ps##type* inputRow = input->data.type[row]; \ 165 for ( unsigned intcol = 0; col < numCols; col++) { \164 for (psU32 col = 0; col < numCols; col++) { \ 166 165 if (! isfinite(inputRow[col])) { \ 167 166 inputRow[col] = (ps##type)value; \ … … 190 189 } 191 190 192 intpsImageOverlaySection(psImage* image,193 const psImage* overlay,194 intcol0,195 introw0,196 const char *op)191 psS32 psImageOverlaySection(psImage* image, 192 const psImage* overlay, 193 psS32 col0, 194 psS32 row0, 195 const char *op) 197 196 { 198 unsigned intimageNumRows;199 unsigned intimageNumCols;200 unsigned intoverlayNumRows;201 unsigned intoverlayNumCols;202 unsigned intimageRowLimit;203 unsigned intimageColLimit;197 psU32 imageNumRows; 198 psU32 imageNumCols; 199 psU32 overlayNumRows; 200 psU32 overlayNumCols; 201 psU32 imageRowLimit; 202 psU32 imageColLimit; 204 203 psElemType type; 205 204 … … 257 256 #define psImageOverlayCase(DATATYPE) \ 258 257 case PS_TYPE_##DATATYPE: \ 259 for ( unsigned introw=row0;row<imageRowLimit;row++) { \258 for (psU32 row=row0;row<imageRowLimit;row++) { \ 260 259 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 261 260 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \ 262 for ( unsigned intcol=col0;col<imageColLimit;col++) { \261 for (psU32 col=col0;col<imageColLimit;col++) { \ 263 262 switch (*op) { \ 264 263 case '+': \ … … 315 314 } 316 315 317 intpsImageClipComplexRegion(psImage* input,318 psC64 min,319 psC64 vmin,320 psC64 max,321 psC64 vmax)316 psS32 psImageClipComplexRegion(psImage* input, 317 psC64 min, 318 psC64 vmin, 319 psC64 max, 320 psC64 vmax) 322 321 { 323 intnumClipped = 0;324 unsigned intnumRows;325 unsigned intnumCols;322 psS32 numClipped = 0; 323 psU32 numRows; 324 psU32 numCols; 326 325 psF64 realMin = creal(min); 327 326 psF64 imagMin = cimag(min); … … 374 373 break; \ 375 374 } \ 376 for ( unsigned introw = 0;row<numRows;row++) { \375 for (psU32 row = 0;row<numRows;row++) { \ 377 376 ps##type* inputRow = input->data.type[row]; \ 378 for ( unsigned intcol = 0; col < numCols; col++) { \377 for (psU32 col = 0; col < numCols; col++) { \ 379 378 if ( (realfcn(inputRow[col]) > realMax) || (imagfcn(inputRow[col]) > imagMax) ) { \ 380 379 inputRow[col] = (ps##type)vmax; \ … … 411 410 const psImage* restrict mask, 412 411 psMaskType maskVal, 413 unsigned intscale,412 psU32 scale, 414 413 const psStats* stats) 415 414 { 416 intinRows;417 intinCols;418 intoutRows;419 intoutCols;415 psS32 inRows; 416 psS32 inCols; 417 psS32 outRows; 418 psS32 outCols; 420 419 psVector* vec; // vector to hold the values of a single bin. 421 420 psVector* maskVec = NULL; // vector to hold the mask of a single bin. … … 491 490 ps##type* vecData = vec->data.type; \ 492 491 psMaskType* inRowMask = NULL; \ 493 for ( introw = 0; row < outRows; row++) { \492 for (psS32 row = 0; row < outRows; row++) { \ 494 493 outRowData = out->data.type[row]; \ 495 intinCurrentRow = row*scale; \496 intinNextRow = (row+1)*scale; \497 for ( intcol = 0; col < outCols; col++) { \498 intinCurrentCol = col*scale; \499 intinNextCol = (col+1)*scale; \500 intn = 0; \501 for ( intinRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \494 psS32 inCurrentRow = row*scale; \ 495 psS32 inNextRow = (row+1)*scale; \ 496 for (psS32 col = 0; col < outCols; col++) { \ 497 psS32 inCurrentCol = col*scale; \ 498 psS32 inNextCol = (col+1)*scale; \ 499 psS32 n = 0; \ 500 for (psS32 inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \ 502 501 ps##type* inRowData = in->data.type[inRow]; \ 503 502 if (mask != NULL) { \ 504 503 inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \ 505 504 } \ 506 for ( intinCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \505 for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \ 507 506 if (maskData != NULL) { \ 508 507 maskData[n] = inRowMask[inCol]; \ … … 555 554 psImage* psImageResample(psImage* out, 556 555 const psImage* in, 557 intscale,556 psS32 scale, 558 557 psImageInterpolateMode mode) 559 558 { 560 intoutRows;561 intoutCols;559 psS32 outRows; 560 psS32 outCols; 562 561 float invScale; 563 562 … … 597 596 case PS_TYPE_##TYPE: { \ 598 597 out = psImageRecycle(out,outCols, outRows, PS_TYPE_##TYPE); \ 599 for ( introw=0;row<outRows;row++) { \598 for (psS32 row=0;row<outRows;row++) { \ 600 599 ps##TYPE* rowData = out->data.TYPE[row]; \ 601 600 float inRow = (float)row * invScale; \ 602 for ( intcol=0;col<outCols;col++) { \601 for (psS32 col=0;col<outCols;col++) { \ 603 602 rowData[col] = psImagePixelInterpolate(in,(float)col*invScale,inRow,NULL,0,0,mode); \ 604 603 } \ … … 637 636 psImage* psImageRoll(psImage* out, 638 637 const psImage* in, 639 intdx,640 intdy)638 psS32 dx, 639 psS32 dy) 641 640 { 642 intoutRows;643 intoutCols;644 intelementSize;641 psS32 outRows; 642 psS32 outCols; 643 psS32 elementSize; 645 644 646 645 if (in == NULL) { … … 669 668 } 670 669 671 intsegment1Size = elementSize * (outCols - dx);672 intsegment2Size = elementSize * dx;673 674 for ( introw = 0; row < outRows; row++) {675 intinRowNumber = row + dy;670 psS32 segment1Size = elementSize * (outCols - dx); 671 psS32 segment2Size = elementSize * dx; 672 673 for (psS32 row = 0; row < outRows; row++) { 674 psS32 inRowNumber = row + dy; 676 675 677 676 if (inRowNumber >= outRows) { … … 706 705 if (fabsf(angle - 90.0f) < FLT_EPSILON) { 707 706 // perform 1/4 rotate counter-clockwise 708 intnumRows = in->numCols;709 intnumCols = in->numRows;710 intlastCol = numCols - 1;707 psS32 numRows = in->numCols; 708 psS32 numCols = in->numRows; 709 psS32 lastCol = numCols - 1; 711 710 psElemType type = in->type.type; 712 711 … … 716 715 case PS_TYPE_##TYPE: { \ 717 716 ps##TYPE** inData = in->data.TYPE; \ 718 for ( introw=0;row<numRows;row++) { \717 for (psS32 row=0;row<numRows;row++) { \ 719 718 ps##TYPE* outRow = out->data.TYPE[row]; \ 720 for ( intcol=0;col<numCols;col++) { \719 for (psS32 col=0;col<numCols;col++) { \ 721 720 outRow[col] = inData[lastCol-col][row]; \ 722 721 } \ … … 752 751 } else if (fabsf(angle - 180.0f) < FLT_EPSILON) { 753 752 // perform 1/2 rotate 754 intnumRows = in->numRows;755 intlastRow = numRows - 1;756 intnumCols = in->numCols;757 intlastCol = numCols - 1;753 psS32 numRows = in->numRows; 754 psS32 lastRow = numRows - 1; 755 psS32 numCols = in->numCols; 756 psS32 lastCol = numCols - 1; 758 757 psElemType type = in->type.type; 759 758 … … 762 761 #define PSIMAGE_ROTATE_180_CASE(TYPE) \ 763 762 case PS_TYPE_##TYPE: { \ 764 for ( introw=0;row<numRows;row++) { \763 for (psS32 row=0;row<numRows;row++) { \ 765 764 ps##TYPE* outRow = out->data.TYPE[row]; \ 766 765 ps##TYPE* inRow = in->data.TYPE[lastRow-row]; \ 767 for ( intcol=0;col<numCols;col++) { \766 for (psS32 col=0;col<numCols;col++) { \ 768 767 outRow[col] = inRow[lastCol - col]; \ 769 768 } \ … … 799 798 } else if (fabsf(angle - 270.0f) < FLT_EPSILON) { 800 799 // perform 1/4 rotate clockwise 801 intnumRows = in->numCols;802 intlastRow = numRows - 1;803 intnumCols = in->numRows;800 psS32 numRows = in->numCols; 801 psS32 lastRow = numRows - 1; 802 psS32 numCols = in->numRows; 804 803 psElemType type = in->type.type; 805 804 … … 809 808 case PS_TYPE_##TYPE: { \ 810 809 ps##TYPE** inData = in->data.TYPE; \ 811 for ( introw=0;row<numRows;row++) { \810 for (psS32 row=0;row<numRows;row++) { \ 812 811 ps##TYPE* outRow = out->data.TYPE[row]; \ 813 for ( intcol=0;col<numCols;col++) { \812 for (psS32 col=0;col<numCols;col++) { \ 814 813 outRow[col] = inData[col][lastRow-row]; \ 815 814 } \ … … 847 846 } else { 848 847 psElemType type = in->type.type; 849 intnumRows = in->numRows;850 intnumCols = in->numCols;848 psS32 numRows = in->numRows; 849 psS32 numCols = in->numCols; 851 850 float centerX = (float)(numCols) / 2.0f; 852 851 float centerY = (float)(numRows) / 2.0f; … … 859 858 // y' = y cos(t) - x sin(t); i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT; 860 859 861 intoutCols = ceil(abs(numCols * cosT) + abs(numRows * sinT)) + 1;862 intoutRows = ceil(abs(numCols * sinT) + abs(numRows * cosT)) + 1;860 psS32 outCols = ceil(abs(numCols * cosT) + abs(numRows * sinT)) + 1; 861 psS32 outRows = ceil(abs(numCols * sinT) + abs(numRows * cosT)) + 1; 863 862 float minX = (float)outCols / -2.0f; 864 intintMinY = outRows / -2;863 psS32 intMinY = outRows / -2; 865 864 866 865 out = psImageRecycle(out, outCols, outRows, type); … … 906 905 float inY; \ 907 906 ps##TYPE* outRow; \ 908 for ( inty = 0; y < outRows; y++) { \907 for (psS32 y = 0; y < outRows; y++) { \ 909 908 inX = minXTimesCosTPlusCenterX + (y+intMinY) * sinT; \ 910 909 inY = CenterYMinusminXTimesSinT + (y+intMinY) * cosT; \ 911 910 outRow = out->data.TYPE[y]; \ 912 for ( intx = 0; x < outCols; x++) { \911 for (psS32 x = 0; x < outCols; x++) { \ 913 912 outRow[x] = p_psImagePixelInterpolate##MODE##_##TYPE(in,inX,inY,NULL,0,unexposedValue); \ 914 913 inX += cosT; \ … … 993 992 psImageInterpolateMode mode) 994 993 { 995 intoutRows;996 intoutCols;997 intelementSize;994 psS32 outRows; 995 psS32 outCols; 996 psS32 elementSize; 998 997 psElemType type; 999 998 … … 1030 1029 break; \ 1031 1030 } \ 1032 for ( introw=0;row<outRows;row++) { \1031 for (psS32 row=0;row<outRows;row++) { \ 1033 1032 ps##TYPE* outRow = out->data.TYPE[row]; \ 1034 1033 float y = dy+(float)row; \ 1035 for ( intcol=0;col<outCols;col++) { \1034 for (psS32 col=0;col<outCols;col++) { \ 1036 1035 outRow[col] = p_psImagePixelInterpolate##MODE##_##TYPE( \ 1037 1036 in,dx+(float)col,y,NULL,0,unexposedValue); \
Note:
See TracChangeset
for help on using the changeset viewer.
