Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxFuncRecGenConv2dK1d.c File Reference

More...

#include "HxFuncRecGenConv2dK1d.h"
#include "HxEnvironment.h"

Line_variations

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_Line_XdirSim (DataPtrT imgPtr, int imgWidth, ArithT *kernel, int kerSize, PixOpT &pixOp, RedOpT &redOp)
 Line : X direction, simple. More...

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_Line_YdirSim (DataPtrT imgPtr, int imgHeight, ArithT *kernel, int kerSize, ArithT *ngbBuf, PixOpT &pixOp, RedOpT &redOp)
 Line : Y direction, simple. More...

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_Line_YdirBuf (DataPtrT imgPtr, int imgWidth, ArithT *kernel, int kerSize, PixOpT &pixOp, RedOpT &redOp)
 Line : Y direction, buffered. More...

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_Line_YdirBufAnti (DataPtrT imgPtr, int imgWidth, ArithT *kernel, int kerSize, PixOpT &pixOp, RedOpT &redOp)

RecGenConv2dK1d_variations

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_XdirSim (DataPtrType imgPtr, KerDataPtrType kerPtr, ArithType dummy, HxSizes imgSize, HxSizes borderSize, HxSizes kerSize, PixOpT &pixOp, RedOpT &redOp)
 RecGenConv2dK1d : X direction, simple. More...

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_YdirSim (DataPtrType imgPtr, KerDataPtrType kerPtr, ArithType dummy, HxSizes imgSize, HxSizes borderSize, HxSizes kerSize, PixOpT &pixOp, RedOpT &redOp)
 RecGenConv2dK1d : Y direction, simple. More...

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1d_YdirBuf (DataPtrType imgPtr, KerDataPtrType kerPtr, ArithType dummy, HxSizes imgSize, HxSizes borderSize, HxSizes kerSize, PixOpT &pixOp, RedOpT &redOp)
 RecGenConv2dK1d : Y direction, buffered. More...


Functions

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT> void HxFuncRecGenConv2dK1dDispatch (DataPtrType imgPtr, KerDataPtrType kerPtr, ArithType dummy, HxSizes imgSize, HxSizes borderSize, HxSizes kerSize, PixOpT &pixOp, RedOpT &redOp, int dimension, bool buffered)
 Dispatch function for RecGenConv2dK1d (see Global functions for RecGenConv2dK1d) Dispatch is based on dimension and inplace parameters. More...


Detailed Description


Function Documentation

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1d_Line_XdirSim DataPtrT    imgPtr,
int    imgWidth,
ArithT *    kernel,
int    kerSize,
PixOpT &    pixOp,
RedOpT &    redOp
[static]
 

Line : X direction, simple.

00052 {
00053     int x, n, ngbSize = kerSize/2, scanSize = imgWidth+ngbSize;
00054     ArithT result;
00055 
00056     // scan order
00057 
00058     for (x=0; x<scanSize; x++)
00059     {
00060         result = pixOp.doIt(imgPtr.readIncX(), kernel[0]);
00061         for (n=1; n<=ngbSize; n++)
00062             redOp.doIt(result, pixOp.doIt(imgPtr.readIncX(), kernel[n]));
00063         imgPtr.decX();
00064         imgPtr.write(result);
00065         imgPtr.decX(ngbSize-1);
00066     }
00067 
00068     // anti scan order
00069 
00070     imgPtr.decX();
00071     kernel += kerSize/2;
00072 
00073     for (x=0; x<imgWidth; x++)
00074     {
00075         result = pixOp.doIt(imgPtr.readIncX(), kernel[0]);
00076         for (n=1; n<=ngbSize; n++)
00077             redOp.doIt(result, pixOp.doIt(imgPtr.readIncX(), kernel[n]));
00078         imgPtr.decX(ngbSize+1);
00079         imgPtr.write(result);
00080         imgPtr.decX();
00081     }
00082 
00083 }

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1d_Line_YdirSim DataPtrT    imgPtr,
int    imgHeight,
ArithT *    kernel,
int    kerSize,
ArithT *    ngbBuf,
PixOpT &    pixOp,
RedOpT &    redOp
[static]
 

Line : Y direction, simple.

00092 {
00093     int y, n, ngbSize = kerSize/2, scanSize = imgHeight+ngbSize;
00094     ArithT result;
00095     ArithT* ngbPtr = ngbBuf;
00096 
00097     // scan order
00098 
00099     for (n=0; n<ngbSize; n++)
00100     {
00101         ngbBuf[n] = imgPtr.read();
00102         imgPtr.incY();
00103     }
00104 
00105 
00106     for (y=0; y<scanSize; y++)
00107     {
00108         ngbPtr[ngbSize] = imgPtr.read();
00109         imgPtr.incY();
00110         result = pixOp.doIt(ngbPtr[0], kernel[0]);
00111         for (n=1; n<=ngbSize; n++)
00112             redOp.doIt(result, pixOp.doIt(ngbPtr[n], kernel[n]));
00113         ngbPtr[ngbSize] = result;
00114         ngbPtr++;
00115     }
00116 
00117     // anti scan order
00118 
00119     imgPtr.decY(ngbSize+1);
00120     ngbPtr -= 1;
00121     kernel += ngbSize;
00122 
00123     for (y=0; y<imgHeight; y++)
00124     {
00125         result = pixOp.doIt(ngbPtr[0], kernel[0]);
00126         for (n=1; n<=ngbSize; n++)
00127             redOp.doIt(result, pixOp.doIt(ngbPtr[n], kernel[n]));
00128         imgPtr.write(*ngbPtr-- = result);
00129         imgPtr.decY();
00130     }
00131 }

template<class DataPtrT, class ArithT, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1d_Line_YdirBuf DataPtrT    imgPtr,
int    imgWidth,
ArithT *    kernel,
int    kerSize,
PixOpT &    pixOp,
RedOpT &    redOp
[static]
 

Line : Y direction, buffered.

00139 {
00140     const int ngbSize = kerSize/2;
00141     int x, n;
00142     ArithT result;
00143     DataPtrT linePtr(imgPtr);
00144 
00145     // scan order
00146 
00147     for (x=0; x<imgWidth; x++)
00148         imgPtr.writeIncX(pixOp.doIt(imgPtr.read(), kernel[ngbSize]));
00149 
00150     imgPtr.decX(imgWidth);
00151 
00152     // previous lines
00153     for (n=ngbSize-1; n>=0; n--)
00154     {
00155         linePtr.decY();
00156         for (x=0; x<imgWidth; x++) {
00157             result = imgPtr.read();
00158             redOp.doIt(result, pixOp.doIt(linePtr.readIncX(), kernel[n]));
00159             imgPtr.writeIncX(result);
00160         }
00161         imgPtr.decX(imgWidth);
00162         linePtr.decX(imgWidth);
00163     }
00164 }

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1d_XdirSim DataPtrType    imgPtr,
KerDataPtrType    kerPtr,
ArithType    dummy,
HxSizes    imgSize,
HxSizes    borderSize,
HxSizes    kerSize,
PixOpT &    pixOp,
RedOpT &    redOp
 

RecGenConv2dK1d : X direction, simple.

00216 {
00217     int borderWidth = borderSize.x() > 0 ? borderSize.x() : kerSize.x()/2;
00218     int borderHeight = borderSize.y();
00219     imgSize = imgSize - HxSizes(2*borderWidth, 2*borderHeight, 0);
00220     int imgWidth = imgSize.x();
00221     int imgHeight = imgSize.y();
00222     int y, i;
00223 
00224     HxPixelAllocator<ArithType> allocator;
00225 
00226     ArithType* kernel = allocator.allocate(kerSize.x());
00227 
00228     for (i=0; i<kerSize.x(); i++)
00229         kernel[i] = kerPtr.readIncX();
00230 
00231     imgPtr.incXYZ(borderWidth-kerSize.x()/2, borderHeight, 0);
00232 
00233     for (y=0; y<imgHeight; y++)
00234     {
00235         HxFuncRecGenConv2dK1d_Line_XdirSim(
00236             imgPtr, imgWidth, kernel, kerSize.x(), pixOp, redOp);
00237         imgPtr.incY();
00238     }
00239 
00240     allocator.deallocate(kernel);
00241 }

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1d_YdirSim DataPtrType    imgPtr,
KerDataPtrType    kerPtr,
ArithType    dummy,
HxSizes    imgSize,
HxSizes    borderSize,
HxSizes    kerSize,
PixOpT &    pixOp,
RedOpT &    redOp
 

RecGenConv2dK1d : Y direction, simple.

00251 {
00252     int borderWidth = borderSize.x();
00253     int borderHeight = borderSize.y() > 0 ? borderSize.y() : kerSize.x()/2;
00254     imgSize = imgSize - HxSizes(2*borderWidth, 2*borderHeight, 0);
00255     int imgWidth = imgSize.x();
00256     int imgHeight = imgSize.y();
00257     int x, i;
00258 
00259     HxPixelAllocator<ArithType> allocator;
00260 
00261     ArithType* kernel = allocator.allocate(kerSize.x());
00262 
00263     for (i=0; i<kerSize.x(); i++)
00264         kernel[i] = kerPtr.readIncX();
00265 
00266     ArithType* ngbBuf = allocator.allocate(imgHeight+kerSize.x());
00267 
00268     imgPtr.incXYZ(borderWidth, borderHeight-kerSize.x()/2, 0);
00269 
00270     for (x=0; x<imgWidth; x++)
00271     {
00272         HxFuncRecGenConv2dK1d_Line_YdirSim(
00273             imgPtr, imgHeight, kernel, kerSize.x(), ngbBuf, pixOp, redOp);
00274         imgPtr.incX();
00275     }
00276 
00277     allocator.deallocate(ngbBuf);
00278     allocator.deallocate(kernel);
00279 }

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1d_YdirBuf DataPtrType    imgPtr,
KerDataPtrType    kerPtr,
ArithType    dummy,
HxSizes    imgSize,
HxSizes    borderSize,
HxSizes    kerSize,
PixOpT &    pixOp,
RedOpT &    redOp
 

RecGenConv2dK1d : Y direction, buffered.

00290 {
00291     HxEnvironment::instance()->outputStream() << "Buffered" << STD_ENDL;
00292     int borderWidth = borderSize.x();
00293     int borderHeight = borderSize.y() > 0 ? borderSize.y() : kerSize.x()/2;
00294     imgSize = imgSize - HxSizes(2*borderWidth, 2*borderHeight, 0);
00295     int imgWidth = imgSize.x();
00296     int imgHeight = imgSize.y();
00297     int y, i;
00298 
00299     HxPixelAllocator<ArithType> allocator;
00300 
00301     ArithType* kernel = allocator.allocate(kerSize.x());
00302 
00303     for (i=0; i<kerSize.x(); i++)
00304         kernel[i] = kerPtr.readIncX();
00305 
00306     imgPtr.incXYZ(borderWidth, borderHeight, 0);
00307 
00308     for (y=0; y<imgHeight+kerSize.x()/2; y++)
00309     {
00310         HxFuncRecGenConv2dK1d_Line_YdirBuf(
00311             imgPtr, imgWidth, kernel, kerSize.x(), pixOp, redOp);
00312         imgPtr.incY();
00313     }
00314     imgPtr.decY(kerSize.x()/2);
00315 
00316     for (y=imgHeight-1; y>=0; y--)
00317     {
00318         imgPtr.decY();
00319         HxFuncRecGenConv2dK1d_Line_YdirBufAnti(
00320             imgPtr, imgWidth, kernel, kerSize.x(), pixOp, redOp);
00321     }
00322 
00323     allocator.deallocate(kernel);
00324 }

template<class DataPtrType, class KerDataPtrType, class ArithType, class PixOpT, class RedOpT>
void HxFuncRecGenConv2dK1dDispatch DataPtrType    imgPtr,
KerDataPtrType    kerPtr,
ArithType    dummy,
HxSizes    imgSize,
HxSizes    borderSize,
HxSizes    kerSize,
PixOpT &    pixOp,
RedOpT &    redOp,
int    dimension,
bool    buffered
 

Dispatch function for RecGenConv2dK1d (see Global functions for RecGenConv2dK1d) Dispatch is based on dimension and inplace parameters.

Assertions:

Parameters:
imgPtr  Input/Output image: IS = imgSize, IBS = borderSize, imgPtr is at (IX0,IY0)
kerPtr  Input image, IS = kerSize, IBS = 0

00345 {
00346     switch (dimension) {
00347     case 1  :
00348         HxFuncRecGenConv2dK1d_XdirSim(imgPtr, kerPtr, dummy, imgSize, borderSize,
00349                                kerSize, pixOp, redOp);
00350         break;
00351     case 2  :
00352         if (buffered)
00353             HxFuncRecGenConv2dK1d_YdirBuf(imgPtr, kerPtr, dummy, imgSize, borderSize,
00354                                    kerSize, pixOp, redOp);
00355         else
00356             HxFuncRecGenConv2dK1d_YdirSim(imgPtr, kerPtr, dummy, imgSize, borderSize,
00357                                    kerSize, pixOp, redOp);
00358         break;
00359     default :
00360         HxEnvironment::instance()->errorStream()
00361             << "HxFuncRecGenConv2dK1dDispatch: "
00362             << "cannot execute convolution in dimension " << dimension
00363             << STD_ENDL;
00364         HxEnvironment::instance()->flush();
00365     }
00366 }


Generated on Mon Jan 27 15:48:53 2003 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001