00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DIMOIMG_H
00031 #define DIMOIMG_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034
00035 #include "dcmtk/ofstd/ofcast.h"
00036
00037 #include "dcmtk/dcmimgle/diimage.h"
00038 #include "dcmtk/dcmimgle/dimopx.h"
00039 #include "dcmtk/dcmimgle/dimoopx.h"
00040 #include "dcmtk/dcmimgle/didispfn.h"
00041
00042
00043
00044
00045
00046
00047 class DiColorImage;
00048
00049
00050
00051
00052
00053
00056 class DiMonoImage
00057 : public DiImage
00058 {
00059
00060 public:
00061
00067 DiMonoImage(const DiDocument *docu,
00068 const EI_Status status);
00069
00077 DiMonoImage(const DiDocument *docu,
00078 const EI_Status status,
00079 const double slope,
00080 const double intercept);
00081
00090 DiMonoImage(const DiDocument *docu,
00091 const EI_Status status,
00092 const DcmUnsignedShort &data,
00093 const DcmUnsignedShort &descriptor,
00094 const DcmLongString *explanation);
00095
00098 virtual ~DiMonoImage();
00099
00106 virtual int processNextFrames(const unsigned long fcount);
00107
00119 int getMinMaxValues(double &min,
00120 double &max,
00121 const int mode) const;
00122
00127 DiDisplayFunction *getDisplayFunction() const
00128 {
00129 return DisplayFunction;
00130 }
00131
00138 int setDisplayFunction(DiDisplayFunction *display);
00139
00147 int setNoDisplayFunction();
00148
00156 int setNoVoiTransformation();
00157
00164 inline int deleteDisplayLUT(const int bits)
00165 {
00166 return (DisplayFunction != NULL) ? DisplayFunction->deleteLookupTable(bits) : 0;
00167 }
00168
00175 inline int isValueUnused(const unsigned long value)
00176 {
00177 return (OutputData != NULL) ? OutputData->isUnused(value) : 0;
00178 }
00179
00191 int convertPValueToDDL(const Uint16 pvalue,
00192 Uint16 &ddl,
00193 const int bits);
00194
00204 int setMinMaxWindow(const int idx = 1);
00205
00220 int setRoiWindow(const unsigned long left_pos,
00221 const unsigned long top_pos,
00222 const unsigned long width,
00223 const unsigned long height,
00224 const unsigned long frame);
00225
00233 int setHistogramWindow(const double thresh);
00234
00242 int setWindow(const unsigned long pos = 0);
00243
00255 int setWindow(const double center,
00256 const double width,
00257 const char *explanation = NULL);
00258
00266 int getWindow(double ¢er,
00267 double &width);
00268
00273 inline unsigned long getWindowCount() const
00274 {
00275 return WindowCount;
00276 }
00277
00283 EF_VoiLutFunction getVoiLutFunction() const;
00284
00294 int setVoiLutFunction(const EF_VoiLutFunction function);
00295
00306 int setVoiLut(const DcmUnsignedShort &data,
00307 const DcmUnsignedShort &descriptor,
00308 const DcmLongString *explanation,
00309 const EL_BitsPerTableEntry descripMode = ELM_UseValue);
00310
00319 int setVoiLut(const unsigned long pos,
00320 const EL_BitsPerTableEntry descripMode = ELM_UseValue);
00321
00326 inline unsigned long getVoiLutCount() const
00327 {
00328 return VoiLutCount;
00329 }
00330
00335 inline const char *getVoiTransformationExplanation() const
00336 {
00337 return VoiExplanation.c_str();
00338 }
00339
00347 const char *getVoiWindowExplanation(const unsigned long pos,
00348 OFString &explanation) const;
00349
00357 const char *getVoiLutExplanation(const unsigned long pos,
00358 OFString &explanation) const;
00359
00364 inline const char *getModalityLutExplanation() const
00365 {
00366 return (InterData != NULL) ? InterData->getModalityLutExplanation() : OFstatic_cast(const char *, NULL);
00367 }
00368
00380 int setHardcopyParameters(const unsigned int min,
00381 const unsigned int max,
00382 const unsigned int reflect,
00383 const unsigned int illumin);
00384
00391 ES_PresentationLut getPresentationLutShape() const;
00392
00404 int setPresentationLutShape(const ES_PresentationLut shape);
00405
00416 int setPresentationLut(const DcmUnsignedShort &data,
00417 const DcmUnsignedShort &descriptor,
00418 const DcmLongString *explanation = NULL,
00419 const EL_BitsPerTableEntry descripMode = ELM_UseValue);
00420
00431 int setInversePresentationLut(const DcmUnsignedShort &data,
00432 const DcmUnsignedShort &descriptor,
00433 const EL_BitsPerTableEntry descripMode = ELM_UseValue);
00434
00439 inline const char *getPresentationLutExplanation() const
00440 {
00441 return (PresLutData != NULL) ? PresLutData->getExplanation() : OFstatic_cast(const char *, NULL);
00442 }
00443
00460 int addOverlay(const unsigned int group,
00461 const signed int left_pos,
00462 const signed int top_pos,
00463 const unsigned int columns,
00464 const unsigned int rows,
00465 const DcmOverlayData &data,
00466 const DcmLongString &label,
00467 const DcmLongString &description,
00468 const EM_Overlay mode);
00469
00474 int removeAllOverlays();
00475
00482 inline DiOverlay *getOverlayPtr(const unsigned int idx)
00483 {
00484 return (idx < 2) ? Overlays[idx] : OFstatic_cast(DiOverlay *, NULL);
00485 }
00486
00491 inline DiMonoImage *getMonoImagePtr()
00492 {
00493 return this;
00494 }
00495
00505 int flip(const int horz,
00506 const int vert);
00507
00516 int rotate(const int degree);
00517
00528 virtual int getBits(const int bits = 0) const
00529 {
00530 return (((bits < 1) || (bits > MAX_BITS)) && (bits != MI_PastelColor)) ? BitsPerSample : bits;
00531 }
00532
00539 virtual unsigned long getOutputDataSize(const int bits = 0) const;
00540
00550 virtual const void *getOutputData(const unsigned long frame,
00551 const int bits,
00552 const int planar = 0) = 0;
00553
00565 virtual int getOutputData(void *buffer,
00566 const unsigned long size,
00567 const unsigned long frame,
00568 const int bits,
00569 const int planar = 0) = 0;
00570
00578 const void *getOutputPlane(const int dummy) const;
00579
00583 void deleteOutputData();
00584
00602 const void *getOverlayData(const unsigned long frame,
00603 const unsigned int plane,
00604 unsigned int &left_pos,
00605 unsigned int &top_pos,
00606 unsigned int &width,
00607 unsigned int &height,
00608 EM_Overlay &mode,
00609 const unsigned int idx,
00610 const int bits = 8,
00611 const Uint16 fore = 0xff,
00612 const Uint16 back = 0x0);
00613
00628 const void *getFullOverlayData(const unsigned long frame,
00629 const unsigned int plane,
00630 unsigned int &width,
00631 unsigned int &height,
00632 const unsigned int idx,
00633 const int bits = 8,
00634 const Uint16 fore = 0xff,
00635 const Uint16 back = 0x0);
00636
00640 void deleteOverlayData();
00641
00658 unsigned long create6xxx3000OverlayData(Uint8 *&buffer,
00659 const unsigned int plane,
00660 unsigned int &width,
00661 unsigned int &height,
00662 unsigned long &frames,
00663 const unsigned int idx = 0);
00664
00669 const DiPixel *getInterData() const
00670 {
00671 return InterData;
00672 }
00673
00678 const DiMonoPixel *getMonoInterData() const
00679 {
00680 return InterData;
00681 }
00682
00695 unsigned long createDIB(void *&data,
00696 const unsigned long size,
00697 const unsigned long frame,
00698 const int bits,
00699 const int upsideDown,
00700 const int padding = 1);
00701
00711 unsigned long createAWTBitmap(void *&data,
00712 const unsigned long frame,
00713 const int bits);
00714
00726 static void *createPackedBitmap(const void *buffer,
00727 const unsigned long size,
00728 const unsigned long count,
00729 const int alloc,
00730 const int stored);
00731
00740 DiImage *createOutputImage(const unsigned long frame,
00741 const int bits);
00742
00752 int writeImageToDataset(DcmItem &dataset,
00753 const int mode,
00754 const int planar);
00755
00765 int writePPM(STD_NAMESPACE ostream& stream,
00766 const unsigned long frame,
00767 const int bits);
00768
00778 int writePPM(FILE *stream,
00779 const unsigned long frame,
00780 const int bits);
00781
00790 int writeRawPPM(FILE *stream,
00791 const unsigned long frame,
00792 const int bits);
00793
00802 int writeBMP(FILE *stream,
00803 const unsigned long frame,
00804 const int bits);
00805
00806
00807 protected:
00808
00815 DiMonoImage(const DiDocument *image,
00816 const EI_Status status,
00817 const char dummy);
00818
00825 DiMonoImage(const DiMonoImage *image,
00826 const unsigned long fstart,
00827 const unsigned long fcount);
00828
00838 DiMonoImage(const DiColorImage *image,
00839 const double red,
00840 const double green,
00841 const double blue);
00842
00862 DiMonoImage(const DiMonoImage *image,
00863 const signed long left_pos,
00864 const signed long top_pos,
00865 const Uint16 src_cols,
00866 const Uint16 src_rows,
00867 const Uint16 dest_cols,
00868 const Uint16 dest_rows,
00869 const int interpolate,
00870 const int aspect,
00871 const Uint16 pvalue);
00872
00879 DiMonoImage(const DiMonoImage *image,
00880 const int horz,
00881 const int vert);
00882
00888 DiMonoImage(const DiMonoImage *image,
00889 const int degree);
00890
00899 DiMonoImage(const DiMonoImage *image,
00900 DiMonoOutputPixel *pixel,
00901 const unsigned long frame,
00902 const int stored,
00903 const int alloc);
00904
00910 void Init(DiMonoModality *modality,
00911 const OFBool reuse = OFFalse);
00912
00917 void InitUint8(DiMonoModality *modality);
00918
00923 void InitSint8(DiMonoModality *modality);
00924
00929 void InitUint16(DiMonoModality *modality);
00930
00935 void InitSint16(DiMonoModality *modality);
00936
00941 void InitUint32(DiMonoModality *modality);
00942
00947 void InitSint32(DiMonoModality *modality);
00948
00953 int checkInterData(const int mode = 1);
00954
00962 virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00963
00976 const void *getData(void *buffer,
00977 const unsigned long size,
00978 const unsigned long frame,
00979 int bits,
00980 const int planar,
00981 const int negative);
00982
00994 void getDataUint8(void *buffer,
00995 DiDisplayFunction *disp,
00996 const int samples,
00997 const unsigned long frame,
00998 const int bits,
00999 const Uint32 low,
01000 const Uint32 high);
01001
01013 void getDataSint8(void *buffer,
01014 DiDisplayFunction *disp,
01015 const int samples,
01016 const unsigned long frame,
01017 const int bits,
01018 const Uint32 low,
01019 const Uint32 high);
01020
01032 void getDataUint16(void *buffer,
01033 DiDisplayFunction *disp,
01034 const int samples,
01035 const unsigned long frame,
01036 const int bits,
01037 const Uint32 low,
01038 const Uint32 high);
01039
01051 void getDataSint16(void *buffer,
01052 DiDisplayFunction *disp,
01053 const int samples,
01054 const unsigned long frame,
01055 const int bits,
01056 const Uint32 low,
01057 const Uint32 high);
01058
01070 void getDataUint32(void *buffer,
01071 DiDisplayFunction *disp,
01072 const int samples,
01073 const unsigned long frame,
01074 const int bits,
01075 const Uint32 low,
01076 const Uint32 high);
01077
01089 void getDataSint32(void *buffer,
01090 DiDisplayFunction *disp,
01091 const int samples,
01092 const unsigned long frame,
01093 const int bits,
01094 const Uint32 low,
01095 const Uint32 high);
01096
01105 int createLinODPresentationLut(const unsigned long count, const int bits);
01106
01108 double WindowCenter;
01110 double WindowWidth;
01112 unsigned long WindowCount;
01114 unsigned long VoiLutCount;
01115
01117 int ValidWindow;
01118
01120 OFString VoiExplanation;
01122 EF_VoiLutFunction VoiLutFunction;
01124 ES_PresentationLut PresLutShape;
01125
01127 unsigned int MinDensity;
01129 unsigned int MaxDensity;
01131 unsigned int Reflection;
01133 unsigned int Illumination;
01134
01136 DiOverlay *Overlays[2];
01138 DiLookupTable *VoiLutData;
01140 DiLookupTable *PresLutData;
01142 DiMonoPixel *InterData;
01143
01145 DiDisplayFunction *DisplayFunction;
01146
01147
01148 private:
01149
01151 DiMonoOutputPixel *OutputData;
01153 void *OverlayData;
01154
01155
01156
01157 DiMonoImage(const DiMonoImage &);
01158 DiMonoImage &operator=(const DiMonoImage &);
01159 };
01160
01161
01162 #endif
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397