#include <HxImageData.h>
Inheritance diagram for HxImageData::

Constructors and destructor | |
| HxImageData () | |
| Constructor. More... | |
| HxImageData (const HxImageData &) | |
| Copy constructor. More... | |
| virtual | ~HxImageData () |
| Destructor. More... | |
Inquiry | |
| int | ident () const |
| Get identity. More... | |
| HxString | name () const |
| Get name. More... | |
| void | name (HxString s) |
| Set name. More... | |
| virtual int | dimensionality () const=0 |
| Get dimensionality. More... | |
| virtual int | dimensionSize (int i) const=0 |
| Get image size in given dimension. More... | |
| virtual HxSizes | sizes () const=0 |
| Get image sizes. More... | |
| virtual int | numberOfPixels () const=0 |
| Get total number of pixels. More... | |
| virtual int | pixelDimensionality () const=0 |
| Get dimensionality of pixels. More... | |
| virtual HxValueType | pixelType () const=0 |
| Get type of pixel. More... | |
| virtual int | pixelPrecision () const=0 |
| Get pixel precision. More... | |
| virtual HxImageSignature | signature () const=0 |
| Get image signature. More... | |
Import/export operations | |
| virtual void | import (HxByte *data, HxTagList &tags=HxMakeTagList(), HxString importOp="importPix") |
| Import pixels from HxByte data. More... | |
| virtual void | import (short *data, HxTagList &tags=HxMakeTagList(), HxString importOp="importPix") |
| Import pixels from short data. More... | |
| virtual void | import (int *data, HxTagList &tags=HxMakeTagList(), HxString importOp="importPix") |
| Import pixels from int data. More... | |
| virtual void | import (float *data, HxTagList &tags=HxMakeTagList(), HxString importOp="importPix") |
| Import pixels from float data. More... | |
| virtual void | import (double *data, HxTagList &tags=HxMakeTagList(), HxString importOp="importPix") |
| Import pixels from double data. More... | |
| virtual void | exportOp (HxByte *data, HxTagList &tags, HxString exportOp="exportPix") |
| Export pixels as HxByte data. More... | |
| virtual void | exportOp (short *data, HxTagList &tags, HxString exportOp="exportPix") |
| Export pixels as short data. More... | |
| virtual void | exportOp (int *data, HxTagList &tags, HxString exportOp="exportPix") |
| Export pixels as int data. More... | |
| virtual void | exportOp (float *data, HxTagList &tags, HxString exportOp="exportPix") |
| Export pixels as float data. More... | |
| virtual void | exportOp (double *data, HxTagList &tags, HxString exportOp="exportPix") |
| Export pixels as double data. More... | |
| virtual void | inout (void *data, HxString dataType, HxString inOutOp, HxTagList &tags) |
| InOut operation. More... | |
| virtual void | inout (HxString inOutOp, HxTagList &tags) |
| InOut operation (the real one). More... | |
| virtual void | exportExtra (HxString exportOp, HxImageData *extraIm, HxTagList &tags) |
| Export operation with extra image. More... | |
Set and border operations | |
| virtual void | set (const HxValue val) |
| virtual void | set (HxImageData *arg) |
| virtual void | set (int *pixels) |
| virtual void | set (HxByte *pixels) |
| virtual void | set (double *pixels)=0 |
| void | setPartImage (HxImageData *src) |
| void | setPartImage (HxImageData *src, HxTagList &tags) |
| Set operation (the real one). More... | |
| void | setPartImage (HxImageData *src, HxPointInt srcBegin, HxPointInt srcEnd, HxPointInt dstBegin) |
| void | setBorder (HxTagList &tags) |
| Set border operation (the real one). More... | |
| void | setBorder (HxSizes borderSize, HxTagList &tags, HxBorderType borderType=HXBORDERMIRROR) |
| void | setBorder (HxBorderType borderType, HxSizes borderSize, HxTagList &tags) |
| void | setBorder (HxSizes borderSize, HxValue val) |
| void | mirrorBorder (HxSizes borderSize) |
| void | propagateBorder (HxSizes borderSize) |
Generic operations | |
| virtual void | unaryPixOp (HxImageData *src, HxString upoName, HxTagList &tags) |
| Unary pixel operation. More... | |
| virtual void | binaryPixOp (HxImageData *arg1, HxImageData *arg2, HxString bpoName, HxTagList &tags) |
| Binary pixel operation. More... | |
| virtual void | multiPixOp (HxImageData **args, int nArgs, HxString mpoName, HxTagList &tags) |
| Multi pixel operation. More... | |
| virtual void | generalizedConvolution (HxImageData *srcImg, HxImageData *kerImg, HxString genMul, HxString genAdd, HxString kerName, HxTagList &tags) |
| Generalized convolution operation. More... | |
| virtual void | generalizedConvolutionK1d (HxImageData *srcImg, int dimension, HxImageData *kerImg, HxString genMul, HxString genAdd, HxString kerName, HxTagList &tags) |
| Generalized convolution operation in one dimension. More... | |
| virtual void | genConvSeparated (HxImageData *srcImg, int dimension, HxImageData *kerImg1, HxImageData *kerImg2, HxString genMul, HxString genAdd, HxString kerName, HxTagList &tags) |
| Generalized convolution operation separated by dimension. More... | |
| virtual void | genConv2dSep (HxImageData *srcImg, HxImageData *kerImg1, HxImageData *kerImg2, HxString genMul, HxString genAdd, HxString kerName, HxTagList &tags) |
| Separable generalized convolution operation on 2D images. More... | |
| virtual void | genConv3dSep (HxImageData *srcImg, HxImageData *kerImg1, HxImageData *kerImg2, HxImageData *kerImg3, HxString genMul, HxString genAdd, HxString kerName, HxTagList &tags) |
| Separable generalized convolution operation on 3D images. More... | |
| virtual void | recGenConv (HxImageData *srcImg, HxImageData *kerImg, HxString genMul, HxString genAdd, HxTagList &tags) |
| Recursive generalized convolution operation. More... | |
| virtual void | recGenConv2dSep (HxImageData *srcImg, HxImageData *kerImg1, HxImageData *kerImg2, HxString genMul, HxString genAdd, HxTagList &tags) |
| Separable recursive generalized convolution operation on 2D images. More... | |
| virtual void | neighbourhoodOp (HxImageData *src, HxString ngbName, HxTagList &tags) |
| Neighbourhood operation. More... | |
| virtual void | neighbourhoodOpExtra (HxImageData *src, HxImageData *extraIm, HxString ngbName, HxTagList &tags) |
| Neighbourhood operation with extra image. More... | |
| virtual void | neighbourhoodOpExtra2 (HxImageData *src, HxImageData *extraIm, HxImageData *extraIm2, HxString ngbName, HxTagList &tags) |
| Neighbourhood operation with extra images. More... | |
| virtual void | neighbourhoodOp (HxImageData *src, HxImageData *kernel, HxString ngbName, HxTagList &tags) |
| Neighbourhood operation with kernel. More... | |
| virtual void | queueBasedOp (HxImageData *srcImg, HxImageData *kerImg, HxString genOp, HxTagList &tags) |
| Queue based operation. More... | |
| virtual void | diyOp (HxImageData *src, HxString diyName, HxTagList &tags) |
| Do it yourself operation. More... | |
| virtual void | rgbOp (HxString rgbName, HxTagList &tags) |
| Display operation. More... | |
| void | MNPixOp (HxImageData **results, int resultCnt, HxImageData **args, int argCnt, HxString mpoName, HxTagList &tags) |
| M output N input pixel operation. More... | |
Geometric operations | |
| virtual void | geometricOp2d (HxImageData *arg, HxMatrix func, HxGeoIntType gi, HxVec3Double translate, HxValue background)=0 |
| Geometric operation on 2D images. More... | |
| virtual void | restrict (HxImageData *arg, HxPoint begin) |
| virtual void | extend (HxImageData *arg, HxPoint begin) |
| virtual HxImageData * | projectDomain (int dimension, int coordinate)=0 |
| virtual void | inverseProjectDomain (int dimension, int coordinate, HxImageData *arg)=0 |
Sample operations | |
| virtual void | getValues (HxPointListConstIter first, HxPointListConstIter last, HxValueListBackInserter)=0 |
Misc operations | |
| virtual void | setAt (int x, int y, int z, const HxValue v)=0 |
| virtual HxValue | getAt (int x, int y, int z) const=0 |
| virtual HxRcObject * | clone () |
| virtual void | setPpmPixels (const HxByte *pixels) |
| virtual void | getPpmPixels (HxByte *pixels) |
| virtual void | getRgbPixels2d (int *pixels, HxString dispF, int bufWidth, int bufHeight, int VX, int VY, int VW, int VH, double SX, double SY, double scaleX, double scaleY, HxGeoIntType gi) const |
| virtual void | getDoublePixels (double *pixels)=0 |
| virtual STD_OSTREAM & | printInfo (STD_OSTREAM &os, int doData=0) const=0 |
| void | setObjectObserver (const HxObjectObserver &) |
| bool | probeMNpo (const HxImageSignature resultsSig, const HxImageSignature argsSig, HxString mpoName, HxTagList &tags) |
To be rewritten | |
| virtual HxImageData * | projectRange (int dimension) |
| virtual void | inverseProjectRange (int dimension, HxImageData *arg) |
Public Methods | |
| void | weight (double w) |
| HxScalarDouble | weight () const |
Protected Methods | |
| int | checkEqualImageSig (HxString func, HxImageData *arg) |
| int | checkEqualImageSizes (HxString func, HxImageData *arg) |
| int | checkEqualImageSigAndSizes (HxString func, HxImageData *arg) |
| int | checkLargerImageSigAndSizes (HxString func, HxImageData *arg) |
| int | checkProperKernelSigAndSizes (HxString func, HxImageData *kernel, int reqDim, int reqScalar, int appliedDim=0) |
| int | checkEqualImageSizesDim (HxString func, HxImageData *arg, int dimension) |
| int | checkImageDimension (HxString func, int dim, int coord) |
| int | checkPixelDimension (HxString func, int dim) |
| bool | checkBorderSize (HxString funcName, HxSizes borderSize) const |
| HxSizes | getProjectDomainSizes (int dimension) const |
All operations on images can be accessed by this interface, yet little of them are implemented by this class. This class serves as a handle of all types of images that are derived from this base class. The HxImageData class provides methods to make inquiries about the type of the image.
|
|
Constructor.
00052 {
00053 _ident = _nr++;
00054 _name = HxString("image") + makeString(_ident);
00055 _weight = 1;
00056 HxImageDataRepository::instance()->insertImage(this);
00057 if (_objectObserver)
00058 _objectObserver->constructed(_name);
00059 }
|
|
|
Copy constructor.
00061 : HxRcObject() 00062 { 00063 HxEnvironment::instance()->warningStream() << 00064 "HxImageData copy constructor called" << STD_ENDL; 00065 HxEnvironment::instance()->flush(); 00066 } |
|
|
Destructor.
00069 {
00070 HxImageDataRepository::instance()->removeImage(this);
00071 if (_objectObserver)
00072 _objectObserver->destructed(_name);
00073 }
|
|
|
Get identity.
00077 {
00078 return _ident;
00079 }
|
|
|
Get name.
00083 {
00084 return _name;
00085 }
|
|
|
Set name.
00089 {
00090 _name = s;
00091 }
|
|
|
Get dimensionality.
Reimplemented in HxImageTem. |
|
|
Get image size in given dimension.
Reimplemented in HxImageTem. |
|
|
Get image sizes.
Reimplemented in HxImageTem. |
|
|
Get total number of pixels.
Reimplemented in HxImageTem. |
|
|
Get dimensionality of pixels.
Reimplemented in HxImageTem. |
|
|
Get type of pixel.
Reimplemented in HxImageTem. |
|
|
Get pixel precision.
Reimplemented in HxImageTem. |
|
|
Get image signature.
Reimplemented in HxImageTem. |
|
||||||||||||||||
|
Import pixels from HxByte data.
01062 {
01063 inout((void*)data, HxClassName<HxByte>(), importOp, tags);
01064 }
|
|
||||||||||||||||
|
Import pixels from short data.
01068 {
01069 inout((void*)data, HxClassName<short>(), importOp, tags);
01070 }
|
|
||||||||||||||||
|
Import pixels from int data.
01074 {
01075 inout((void*)data, HxClassName<int>(), importOp, tags);
01076 }
|
|
||||||||||||||||
|
Import pixels from float data.
01080 {
01081 inout((void*)data, HxClassName<float>(), importOp, tags);
01082 }
|
|
||||||||||||||||
|
Import pixels from double data.
01086 {
01087 inout((void*)data, HxClassName<double>(), importOp, tags);
01088 }
|
|
||||||||||||||||
|
Export pixels as HxByte data.
01092 {
01093 inout((void*)data, HxClassName<HxByte>(), exportOp, tags);
01094 }
|
|
||||||||||||||||
|
Export pixels as short data.
01098 {
01099 inout((void*)data, HxClassName<short>(), exportOp, tags);
01100 }
|
|
||||||||||||||||
|
Export pixels as int data.
01104 {
01105 inout((void*)data, HxClassName<int>(), exportOp, tags);
01106 }
|
|
||||||||||||||||
|
Export pixels as float data.
01110 {
01111 inout((void*)data, HxClassName<float>(), exportOp, tags);
01112 }
|
|
||||||||||||||||
|
Export pixels as double data.
01116 {
01117 inout((void*)data, HxClassName<double>(), exportOp, tags);
01118 }
|
|
||||||||||||||||||||
|
InOut operation.
|
|
||||||||||||
|
InOut operation (the real one).
01131 {
01132 HxImgFtorInOutKey funcKey(signature().toString(), inOutOp);
01133
01134 static HxImgFtorTableTem<HxImgFtorI1> funcTable;
01135 HxImgFtorI1* func = funcTable.find(funcKey);
01136
01137 if (func) {
01138 func->callIt(this, tags);
01139 } else {
01140 HxEnvironment::instance()->errorStream()
01141 << "Can't find " << funcKey << STD_ENDL;
01142 HxEnvironment::instance()->flush();
01143 }
01144 }
|
|
||||||||||||||||
|
Export operation with extra image.
01149 {
01150 HxImgFtorExportExtraKey funcKey(signature().toString(),
01151 extraIm->signature().toString(),
01152 exportOp);
01153
01154 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
01155 HxImgFtorI2* func = funcTable.find(funcKey);
01156
01157 if (func) {
01158 func->callIt(this, extraIm, tags);
01159 } else {
01160 HxEnvironment::instance()->errorStream()
01161 << "Can't find " << funcKey << STD_ENDL;
01162 HxEnvironment::instance()->flush();
01163 }
01164 }
|
|
||||||||||||
|
Set operation (the real one).
01213 {
01214 HxImgFtorSetKey funcKey(signature().toString(),
01215 src->signature().toString());
01216
01217 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
01218 HxImgFtorI2* func = funcTable.find(funcKey);
01219
01220 if (func) {
01221 func->callIt(this, src, tags);
01222 } else {
01223 HxEnvironment::instance()->errorStream()
01224 << "Can't find " << funcKey << STD_ENDL;
01225 HxEnvironment::instance()->flush();
01226 }
01227 }
|
|
|
Set border operation (the real one).
01299 {
01300 HxImgFtorSetBorderKey funcKey(signature().toString());
01301
01302 static HxImgFtorTableTem<HxImgFtorI1> funcTable;
01303 HxImgFtorI1* func = funcTable.find(funcKey);
01304
01305 if (func) {
01306 func->callIt(this, tags);
01307 } else {
01308 HxEnvironment::instance()->errorStream()
01309 << "Can't find " << funcKey << STD_ENDL;
01310 HxEnvironment::instance()->flush();
01311 }
01312 }
|
|
||||||||||||||||
|
Unary pixel operation.
00354 {
00355 HxImgFtorUpoKey funcKey(signature().toString(),
00356 srcImg->signature().toString(),
00357 upoName);
00358
00359 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
00360 HxImgFtorI2* func = funcTable.find(funcKey);
00361
00362 if (func) {
00363 func->callIt(this, srcImg, tags);
00364 } else {
00365 HxEnvironment::instance()->errorStream()
00366 << "Can't find " << funcKey << STD_ENDL;
00367 HxEnvironment::instance()->flush();
00368 }
00369 }
|
|
||||||||||||||||||||
|
Binary pixel operation.
00374 {
00375 if (!checkEqualImageSizes("binaryPixOp", arg1) ||
00376 !checkEqualImageSizes("binaryPixOp", arg2))
00377 return;
00378
00379 HxImgFtorBpoKey funcKey(signature().toString(),
00380 arg1->signature().toString(),
00381 arg2->signature().toString(),
00382 bpoName);
00383
00384 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00385 HxImgFtorI3* func = funcTable.find(funcKey);
00386
00387 if (func) {
00388 func->callIt(this, arg1, arg2, tags);
00389 } else {
00390 HxEnvironment::instance()->errorStream()
00391 << "Can't find " << funcKey << STD_ENDL;
00392 HxEnvironment::instance()->flush();
00393 }
00394 }
|
|
||||||||||||||||||||
|
Multi pixel operation.
00400 {
00401 HxImgFtorMpoKey funcKey(signature().toString(),
00402 srcImgs[0]->signature().toString(),
00403 mpoName);
00404
00405 static HxImgFtorTableTem<HxImgFtorIM> funcTable;
00406 HxImgFtorIM* func = funcTable.find(funcKey);
00407
00408 if (func) {
00409 func->callIt(this, srcImgs, nImgs, tags);
00410 } else {
00411 HxEnvironment::instance()->errorStream()
00412 << "Can't find " << funcKey << STD_ENDL;
00413 HxEnvironment::instance()->flush();
00414 }
00415 }
|
|
||||||||||||||||||||||||||||
|
M output N input pixel operation.
00443 {
00444 HxImgFtorMNpoKey funcKey(resImgs[0]->signature().toString(),
00445 srcImgs[0]->signature().toString(),
00446 mpoName);
00447
00448 static HxImgFtorTableTem<HxImgFtorIMN> funcTable;
00449 HxImgFtorIMN* func = funcTable.find(funcKey);
00450
00451 if (func) {
00452 func->callIt(resImgs, resCnt, srcImgs, srcCnt, tags);
00453 } else {
00454 HxEnvironment::instance()->errorStream()
00455 << "Can't find " << funcKey << STD_ENDL;
00456 HxEnvironment::instance()->flush();
00457 }
00458 }
|
|
||||||||||||||||||||||||||||
|
Generalized convolution operation.
00466 {
00467 HxSizes borderSize = kerImg->sizes() / HxSizes(2, 2, 2);
00468 if (!checkBorderSize("generalizedConvolution", borderSize))
00469 return;
00470 HxSizes scratchSize = srcImg->sizes() + borderSize * HxSizes(2, 2, 2);
00471 HxImageData* scratchImg
00472 = HxImgDataFactory::instance().makeImage(
00473 kerImg->signature(), scratchSize);
00474 scratchImg->setPartImage(
00475 srcImg, HxPointInt(0, 0, 0),
00476 srcImg->sizes() - HxPointInt(1, 1, 1), borderSize);
00477 scratchImg->setBorder(borderSize, tags);
00478
00479 HxImgFtorGenConvKey funcKey(
00480 signature().toString(),
00481 scratchImg->signature().toString(),
00482 kerImg->signature().toString(),
00483 genMul, genAdd, kerName);
00484
00485 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00486 HxImgFtorI3* func = funcTable.find(funcKey);
00487
00488 if (func) {
00489 func->callIt(this, scratchImg, kerImg, tags);
00490 } else {
00491 HxEnvironment::instance()->errorStream()
00492 << "Can't find " << funcKey << STD_ENDL;
00493 HxEnvironment::instance()->flush();
00494 }
00495
00496 delete scratchImg;
00497 }
|
|
||||||||||||||||||||||||||||||||
|
Generalized convolution operation in one dimension.
00505 {
00506 HxSizes borderSize;
00507
00508 switch (dimension) {
00509 case 1 :
00510 borderSize = HxSizes(kerImg->sizes().x() / 2, 0, 0);
00511 break;
00512 case 2 :
00513 borderSize = HxSizes(0, kerImg->sizes().x() / 2, 0);
00514 break;
00515 case 3 :
00516 borderSize = HxSizes(0, 0, kerImg->sizes().x() / 2);
00517 break;
00518 }
00519
00520 if (!checkBorderSize("generalizedConvolutionK1d", borderSize))
00521 return;
00522
00523 HxAddTag<HxSizes>(tags, "borderSize", borderSize);
00524 HxAddTag<int>(tags, "dimension", dimension);
00525
00526 HxSizes scratchSize = srcImg->sizes() + borderSize * HxSizes(2, 2, 2);
00527 HxImageSignature scratchSig(kerImg->signature());
00528 scratchSig.setImageDimensionality(signature().imageDimensionality());
00529 HxImageData* scratchImg
00530 = HxImgDataFactory::instance().makeImage(scratchSig, scratchSize);
00531
00532 scratchImg->setPartImage(
00533 srcImg, HxPointInt(0, 0, 0),
00534 srcImg->sizes() - HxPointInt(1, 1, 1), borderSize);
00535 scratchImg->setBorder(borderSize, tags);
00536
00537 HxImgFtorGenConvK1dKey funcKey(
00538 signature().toString(),
00539 scratchImg->signature().toString(),
00540 kerImg->signature().toString(),
00541 genMul, genAdd, kerName);
00542
00543 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00544 HxImgFtorI3* func = funcTable.find(funcKey);
00545
00546 if (func) {
00547 func->callIt(this, scratchImg, kerImg, tags);
00548 } else {
00549 HxEnvironment::instance()->errorStream()
00550 << "Can't find " << funcKey << STD_ENDL;
00551 HxEnvironment::instance()->flush();
00552 }
00553
00554 delete scratchImg;
00555 }
|
|
||||||||||||||||||||||||||||||||||||
|
Generalized convolution operation separated by dimension.
00563 {
00564 HxImageData* srcCopy = srcImg;
00565 for (int dim=1 ; dim<=dimensionality() ; dim++) {
00566 HxImageData* kerImg = (dim == dimension) ? kerImg1 : kerImg2;
00567 HxSizes borderSize;
00568
00569 switch (dim) {
00570 case 1 :
00571 borderSize = HxSizes(kerImg->sizes().x() / 2, 0, 0);
00572 break;
00573 case 2 :
00574 borderSize = HxSizes(0, kerImg->sizes().x() / 2, 0);
00575 break;
00576 case 3 :
00577 borderSize = HxSizes(0, 0, kerImg->sizes().x() / 2);
00578 break;
00579 }
00580
00581 if (!checkBorderSize("genConvSeparated", borderSize))
00582 return;
00583
00584 HxAddTag<HxSizes>(tags, "borderSize", borderSize);
00585 HxAddTag<int>(tags, "dimension", dim);
00586
00587 HxSizes scratchSize = srcCopy->sizes() + borderSize * HxSizes(2, 2, 2);
00588 HxImageSignature scratchSig(kerImg->signature());
00589 scratchSig.setImageDimensionality(signature().imageDimensionality());
00590 HxImageData* scratchImg
00591 = HxImgDataFactory::instance().makeImage(scratchSig, scratchSize);
00592
00593 scratchImg->setPartImage(
00594 srcCopy, HxPointInt(0, 0, 0),
00595 srcCopy->sizes() - HxPointInt(1, 1, 1), borderSize);
00596 scratchImg->setBorder(borderSize, tags);
00597
00598 HxImgFtorGenConvK1dKey funcKey(
00599 signature().toString(),
00600 scratchImg->signature().toString(),
00601 kerImg->signature().toString(),
00602 genMul, genAdd, kerName);
00603
00604 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00605 HxImgFtorI3* func = funcTable.find(funcKey);
00606
00607 if (func) {
00608 func->callIt(this, scratchImg, kerImg, tags);
00609 } else {
00610 HxEnvironment::instance()->errorStream()
00611 << "Can't find " << funcKey << STD_ENDL;
00612 HxEnvironment::instance()->flush();
00613 }
00614
00615 // setup srcCopy for the next loop (if any)
00616 if (dim == 1)
00617 srcCopy = HxImgDataFactory::instance().makeImage(scratchSig,
00618 srcImg->sizes());
00619 if (dim != dimensionality())
00620 srcCopy->set(this);
00621 delete scratchImg;
00622 } // end of dim loop
00623 delete srcCopy;
00624 }
|
|
||||||||||||||||||||||||||||||||
|
Separable generalized convolution operation on 2D images.
00632 {
00633 HxSizes borderSize(kerImg1->sizes().x() / 2, kerImg2->sizes().x() / 2, 0);
00634
00635 if (!checkBorderSize("genConv2dSep", borderSize))
00636 return;
00637
00638 HxAddTag<HxSizes>(tags, "borderSize", borderSize);
00639
00640 HxSizes scratchSize = srcImg->sizes() + borderSize * HxSizes(2, 2, 2);
00641 HxImageSignature scratchSig(kerImg1->signature());
00642 scratchSig.setImageDimensionality(signature().imageDimensionality());
00643 HxImageData* scratchImg
00644 = HxImgDataFactory::instance().makeImage(scratchSig, scratchSize);
00645
00646 scratchImg->setPartImage(
00647 srcImg, HxPointInt(0, 0, 0),
00648 srcImg->sizes() - HxPointInt(1, 1, 1), borderSize);
00649 scratchImg->setBorder(borderSize, tags);
00650
00651 HxImgFtorGenConv2dSepKey funcKey(
00652 signature().toString(),
00653 scratchImg->signature().toString(),
00654 kerImg1->signature().toString(),
00655 kerImg2->signature().toString(),
00656 genMul, genAdd, kerName);
00657
00658 static HxImgFtorTableTem<HxImgFtorI4> funcTable;
00659 HxImgFtorI4* func = funcTable.find(funcKey);
00660
00661 if (func) {
00662 func->callIt(this, scratchImg, kerImg1, kerImg2, tags);
00663 } else {
00664 HxEnvironment::instance()->errorStream()
00665 << "Can't find " << funcKey << STD_ENDL;
00666 HxEnvironment::instance()->flush();
00667 }
00668
00669 delete scratchImg;
00670 }
|
|
||||||||||||||||||||||||||||||||||||
|
Separable generalized convolution operation on 3D images.
00678 {
00679 HxImageData* srcCopy = srcImg;
00680 for (int dim=1 ; dim<=dimensionality() ; dim++) {
00681 HxImageData* kerImg;
00682 HxSizes borderSize;
00683
00684 switch (dim) {
00685 case 1 :
00686 kerImg = kerImg1;
00687 borderSize = HxSizes(kerImg->sizes().x() / 2, 0, 0);
00688 break;
00689 case 2 :
00690 kerImg = kerImg2;
00691 borderSize = HxSizes(0, kerImg->sizes().x() / 2, 0);
00692 break;
00693 case 3 :
00694 kerImg = kerImg3;
00695 borderSize = HxSizes(0, 0, kerImg->sizes().x() / 2);
00696 break;
00697 }
00698
00699 if (!checkBorderSize("genConv3dSep", borderSize))
00700 return;
00701
00702 HxAddTag<HxSizes>(tags, "borderSize", borderSize);
00703 HxAddTag<int>(tags, "dimension", dim);
00704
00705 HxSizes scratchSize = srcCopy->sizes() + borderSize * HxSizes(2, 2, 2);
00706 HxImageSignature scratchSig(kerImg->signature());
00707 scratchSig.setImageDimensionality(signature().imageDimensionality());
00708 HxImageData* scratchImg
00709 = HxImgDataFactory::instance().makeImage(scratchSig, scratchSize);
00710
00711 scratchImg->setPartImage(
00712 srcCopy, HxPointInt(0, 0, 0),
00713 srcCopy->sizes() - HxPointInt(1, 1, 1), borderSize);
00714 scratchImg->setBorder(borderSize, tags);
00715
00716 HxImgFtorGenConvK1dKey funcKey(
00717 signature().toString(),
00718 scratchImg->signature().toString(),
00719 kerImg->signature().toString(),
00720 genMul, genAdd, kerName);
00721
00722 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00723 HxImgFtorI3* func = funcTable.find(funcKey);
00724
00725 if (func) {
00726 func->callIt(this, scratchImg, kerImg, tags);
00727 } else {
00728 HxEnvironment::instance()->errorStream()
00729 << "Can't find " << funcKey << STD_ENDL;
00730 HxEnvironment::instance()->flush();
00731 }
00732
00733 // setup srcCopy for the next loop (if any)
00734 if (dim == 1)
00735 srcCopy = HxImgDataFactory::instance().makeImage(scratchSig,
00736 srcImg->sizes());
00737 if (dim != dimensionality())
00738 srcCopy->set(this);
00739 delete scratchImg;
00740 } // end of dim loop
00741 delete srcCopy;
00742 }
|
|
||||||||||||||||||||||||
|
Recursive generalized convolution operation.
00749 {
00750 HxSizes borderSize = kerImg->sizes() / HxSizes(2, 2, 2);
00751 if (!checkBorderSize("recursiveNeighOp", borderSize))
00752 return;
00753
00754 HxSizes scratchSize = srcImg->sizes() + borderSize * HxSizes(2, 2, 2);
00755 HxImageData* scratchImg
00756 = HxImgDataFactory::instance().makeImage(
00757 kerImg->signature(), scratchSize);
00758
00759 scratchImg->setPartImage(
00760 srcImg, HxPointInt(0, 0, 0),
00761 srcImg->sizes() - HxPointInt(1, 1, 1), borderSize);
00762 scratchImg->setBorder(borderSize, tags, HXBORDERPROPAGATE);
00763
00764 HxImgFtorRecGenConvKey funcKey(
00765 scratchImg->signature().toString(),
00766 kerImg->signature().toString(), genMul, genAdd);
00767
00768 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
00769 HxImgFtorI2* func = funcTable.find(funcKey);
00770
00771 if (func) {
00772 func->callIt(scratchImg, kerImg, tags);
00773 } else {
00774 HxEnvironment::instance()->errorStream()
00775 << "Can't find " << funcKey << STD_ENDL;
00776 HxEnvironment::instance()->flush();
00777 }
00778
00779 setPartImage(
00780 scratchImg, borderSize, borderSize + sizes() - HxPointInt(1, 1, 1),
00781 HxPointInt(0, 0, 0));
00782
00783 delete scratchImg;
00784 }
|
|
||||||||||||||||||||||||||||
|
Separable recursive generalized convolution operation on 2D images.
00792 {
00793 HxSizes borderSize(kerImg1->sizes().x() / 2, kerImg2->sizes().x() / 2, 0);
00794 if (!checkBorderSize("recGenConv2dSep", borderSize))
00795 return;
00796
00797 HxSizes scratchSize = srcImg->sizes() + borderSize * HxSizes(2, 2, 2);
00798 HxImageData* scratchImg
00799 = HxImgDataFactory::instance().makeImage(
00800 kerImg1->signature(), scratchSize);
00801
00802 scratchImg->setPartImage(
00803 srcImg, HxPointInt(0, 0, 0),
00804 srcImg->sizes() - HxPointInt(1, 1, 1), borderSize);
00805 scratchImg->setBorder(borderSize, tags, HXBORDERPROPAGATE);
00806
00807 HxImgFtorRecGenConvK1dKey funcKey(
00808 scratchImg->signature().toString(),
00809 kerImg1->signature().toString(), genMul, genAdd);
00810
00811 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
00812 HxImgFtorI2* func = funcTable.find(funcKey);
00813
00814 int dimension = 1;
00815 if (func) {
00816 HxAddTag(tags, "borderSize", borderSize);
00817 HxAddTag(tags, "dimension", dimension);
00818 func->callIt(scratchImg, kerImg1, tags);
00819
00820 dimension = 2;
00821 scratchImg->setBorder(borderSize, tags, HXBORDERPROPAGATE);
00822 HxAddTag(tags, "dimension", dimension);
00823 func->callIt(scratchImg, kerImg2, tags);
00824 } else {
00825 HxEnvironment::instance()->errorStream()
00826 << "Can't find " << funcKey << STD_ENDL;
00827 HxEnvironment::instance()->flush();
00828 }
00829
00830 setPartImage(
00831 scratchImg, borderSize, borderSize + sizes() - HxPointInt(1, 1, 1),
00832 HxPointInt(0, 0, 0));
00833
00834 delete scratchImg;
00835 }
|
|
||||||||||||||||
|
Neighbourhood operation.
00840 {
00841 HxImgFtorNgbKey funcKey(signature().toString(),
00842 src->signature().toString(), ngbName);
00843
00844 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
00845 HxImgFtorI2* func = funcTable.find(funcKey);
00846
00847 if (func) {
00848 func->probeOp(tags); // should put borderSize in the list
00849 HxSizes borderSize = HxGetTag(tags, "borderSize", HxSizes(0,0,0));
00850 HxSizes scratchSize = src->sizes() + borderSize * HxSizes(2, 2, 2);
00851 HxImageData* scratch = HxImgDataFactory::instance().makeImage(
00852 src->signature(), scratchSize);
00853 scratch->setPartImage(
00854 src, HxPointInt(0, 0, 0),
00855 src->sizes() - HxPointInt(1, 1, 1), borderSize);
00856 scratch->setBorder(borderSize, tags);
00857
00858 func->callIt(this, scratch, tags);
00859
00860 delete scratch;
00861 } else {
00862 HxEnvironment::instance()->errorStream()
00863 << "Can't find " << funcKey << STD_ENDL;
00864 HxEnvironment::instance()->flush();
00865 }
00866 }
|
|
||||||||||||||||||||
|
Neighbourhood operation with extra image.
00871 {
00872 HxImgFtorNgbExtraKey funcKey(signature().toString(),
00873 src->signature().toString(),
00874 extraIm->signature().toString(), ngbName);
00875
00876 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00877 HxImgFtorI3* func = funcTable.find(funcKey);
00878
00879 if (func) {
00880 func->probeOp(tags); // should put borderSize in the list
00881 HxSizes borderSize = HxGetTag(tags, "borderSize", HxSizes(0,0,0));
00882 HxSizes scratchSize = src->sizes() + borderSize * HxSizes(2, 2, 2);
00883 HxImageData* scratch = HxImgDataFactory::instance().makeImage(
00884 src->signature(), scratchSize);
00885 scratch->setPartImage(
00886 src, HxPointInt(0, 0, 0),
00887 src->sizes() - HxPointInt(1, 1, 1), borderSize);
00888 scratch->setBorder(borderSize, tags);
00889
00890 HxImageData* scratchEx = HxImgDataFactory::instance().makeImage(
00891 extraIm->signature(), scratchSize);
00892 scratchEx->setPartImage(
00893 extraIm, HxPointInt(0, 0, 0),
00894 extraIm->sizes() - HxPointInt(1, 1, 1), borderSize);
00895 scratchEx->setBorder(borderSize, tags);
00896
00897 func->callIt(this, scratch, scratchEx, tags);
00898
00899 delete scratch;
00900 delete scratchEx;
00901 } else {
00902 HxEnvironment::instance()->errorStream()
00903 << "Can't find " << funcKey << STD_ENDL;
00904 HxEnvironment::instance()->flush();
00905 }
00906 }
|
|
||||||||||||||||||||||||
|
Neighbourhood operation with extra images.
00912 {
00913 HxImgFtorNgbExtra2Key funcKey(signature().toString(),
00914 src->signature().toString(),
00915 extraIm->signature().toString(),
00916 extraIm2->signature().toString(), ngbName);
00917
00918 static HxImgFtorTableTem<HxImgFtorI4> funcTable;
00919 HxImgFtorI4* func = funcTable.find(funcKey);
00920
00921 if (func) {
00922 func->probeOp(tags); // should put borderSize in the list
00923 HxSizes borderSize = HxGetTag(tags, "borderSize", HxSizes(0,0,0));
00924 HxSizes scratchSize = src->sizes() + borderSize * HxSizes(2, 2, 2);
00925 HxImageData* scratch = HxImgDataFactory::instance().makeImage(
00926 src->signature(), scratchSize);
00927 scratch->setPartImage(
00928 src, HxPointInt(0, 0, 0),
00929 src->sizes() - HxPointInt(1, 1, 1), borderSize);
00930 scratch->setBorder(borderSize, tags);
00931
00932 HxImageData* scratchEx = HxImgDataFactory::instance().makeImage(
00933 extraIm->signature(), scratchSize);
00934 scratchEx->setPartImage(
00935 extraIm, HxPointInt(0, 0, 0),
00936 extraIm->sizes() - HxPointInt(1, 1, 1), borderSize);
00937 scratchEx->setBorder(borderSize, tags);
00938
00939 HxImageData* scratchEx2 = HxImgDataFactory::instance().makeImage(
00940 extraIm2->signature(), scratchSize);
00941 scratchEx2->setPartImage(
00942 extraIm2, HxPointInt(0, 0, 0),
00943 extraIm2->sizes() - HxPointInt(1, 1, 1), borderSize);
00944 scratchEx2->setBorder(borderSize, tags);
00945
00946 func->callIt(this, scratch, scratchEx, scratchEx2, tags);
00947
00948 delete scratch;
00949 delete scratchEx;
00950 delete scratchEx2;
00951 } else {
00952 HxEnvironment::instance()->errorStream()
00953 << "Can't find " << funcKey << STD_ENDL;
00954 HxEnvironment::instance()->flush();
00955 }
00956 }
|
|
||||||||||||||||||||
|
Neighbourhood operation with kernel.
00962 {
00963 HxImgFtorKernelNgbKey funcKey(signature().toString(),
00964 src->signature().toString(),
00965 kernel->signature().toString(),
00966 ngbName);
00967
00968 static HxImgFtorTableTem<HxImgFtorI3> funcTable;
00969 HxImgFtorI3* func = funcTable.find(funcKey);
00970
00971 if (func) {
00972 HxAddTag(tags, "kernelSize", kernel->sizes());
00973 func->probeOp(tags); // should put borderSize in the list
00974 HxSizes borderSize = HxGetTag(tags, "borderSize", HxSizes(0,0,0));
00975 HxSizes scratchSize = src->sizes() + borderSize * HxSizes(2, 2, 2);
00976 HxImageData* scratch = HxImgDataFactory::instance().makeImage(
00977 src->signature(), scratchSize);
00978 scratch->setPartImage(
00979 src, HxPointInt(0, 0, 0),
00980 src->sizes() - HxPointInt(1, 1, 1), borderSize);
00981 scratch->setBorder(borderSize, tags);
00982
00983 func->callIt(this, scratch, kernel, tags);
00984
00985 delete scratch;
00986 } else {
00987 HxEnvironment::instance()->errorStream()
00988 << "Can't find " << funcKey << STD_ENDL;
00989 HxEnvironment::instance()->flush();
00990 }
00991 }
|
|
||||||||||||||||||||
|
Queue based operation.
00998 {
00999
01000 // NOT YET GET/SET PART (SCRATCH) IMAGE
01001 HxImageData * thisScratchImg=const_cast<HxImageData *>(this);
01002 HxImageData * srcScratchImg=const_cast<HxImageData *>(srcImg);
01003
01004 HxImgFtorQueueBasedKey funcKey(
01005 thisScratchImg->signature().toString(),
01006 srcScratchImg->signature().toString(),
01007 kerImg->signature().toString(),
01008 genOp);
01009
01010 typedef HxImgFtorI3 FunctorType;
01011 static HxImgFtorTableTem<FunctorType> funcTable;
01012 FunctorType* func = funcTable.find(funcKey);
01013
01014 if (func) {
01015 //HxAddTag(tags, "borderSize", borderSize);
01016 func->callIt(thisScratchImg, srcScratchImg, kerImg, tags);
01017 } else {
01018 HxEnvironment::instance()->errorStream()
01019 << "Can't find " << funcKey << STD_ENDL;
01020 HxEnvironment::instance()->flush();
01021 }
01022 }
|
|
||||||||||||||||
|
Do it yourself operation.
01027 {
01028 HxImgFtorDiyKey funcKey(signature().toString(),
01029 src->signature().toString(), diyName);
01030
01031 static HxImgFtorTableTem<HxImgFtorI2> funcTable;
01032 HxImgFtorI2* func = funcTable.find(funcKey);
01033
01034 if (func) {
01035 func->callIt(this, src, tags);
01036 } else {
01037 HxEnvironment::instance()->errorStream()
01038 << "Can't find " << funcKey << STD_ENDL;
01039 HxEnvironment::instance()->flush();
01040 }
01041 }
|
|
||||||||||||
|
Display operation.
01045 {
01046 HxImgFtorRgbKey funcKey(signature().toString(), rgbName);
01047
01048 static HxImgFtorTableTem<HxImgFtorI1> funcTable;
01049 HxImgFtorI1* func = funcTable.find(funcKey);
01050
01051 if (func) {
01052 func->callIt(this, tags);
01053 } else {
01054 HxEnvironment::instance()->errorStream()
01055 << "Can't find " << funcKey << STD_ENDL;
01056 HxEnvironment::instance()->flush();
01057 }
01058 }
|
|
||||||||||||||||||||||||
|
Geometric operation on 2D images.
Reimplemented in HxImageTem2d, and HxImageTem3d. |
1.2.12 written by Dimitri van Heesch,
© 1997-2001