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> 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>
void HxFuncBorderPropagate3d DataPtrT    imgPtr,
HxSizes    imgSize,
HxSizes    borderSize
 

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

00335 {
00336     int     borderWidth = borderSize.x();
00337     int     borderHeight = borderSize.y();
00338     int     borderDepth = borderSize.z();
00339     int     imgWidth = imgSize.x() - borderWidth * 2;
00340     int     imgHeight = imgSize.y() - borderHeight * 2;
00341     int     imgDepth = imgSize.y() - borderDepth * 2;
00342     int     x, y, z;
00343     int     totalWidth = imgWidth + 2*borderWidth;
00344     int     totalHeight = imgHeight + 2*borderHeight;
00345     int     totalDepth = imgDepth + 2*borderDepth;
00346 
00347     DataPtrT basePtr = imgPtr;
00348     DataPtrT srcPtr = imgPtr;
00349     DataPtrT dstPtr = imgPtr;
00350 
00351     imgPtr.incZ(borderDepth);
00352 
00353     for (z=0; z<imgDepth; z++)
00354     {
00355         // propagate left and right part
00356         for (y=0 ; y<imgHeight ; y++) {
00357             dstPtr = srcPtr = imgPtr;
00358             srcPtr.incXYZ(borderWidth, borderHeight + y, 0);
00359             dstPtr.incY(borderHeight + y);
00360             for (x=0 ; x<borderWidth ; x++)
00361                 dstPtr.writeIncX(srcPtr.read());
00362 
00363             dstPtr = srcPtr = imgPtr;
00364             srcPtr.incXYZ(borderWidth + imgWidth - 1, borderHeight + y, 0);
00365             dstPtr.incXYZ(borderWidth + imgWidth, borderHeight + y, 0);
00366             for (x=0 ; x<borderWidth ; x++)
00367                 dstPtr.writeIncX(srcPtr.read());
00368         }
00369 
00370         // propagate top and bottom part including left and right "corners"
00371         for (y=0 ; y<borderHeight ; y++) {
00372             dstPtr = srcPtr = imgPtr;
00373             srcPtr.incY(borderHeight);
00374             dstPtr.incY(y);
00375             for (x=0 ; x<totalWidth ; x++)
00376                 dstPtr.writeIncX(srcPtr.readIncX());
00377 
00378             dstPtr = srcPtr = imgPtr;
00379             srcPtr.incY(borderHeight + imgHeight - 1);
00380             dstPtr.incY(borderHeight + imgHeight + y);
00381             for (x=0 ; x<totalWidth ; x++)
00382                 dstPtr.writeIncX(srcPtr.readIncX());
00383         }
00384         imgPtr.incZ();
00385     }
00386 
00387     imgPtr = basePtr;
00388 
00389     // propagate front planes
00390 
00391     for (z=0; z<borderDepth; z++)
00392     {
00393         srcPtr = imgPtr;
00394         srcPtr.incZ(borderDepth);
00395         dstPtr = imgPtr;
00396         dstPtr.incZ(z);
00397         for (y=0; y<totalHeight; y++)
00398         {
00399             for (x=0; x<totalWidth; x++)
00400             {
00401                 dstPtr.writeIncX(srcPtr.readIncX());
00402             }
00403             dstPtr.decX(totalWidth);
00404             dstPtr.incY();
00405             srcPtr.decX(totalWidth);
00406             srcPtr.incY();
00407         }
00408     }
00409 
00410     // propagate back planes
00411 
00412     for (z=0; z<borderDepth; z++)
00413     {
00414         srcPtr = imgPtr;
00415         srcPtr.incZ(imgDepth + borderDepth - 1);
00416         dstPtr = imgPtr;
00417         dstPtr.incZ(imgDepth + borderDepth + z);
00418         for (y=0; y<totalHeight; y++)
00419         {
00420             for (x=0; x<totalWidth; x++)
00421             {
00422                 dstPtr.writeIncX(srcPtr.readIncX());
00423             }
00424             dstPtr.decX(totalWidth);
00425             dstPtr.incY();
00426             srcPtr.decX(totalWidth);
00427             srcPtr.incY();
00428         }
00429     }
00430 }


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