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 "dcmtk/config/osconfig.h"
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/dcmdata/dcitem.h"
00040
00041 #ifdef SUNCC
00042 #include "dcmtk/dcmimgle/didocu.h"
00043 #endif
00044
00045 #include "dcmtk/dcmimgle/diovlay.h"
00046 #include "dcmtk/dcmimgle/diutils.h"
00047
00048 #define INCLUDE_CSTDIO
00049 #include "dcmtk/ofstd/ofstdinc.h"
00050
00051 #include "dcmtk/ofstd/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 DiPixel;
00066 class DiMonoImage;
00067 class DiInputPixel;
00068
00069
00070
00071
00072
00073
00076 class DiImage
00077 {
00078
00079 public:
00080
00087 DiImage(const DiDocument *docu,
00088 const EI_Status status,
00089 const int spp);
00090
00093 virtual ~DiImage();
00094
00099 inline EI_Status getStatus() const
00100 {
00101 return ImageStatus;
00102 }
00103
00108 inline Uint32 getNumberOfFrames() const
00109 {
00110 return NumberOfFrames;
00111 }
00112
00117 inline Uint32 getFirstFrame() const
00118 {
00119 return FirstFrame;
00120 }
00121
00126 inline Uint32 getRepresentativeFrame() const
00127 {
00128 return RepresentativeFrame;
00129 }
00130
00135 inline Uint16 getRows() const
00136 {
00137 return Rows;
00138 }
00139
00144 inline Uint16 getColumns() const
00145 {
00146 return Columns;
00147 }
00148
00153 inline double getPixelWidth() const
00154 {
00155 return (PixelWidth > 0) ? PixelWidth : 1;
00156 }
00157
00162 inline double getPixelHeight() const
00163 {
00164 return (PixelHeight > 0) ? PixelHeight : 1;
00165 }
00166
00171 inline double getRowColumnRatio() const
00172 {
00173 return getPixelHeight() / getPixelWidth();
00174 }
00175
00180 inline double getColumnRowRatio() const
00181 {
00182 return getPixelWidth() / getPixelHeight();
00183 }
00184
00191 int setRowColumnRatio(const double ratio);
00192
00199 int setColumnRowRatio(const double ratio);
00200
00206 inline EP_Polarity getPolarity() const
00207 {
00208 return Polarity;
00209 }
00210
00219 int setPolarity(const EP_Polarity polarity);
00220
00231 virtual int getBits(const int bits = 0) const
00232 {
00233 return ((bits < 1) || (bits > MAX_BITS)) ? BitsPerSample : bits;
00234 }
00235
00241 virtual EP_Interpretation getInternalColorModel() const = 0;
00242
00247 virtual const DiPixel *getInterData() const = 0;
00248
00255 virtual unsigned long getOutputDataSize(const int bits = 0) const = 0;
00256
00266 virtual const void *getOutputData(const unsigned long frame,
00267 const int bits,
00268 const int planar) = 0;
00269
00281 virtual int getOutputData(void *buffer,
00282 const unsigned long size,
00283 const unsigned long frame,
00284 const int bits,
00285 const int planar) = 0;
00286
00294 virtual const void *getOutputPlane(const int plane) const = 0;
00295
00298 virtual void deleteOutputData() = 0;
00299
00306 virtual DiOverlay *getOverlayPtr(const unsigned int )
00307 {
00308 return NULL;
00309 }
00310
00315 virtual DiMonoImage *getMonoImagePtr()
00316 {
00317 return NULL;
00318 }
00319
00327 virtual DiImage *createImage(const unsigned long fstart,
00328 const unsigned long fcount) const = 0;
00329
00348 virtual DiImage *createScale(const signed long left_pos,
00349 const signed long top_pos,
00350 const unsigned long clip_width,
00351 const unsigned long clip_height,
00352 const unsigned long scale_width,
00353 const unsigned long scale_height,
00354 const int interpolate,
00355 const int aspect,
00356 const Uint16 pvalue) const = 0;
00357
00365 virtual int flip(const int horz,
00366 const int vert) = 0;
00367
00375 virtual DiImage *createFlip(const int horz,
00376 const int vert) const = 0;
00377
00384 virtual int rotate(const int degree);
00385
00392 virtual DiImage *createRotate(const int degree) const = 0;
00393
00402 virtual DiImage *createMono(const double red,
00403 const double green,
00404 const double blue) const = 0;
00405
00417 virtual unsigned long createDIB(void *&data,
00418 const unsigned long size,
00419 const unsigned long frame,
00420 const int bits,
00421 const int upsideDown,
00422 const int padding = 1) = 0;
00423
00432 virtual unsigned long createAWTBitmap(void *&data,
00433 const unsigned long frame,
00434 const int bits) = 0;
00435
00445 int writeFrameToDataset(DcmItem &dataset,
00446 const unsigned long frame = 0,
00447 const int bits = 0,
00448 const int planar = 0);
00449
00457 virtual int writeImageToDataset(DcmItem &dataset,
00458 const int mode = 0) = 0;
00459
00469 virtual int writePPM(ostream &stream,
00470 const unsigned long frame,
00471 const int bits) = 0;
00472
00482 virtual int writePPM(FILE *stream,
00483 const unsigned long frame,
00484 const int bits) = 0;
00485
00494 virtual int writeRawPPM(FILE *stream,
00495 const unsigned long frame,
00496 const int bits) = 0;
00497
00506 virtual int writeBMP(FILE *stream,
00507 const unsigned long frame,
00508 const int bits);
00509
00510
00511 protected:
00512
00518 DiImage(const DiDocument *docu,
00519 const EI_Status status);
00520
00527 DiImage(const DiImage *image,
00528 const unsigned long fstart,
00529 const unsigned long fcount);
00530
00538 DiImage(const DiImage *image,
00539 const Uint16 width,
00540 const Uint16 height,
00541 const int aspect = 0);
00542
00548 DiImage(const DiImage *image,
00549 const int degree = 0);
00550
00558 DiImage(const DiImage *image,
00559 const unsigned long frame,
00560 const int stored,
00561 const int alloc);
00562
00565 void deleteInputData();
00566
00569 void checkPixelExtension();
00570
00576 void convertPixelData( DcmPixelData *pixel,
00577 const int spp);
00578
00586 virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00587
00591 int detachPixelData();
00592
00594 EI_Status ImageStatus;
00596 const DiDocument *Document;
00597
00599 Uint32 FirstFrame;
00601 Uint32 NumberOfFrames;
00603 Uint32 TotalNumberOfFrames;
00605 Uint32 RepresentativeFrame;
00607 Uint16 Rows;
00609 Uint16 Columns;
00611 double PixelWidth;
00613 double PixelHeight;
00615 Uint16 BitsAllocated;
00617 Uint16 BitsStored;
00619 Uint16 HighBit;
00620
00622 int BitsPerSample;
00623
00625 EP_Polarity Polarity;
00626
00628 int hasSignedRepresentation;
00630 int hasPixelSpacing;
00632 int hasImagerPixelSpacing;
00634 int hasPixelAspectRatio;
00636 int isOriginal;
00637
00639 DiInputPixel *InputData;
00640
00641
00642
00643 DiImage(const DiImage &);
00644 DiImage &operator=(const DiImage &);
00645 };
00646
00647
00648 #endif
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
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810