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

HxFuncBorderOp.h File Reference

More...

#include "HxBorderType.h"

Go to the source code of this file.

Functions

template<class DataPtrT> void HxFuncBorderMirror2d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize)
 Set the border of a 2D image by mirroring. More...

template<class DataPtrT> void HxFuncBorderMirror3d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize)
 Set the border of a 3D image by mirroring. More...

template<class DataPtrT, class ArithT> void HxFuncBorderConstant2d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize, ArithT value)
 Set the border of a 2D image to a constant value. More...

template<class DataPtrT, class ArithT> void HxFuncBorderConstant3d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize, ArithT value)
 Set the border of a 3D image to a constant value. More...

template<class DataPtrT> void HxFuncBorderPropagate2d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize)
 Set the border of a 2D image by propagating the "last" value. More...

template<class DataPtrT, class ArithT> void HxFuncBorderPropagateNormalized2d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize, ArithT normLeft, ArithT normRight, ArithT normTop, ArithT normBottom)
 Set the border of a 2D image by propagating the "last" value, Multiplying the propagated left border value by normLeft Multiplying the propagated right border value by normRight Multiplying the propagated top border value by normTop Multiplying the propagated bottom border value by normBottom (as used in HxRecGabor). More...

template<class DataPtrT> void HxFuncBorderPropagate3d (DataPtrT imgPtr, HxSizes imgSize, HxSizes borderSize)
 Set the border of a 3D image by propagating the "last" value. More...


Detailed Description


Function Documentation

template<class DataPtrT>
void HxFuncBorderMirror2d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize
 

Set the border of a 2D image by mirroring.

00019 {
00020     int     borderWidth = borderSize.x();
00021     int     borderHeight = borderSize.y();
00022     int     imgWidth = imgSize.x() - borderWidth * 2;
00023     int     imgHeight = imgSize.y() - borderHeight * 2;
00024     int     x, y;
00025 
00026     // mirror top part
00027     for (y=0 ; y<borderHeight ; y++) {
00028         DataPtrT srcPtr = imgPtr;
00029         srcPtr.incXYZ(borderWidth, borderHeight + y, 0);
00030         DataPtrT dstPtr = imgPtr;
00031         dstPtr.incXYZ(borderWidth, borderHeight - 1 - y, 0);
00032         for (x=0 ; x<imgWidth ; x++) {
00033             dstPtr.write(srcPtr.read());
00034             srcPtr.incX();
00035             dstPtr.incX();
00036         }
00037     }
00038 
00039     // mirror bottom part
00040     for (y=0 ; y<borderHeight ; y++) {
00041         DataPtrT srcPtr = imgPtr;
00042         srcPtr.incXYZ(borderWidth, borderHeight + imgHeight - 1 - y, 0);
00043         DataPtrT dstPtr = imgPtr;
00044         dstPtr.incXYZ(borderWidth, borderHeight + imgHeight + y, 0);
00045         for (x=0 ; x<imgWidth ; x++) {
00046             dstPtr.write(srcPtr.read());
00047             srcPtr.incX();
00048             dstPtr.incX();
00049         }
00050     }
00051 
00052     // mirror left part including upper and lower "corner"
00053     int totalHeight = imgHeight + 2*borderHeight;
00054     for (y=0 ; y<totalHeight ; y++) {
00055         DataPtrT srcPtr = imgPtr;
00056         srcPtr.incXYZ(borderWidth, y, 0);
00057         DataPtrT dstPtr = imgPtr;
00058         dstPtr.incXYZ(borderWidth - 1, y, 0);
00059         for (x=0 ; x<borderWidth ; x++) {
00060             dstPtr.write(srcPtr.read());
00061             srcPtr.incX();
00062             dstPtr.decX();
00063         }
00064     }
00065 
00066     // mirror right part including upper and lower "corner"
00067     for (y=0 ; y<totalHeight ; y++) {
00068         DataPtrT srcPtr = imgPtr;
00069         srcPtr.incXYZ(borderWidth + imgWidth - 1, y, 0);
00070         DataPtrT dstPtr = imgPtr;
00071         dstPtr.incXYZ(borderWidth + imgWidth, y, 0);
00072         for (x=0 ; x<borderWidth ; x++) {
00073             dstPtr.write(srcPtr.read());
00074             srcPtr.decX();
00075             dstPtr.incX();
00076         }
00077     }
00078 }

template<class DataPtrT>
void HxFuncBorderMirror3d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize
 

Set the border of a 3D image by mirroring.

00084 {
00085     int     borderWidth = borderSize.x();
00086     int     borderHeight = borderSize.y();
00087     int     borderDepth = borderSize.z();
00088     int     imgWidth = imgSize.x() - borderWidth * 2;
00089     int     imgHeight = imgSize.y() - borderHeight * 2;
00090     int     imgDepth = imgSize.z() - borderDepth * 2;
00091     int     x, y, z;
00092 
00093     // mirror top part of each XY plane
00094     for (z=0 ; z<imgDepth ; z++) {
00095         for (y=0 ; y<borderHeight ; y++) {
00096             DataPtrT srcPtr = imgPtr;
00097             srcPtr.incXYZ(borderWidth, borderHeight + y, borderDepth + z);
00098             DataPtrT dstPtr = imgPtr;
00099             dstPtr.incXYZ(borderWidth, borderHeight - 1 - y, borderDepth + z);
00100             for (x=0 ; x<imgWidth ; x++) {
00101                 dstPtr.write(srcPtr.read());
00102                 srcPtr.incX();
00103                 dstPtr.incX();
00104             }
00105         }
00106     }
00107     // mirror bottom part of each XY plane
00108     for (z=0 ; z<imgDepth ; z++) {
00109         for (y=0 ; y<borderHeight ; y++) {
00110             DataPtrT srcPtr = imgPtr;
00111             srcPtr.incXYZ(
00112                 borderWidth, borderHeight + imgHeight - 1 - y, borderDepth + z);
00113             DataPtrT dstPtr = imgPtr;
00114             dstPtr.incXYZ(
00115                 borderWidth, borderHeight + imgHeight + y, borderDepth + z);
00116             for (x=0 ; x<imgWidth ; x++) {
00117                 dstPtr.write(srcPtr.read());
00118                 srcPtr.incX();
00119                 dstPtr.incX();
00120             }
00121         }
00122     }
00123     // mirror left part of each XY plane including upper and lower "corner"
00124     int totalHeight = imgHeight + 2*borderHeight;
00125     for (z=0 ; z<imgDepth ; z++) {
00126         for (y=0 ; y<totalHeight ; y++) {
00127             DataPtrT srcPtr = imgPtr;
00128             srcPtr.incXYZ(borderWidth, y, borderDepth + z);
00129             DataPtrT dstPtr = imgPtr;
00130             dstPtr.incXYZ(borderWidth - 1, y, borderDepth + z);
00131             for (x=0 ; x<borderWidth ; x++) {
00132                 dstPtr.write(srcPtr.read());
00133                 srcPtr.incX();
00134                 dstPtr.decX();
00135             }
00136         }
00137     }
00138     // mirror right part of each XY plane including upper and lower "corner"
00139     for (z=0 ; z<imgDepth ; z++) {
00140         for (y=0 ; y<totalHeight ; y++) {
00141             DataPtrT srcPtr = imgPtr;
00142             srcPtr.incXYZ(borderWidth + imgWidth - 1, y, borderDepth + z);
00143             DataPtrT dstPtr = imgPtr;
00144             dstPtr.incXYZ(borderWidth + imgWidth, y, borderDepth + z);
00145             for (x=0 ; x<borderWidth ; x++) {
00146                 dstPtr.write(srcPtr.read());
00147                 srcPtr.decX();
00148                 dstPtr.incX();
00149             }
00150         }
00151     }
00152     int totalPlane = (imgWidth + 2*borderWidth) * (imgHeight + 2*borderHeight);
00153     // mirror front planes
00154     for (z=0 ; z<borderDepth ; z++) {
00155         DataPtrT srcPtr = imgPtr;
00156         srcPtr.incXYZ(0, 0, borderDepth + z);
00157         DataPtrT dstPtr = imgPtr;
00158         dstPtr.incXYZ(0, 0, borderDepth - 1 - z);
00159         for (x=0 ; x<totalPlane ; x++) {
00160             dstPtr.write(srcPtr.read());
00161             srcPtr.incX();
00162             dstPtr.incX();
00163         }
00164     }
00165     // mirror back planes
00166     for (z=0 ; z<borderDepth ; z++) {
00167         DataPtrT srcPtr = imgPtr;
00168         srcPtr.incXYZ(0, 0, borderDepth + imgDepth - 1 - z);
00169         DataPtrT dstPtr = imgPtr;
00170         dstPtr.incXYZ(0, 0, borderDepth + imgDepth + z);
00171         for (x=0 ; x<totalPlane ; x++) {
00172             dstPtr.write(srcPtr.read());
00173             srcPtr.incX();
00174             dstPtr.incX();
00175         }
00176     }
00177 }

template<class DataPtrT, class ArithT>
void HxFuncBorderConstant2d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize,
ArithT    value
 

Set the border of a 2D image to a constant value.

00183 {
00184     int     borderWidth = borderSize.x();
00185     int     borderHeight = borderSize.y();
00186     int     imgWidth = imgSize.x() - borderWidth * 2;
00187     int     imgHeight = imgSize.y() - borderHeight * 2;
00188     int     x, y, totalWidth = imgWidth + 2*borderWidth;
00189 
00190     DataPtrT dstPtr = imgPtr;
00191 
00192     // set left and right part
00193     for (y=0 ; y<imgHeight ; y++) {
00194         DataPtrT dstPtr = imgPtr;
00195         dstPtr.incY(borderHeight + y);
00196         for (x=0 ; x<borderWidth ; x++)
00197             dstPtr.writeIncX(value);
00198         dstPtr.incX(imgWidth);
00199         for (x=0 ; x<borderWidth ; x++)
00200             dstPtr.writeIncX(value);
00201     }
00202 
00203     // set top and bottom part including left and right "corners"
00204     for (y=0 ; y<borderHeight ; y++) {
00205         DataPtrT dstPtr = imgPtr;
00206         dstPtr.incY(y);
00207         for (x=0 ; x<totalWidth ; x++)
00208             dstPtr.writeIncX(value);
00209         dstPtr.incXYZ(-totalWidth, imgHeight + borderHeight, 0);
00210         for (x=0 ; x<totalWidth ; x++)
00211             dstPtr.writeIncX(value);
00212     }
00213 }

template<class DataPtrT, class ArithT>
void HxFuncBorderConstant3d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize,
ArithT    value
 

Set the border of a 3D image to a constant value.

00219 {
00220     int     borderWidth = borderSize.x();
00221     int     borderHeight = borderSize.y();
00222     int     borderDepth = borderSize.z();
00223     int     imgWidth = imgSize.x() - borderWidth * 2;
00224     int     imgHeight = imgSize.y() - borderHeight * 2;
00225     int     imgDepth = imgSize.z() - borderDepth * 2;
00226     int     totalWidth = imgWidth + 2*borderWidth;
00227     int     totalHeight = imgHeight + 2*borderHeight;
00228     int     totalDepth = imgDepth + 2*borderDepth;
00229     int     x, y, z;
00230 
00231     DataPtrT basePtr = imgPtr;
00232     imgPtr.incZ(imgDepth);
00233 
00234     for (z=0 ; z<imgDepth ; z++)
00235     {
00236 
00237         // set left and right part
00238         for (y=0 ; y<imgHeight ; y++) {
00239             DataPtrT dstPtr = imgPtr;
00240             dstPtr.incY(borderHeight + y);
00241             for (x=0 ; x<borderWidth ; x++)
00242                 dstPtr.writeIncX(value);
00243             dstPtr.incX(imgWidth);
00244             for (x=0 ; x<borderWidth ; x++)
00245                 dstPtr.writeIncX(value);
00246         }
00247 
00248         // set top and bottom part including left and right "corners"
00249         for (y=0 ; y<borderHeight ; y++) {
00250             DataPtrT dstPtr = imgPtr;
00251             dstPtr.incY(y);
00252             for (x=0 ; x<totalWidth ; x++)
00253                 dstPtr.writeIncX(value);
00254             dstPtr.incXYZ(-totalWidth, imgHeight + borderHeight, 0);
00255             for (x=0 ; x<totalWidth ; x++)
00256                 dstPtr.writeIncX(value);
00257         }
00258 
00259         imgPtr.incZ();
00260     }
00261 
00262     // set front and back planes
00263 
00264     for (int p=0; p<totalDepth; p += imgDepth + borderDepth)
00265     {
00266         imgPtr = basePtr;
00267         imgPtr.incZ(p);
00268         for (z=0; z<borderDepth; z++)
00269         {
00270             for (y=0; y<totalHeight; y++)
00271             {
00272                 for (x=0; x<totalWidth; x++)
00273                 {
00274                     imgPtr.writeIncX(value);
00275                 }
00276                 imgPtr.decX(totalWidth);
00277                 imgPtr.incY();
00278             }
00279             imgPtr.decY(totalHeight);
00280             imgPtr.incZ();
00281         }
00282     }
00283 }

template<class DataPtrT>
void HxFuncBorderPropagate2d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize
 

Set the border of a 2D image by propagating the "last" value.

00289 {
00290     int     borderWidth = borderSize.x();
00291     int     borderHeight = borderSize.y();
00292     int     imgWidth = imgSize.x() - borderWidth * 2;
00293     int     imgHeight = imgSize.y() - borderHeight * 2;
00294     int     x, y, totalWidth = imgWidth + 2*borderWidth;
00295 
00296     DataPtrT srcPtr = imgPtr;
00297     DataPtrT dstPtr = imgPtr;
00298 
00299     // propagate left and right part
00300     for (y=0 ; y<imgHeight ; y++) {
00301         dstPtr = srcPtr = imgPtr;
00302         srcPtr.incXYZ(borderWidth, borderHeight + y, 0);
00303         dstPtr.incY(borderHeight + y);
00304         for (x=0 ; x<borderWidth ; x++)
00305             dstPtr.writeIncX(srcPtr.read());
00306 
00307         dstPtr = srcPtr = imgPtr;
00308         srcPtr.incXYZ(borderWidth + imgWidth - 1, borderHeight + y, 0);
00309         dstPtr.incXYZ(borderWidth + imgWidth, borderHeight + y, 0);
00310         for (x=0 ; x<borderWidth ; x++)
00311             dstPtr.writeIncX(srcPtr.read());
00312     }
00313 
00314     // propagate top and bottom part including left and right "corners"
00315     for (y=0 ; y<borderHeight ; y++) {
00316         dstPtr = srcPtr = imgPtr;
00317         srcPtr.incY(borderHeight);
00318         dstPtr.incY(y);
00319         for (x=0 ; x<totalWidth ; x++)
00320             dstPtr.writeIncX(srcPtr.readIncX());
00321 
00322         dstPtr = srcPtr = imgPtr;
00323         srcPtr.incY(borderHeight + imgHeight - 1);
00324         dstPtr.incY(borderHeight + imgHeight + y);
00325         for (x=0 ; x<totalWidth ; x++)
00326             dstPtr.writeIncX(srcPtr.readIncX());
00327     }
00328 
00329 }

template<class DataPtrT, class ArithT>
void HxFuncBorderPropagateNormalized2d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize,
ArithT    normLeft,
ArithT    normRight,
ArithT    normTop,
ArithT    normBottom
 

Set the border of a 2D image by propagating the "last" value, Multiplying the propagated left border value by normLeft Multiplying the propagated right border value by normRight Multiplying the propagated top border value by normTop Multiplying the propagated bottom border value by normBottom (as used in HxRecGabor).

00335 {
00336 //  printf("HxFuncBorderPropagateNormalized2d \n") ;
00337 //  printf("leftBorderVals: r=%f, im=%f \n", HxComplex(normLeft).x(), HxComplex(normLeft).y());
00338 //  printf("rightBorderVals: r=%f, im=%f \n", HxComplex(normRight).x(), HxComplex(normRight).y());
00339 //  printf("topBorderVals: r=%f, im=%f \n", HxComplex(normTop).x(), HxComplex(normTop).y());
00340 //  printf("BottomBorderVals: r=%f, im=%f \n", HxComplex(normBottom).x(), HxComplex(normBottom).y());
00341 
00342     int     borderWidth = borderSize.x();
00343     int     borderHeight = borderSize.y();
00344     int     imgWidth = imgSize.x() - borderWidth * 2;
00345     int     imgHeight = imgSize.y() - borderHeight * 2;
00346     int     x, y, totalWidth = imgWidth + 2*borderWidth;
00347 
00348     DataPtrT srcPtr = imgPtr;
00349     DataPtrT dstPtr = imgPtr;
00350 
00351     // propagate and normalize left and right part
00352     for (y=0 ; y<imgHeight ; y++) {
00353         dstPtr = srcPtr = imgPtr;
00354         srcPtr.incXYZ(borderWidth, borderHeight + y, 0);
00355         dstPtr.incY(borderHeight + y);
00356         for (x=0 ; x<borderWidth ; x++)
00357             dstPtr.writeIncX(srcPtr.read() * normLeft);
00358 
00359         dstPtr = srcPtr = imgPtr;
00360         srcPtr.incXYZ(borderWidth + imgWidth - 1, borderHeight + y, 0);
00361         dstPtr.incXYZ(borderWidth + imgWidth, borderHeight + y, 0);
00362         for (x=0 ; x<borderWidth ; x++)
00363             //dstPtr.writeIncX(srcPtr.read() * normRight);
00364             // normalization right part is done by the recursive operation itself
00365             dstPtr.writeIncX(srcPtr.read());
00366     }
00367 
00368     // propagate and normalize top and bottom part including left and right "corners"
00369     for (y=0 ; y<borderHeight ; y++) {
00370         dstPtr = srcPtr = imgPtr;
00371         srcPtr.incY(borderHeight);
00372         dstPtr.incY(y);
00373         for (x=0 ; x<totalWidth ; x++)
00374           dstPtr.writeIncX(srcPtr.readIncX() * normTop);
00375 
00376         dstPtr = srcPtr = imgPtr;
00377         srcPtr.incY(borderHeight + imgHeight - 1);
00378         dstPtr.incY(borderHeight + imgHeight + y);
00379         for (x=0 ; x<totalWidth ; x++)
00380             //dstPtr.writeIncX(srcPtr.readIncX()* normBottom);
00381             // normalization bottom part is done by the recursive operation itself
00382             dstPtr.writeIncX(srcPtr.readIncX());
00383     }
00384 
00385 }

template<class DataPtrT>
void HxFuncBorderPropagate3d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize
 

Set the border of a 3D image by propagating the "last" value.

00393 {
00394     int     borderWidth = borderSize.x();
00395     int     borderHeight = borderSize.y();
00396     int     borderDepth = borderSize.z();
00397     int     imgWidth = imgSize.x() - borderWidth * 2;
00398     int     imgHeight = imgSize.y() - borderHeight * 2;
00399     int     imgDepth = imgSize.y() - borderDepth * 2;
00400     int     x, y, z;
00401     int     totalWidth = imgWidth + 2*borderWidth;
00402     int     totalHeight = imgHeight + 2*borderHeight;
00403     int     totalDepth = imgDepth + 2*borderDepth;
00404 
00405     DataPtrT basePtr = imgPtr;
00406     DataPtrT srcPtr = imgPtr;
00407     DataPtrT dstPtr = imgPtr;
00408 
00409     imgPtr.incZ(borderDepth);
00410 
00411     for (z=0; z<imgDepth; z++)
00412     {
00413         // propagate left and right part
00414         for (y=0 ; y<imgHeight ; y++) {
00415             dstPtr = srcPtr = imgPtr;
00416             srcPtr.incXYZ(borderWidth, borderHeight + y, 0);
00417             dstPtr.incY(borderHeight + y);
00418             for (x=0 ; x<borderWidth ; x++)
00419                 dstPtr.writeIncX(srcPtr.read());
00420 
00421             dstPtr = srcPtr = imgPtr;
00422             srcPtr.incXYZ(borderWidth + imgWidth - 1, borderHeight + y, 0);
00423             dstPtr.incXYZ(borderWidth + imgWidth, borderHeight + y, 0);
00424             for (x=0 ; x<borderWidth ; x++)
00425                 dstPtr.writeIncX(srcPtr.read());
00426         }
00427 
00428         // propagate top and bottom part including left and right "corners"
00429         for (y=0 ; y<borderHeight ; y++) {
00430             dstPtr = srcPtr = imgPtr;
00431             srcPtr.incY(borderHeight);
00432             dstPtr.incY(y);
00433             for (x=0 ; x<totalWidth ; x++)
00434                 dstPtr.writeIncX(srcPtr.readIncX());
00435 
00436             dstPtr = srcPtr = imgPtr;
00437             srcPtr.incY(borderHeight + imgHeight - 1);
00438             dstPtr.incY(borderHeight + imgHeight + y);
00439             for (x=0 ; x<totalWidth ; x++)
00440                 dstPtr.writeIncX(srcPtr.readIncX());
00441         }
00442         imgPtr.incZ();
00443     }
00444 
00445     imgPtr = basePtr;
00446 
00447     // propagate front planes
00448 
00449     for (z=0; z<borderDepth; z++)
00450     {
00451         srcPtr = imgPtr;
00452         srcPtr.incZ(borderDepth);
00453         dstPtr = imgPtr;
00454         dstPtr.incZ(z);
00455         for (y=0; y<totalHeight; y++)
00456         {
00457             for (x=0; x<totalWidth; x++)
00458             {
00459                 dstPtr.writeIncX(srcPtr.readIncX());
00460             }
00461             dstPtr.decX(totalWidth);
00462             dstPtr.incY();
00463             srcPtr.decX(totalWidth);
00464             srcPtr.incY();
00465         }
00466     }
00467 
00468     // propagate back planes
00469 
00470     for (z=0; z<borderDepth; z++)
00471     {
00472         srcPtr = imgPtr;
00473         srcPtr.incZ(imgDepth + borderDepth - 1);
00474         dstPtr = imgPtr;
00475         dstPtr.incZ(imgDepth + borderDepth + z);
00476         for (y=0; y<totalHeight; y++)
00477         {
00478             for (x=0; x<totalWidth; x++)
00479             {
00480                 dstPtr.writeIncX(srcPtr.readIncX());
00481             }
00482             dstPtr.decX(totalWidth);
00483             dstPtr.incY();
00484             srcPtr.decX(totalWidth);
00485             srcPtr.incY();
00486         }
00487     }
00488 }


Generated on Tue Feb 3 14:18:47 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001