IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 23, 2004, 4:00:21 PM (22 years ago)
Author:
desonia
Message:

initial coding of psImageSlice and changed psImageRotate to be more inline
with ADD (mathematically equivalent).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImageManip.c

    r1263 r1292  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-07-22 20:42:22 $
     12 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-07-24 02:00:21 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psMemory.h"
    2626#include "psImageExtraction.h"
    27 
    28 bool getSpecifiedStatValue(const psStats* stats, double* value);
    2927
    3028int psImageClip(psImage* input, psF64 min, psF64 vmin, psF64 max, psF64 vmax)
     
    337335}
    338336
    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 
    393337
    394338psImage* psImageRebin(psImage* out,const psImage* in,unsigned int scale,const psStats* stats)
     
    420364    }
    421365
    422     if (getSpecifiedStatValue(stats,&statVal) == false) {
     366    if (p_psGetStatValue(stats,&statVal) == false) {
    423367        psError(__func__,"The stat options didn't specify a single supported statistic type.");
    424368        psFree(out);
     
    457401                vec->n = n; \
    458402                myStats = psVectorStats(myStats,vec,NULL,0); \
    459                 getSpecifiedStatValue(myStats,&statVal); \
     403                p_psGetStatValue(myStats,&statVal); \
    460404                outRowData[col] = (ps##type)statVal; \
    461405            } \
     
    723667        float cosT = cosf(t);
    724668        float sinT = sinf(t);
    725         float cosNegT = cosf(-t);
    726         float sinNegT = sinf(-t);
    727669
    728670        // calculate the corners of the rotated image so we know the proper output image size.
     
    730672        //    y' = y cos(t) - x sin(t);  i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT;
    731673
    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;
    771679
    772680        out = psImageRecycle(out,outCols,outRows,type);
Note: See TracChangeset for help on using the changeset viewer.