#include "HxFuncGenConv2dK1d.h"
#include "HxEnvironment.h"
Pix_variations | |
template<class DstDataPtrT, class SrcDataPtrT, class ArithT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_Line_XdirInp (DstDataPtrT dstPtr, SrcDataPtrT srcPtr, ArithT *ngbPtr, ArithT *kernel, int nPix, int kernelSize, PixOpT &pixOp, RedOpT &redOp, ArithT neutralElement) |
Pix : X direction, inplace. More... | |
template<class DstDataPtrT, class SrcDataPtrT, class ArithT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_Line_YdirInp (DstDataPtrT dstPtr, SrcDataPtrT srcPtr, ArithT *ngbBuf, ArithT *ngbPtr, ArithT *kernel, int width, int kernelSize, PixOpT &pixOp, RedOpT &redOp, const ArithT &neutralElement) |
Pix : Y direction, inplace. More... | |
Line_variations | |
template<class DstPtrT, class SrcPtrT, class ArithT, class PixOpT, class RedOpT, class KernelT> void | HxFuncGenConv2dK1d_Line_XdirSim (DstPtrT dstPtr, SrcPtrT srcPtr, ArithT neutralElement, int nPix, int kernelSize, PixOpT &pixOp, RedOpT &redOp, KernelT &kernel) |
Line : X direction, simple. More... | |
template<class DstPtrT, class SrcPtrT, class ArithT, class PixOpT, class RedOpT, class KernelT> void | HxFuncGenConv2dK1d_Line_YdirSim (DstPtrT dstPtr, SrcPtrT srcPtr, ArithT neutralElement, int nPix, int kernelSize, PixOpT &pixOp, RedOpT &redOp, KernelT &kernel) |
Line : Y direction, simple. More... | |
template<class DstDataPtrT, class SrcDataPtrT, class ArithT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_Im_XdirInp (DstDataPtrT dstPtr, SrcDataPtrT srcPtr, ArithT *kernel, int width, int height, int kernelSize, PixOpT &pixOp, RedOpT &redOp) |
Line : X direction, inplace. More... | |
template<class DstDataPtrT, class SrcDataPtrT, class ArithT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_Im_YdirInp (DstDataPtrT dstPtr, SrcDataPtrT srcPtr, ArithT *kernel, HxSizes dstSize, int kernelSize, PixOpT &pixOp, RedOpT &redOp) |
Line : Y direction, inplace. More... | |
GenConv2dK1d_variations | |
template<class DstDataPtrType, class SrcDataPtrType, class KernelT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_XdirSim (DstDataPtrType dstPtr, SrcDataPtrType srcPtr, KernelT &kernel, HxSizes dstSize, PixOpT &pixOp, RedOpT &redOp) |
GenConv2dK1d : X direction, simple. More... | |
template<class DstDataPtrType, class SrcDataPtrType, class KernelT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_YdirSim (DstDataPtrType dstPtr, SrcDataPtrType srcPtr, KernelT &kernel, HxSizes dstSize, PixOpT &pixOp, RedOpT &redOp) |
GenConv2dK1d : Y direction, simple. More... | |
template<class DstDataPtrType, class SrcDataPtrType, class KernelT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_XdirInp (DstDataPtrType dstPtr, SrcDataPtrType srcPtr, KernelT &kernel, HxSizes dstSize, PixOpT &pixOp, RedOpT &redOp) |
GenConv2dK1d : X direction, inplace. More... | |
template<class DstDataPtrType, class SrcDataPtrType, class KernelT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1d_YdirInp (DstDataPtrType dstPtr, SrcDataPtrType srcPtr, KernelT &kernel, HxSizes dstSize, PixOpT &pixOp, RedOpT &redOp) |
GenConv2dK1d : Y direction, inplace. More... | |
Functions | |
template<class DstDataPtrType, class SrcDataPtrType, class KernelT, class PixOpT, class RedOpT> void | HxFuncGenConv2dK1dDispatch (DstDataPtrType dstPtr, SrcDataPtrType srcPtr, KernelT &kernel, HxSizes dstSize, PixOpT &pixOp, RedOpT &redOp, int dimension, bool inplace) |
Dispatch function for GenConv2dK1d (see Global functions for GenConv2dK1d) Dispatch is based on dimension and inplace parameters. More... |
|
Pix : X direction, inplace.
00054 { 00055 ArithT* ngbEnd = &ngbPtr[nPix]; 00056 for (;ngbPtr < ngbEnd; ngbPtr++) 00057 { 00058 ArithT result(neutralElement); 00059 for (int k=0; k<kernelSize; k++) 00060 redOp.doIt(result, pixOp.doIt(ngbPtr[k], kernel[k])); 00061 dstPtr.writeIncX(result); 00062 ngbPtr[kernelSize] = srcPtr.readIncX(); 00063 } 00064 } |
|
Pix : Y direction, inplace.
00075 { 00076 int lastKerElt = kernelSize-1; 00077 int ngbBufSize = width * kernelSize; 00078 ArithT* ngbEnd = ngbBuf + ngbBufSize; 00079 00080 while (--width >= 0) 00081 { 00082 ngbPtr[lastKerElt] = srcPtr.readIncX(); 00083 ArithT result(neutralElement); 00084 for (int k=0; k<kernelSize; k++) 00085 redOp.doIt(result, pixOp.doIt(ngbPtr[k], kernel[k])); 00086 dstPtr.writeIncX(result); 00087 ngbPtr += kernelSize; 00088 if (ngbPtr >= ngbEnd) 00089 ngbPtr -= ngbBufSize; 00090 } 00091 } |
|
Line : X direction, simple.
00107 { 00108 while (--nPix >= 0) { 00109 SrcPtrT nPtr(srcPtr); 00110 srcPtr.incX(); 00111 ArithT result(neutralElement); 00112 for (int i=0 ; i<kernelSize ; i++) 00113 redOp.doIt(result, pixOp.doIt(nPtr.readIncX(), kernel(i))); 00114 dstPtr.writeIncX(result); 00115 } 00116 } |
|
Line : Y direction, simple.
00125 { 00126 while (--nPix >= 0) { 00127 SrcPtrT nPtr(srcPtr); 00128 srcPtr.incX(); 00129 ArithT result(neutralElement); 00130 for (int i=0 ; i<kernelSize ; i++) { 00131 redOp.doIt(result, pixOp.doIt(nPtr.read(), kernel(i))); 00132 nPtr.incY(); 00133 } 00134 dstPtr.writeIncX(result); 00135 } 00136 } |
|
Line : X direction, inplace.
00145 { 00146 HxPixelAllocator<ArithT> allocator; 00147 00148 ArithT* ngbBuf = allocator.allocate(width + kernelSize); 00149 00150 srcPtr.decX(kernelSize/2); 00151 while (--height >= 0) 00152 { 00153 for (int k=0; k<kernelSize; k++) 00154 ngbBuf[k] = srcPtr.readIncX(); 00155 HxFuncGenConv2dK1d_Line_XdirInp( 00156 dstPtr, srcPtr, ngbBuf, 00157 kernel, width, kernelSize, 00158 pixOp, redOp, RedOpT::neutralElement()); 00159 dstPtr.incY(); 00160 srcPtr.incXYZ(-kernelSize, 1); 00161 } 00162 00163 allocator.deallocate(ngbBuf, width + kernelSize); 00164 } |
|
Line : Y direction, inplace.
00173 { 00174 HxPixelAllocator<ArithT> allocator; 00175 00176 int ngbBufSize = dstSize.x() * kernelSize; 00177 ArithT* ngbBuf = allocator.allocate(ngbBufSize+kernelSize); 00178 ArithT* ngbPtr; 00179 ArithT* ngbEnd = ngbBuf + ngbBufSize; 00180 SrcDataPtrT sPtr(srcPtr); 00181 int x, y, k, i; 00182 ArithT* ngbOverflow; 00183 00184 // initialize neighborhood buffer 00185 00186 sPtr.decY(kernelSize/2); 00187 for (y=0; y<kernelSize-1; y++) 00188 { 00189 ngbPtr = &ngbBuf[y]; 00190 for (x=0; x<dstSize.x(); x++) 00191 { 00192 *ngbPtr = sPtr.readIncX(); 00193 ngbPtr += kernelSize; 00194 } 00195 sPtr.decX(dstSize.x()); 00196 sPtr.incY(); 00197 } 00198 ngbOverflow = &ngbBuf[dstSize.x() * kernelSize]; 00199 00200 // execute convolution by kernelsize clusters 00201 00202 srcPtr.incY(kernelSize/2); 00203 ngbPtr = ngbBuf; 00204 00205 for (y=dstSize.y(); y>0; ) 00206 { 00207 for (k = kernelSize < y ? kernelSize : y;--k >= 0; y--) 00208 { 00209 HxFuncGenConv2dK1d_Line_YdirInp( 00210 dstPtr, srcPtr, ngbBuf, ngbPtr, 00211 kernel, dstSize.x(), kernelSize, 00212 pixOp, redOp, RedOpT::neutralElement()); 00213 dstPtr.incY(); 00214 srcPtr.incY(); 00215 ngbPtr++; 00216 } 00217 // neighborhood buffer is cyclic 00218 if (ngbPtr >= ngbEnd) 00219 ngbPtr -= ngbBufSize; 00220 // copy overflow neighborhood to first neighborhood 00221 for (i=0; i<kernelSize; i++) 00222 ngbBuf[i] = ngbOverflow[i]; 00223 } 00224 00225 // clean up 00226 00227 allocator.deallocate(ngbBuf, ngbBufSize+kernelSize); 00228 } |
|
GenConv2dK1d : X direction, simple.
00244 { 00245 HxSizes kerSize = kernel.sizes(); 00246 int kerWidth = kerSize.x(); 00247 int imgWidth = dstSize.x(); 00248 int imgHeight = dstSize.y(); 00249 00250 typedef typename KernelT::ArithType ArithType; 00251 ArithType neutralElement(RedOpT::neutralElement()); 00252 00253 for (int y=0 ; y<imgHeight ; y++) { 00254 DstDataPtrType dPtr(dstPtr); 00255 dPtr.incY(y); 00256 SrcDataPtrType sPtr(srcPtr); 00257 sPtr.incXYZ(-(kerWidth/2), y); 00258 HxFuncGenConv2dK1d_Line_XdirSim( 00259 dPtr, sPtr, neutralElement, imgWidth, kerWidth, 00260 pixOp, redOp, kernel); 00261 } 00262 } |
|
GenConv2dK1d : Y direction, simple.
00271 { 00272 HxSizes kerSize = kernel.sizes(); 00273 int kerWidth = kerSize.x(); 00274 int imgWidth = dstSize.x(); 00275 int imgHeight = dstSize.y(); 00276 00277 typedef typename KernelT::ArithType ArithType; 00278 ArithType neutralElement(RedOpT::neutralElement()); 00279 00280 for (int y=0 ; y<imgHeight ; y++) { 00281 DstDataPtrType dPtr(dstPtr); 00282 dPtr.incY(y); 00283 SrcDataPtrType sPtr(srcPtr); 00284 sPtr.incY(y-(kerWidth/2)); 00285 HxFuncGenConv2dK1d_Line_YdirSim( 00286 dPtr, sPtr, neutralElement, imgWidth, kerWidth, 00287 pixOp, redOp, kernel); 00288 } 00289 } |
|
GenConv2dK1d : X direction, inplace.
00298 { 00299 HxSizes kerSize = kernel.sizes(); 00300 typedef typename KernelT::ArithType ArithType; 00301 00302 HxPixelAllocator<ArithType> allocator; 00303 ArithType* kernelBuffer = allocator.allocate(kerSize.x()); 00304 for (int i=0; i<kerSize.x(); i++) 00305 kernelBuffer[i] = kernel(i); 00306 00307 HxFuncGenConv2dK1d_Im_XdirInp( 00308 dstPtr, srcPtr, kernelBuffer, 00309 dstSize.x(), dstSize.y(), kerSize.x(), pixOp, redOp); 00310 00311 allocator.deallocate(kernelBuffer, kerSize.x()); 00312 } |
|
GenConv2dK1d : Y direction, inplace.
00321 { 00322 HxSizes kerSize = kernel.sizes(); 00323 typedef typename KernelT::ArithType ArithType; 00324 00325 HxPixelAllocator<ArithType> allocator; 00326 ArithType* kernelBuffer = allocator.allocate(kerSize.x()); 00327 for (int i=0; i<kerSize.x(); i++) 00328 kernelBuffer[i] = kernel(i); 00329 00330 HxFuncGenConv2dK1d_Im_YdirInp( 00331 dstPtr, srcPtr, kernelBuffer, dstSize, kerSize.x(), pixOp, redOp); 00332 00333 allocator.deallocate(kernelBuffer, kerSize.x()); 00334 } |
|
Dispatch function for GenConv2dK1d (see Global functions for GenConv2dK1d) Dispatch is based on dimension and inplace parameters.
00354 { 00355 switch (dimension) { 00356 case 1 : 00357 if (inplace) 00358 HxFuncGenConv2dK1d_XdirInp( 00359 dstPtr, srcPtr, kernel, dstSize, pixOp, redOp); 00360 else 00361 HxFuncGenConv2dK1d_XdirSim( 00362 dstPtr, srcPtr, kernel, dstSize, pixOp, redOp); 00363 break; 00364 case 2 : 00365 if (inplace) 00366 HxFuncGenConv2dK1d_YdirInp( 00367 dstPtr, srcPtr, kernel, dstSize, pixOp, redOp); 00368 else 00369 HxFuncGenConv2dK1d_YdirSim( 00370 dstPtr, srcPtr, kernel, dstSize, pixOp, redOp); 00371 break; 00372 default : 00373 HxEnvironment::instance()->errorStream() 00374 << "HxFuncGenConv2dK1dDispatch: " 00375 << "cannot execute convolution in dimension " << dimension 00376 << STD_ENDL; 00377 HxEnvironment::instance()->flush(); 00378 } 00379 } |