#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, ArithT rightNorm) |
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, ArithT bottomNorm) |
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, ArithType rightNorm) |
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, ArithType bottomNorm) |
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, ArithType rightNorm, ArithType bottomNorm) |
Dispatch function for RecGenConv2dK1d (see Global functions for RecGenConv2dK1d) Dispatch is based on dimension and inplace parameters. More... |
|
Line : X direction, simple.
00092 { 00093 int x, n, ngbSize = kerSize/2; 00094 int scanSize = imgWidth+ngbSize; 00095 //int scanSize = imgWidth; 00096 ArithT result; 00097 00098 // scan order 00099 00100 for (x=0; x<scanSize; x++) 00101 { 00102 result = pixOp.doIt(imgPtr.readIncX(), kernel[0]); 00103 for (n=1; n<=ngbSize; n++) 00104 redOp.doIt(result, pixOp.doIt(imgPtr.readIncX(), kernel[n])); 00105 imgPtr.decX(); 00106 imgPtr.write(result); 00107 imgPtr.decX(ngbSize-1); 00108 } 00109 00110 // Propagate last pixel value into border 00111 00112 imgPtr.incX(ngbSize-1); // now at last pixel on the line 00113 ArithT borderVal = imgPtr.readIncX(); 00114 borderVal *= rightNorm; 00115 for (x=0 ; x<ngbSize ; x++) 00116 imgPtr.writeIncX(borderVal); 00117 imgPtr.decX(ngbSize); 00118 00119 // anti scan order 00120 00121 imgPtr.decX(); 00122 kernel += kerSize/2; 00123 00124 for (x=0; x<scanSize; x++) 00125 { 00126 result = pixOp.doIt(imgPtr.readIncX(), kernel[0]); 00127 for (n=1; n<=ngbSize; n++) 00128 redOp.doIt(result, pixOp.doIt(imgPtr.readIncX(), kernel[n])); 00129 imgPtr.decX(ngbSize+1); 00130 imgPtr.write(result); 00131 imgPtr.decX(); 00132 } 00133 } |
|
Line : Y direction, simple.
00142 { 00143 int y, n, ngbSize = kerSize/2; 00144 int scanSize = imgHeight+ngbSize; 00145 //int scanSize = imgHeight; 00146 ArithT result; 00147 ArithT* ngbPtr = ngbBuf; 00148 00149 // scan order 00150 00151 for (n=0; n<ngbSize; n++) 00152 { 00153 ngbBuf[n] = imgPtr.read(); 00154 imgPtr.incY(); 00155 } 00156 00157 for (y=0; y<scanSize; y++) 00158 { 00159 ngbPtr[ngbSize] = imgPtr.read(); 00160 imgPtr.incY(); 00161 result = pixOp.doIt(ngbPtr[0], kernel[0]); 00162 for (n=1; n<=ngbSize; n++) 00163 redOp.doIt(result, pixOp.doIt(ngbPtr[n], kernel[n])); 00164 ngbPtr[ngbSize] = result; 00165 ngbPtr++; 00166 } 00167 00168 // Propagate last pixel value into border 00169 00170 ngbPtr += ngbSize-1; // now at last pixel 00171 ArithT borderVal = ngbPtr[0]; 00172 borderVal *= bottomNorm; 00173 ngbPtr++; 00174 for (y=0 ; y<ngbSize ; y++) { 00175 ngbPtr[y] = borderVal; 00176 } 00177 imgPtr.incY(ngbSize); 00178 00179 // anti scan order 00180 00181 imgPtr.decY(ngbSize+1); 00182 ngbPtr -= 1; 00183 kernel += ngbSize; 00184 00185 for (y=0; y<scanSize; y++) 00186 { 00187 result = pixOp.doIt(ngbPtr[0], kernel[0]); 00188 for (n=1; n<=ngbSize; n++) 00189 redOp.doIt(result, pixOp.doIt(ngbPtr[n], kernel[n])); 00190 imgPtr.write(*ngbPtr-- = result); 00191 imgPtr.decY(); 00192 } 00193 } |
|
Line : Y direction, buffered.
00201 { 00202 const int ngbSize = kerSize/2; 00203 int x, n; 00204 ArithT result; 00205 DataPtrT linePtr(imgPtr); 00206 00207 // scan order 00208 00209 for (x=0; x<imgWidth; x++) 00210 imgPtr.writeIncX(pixOp.doIt(imgPtr.read(), kernel[ngbSize])); 00211 00212 imgPtr.decX(imgWidth); 00213 00214 // previous lines 00215 for (n=ngbSize-1; n>=0; n--) 00216 { 00217 linePtr.decY(); 00218 for (x=0; x<imgWidth; x++) { 00219 result = imgPtr.read(); 00220 redOp.doIt(result, pixOp.doIt(linePtr.readIncX(), kernel[n])); 00221 imgPtr.writeIncX(result); 00222 } 00223 imgPtr.decX(imgWidth); 00224 linePtr.decX(imgWidth); 00225 } 00226 } |
|
RecGenConv2dK1d : X direction, simple.
00278 { 00279 int borderWidth = borderSize.x() > 0 ? borderSize.x() : kerSize.x()/2; 00280 int borderHeight = borderSize.y(); 00281 imgSize = imgSize - HxSizes(2*borderWidth, 2*borderHeight, 0); 00282 int imgWidth = imgSize.x(); 00283 int imgHeight = imgSize.y(); 00284 int y, i; 00285 00286 HxPixelAllocator<ArithType> allocator; 00287 00288 ArithType* kernel = allocator.allocate(kerSize.x()); 00289 00290 for (i=0; i<kerSize.x(); i++) 00291 kernel[i] = kerPtr.readIncX(); 00292 00293 imgPtr.incXYZ(borderWidth-kerSize.x()/2, borderHeight, 0); 00294 00295 for (y=0; y<imgHeight; y++) 00296 { 00297 HxFuncRecGenConv2dK1d_Line_XdirSim( 00298 imgPtr, imgWidth, kernel, kerSize.x(), pixOp, redOp, rightNorm); 00299 imgPtr.incY(); 00300 } 00301 00302 allocator.deallocate(kernel); 00303 } |
|
RecGenConv2dK1d : Y direction, simple.
00313 { 00314 int borderWidth = borderSize.x(); 00315 int borderHeight = borderSize.y() > 0 ? borderSize.y() : kerSize.x()/2; 00316 imgSize = imgSize - HxSizes(2*borderWidth, 2*borderHeight, 0); 00317 int imgWidth = imgSize.x(); 00318 int imgHeight = imgSize.y(); 00319 int x, i; 00320 00321 HxPixelAllocator<ArithType> allocator; 00322 00323 ArithType* kernel = allocator.allocate(kerSize.x()); 00324 00325 for (i=0; i<kerSize.x(); i++) 00326 kernel[i] = kerPtr.readIncX(); 00327 00328 ArithType* ngbBuf = allocator.allocate(imgHeight+2*borderHeight); 00329 00330 imgPtr.incXYZ(borderWidth, borderHeight-kerSize.x()/2, 0); 00331 00332 for (x=0; x<imgWidth; x++) 00333 { 00334 HxFuncRecGenConv2dK1d_Line_YdirSim(imgPtr, imgHeight, kernel, 00335 kerSize.x(), ngbBuf, pixOp, redOp, bottomNorm); 00336 imgPtr.incX(); 00337 } 00338 00339 allocator.deallocate(ngbBuf); 00340 allocator.deallocate(kernel); 00341 } |
|
RecGenConv2dK1d : Y direction, buffered.
00352 { 00353 HxEnvironment::instance()->outputStream() << "Buffered" << STD_ENDL; 00354 int borderWidth = borderSize.x(); 00355 int borderHeight = borderSize.y() > 0 ? borderSize.y() : kerSize.x()/2; 00356 imgSize = imgSize - HxSizes(2*borderWidth, 2*borderHeight, 0); 00357 int imgWidth = imgSize.x(); 00358 int imgHeight = imgSize.y(); 00359 int y, i; 00360 00361 HxPixelAllocator<ArithType> allocator; 00362 00363 ArithType* kernel = allocator.allocate(kerSize.x()); 00364 00365 for (i=0; i<kerSize.x(); i++) 00366 kernel[i] = kerPtr.readIncX(); 00367 00368 imgPtr.incXYZ(borderWidth, borderHeight, 0); 00369 00370 for (y=0; y<imgHeight+kerSize.x()/2; y++) 00371 { 00372 HxFuncRecGenConv2dK1d_Line_YdirBuf( 00373 imgPtr, imgWidth, kernel, kerSize.x(), pixOp, redOp); 00374 imgPtr.incY(); 00375 } 00376 imgPtr.decY(kerSize.x()/2); 00377 00378 for (y=imgHeight-1; y>=0; y--) 00379 { 00380 imgPtr.decY(); 00381 HxFuncRecGenConv2dK1d_Line_YdirBufAnti( 00382 imgPtr, imgWidth, kernel, kerSize.x(), pixOp, redOp); 00383 } 00384 00385 allocator.deallocate(kernel); 00386 } |
|
Dispatch function for RecGenConv2dK1d (see Global functions for RecGenConv2dK1d) Dispatch is based on dimension and inplace parameters. Assertions:
00408 { 00409 switch (dimension) { 00410 case 1 : 00411 HxFuncRecGenConv2dK1d_XdirSim(imgPtr, kerPtr, dummy, imgSize, borderSize, 00412 kerSize, pixOp, redOp, rightNorm); 00413 break; 00414 case 2 : 00415 if (buffered) 00416 HxFuncRecGenConv2dK1d_YdirBuf(imgPtr, kerPtr, dummy, imgSize, borderSize, 00417 kerSize, pixOp, redOp); 00418 else 00419 HxFuncRecGenConv2dK1d_YdirSim(imgPtr, kerPtr, dummy, imgSize, borderSize, 00420 kerSize, pixOp, redOp, bottomNorm); 00421 break; 00422 default : 00423 HxEnvironment::instance()->errorStream() 00424 << "HxFuncRecGenConv2dK1dDispatch: " 00425 << "cannot execute convolution in dimension " << dimension 00426 << STD_ENDL; 00427 HxEnvironment::instance()->flush(); 00428 } 00429 } |