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
00031
00032
00033
00034 #ifndef DIMOIMG_H
00035 #define DIMOIMG_H
00036
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/ofstd/ofcast.h"
00040
00041 #include "dcmtk/dcmimgle/diimage.h"
00042 #include "dcmtk/dcmimgle/dimopx.h"
00043 #include "dcmtk/dcmimgle/dimoopx.h"
00044 #include "dcmtk/dcmimgle/diovlay.h"
00045 #include "dcmtk/dcmimgle/diluptab.h"
00046 #include "dcmtk/dcmimgle/didispfn.h"
00047
00048
00049
00050
00051
00052
00053 class DiColorImage;
00054
00055
00056
00057
00058
00059
00062 class DiMonoImage
00063 : public DiImage
00064 {
00065
00066 public:
00067
00073 DiMonoImage(const DiDocument *docu,
00074 const EI_Status status);
00075
00083 DiMonoImage(const DiDocument *docu,
00084 const EI_Status status,
00085 const double slope,
00086 const double intercept);
00087
00096 DiMonoImage(const DiDocument *docu,
00097 const EI_Status status,
00098 const DcmUnsignedShort &data,
00099 const DcmUnsignedShort &descriptor,
00100 const DcmLongString *explanation);
00101
00104 virtual ~DiMonoImage();
00105
00117 int getMinMaxValues(double &min,
00118 double &max,
00119 const int mode) const;
00120
00125 DiDisplayFunction *getDisplayFunction() const
00126 {
00127 return DisplayFunction;
00128 }
00129
00136 int setDisplayFunction(DiDisplayFunction *display);
00137
00145 int setNoDisplayFunction();
00146
00154 int setNoVoiTransformation();
00155
00162 inline int deleteDisplayLUT(const int bits)
00163 {
00164 return (DisplayFunction != NULL) ? DisplayFunction->deleteLookupTable(bits) : 0;
00165 }
00166
00173 inline int isValueUnused(const unsigned long value)
00174 {
00175 return (OutputData != NULL) ? OutputData->isUnused(value) : 0;
00176 }
00177
00189 int convertPValueToDDL(const Uint16 pvalue,
00190 Uint16 &ddl,
00191 const int bits);
00192
00202 int setMinMaxWindow(const int idx = 1);
00203
00218 int setRoiWindow(const unsigned long left_pos,
00219 const unsigned long top_pos,
00220 const unsigned long width,
00221 const unsigned long height,
00222 const unsigned long frame);
00223
00231 int setHistogramWindow(const double thresh);
00232
00240 int setWindow(const unsigned long pos = 0);
00241
00253 int setWindow(const double center,
00254 const double width,
00255 const char *explanation = NULL);
00256
00264 int getWindow(double ¢er,
00265 double &width);
00266
00271 inline unsigned long getWindowCount() const
00272 {
00273 return WindowCount;
00274 }
00275
00287 int setVoiLut(const DcmUnsignedShort &data,
00288 const DcmUnsignedShort &descriptor,
00289 const DcmLongString *explanation,
00290 const OFBool ignoreDepth = OFFalse);
00291
00301 int setVoiLut(const unsigned long pos,
00302 const OFBool ignoreDepth = OFFalse);
00303
00308 inline unsigned long getVoiLutCount() const
00309 {
00310 return VoiLutCount;
00311 }
00312
00317 inline const char *getVoiTransformationExplanation() const
00318 {
00319 return VoiExplanation.c_str();
00320 }
00321
00329 const char *getVoiWindowExplanation(const unsigned long pos,
00330 OFString &explanation) const;
00331
00339 const char *getVoiLutExplanation(const unsigned long pos,
00340 OFString &explanation) const;
00341
00346 inline const char *getModalityLutExplanation() const
00347 {
00348 return (InterData != NULL) ? InterData->getModalityLutExplanation() : OFstatic_cast(const char *, NULL);
00349 }
00350
00362 int setHardcopyParameters(const unsigned int min,
00363 const unsigned int max,
00364 const unsigned int reflect,
00365 const unsigned int illumin);
00366
00373 ES_PresentationLut getPresentationLutShape() const;
00374
00386 int setPresentationLutShape(const ES_PresentationLut shape);
00387
00399 int setPresentationLut(const DcmUnsignedShort &data,
00400 const DcmUnsignedShort &descriptor,
00401 const DcmLongString *explanation = NULL,
00402 const OFBool ignoreDepth = OFFalse);
00403
00415 int setInversePresentationLut(const DcmUnsignedShort &data,
00416 const DcmUnsignedShort &descriptor,
00417 const OFBool ignoreDepth = OFFalse);
00418
00423 inline const char *getPresentationLutExplanation() const
00424 {
00425 return (PresLutData != NULL) ? PresLutData->getExplanation() : OFstatic_cast(const char *, NULL);
00426 }
00427
00444 int addOverlay(const unsigned int group,
00445 const signed int left_pos,
00446 const signed int top_pos,
00447 const unsigned int columns,
00448 const unsigned int rows,
00449 const DcmOverlayData &data,
00450 const DcmLongString &label,
00451 const DcmLongString &description,
00452 const EM_Overlay mode);
00453
00458 int removeAllOverlays();
00459
00466 inline DiOverlay *getOverlayPtr(const unsigned int idx)
00467 {
00468 return (idx < 2) ? Overlays[idx] : OFstatic_cast(DiOverlay *, NULL);
00469 }
00470
00475 inline DiMonoImage *getMonoImagePtr()
00476 {
00477 return this;
00478 }
00479
00489 int flip(const int horz,
00490 const int vert);
00491
00500 int rotate(const int degree);
00501
00512 virtual int getBits(const int bits = 0) const
00513 {
00514 return (((bits < 1) || (bits > MAX_BITS)) && (bits != MI_PastelColor)) ? BitsPerSample : bits;
00515 }
00516
00523 virtual unsigned long getOutputDataSize(const int bits = 0) const;
00524
00534 virtual const void *getOutputData(const unsigned long frame,
00535 const int bits,
00536 const int planar = 0) = 0;
00537
00549 virtual int getOutputData(void *buffer,
00550 const unsigned long size,
00551 const unsigned long frame,
00552 const int bits,
00553 const int planar = 0) = 0;
00554
00562 const void *getOutputPlane(const int dummy) const;
00563
00567 void deleteOutputData();
00568
00586 const void *getOverlayData(const unsigned long frame,
00587 const unsigned int plane,
00588 unsigned int &left_pos,
00589 unsigned int &top_pos,
00590 unsigned int &width,
00591 unsigned int &height,
00592 EM_Overlay &mode,
00593 const unsigned int idx,
00594 const int bits = 8,
00595 const Uint16 fore = 0xff,
00596 const Uint16 back = 0x0);
00597
00612 const void *getFullOverlayData(const unsigned long frame,
00613 const unsigned int plane,
00614 unsigned int &width,
00615 unsigned int &height,
00616 const unsigned int idx,
00617 const int bits = 8,
00618 const Uint16 fore = 0xff,
00619 const Uint16 back = 0x0);
00620
00624 void deleteOverlayData();
00625
00642 unsigned long create6xxx3000OverlayData(Uint8 *&buffer,
00643 const unsigned int plane,
00644 unsigned int &width,
00645 unsigned int &height,
00646 unsigned long &frames,
00647 const unsigned int idx = 0);
00648
00653 const DiPixel *getInterData() const
00654 {
00655 return InterData;
00656 }
00657
00662 const DiMonoPixel *getMonoInterData() const
00663 {
00664 return InterData;
00665 }
00666
00679 unsigned long createDIB(void *&data,
00680 const unsigned long size,
00681 const unsigned long frame,
00682 const int bits,
00683 const int upsideDown,
00684 const int padding = 1);
00685
00695 unsigned long createAWTBitmap(void *&data,
00696 const unsigned long frame,
00697 const int bits);
00698
00710 static void *createPackedBitmap(const void *buffer,
00711 const unsigned long size,
00712 const unsigned long count,
00713 const int alloc,
00714 const int stored);
00715
00724 DiImage *createOutputImage(const unsigned long frame,
00725 const int bits);
00726
00735 int writeImageToDataset(DcmItem &dataset,
00736 const int mode);
00737
00747 int writePPM(ostream &stream,
00748 const unsigned long frame,
00749 const int bits);
00750
00760 int writePPM(FILE *stream,
00761 const unsigned long frame,
00762 const int bits);
00763
00772 int writeRawPPM(FILE *stream,
00773 const unsigned long frame,
00774 const int bits);
00775
00784 int writeBMP(FILE *stream,
00785 const unsigned long frame,
00786 const int bits);
00787
00788
00789 protected:
00790
00797 DiMonoImage(const DiDocument *image,
00798 const EI_Status status,
00799 const char dummy);
00800
00807 DiMonoImage(const DiMonoImage *image,
00808 const unsigned long fstart,
00809 const unsigned long fcount);
00810
00820 DiMonoImage(const DiColorImage *image,
00821 const double red,
00822 const double green,
00823 const double blue);
00824
00842 DiMonoImage(const DiMonoImage *image,
00843 const signed long left_pos,
00844 const signed long top_pos,
00845 const Uint16 src_cols,
00846 const Uint16 src_rows,
00847 const Uint16 dest_cols,
00848 const Uint16 dest_rows,
00849 const int interpolate,
00850 const int aspect,
00851 const Uint16 pvalue);
00852
00859 DiMonoImage(const DiMonoImage *image,
00860 const int horz,
00861 const int vert);
00862
00868 DiMonoImage(const DiMonoImage *image,
00869 const int degree);
00870
00879 DiMonoImage(const DiMonoImage *image,
00880 DiMonoOutputPixel *pixel,
00881 const unsigned long frame,
00882 const int stored,
00883 const int alloc);
00884
00889 void Init(DiMonoModality *modality);
00890
00895 void InitUint8(DiMonoModality *modality);
00896
00901 void InitSint8(DiMonoModality *modality);
00902
00907 void InitUint16(DiMonoModality *modality);
00908
00913 void InitSint16(DiMonoModality *modality);
00914
00919 void InitUint32(DiMonoModality *modality);
00920
00925 void InitSint32(DiMonoModality *modality);
00926
00931 int checkInterData(const int mode = 1);
00932
00940 virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00941
00954 const void *getData(void *buffer,
00955 const unsigned long size,
00956 const unsigned long frame,
00957 int bits,
00958 const int planar,
00959 const int negative);
00960
00972 void getDataUint8(void *buffer,
00973 DiDisplayFunction *disp,
00974 const int samples,
00975 const unsigned long frame,
00976 const int bits,
00977 const Uint32 low,
00978 const Uint32 high);
00979
00991 void getDataSint8(void *buffer,
00992 DiDisplayFunction *disp,
00993 const int samples,
00994 const unsigned long frame,
00995 const int bits,
00996 const Uint32 low,
00997 const Uint32 high);
00998
01010 void getDataUint16(void *buffer,
01011 DiDisplayFunction *disp,
01012 const int samples,
01013 const unsigned long frame,
01014 const int bits,
01015 const Uint32 low,
01016 const Uint32 high);
01017
01029 void getDataSint16(void *buffer,
01030 DiDisplayFunction *disp,
01031 const int samples,
01032 const unsigned long frame,
01033 const int bits,
01034 const Uint32 low,
01035 const Uint32 high);
01036
01048 void getDataUint32(void *buffer,
01049 DiDisplayFunction *disp,
01050 const int samples,
01051 const unsigned long frame,
01052 const int bits,
01053 const Uint32 low,
01054 const Uint32 high);
01055
01067 void getDataSint32(void *buffer,
01068 DiDisplayFunction *disp,
01069 const int samples,
01070 const unsigned long frame,
01071 const int bits,
01072 const Uint32 low,
01073 const Uint32 high);
01074
01083 int createLinODPresentationLut(const unsigned long count, const int bits);
01084
01086 double WindowCenter;
01088 double WindowWidth;
01090 unsigned long WindowCount;
01092 unsigned long VoiLutCount;
01093
01095 int ValidWindow;
01096
01098 OFString VoiExplanation;
01099
01101 ES_PresentationLut PresLutShape;
01102
01104 unsigned int MinDensity;
01106 unsigned int MaxDensity;
01108 unsigned int Reflection;
01110 unsigned int Illumination;
01111
01113 DiOverlay *Overlays[2];
01115 DiLookupTable *VoiLutData;
01117 DiLookupTable *PresLutData;
01119 DiMonoPixel *InterData;
01120
01122 DiDisplayFunction *DisplayFunction;
01123
01124
01125 private:
01126
01128 DiMonoOutputPixel *OutputData;
01130 void *OverlayData;
01131
01132
01133
01134 DiMonoImage(const DiMonoImage &);
01135 DiMonoImage &operator=(const DiMonoImage &);
01136 };
01137
01138
01139 #endif
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
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