00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef HxImageRep_h
00011 #define HxImageRep_h
00012
00013 #include "HxValueType.h"
00014 #include "HxValue.h"
00015 #include "HxValueList.h"
00016 #include "HxPoint.h"
00017 #include "HxPointList.h"
00018 #include "HxByte.h"
00019 #include "HxImageSignature.h"
00020 #include "HxSizes.h"
00021 #include "HxString.h"
00022 #include "HxStringList.h"
00023 #include "HxMatrix.h"
00024 #include "HxGeoIntType.h"
00025 #include "HxGeoTransType.h"
00026 #include "HxTagList.h"
00027
00028
00029 #undef min
00030 #undef max
00031
00032 typedef struct image IMAGE;
00033 class HxImageList;
00034
00035 #include "HxRcObject.h"
00036 #include "HxRcPtr.h"
00037
00038 class HxImageData;
00039 typedef HxRcPtr<HxImageData> HxImageDataRcPtr;
00040
00041 class HxImageFactory;
00042
00043 class HxObjectObserver;
00044 class HxImageGenerator;
00045
00050 class L_HXIMAGEREP HxImageRep {
00051 public:
00052
00053
00055
00057 HxImageRep();
00058
00060 HxImageRep(const HxImageRep&);
00061
00063
00065
00067 ~HxImageRep();
00069
00071
00073 HxImageRep& operator=(const HxImageRep&);
00074
00076 int operator==(const HxImageRep& arg) const;
00077
00079 int isNull() const;
00080
00082 operator int() const;
00084
00086
00088 int ident() const;
00089
00091 HxString name() const;
00092
00094 void name(HxString s);
00095
00097 int dimensionality() const;
00098
00102 int dimensionSize(int i) const;
00103
00105 HxSizes sizes() const;
00106
00108 int numberOfPixels() const;
00109
00111 int pixelDimensionality() const;
00112
00116 HxValueType pixelType() const;
00117
00122 int pixelPrecision() const;
00123
00125 HxImageSignature signature() const;
00127
00129
00136 HxImageRep unaryPixOp(HxString upoName,
00137 HxTagList& tags = HxMakeTagList()) const;
00138
00143
00144
00146
00148
00155 HxImageRep binaryPixOp(const HxValue arg, HxString bpoName,
00156 HxTagList& tags = HxMakeTagList()) const;
00157
00163 HxImageRep binaryPixOp(const HxImageRep arg, HxString bpoName,
00164 HxTagList& tags = HxMakeTagList()) const;
00165
00170
00171
00172
00174
00176
00184 HxImageRep multiPixOp(const HxImageList& args,
00185 HxString mpoName,
00186 HxTagList& tags = HxMakeTagList()) const;
00187
00194 HxImageList MNPixOp(const HxImageList& args,
00195 HxString mpoName,
00196 HxTagList& tags = HxMakeTagList()) const;
00198
00200
00208 HxValue reduceOp(HxString op,
00209 HxTagList& tags = HxMakeTagList()) const;
00210
00212
00231 enum ResultPrecision {
00232 DEFAULT_PREC, SOURCE_PREC,
00233 ARITH_PREC, SMALL_PREC};
00234
00236 static void setDefaultResultPrecision(ResultPrecision resPrec);
00237
00239 static ResultPrecision getResultPrecision(
00240 ResultPrecision resPrec = DEFAULT_PREC);
00241
00243
00255 HxImageRep generalizedConvolution(
00256 HxImageRep kerImg,
00257 HxString gMul, HxString gAdd,
00258 ResultPrecision resPrec = DEFAULT_PREC,
00259 HxTagList& tags = HxMakeTagList()) const;
00260
00278 HxImageRep generalizedConvolutionK1d(
00279 int dimension, HxImageRep kerImg,
00280 HxString gMul, HxString gAdd,
00281 ResultPrecision resPrec = DEFAULT_PREC,
00282 HxTagList& tags = HxMakeTagList()) const;
00283
00302 HxImageRep genConvSeparated(
00303 HxImageRep kernel,
00304 HxString gMul, HxString gAdd,
00305 ResultPrecision resPrec = DEFAULT_PREC,
00306 HxTagList& tags = HxMakeTagList()) const;
00307
00327 HxImageRep genConvSeparated(
00328 int dimension,
00329 HxImageRep kernel1, HxImageRep kernel2,
00330 HxString gMul, HxString gAdd,
00331 ResultPrecision resPrec = DEFAULT_PREC,
00332 HxTagList& tags = HxMakeTagList()) const;
00334
00335
00337
00346 HxImageRep neighbourhoodOp(
00347 HxString ngbName,
00348 HxTagList& tags = HxMakeTagList()) const;
00349
00357 HxImageRep neighbourhoodOp(
00358 HxImageRep kernel, HxString ngbName,
00359 HxTagList& tags = HxMakeTagList()) const;
00360
00366 HxImageRep recursiveNeighOp(
00367 HxImageRep kerImg,
00368 HxString gMul, HxString gAdd,
00369 HxTagList& tags = HxMakeTagList(),
00370 ResultPrecision resPrec = DEFAULT_PREC) const;
00371
00373
00374
00376
00378
00379
00380
00394 HxImageRep geometricOp2d(HxMatrix func, HxGeoIntType gi = LINEAR,
00395 HxGeoTransType gt = FORWARD, int adjustSize = 1,
00396 HxValue background = HxValue(0)) const;
00397
00399
00401
00411 HxValue sampleIdentMask(const HxImageRep mask, HxPoint p,
00412 HxSizes size, int label, HxString sFunc) const;
00413
00422 void sampleIdentMask(const HxImageRep mask, HxPoint p,
00423 HxSizes size, int label, HxString sFunc,
00424 HxValueListBackInserter res) const;
00425
00432 HxValue sampleWeightMask(const HxImageRep mask, HxPoint p,
00433 HxString sFunc) const;
00435
00437
00440 void exportOp(HxString exportName,
00441 HxTagList& tags = HxMakeTagList()) const;
00442
00444 void setAt(const HxValue v, int x, int y = 0, int z = 0);
00445
00447 HxValue getAt(int x, int y = 0, int z = 0) const;
00448
00450 STD_OSTREAM& printInfo(STD_OSTREAM& os, int doData = 0);
00451
00453
00454
00456
00469 void getRgbPixels2d(int* pixels, HxString displayMode,
00470 int resWidth = -1, int resHeight = -1,
00471 HxGeoIntType gi = NEAREST) const;
00472
00474 void getRgbPixels2d(int* pixels, HxString displayMode,
00475 int bufWidth, int bufHeight,
00476 int VX, int VY, int VW, int VH,
00477 double SX, double SY, double scaleX, double scaleY,
00478 HxGeoIntType gi) const;
00479
00481 void getRgbPixels3d(int* pixels, HxString displayMode,
00482 int dimension, int coordinate,
00483 int resWidth = -1, int resHeight = -1,
00484 HxGeoIntType gi = NEAREST) const;
00485
00487
00489
00490
00491 HxImageData* dirty() { return pointee(); }
00492
00494 static void setObjectObserver(const HxObjectObserver&);
00496 static void setImageDataObserver(const HxObjectObserver&);
00497
00499 HxString ref() const;
00500
00502
00505 private:
00506 friend class HxImageFactory;
00507 friend class HxImageRepInit;
00508
00509 HxImageRep(const HxImageData*);
00510 void construct(const HxImageSignature&, HxSizes);
00511
00512
00513
00518 HxImageRep(
00519 int pixelDimensionality, HxValueType pixelType,
00520 int pixelPrecision, int dimensions,
00521 int dimSize1, int dimSize2 = 1, int dimSize3 = 1);
00522
00527 HxImageRep(
00528 const HxImageSignature& signature, HxSizes sizes);
00529
00535 HxImageRep(
00536 const HxImageSignature& signature, HxImageRep);
00537
00543 HxImageRep(const HxImageSignature& signature,
00544 HxSizes sizes, HxValue val);
00545
00551 HxImageRep(
00552 int pixelDimensionality, int dimensions,
00553 HxSizes sizes, HxByte* pixels);
00554
00560 HxImageRep(
00561 int pixelDimensionality, int dimensions,
00562 HxSizes sizes, short* pixels);
00563
00569 HxImageRep(
00570 int pixelDimensionality, int dimensions,
00571 HxSizes sizes, int* pixels);
00572
00578 HxImageRep(
00579 int pixelDimensionality, int dimensions,
00580 HxSizes sizes, float* pixels);
00581
00587 HxImageRep(
00588 int pixelDimensionality, int dimensions,
00589 HxSizes sizes, double* pixels);
00590
00597 HxImageRep(const HxImageSignature& signature,
00598 HxSizes sizes, int* pixels);
00599
00605 HxImageRep(const HxImageSignature& signature,
00606 HxSizes sizes, HxByte* pixels);
00607
00614 HxImageRep(const HxImageSignature& signature,
00615 HxSizes sizes, double* pixels);
00616
00622 HxImageRep(
00623 const HxImageSignature& signature,
00624 const HxImageGenerator* imgGenerator);
00625
00632 HxImageRep(
00633 const HxImageSignature& signature,
00634 HxSizes sizes, HxString importOp,
00635 HxTagList& = HxMakeTagList());
00636
00645 HxImageRep(HxImageRep i1, HxImageRep i2);
00646
00655 HxImageRep(HxImageRep i1, HxImageRep i2, HxImageRep i3);
00656
00661 HxImageRep(HxString fileName);
00662
00663 HxImageRep projectRange(int dimension) const;
00664 HxImageRep inverseProjectRange(int dimension,
00665 const HxImageRep arg) const;
00666
00671 HxImageRep convertColor(HxVec3Double scale1, HxVec3Double gamma1,
00672 HxUpoVec3Double step1, HxUpoVec3Double step2,
00673 HxUpoVec3Double step3,
00674 HxVec3Double gamma2, HxVec3Double scale2) const;
00675
00676 HxImageRep restrict(HxPoint begin, HxPoint end) const;
00677 HxImageRep extend(HxSizes newSize, HxValue background,
00678 HxPoint begin = HxPoint(0, 0, 0)) const;
00679 HxImageRep extend(HxImageRep background,
00680 HxPoint begin = HxPoint(0, 0, 0)) const;
00681
00693 HxImageRep projectDomain(int dimension, int coordinate) const;
00694
00699 HxImageRep inverseProjectDomain(int dimension, int coordinate,
00700 const HxImageRep arg) const;
00701
00702 HxImageRep transpose() const;
00703 static HxImageRep makeGaussian(
00704 double sigma, int deri, double acc,
00705 int fsize, int maxfsize);
00706
00707
00711 void getValues(
00712 HxPointListConstIter first,
00713 HxPointListConstIter last,
00714 HxValueListBackInserter);
00715
00719 HxImageRep(IMAGE*);
00720
00724 IMAGE* toImageSi() const;
00725
00729 void getDoublePixels(double* pixels);
00730
00731
00732 friend HxImageRep L_HXIMAGEREP HxProjectRange(HxImageRep im, int dimension);
00733 friend HxImageRep L_HXIMAGEREP HxInverseProjectRange(HxImageRep im, int dimension, HxImageRep arg);
00734 friend HxImageRep L_HXIMAGEREP HxRestrict(HxImageRep img, HxPoint begin, HxPoint end);
00735 friend HxImageRep L_HXIMAGEREP HxExtend(HxImageRep img, HxImageRep background, HxPoint begin);
00736 friend HxImageRep L_HXIMAGEREP HxExtendVal(HxImageRep img, HxSizes newSize, HxValue background, HxPoint begin);
00737
00738 friend void L_HXIMAGEREP HxGetValues(HxImageRep img, HxPointListConstIter first, HxPointListConstIter last, HxValueListBackInserter valPtr);
00739 friend HxValue L_HXIMAGEREP HxIdentMaskMean(HxImageRep im, HxImageRep mask, HxPoint p, HxSizes size, int label);
00740 friend HxValue L_HXIMAGEREP HxIdentMaskStDev(HxImageRep im, HxImageRep mask, HxPoint p, HxSizes size, int label);
00741 friend HxValue L_HXIMAGEREP HxIdentMaskSum(HxImageRep im, HxImageRep mask, HxPoint p, HxSizes size, int label);
00742 friend HxValue L_HXIMAGEREP HxMaskSum(HxImageRep im, HxImageRep mask, HxPoint p);
00743
00744 friend HxImageRep L_HXIMAGEREP HxMakeFromSi(IMAGE* im);
00745 friend L_HXIMAGEREP IMAGE* HxExportSi(HxImageRep img);
00746 friend void L_HXIMAGEREP HxExportMatlabPixels(HxImageRep img, double* pixels);
00747
00748 #pragma warning (disable : 4251)
00749
00750 HxImageDataRcPtr _pointee;
00751
00752 #pragma warning (default : 4251)
00753
00754 HxImageData* pointee() const;
00755
00756 HxImageRep errorIm(HxString msg) const;
00757
00758 static const HxObjectObserver* _objectObserver;
00759
00760 static ResultPrecision _defaultResPrec;
00761
00762 };
00763
00764 inline HxString
00765 ClassName(const HxImageRep&)
00766 {
00767 return "HxImageRep";
00768 }
00769
00770 inline HxString
00771 makeString(const HxImageRep& i)
00772 {
00773 return HxString("HxImageRep") + makeString(i.ident());
00774 }
00775
00776 #endif