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 DIIMAGE_H
00035 #define DIIMAGE_H
00036
00037 #include "osconfig.h"
00038 #include "dctypes.h"
00039 #include "dcitem.h"
00040
00041 #ifdef SUNCC
00042 #include "didocu.h"
00043 #endif
00044
00045 #include "diovlay.h"
00046 #include "diutils.h"
00047
00048 #define INCLUDE_CSTDIO
00049 #include "ofstdinc.h"
00050
00051 #include "ofstream.h"
00052
00053
00054
00055
00056
00057
00058 class DcmPixelData;
00059 class DcmUnsignedShort;
00060
00061 #ifndef SUNCC
00062 class DiDocument;
00063 #endif
00064
00065 class DiMonoImage;
00066 class DiInputPixel;
00067
00068
00069
00070
00071
00072
00075 class DiImage
00076 {
00077
00078 public:
00079
00086 DiImage(const DiDocument *docu,
00087 const EI_Status status,
00088 const int spp);
00089
00092 virtual ~DiImage();
00093
00098 inline EI_Status getStatus() const
00099 {
00100 return ImageStatus;
00101 }
00102
00107 inline Uint32 getNumberOfFrames() const
00108 {
00109 return NumberOfFrames;
00110 }
00111
00116 inline Uint32 getFirstFrame() const
00117 {
00118 return FirstFrame;
00119 }
00120
00125 inline Uint32 getRepresentativeFrame() const
00126 {
00127 return RepresentativeFrame;
00128 }
00129
00134 inline Uint16 getRows() const
00135 {
00136 return Rows;
00137 }
00138
00143 inline Uint16 getColumns() const
00144 {
00145 return Columns;
00146 }
00147
00152 inline double getPixelWidth() const
00153 {
00154 return (PixelWidth > 0) ? PixelWidth : 1;
00155 }
00156
00161 inline double getPixelHeight() const
00162 {
00163 return (PixelHeight > 0) ? PixelHeight : 1;
00164 }
00165
00170 inline double getRowColumnRatio() const
00171 {
00172 return getPixelHeight() / getPixelWidth();
00173 }
00174
00179 inline double getColumnRowRatio() const
00180 {
00181 return getPixelWidth() / getPixelHeight();
00182 }
00183
00190 int setRowColumnRatio(const double ratio);
00191
00198 int setColumnRowRatio(const double ratio);
00199
00205 inline EP_Polarity getPolarity() const
00206 {
00207 return Polarity;
00208 }
00209
00218 int setPolarity(const EP_Polarity polarity);
00219
00224 virtual EP_Interpretation getInternalColorModel() const = 0;
00225
00236 virtual int getBits(const int bits = 0) const
00237 {
00238 return ((bits < 1) || (bits > MAX_BITS)) ? BitsPerSample : bits;
00239 }
00240
00247 virtual unsigned long getOutputDataSize(const int bits = 0) const = 0;
00248
00258 virtual const void *getOutputData(const unsigned long frame,
00259 const int bits,
00260 const int planar) = 0;
00261
00273 virtual int getOutputData(void *buffer,
00274 const unsigned long size,
00275 const unsigned long frame,
00276 const int bits,
00277 const int planar) = 0;
00278
00286 virtual const void *getOutputPlane(const int plane) const = 0;
00287
00290 virtual void deleteOutputData() = 0;
00291
00298 virtual DiOverlay *getOverlayPtr(const unsigned int )
00299 {
00300 return NULL;
00301 }
00302
00307 virtual DiMonoImage *getMonoImagePtr()
00308 {
00309 return NULL;
00310 }
00311
00319 virtual DiImage *createImage(const unsigned long fstart,
00320 const unsigned long fcount) const = 0;
00321
00340 virtual DiImage *createScale(const signed long left_pos,
00341 const signed long top_pos,
00342 const unsigned long clip_width,
00343 const unsigned long clip_height,
00344 const unsigned long scale_width,
00345 const unsigned long scale_height,
00346 const int interpolate,
00347 const int aspect,
00348 const Uint16 pvalue) const = 0;
00349
00357 virtual int flip(const int horz,
00358 const int vert) = 0;
00359
00367 virtual DiImage *createFlip(const int horz,
00368 const int vert) const = 0;
00369
00376 virtual int rotate(const int degree);
00377
00384 virtual DiImage *createRotate(const int degree) const = 0;
00385
00394 virtual DiImage *createMono(const double red,
00395 const double green,
00396 const double blue) const = 0;
00397
00409 virtual unsigned long createDIB(void *&data,
00410 const unsigned long size,
00411 const unsigned long frame,
00412 const int bits,
00413 const int upsideDown,
00414 const int padding = 1) = 0;
00415
00424 virtual unsigned long createAWTBitmap(void *&data,
00425 const unsigned long frame,
00426 const int bits) = 0;
00427
00437 int writeFrameToDataset(DcmItem &dataset,
00438 const unsigned long frame = 0,
00439 const int bits = 0,
00440 const int planar = 0);
00441
00448 virtual int writeImageToDataset(DcmItem &dataset) = 0;
00449
00459 virtual int writePPM(ostream &stream,
00460 const unsigned long frame,
00461 const int bits) = 0;
00462
00472 virtual int writePPM(FILE *stream,
00473 const unsigned long frame,
00474 const int bits) = 0;
00475
00484 virtual int writeRawPPM(FILE *stream,
00485 const unsigned long frame,
00486 const int bits) = 0;
00487
00496 virtual int writeBMP(FILE *stream,
00497 const unsigned long frame,
00498 const int bits);
00499
00500
00501 protected:
00502
00508 DiImage(const DiDocument *docu,
00509 const EI_Status status);
00510
00517 DiImage(const DiImage *image,
00518 const unsigned long fstart,
00519 const unsigned long fcount);
00520
00528 DiImage(const DiImage *image,
00529 const Uint16 width,
00530 const Uint16 height,
00531 const int aspect = 0);
00532
00538 DiImage(const DiImage *image,
00539 const int degree = 0);
00540
00548 DiImage(const DiImage *image,
00549 const unsigned long frame,
00550 const int stored,
00551 const int alloc);
00552
00555 void deleteInputData();
00556
00559 void checkPixelExtension();
00560
00566 void convertPixelData( DcmPixelData *pixel,
00567 const int spp);
00568
00576 virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00577
00581 int detachPixelData();
00582
00584 EI_Status ImageStatus;
00586 const DiDocument *Document;
00587
00589 Uint32 FirstFrame;
00591 Uint32 NumberOfFrames;
00593 Uint32 RepresentativeFrame;
00595 Uint16 Rows;
00597 Uint16 Columns;
00599 double PixelWidth;
00601 double PixelHeight;
00603 Uint16 BitsAllocated;
00605 Uint16 BitsStored;
00607 Uint16 HighBit;
00608
00610 int BitsPerSample;
00611
00613 EP_Polarity Polarity;
00614
00616 int hasSignedRepresentation;
00618 int hasPixelSpacing;
00620 int hasImagerPixelSpacing;
00622 int hasPixelAspectRatio;
00624 int isOriginal;
00625
00627 DiInputPixel *InputData;
00628
00629
00630
00631 DiImage(const DiImage &);
00632 DiImage &operator=(const DiImage &);
00633 };
00634
00635
00636 #endif
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784