Changeset 1292 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- Jul 23, 2004, 4:00:21 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r1263 r1292 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-2 2 20:42:22$12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-24 02:00:21 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "psMemory.h" 26 26 #include "psImageExtraction.h" 27 28 bool getSpecifiedStatValue(const psStats* stats, double* value);29 27 30 28 int psImageClip(psImage* input, psF64 min, psF64 vmin, psF64 max, psF64 vmax) … … 337 335 } 338 336 339 bool getSpecifiedStatValue(const psStats* stats, double* value)340 {341 342 switch (stats->options &343 ~ (PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {344 case PS_STAT_SAMPLE_MEAN:345 *value = stats->sampleMean;346 return true;347 348 case PS_STAT_SAMPLE_MEDIAN:349 *value = stats->sampleMedian;350 return true;351 352 case PS_STAT_SAMPLE_STDEV:353 *value = stats->sampleStdev;354 return true;355 356 case PS_STAT_ROBUST_MEAN:357 *value = stats->robustMean;358 return true;359 360 case PS_STAT_ROBUST_MEDIAN:361 *value = stats->robustMedian;362 return true;363 364 case PS_STAT_ROBUST_MODE:365 *value = stats->robustMode;366 return true;367 368 case PS_STAT_ROBUST_STDEV:369 *value = stats->robustStdev;370 return true;371 372 case PS_STAT_CLIPPED_MEAN:373 *value = stats->clippedMean;374 return true;375 376 case PS_STAT_CLIPPED_STDEV:377 *value = stats->clippedStdev;378 return true;379 380 case PS_STAT_MAX:381 *value = stats->max;382 return true;383 384 case PS_STAT_MIN:385 *value = stats->min;386 return true;387 388 default:389 return false;390 }391 }392 393 337 394 338 psImage* psImageRebin(psImage* out,const psImage* in,unsigned int scale,const psStats* stats) … … 420 364 } 421 365 422 if ( getSpecifiedStatValue(stats,&statVal) == false) {366 if (p_psGetStatValue(stats,&statVal) == false) { 423 367 psError(__func__,"The stat options didn't specify a single supported statistic type."); 424 368 psFree(out); … … 457 401 vec->n = n; \ 458 402 myStats = psVectorStats(myStats,vec,NULL,0); \ 459 getSpecifiedStatValue(myStats,&statVal); \403 p_psGetStatValue(myStats,&statVal); \ 460 404 outRowData[col] = (ps##type)statVal; \ 461 405 } \ … … 723 667 float cosT = cosf(t); 724 668 float sinT = sinf(t); 725 float cosNegT = cosf(-t);726 float sinNegT = sinf(-t);727 669 728 670 // calculate the corners of the rotated image so we know the proper output image size. … … 730 672 // y' = y cos(t) - x sin(t); i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT; 731 673 732 #define rotateProjectX(x,y) (x-centerX)*cosNegT + (y-centerY)*sinNegT 733 #define rotateProjectY(x,y) (y-centerY)*cosNegT - (x-centerX)*sinNegT 734 735 // bottom-left, i.e., (0,0) 736 float xbl = rotateProjectX(0,0); 737 float ybl = rotateProjectY(0,0); 738 // bottom-right, i.e., (numCols,0) 739 float xbr = rotateProjectX(numCols,0); 740 float ybr = rotateProjectY(numCols,0); 741 // top-left, i.e., (0,numRows) 742 float xtl = rotateProjectX(0,numRows); 743 float ytl = rotateProjectY(0,numRows); 744 // top-right, i.e., (numCols,numRows) 745 float xtr = rotateProjectX(numCols,numRows); 746 float ytr = rotateProjectY(numCols,numRows); 747 748 float minX = xbl; 749 minX = (minX > xbr) ? xbr : minX; 750 minX = (minX > xtl) ? xtl : minX; 751 minX = (minX > xtr) ? xtr : minX; 752 753 float minY = ybl; 754 minY = (minY > ybr) ? ybr : minY; 755 minY = (minY > ytl) ? ytl : minY; 756 minY = (minY > ytr) ? ytr : minY; 757 758 float maxX = xbl; 759 maxX = (maxX < xbr) ? xbr : maxX; 760 maxX = (maxX < xtl) ? xtl : maxX; 761 maxX = (maxX < xtr) ? xtr : maxX; 762 763 float maxY = ybl; 764 maxY = (maxY < ybr) ? ybr : maxY; 765 maxY = (maxY < ytl) ? ytl : maxY; 766 maxY = (maxY < ytr) ? ytr : maxY; 767 768 int intMinY = minY; 769 int outRows = ceil(maxY-minY)+1; 770 int outCols = ceil(maxX-minX)+1; 674 675 int outCols = ceil(abs(numCols*cosT)+abs(numRows*sinT))+1; 676 int outRows = ceil(abs(numCols*sinT)+abs(numRows*cosT))+1; 677 float minX = (float)outCols/-2.0f; 678 int intMinY = outRows/-2; 771 679 772 680 out = psImageRecycle(out,outCols,outRows,type);
Note:
See TracChangeset
for help on using the changeset viewer.
