IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1936


Ignore:
Timestamp:
Sep 30, 2004, 11:01:09 AM (22 years ago)
Author:
desonia
Message:

changes associated with adding psKernelAlloc tests.

Location:
trunk/psLib
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.h

    r1920 r1936  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-28 23:26:48 $
     13 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-30 21:01:09 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252
    5353    union {
    54         psU8* *U8;                     ///< Unsigned 8-bit integer data.
    55         psU16* *U16;                   ///< Unsigned 16-bit integer data.
    56         psU32* *U32;                   ///< Unsigned 32-bit integer data.
    57         psU64* *U64;                   ///< Unsigned 64-bit integer data.
    58         psS8* *S8;                     ///< Signed 8-bit integer data.
    59         psS16* *S16;                   ///< Signed 16-bit integer data.
    60         psS32* *S32;                   ///< Signed 32-bit integer data.
    61         psS64* *S64;                   ///< Signed 64-bit integer data.
    62         psF32* *F32;                   ///< Single-precision float data.
    63         psF64* *F64;                   ///< Double-precision float data.
    64         psC32* *C32;                   ///< Single-precision complex data.
    65         psC64* *C64;                   ///< Double-precision complex data.
    66         psPTR* *PTR;                   ///< Void pointers.
    67         psPTR* V;                      ///< Pointer to data.
     54        psU8**  U8;                    ///< Unsigned 8-bit integer data.
     55        psU16** U16;                   ///< Unsigned 16-bit integer data.
     56        psU32** U32;                   ///< Unsigned 32-bit integer data.
     57        psU64** U64;                   ///< Unsigned 64-bit integer data.
     58        psS8**  S8;                    ///< Signed 8-bit integer data.
     59        psS16** S16;                   ///< Signed 16-bit integer data.
     60        psS32** S32;                   ///< Signed 32-bit integer data.
     61        psS64** S64;                   ///< Signed 64-bit integer data.
     62        psF32** F32;                   ///< Single-precision float data.
     63        psF64** F64;                   ///< Double-precision float data.
     64        psC32** C32;                   ///< Single-precision complex data.
     65        psC64** C64;                   ///< Double-precision complex data.
     66        psPTR** PTR;                   ///< Void pointers.
     67        psPTR*  V;                     ///< Pointer to data.
    6868    } data;                            ///< Union for data types.
    6969    const struct psImage* parent;      ///< Parent, if a subimage.
  • trunk/psLib/src/image/psImageConvolve.c

    r1863 r1936  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-09-23 18:30:57 $
     7 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-09-30 21:01:09 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1515#include "psImageConvolve.h"
    1616#include "psImageFFT.h"
     17#include "psImageExtraction.h"
    1718#include "psMatrixVectorArithmetic.h"
    1819#include "psMemory.h"
     
    2122
    2223#include "psImageErrors.h"
     24
     25#define FOURIER_PADDING 32 /* padding amount in every side of the image for fourier convolution */
    2326
    2427static void freeKernel(psKernel* ptr);
     
    3235    // following is explicitly spelled out in the SDRS as a requirement
    3336    if (yMin > yMax) {
     37        psLogMsg(__func__, PS_LOG_WARN,
     38                 "Specified yMin, %d, was greater than yMax, %d.  Values swapped.",
     39                 yMin, yMax);
     40
    3441        int temp = yMin;
    3542        yMin = yMax;
    3643        yMax = temp;
    37 
    38         psLogMsg(__func__, PS_LOG_WARN,
    39                  "Found yMin > yMax (%d > %d).  Values swapped.",
    40                  yMin, yMax);
    4144    }
    4245
    4346    // following is explicitly spelled out in the SDRS as a requirement
    4447    if (xMin > xMax) {
     48        psLogMsg(__func__, PS_LOG_WARN,
     49                 "Specified xMin, %d, was greater than xMax, %d.  Values swapped.",
     50                 xMin, xMax);
     51
    4552        int temp = xMin;
    4653        xMin = xMax;
    4754        xMax = temp;
    48 
    49         psLogMsg(__func__, PS_LOG_WARN,
    50                  "Found xMin > xMax (%d > %d).  Values swapped.",
    51                  xMin, xMax);
    5255    }
    5356
     
    295298    } else {
    296299        // fourier convolution
     300        int paddedCols = numCols+2*FOURIER_PADDING;
     301        int paddedRows = numRows+2*FOURIER_PADDING;
     302
     303        // check to see if kernel is smaller, otherwise padding it up will fail.
    297304        int kRows = kernel->image->numRows;
    298305        int kCols = kernel->image->numCols;
    299         int x0 = (numCols - kCols) / 2;
    300         int y0 = (numRows - kRows) / 2;
    301         psImage* paddedKernel;
    302 
    303         // check to see if kernel is smaller, otherwise padding it up will fail.
     306        int x0 = (paddedCols - kCols) / 2;
     307        int y0 = (paddedRows - kRows) / 2;
    304308        if (x0 < 0 || y0 < 0) {
    305309            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
     
    312316        }
    313317
    314         // pad the kernel to the same size of image
    315         paddedKernel = psImageAlloc(numCols,numRows,PS_TYPE_KERNEL);
    316         memset(paddedKernel->data.V,0,sizeof(psKernelType)*numCols*numRows); // zeroize image
     318        // pad the image
     319        psImage* paddedImage = psImageAlloc(paddedCols,paddedRows,in->type.type);
     320        int elementSize = PSELEMTYPE_SIZEOF(in->type.type);
     321
     322        // zero out padded area on top and bottom
     323        memset(paddedImage->data.U8[0],0,FOURIER_PADDING*paddedCols*elementSize);
     324        memset(paddedImage->data.U8[FOURIER_PADDING+numRows-1],0,FOURIER_PADDING*paddedCols*elementSize);
     325
     326        // fill in the image-containing rows.
     327        int sidePaddingSize = FOURIER_PADDING*elementSize;
     328        int imageRowSize = numCols*elementSize;
     329        psU8* paddedData = paddedImage->data.U8[FOURIER_PADDING];
     330        for (int row=0;row<numRows;row++) {
     331            // zero out padded area on left edge.
     332            memset(paddedData,0,sidePaddingSize);
     333            paddedData += sidePaddingSize;
     334            memcpy(paddedData,in->data.U8[row],imageRowSize);
     335            paddedData += imageRowSize;
     336            // zero out padded area on right edge.
     337            memset(paddedData,0,sidePaddingSize);
     338            paddedData += sidePaddingSize;
     339        }
     340
     341        // pad the kernel to the same size of paddedImage
     342        psImage* paddedKernel = psImageAlloc(paddedCols,paddedRows,PS_TYPE_KERNEL);
     343        memset(paddedKernel->data.U8[0],0,sizeof(psKernelType)*numCols*numRows); // zero-out image
    317344        for (int row=0;row<kRows;row++) {
    318345            psKernelType* padRow = paddedKernel->data.PS_TYPE_KERNEL_DATA[row+y0];
     
    332359        }
    333360
    334 
    335         psImage* inFourier = psImageFFT(NULL, in, PS_FFT_FORWARD);
     361        psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD);
    336362        if (inFourier == NULL) {
    337363            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
     
    343369
    344370        // convolution in fourier domain is just a pixel-wise multiplication
    345         psImage* outFourier = psImageAlloc(numCols,numRows,inFourier->type.type);
     371        psImage* outFourier = psImageAlloc(paddedCols,paddedRows,inFourier->type.type);
    346372        psBinaryOp(outFourier,inFourier,"*",kernelFourier);
    347373
     
    355381        }
    356382
    357         // since our image was real to start, the result is real
    358         out = psImageReal(out,complexOut);
    359 
    360         psFree(complexOut);
     383        // subset out the padded area now.
     384        psImage* complexOutSansPad = psImageSubset(complexOut,
     385                                     FOURIER_PADDING,FOURIER_PADDING,
     386                                     FOURIER_PADDING+numCols,FOURIER_PADDING+numRows);
     387
     388        // since our image was real, the result is to be real as well
     389        out = psImageReal(out,complexOutSansPad);
     390
     391        psFree(complexOut); // frees complexOutSansPad, as it is a child.
    361392        psFree(kernelFourier);
    362393        psFree(inFourier);
     394        psFree(paddedImage);
    363395        psFree(paddedKernel);
    364396
  • trunk/psLib/src/imageops/psImageConvolve.c

    r1863 r1936  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-09-23 18:30:57 $
     7 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-09-30 21:01:09 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1515#include "psImageConvolve.h"
    1616#include "psImageFFT.h"
     17#include "psImageExtraction.h"
    1718#include "psMatrixVectorArithmetic.h"
    1819#include "psMemory.h"
     
    2122
    2223#include "psImageErrors.h"
     24
     25#define FOURIER_PADDING 32 /* padding amount in every side of the image for fourier convolution */
    2326
    2427static void freeKernel(psKernel* ptr);
     
    3235    // following is explicitly spelled out in the SDRS as a requirement
    3336    if (yMin > yMax) {
     37        psLogMsg(__func__, PS_LOG_WARN,
     38                 "Specified yMin, %d, was greater than yMax, %d.  Values swapped.",
     39                 yMin, yMax);
     40
    3441        int temp = yMin;
    3542        yMin = yMax;
    3643        yMax = temp;
    37 
    38         psLogMsg(__func__, PS_LOG_WARN,
    39                  "Found yMin > yMax (%d > %d).  Values swapped.",
    40                  yMin, yMax);
    4144    }
    4245
    4346    // following is explicitly spelled out in the SDRS as a requirement
    4447    if (xMin > xMax) {
     48        psLogMsg(__func__, PS_LOG_WARN,
     49                 "Specified xMin, %d, was greater than xMax, %d.  Values swapped.",
     50                 xMin, xMax);
     51
    4552        int temp = xMin;
    4653        xMin = xMax;
    4754        xMax = temp;
    48 
    49         psLogMsg(__func__, PS_LOG_WARN,
    50                  "Found xMin > xMax (%d > %d).  Values swapped.",
    51                  xMin, xMax);
    5255    }
    5356
     
    295298    } else {
    296299        // fourier convolution
     300        int paddedCols = numCols+2*FOURIER_PADDING;
     301        int paddedRows = numRows+2*FOURIER_PADDING;
     302
     303        // check to see if kernel is smaller, otherwise padding it up will fail.
    297304        int kRows = kernel->image->numRows;
    298305        int kCols = kernel->image->numCols;
    299         int x0 = (numCols - kCols) / 2;
    300         int y0 = (numRows - kRows) / 2;
    301         psImage* paddedKernel;
    302 
    303         // check to see if kernel is smaller, otherwise padding it up will fail.
     306        int x0 = (paddedCols - kCols) / 2;
     307        int y0 = (paddedRows - kRows) / 2;
    304308        if (x0 < 0 || y0 < 0) {
    305309            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
     
    312316        }
    313317
    314         // pad the kernel to the same size of image
    315         paddedKernel = psImageAlloc(numCols,numRows,PS_TYPE_KERNEL);
    316         memset(paddedKernel->data.V,0,sizeof(psKernelType)*numCols*numRows); // zeroize image
     318        // pad the image
     319        psImage* paddedImage = psImageAlloc(paddedCols,paddedRows,in->type.type);
     320        int elementSize = PSELEMTYPE_SIZEOF(in->type.type);
     321
     322        // zero out padded area on top and bottom
     323        memset(paddedImage->data.U8[0],0,FOURIER_PADDING*paddedCols*elementSize);
     324        memset(paddedImage->data.U8[FOURIER_PADDING+numRows-1],0,FOURIER_PADDING*paddedCols*elementSize);
     325
     326        // fill in the image-containing rows.
     327        int sidePaddingSize = FOURIER_PADDING*elementSize;
     328        int imageRowSize = numCols*elementSize;
     329        psU8* paddedData = paddedImage->data.U8[FOURIER_PADDING];
     330        for (int row=0;row<numRows;row++) {
     331            // zero out padded area on left edge.
     332            memset(paddedData,0,sidePaddingSize);
     333            paddedData += sidePaddingSize;
     334            memcpy(paddedData,in->data.U8[row],imageRowSize);
     335            paddedData += imageRowSize;
     336            // zero out padded area on right edge.
     337            memset(paddedData,0,sidePaddingSize);
     338            paddedData += sidePaddingSize;
     339        }
     340
     341        // pad the kernel to the same size of paddedImage
     342        psImage* paddedKernel = psImageAlloc(paddedCols,paddedRows,PS_TYPE_KERNEL);
     343        memset(paddedKernel->data.U8[0],0,sizeof(psKernelType)*numCols*numRows); // zero-out image
    317344        for (int row=0;row<kRows;row++) {
    318345            psKernelType* padRow = paddedKernel->data.PS_TYPE_KERNEL_DATA[row+y0];
     
    332359        }
    333360
    334 
    335         psImage* inFourier = psImageFFT(NULL, in, PS_FFT_FORWARD);
     361        psImage* inFourier = psImageFFT(NULL, paddedImage, PS_FFT_FORWARD);
    336362        if (inFourier == NULL) {
    337363            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
     
    343369
    344370        // convolution in fourier domain is just a pixel-wise multiplication
    345         psImage* outFourier = psImageAlloc(numCols,numRows,inFourier->type.type);
     371        psImage* outFourier = psImageAlloc(paddedCols,paddedRows,inFourier->type.type);
    346372        psBinaryOp(outFourier,inFourier,"*",kernelFourier);
    347373
     
    355381        }
    356382
    357         // since our image was real to start, the result is real
    358         out = psImageReal(out,complexOut);
    359 
    360         psFree(complexOut);
     383        // subset out the padded area now.
     384        psImage* complexOutSansPad = psImageSubset(complexOut,
     385                                     FOURIER_PADDING,FOURIER_PADDING,
     386                                     FOURIER_PADDING+numCols,FOURIER_PADDING+numRows);
     387
     388        // since our image was real, the result is to be real as well
     389        out = psImageReal(out,complexOutSansPad);
     390
     391        psFree(complexOut); // frees complexOutSansPad, as it is a child.
    361392        psFree(kernelFourier);
    362393        psFree(inFourier);
     394        psFree(paddedImage);
    363395        psFree(paddedKernel);
    364396
  • trunk/psLib/src/mathtypes/psImage.h

    r1920 r1936  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-09-28 23:26:48 $
     13 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-09-30 21:01:09 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252
    5353    union {
    54         psU8* *U8;                     ///< Unsigned 8-bit integer data.
    55         psU16* *U16;                   ///< Unsigned 16-bit integer data.
    56         psU32* *U32;                   ///< Unsigned 32-bit integer data.
    57         psU64* *U64;                   ///< Unsigned 64-bit integer data.
    58         psS8* *S8;                     ///< Signed 8-bit integer data.
    59         psS16* *S16;                   ///< Signed 16-bit integer data.
    60         psS32* *S32;                   ///< Signed 32-bit integer data.
    61         psS64* *S64;                   ///< Signed 64-bit integer data.
    62         psF32* *F32;                   ///< Single-precision float data.
    63         psF64* *F64;                   ///< Double-precision float data.
    64         psC32* *C32;                   ///< Single-precision complex data.
    65         psC64* *C64;                   ///< Double-precision complex data.
    66         psPTR* *PTR;                   ///< Void pointers.
    67         psPTR* V;                      ///< Pointer to data.
     54        psU8**  U8;                    ///< Unsigned 8-bit integer data.
     55        psU16** U16;                   ///< Unsigned 16-bit integer data.
     56        psU32** U32;                   ///< Unsigned 32-bit integer data.
     57        psU64** U64;                   ///< Unsigned 64-bit integer data.
     58        psS8**  S8;                    ///< Signed 8-bit integer data.
     59        psS16** S16;                   ///< Signed 16-bit integer data.
     60        psS32** S32;                   ///< Signed 32-bit integer data.
     61        psS64** S64;                   ///< Signed 64-bit integer data.
     62        psF32** F32;                   ///< Single-precision float data.
     63        psF64** F64;                   ///< Double-precision float data.
     64        psC32** C32;                   ///< Single-precision complex data.
     65        psC64** C64;                   ///< Double-precision complex data.
     66        psPTR** PTR;                   ///< Void pointers.
     67        psPTR*  V;                     ///< Pointer to data.
    6868    } data;                            ///< Union for data types.
    6969    const struct psImage* parent;      ///< Parent, if a subimage.
  • trunk/psLib/src/pslib.h

    r1801 r1936  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-09-14 01:32:52 $
     11*  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-09-30 21:01:09 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888#include "psImageExtraction.h"
    8989#include "psImageManip.h"
     90#include "psImageConvolve.h"
    9091
    9192/// @defgroup ImageIO Image File I/O Functions
  • trunk/psLib/test/image/Makefile

    r1358 r1936  
    33##  Makefile:   test/collections
    44##
    5 ##  $Revision: 1.2 $  $Name: not supported by cvs2svn $
    6 ##  $Date: 2004-07-31 02:27:16 $
     5##  $Revision: 1.3 $  $Name: not supported by cvs2svn $
     6##  $Date: 2004-09-30 21:01:09 $
    77##
    88##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626tst_psImageStats02 \
    2727tst_psImageStats03 \
    28 tst_psImageExtraction
     28tst_psImageExtraction \
     29tst_psImageConvolve
    2930
    3031OBJS = $(addsuffix .o,$(TARGET))
Note: See TracChangeset for help on using the changeset viewer.