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 DIIMAGE_H
00031 #define DIIMAGE_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034
00035 #include "dcmtk/dcmdata/dcitem.h"
00036 #include "dcmtk/dcmdata/dcfcache.h"
00037
00038 #ifdef SUNCC
00039 #include "dcmtk/dcmimgle/didocu.h"
00040 #endif
00041
00042 #include "dcmtk/dcmimgle/diovlay.h"
00043 #include "dcmtk/dcmimgle/diutils.h"
00044
00045 #define INCLUDE_CSTDIO
00046 #include "dcmtk/ofstd/ofstdinc.h"
00047
00048 #include "dcmtk/ofstd/ofstream.h"
00049
00050
00051
00052
00053
00054
00055 class DcmPixelData;
00056 class DcmUnsignedShort;
00057
00058 #ifndef SUNCC
00059 class DiDocument;
00060 #endif
00061
00062 class DiPixel;
00063 class DiMonoImage;
00064 class DiInputPixel;
00065
00066
00067
00068
00069
00070
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
00100 virtual int processNextFrames(const unsigned long fcount);
00101
00106 inline EI_Status getStatus() const
00107 {
00108 return ImageStatus;
00109 }
00110
00115 inline Uint32 getNumberOfFrames() const
00116 {
00117 return NumberOfFrames;
00118 }
00119
00124 inline Uint32 getFirstFrame() const
00125 {
00126 return FirstFrame;
00127 }
00128
00133 inline Uint32 getRepresentativeFrame() const
00134 {
00135 return RepresentativeFrame;
00136 }
00137
00142 inline Uint16 getRows() const
00143 {
00144 return Rows;
00145 }
00146
00151 inline Uint16 getColumns() const
00152 {
00153 return Columns;
00154 }
00155
00160 inline double getPixelWidth() const
00161 {
00162 return (PixelWidth > 0) ? PixelWidth : 1;
00163 }
00164
00169 inline double getPixelHeight() const
00170 {
00171 return (PixelHeight > 0) ? PixelHeight : 1;
00172 }
00173
00178 inline double getRowColumnRatio() const
00179 {
00180 return getPixelHeight() / getPixelWidth();
00181 }
00182
00187 inline double getColumnRowRatio() const
00188 {
00189 return getPixelWidth() / getPixelHeight();
00190 }
00191
00198 int setRowColumnRatio(const double ratio);
00199
00206 int setColumnRowRatio(const double ratio);
00207
00213 inline EP_Polarity getPolarity() const
00214 {
00215 return Polarity;
00216 }
00217
00226 int setPolarity(const EP_Polarity polarity);
00227
00238 virtual int getBits(const int bits = 0) const
00239 {
00240 return ((bits < 1) || (bits > MAX_BITS)) ? BitsPerSample : bits;
00241 }
00242
00248 virtual EP_Interpretation getInternalColorModel() const = 0;
00249
00254 virtual const DiPixel *getInterData() const = 0;
00255
00262 virtual unsigned long getOutputDataSize(const int bits = 0) const = 0;
00263
00273 virtual const void *getOutputData(const unsigned long frame,
00274 const int bits,
00275 const int planar) = 0;
00276
00288 virtual int getOutputData(void *buffer,
00289 const unsigned long size,
00290 const unsigned long frame,
00291 const int bits,
00292 const int planar) = 0;
00293
00301 virtual const void *getOutputPlane(const int plane) const = 0;
00302
00305 virtual void deleteOutputData() = 0;
00306
00313 virtual DiOverlay *getOverlayPtr(const unsigned int )
00314 {
00315 return NULL;
00316 }
00317
00322 virtual DiMonoImage *getMonoImagePtr()
00323 {
00324 return NULL;
00325 }
00326
00334 virtual DiImage *createImage(const unsigned long fstart,
00335 const unsigned long fcount) const = 0;
00336
00357 virtual DiImage *createScale(const signed long left_pos,
00358 const signed long top_pos,
00359 const unsigned long clip_width,
00360 const unsigned long clip_height,
00361 const unsigned long scale_width,
00362 const unsigned long scale_height,
00363 const int interpolate,
00364 const int aspect,
00365 const Uint16 pvalue) const = 0;
00366
00374 virtual int flip(const int horz,
00375 const int vert) = 0;
00376
00384 virtual DiImage *createFlip(const int horz,
00385 const int vert) const = 0;
00386
00393 virtual int rotate(const int degree);
00394
00401 virtual DiImage *createRotate(const int degree) const = 0;
00402
00411 virtual DiImage *createMono(const double red,
00412 const double green,
00413 const double blue) const = 0;
00414
00426 virtual unsigned long createDIB(void *&data,
00427 const unsigned long size,
00428 const unsigned long frame,
00429 const int bits,
00430 const int upsideDown,
00431 const int padding = 1) = 0;
00432
00441 virtual unsigned long createAWTBitmap(void *&data,
00442 const unsigned long frame,
00443 const int bits) = 0;
00444
00454 int writeFrameToDataset(DcmItem &dataset,
00455 const unsigned long frame = 0,
00456 const int bits = 0,
00457 const int planar = 0);
00458
00467 virtual int writeImageToDataset(DcmItem &dataset,
00468 const int mode = 0,
00469 const int planar = 2) = 0;
00470
00480 virtual int writePPM(STD_NAMESPACE ostream& stream,
00481 const unsigned long frame,
00482 const int bits) = 0;
00483
00493 virtual int writePPM(FILE *stream,
00494 const unsigned long frame,
00495 const int bits) = 0;
00496
00505 virtual int writeRawPPM(FILE *stream,
00506 const unsigned long frame,
00507 const int bits) = 0;
00508
00517 virtual int writeBMP(FILE *stream,
00518 const unsigned long frame,
00519 const int bits);
00520
00521
00522 protected:
00523
00529 DiImage(const DiDocument *docu,
00530 const EI_Status status);
00531
00538 DiImage(const DiImage *image,
00539 const unsigned long fstart,
00540 const unsigned long fcount);
00541
00549 DiImage(const DiImage *image,
00550 const Uint16 width,
00551 const Uint16 height,
00552 const int aspect = 0);
00553
00559 DiImage(const DiImage *image,
00560 const int degree = 0);
00561
00569 DiImage(const DiImage *image,
00570 const unsigned long frame,
00571 const int stored,
00572 const int alloc);
00573
00576 void deleteInputData();
00577
00580 void checkPixelExtension();
00581
00584 void convertPixelData();
00585
00593 virtual void updateImagePixelModuleAttributes(DcmItem &dataset);
00594
00598 int detachPixelData();
00599
00601 EI_Status ImageStatus;
00603 const DiDocument *Document;
00604
00606 Uint32 FirstFrame;
00608 Uint32 NumberOfFrames;
00610 Uint32 TotalNumberOfFrames;
00612 Uint32 RepresentativeFrame;
00614 Uint16 Rows;
00616 Uint16 Columns;
00618 double PixelWidth;
00620 double PixelHeight;
00622 Uint16 BitsAllocated;
00624 Uint16 BitsStored;
00626 Uint16 HighBit;
00627
00629 int BitsPerSample;
00631 int SamplesPerPixel;
00632
00634 EP_Polarity Polarity;
00635
00637 int hasSignedRepresentation;
00639 int hasPixelSpacing;
00641 int hasImagerPixelSpacing;
00643 int hasNominalScannedPixelSpacing;
00645 int hasPixelAspectRatio;
00647 int isOriginal;
00648
00650 DiInputPixel *InputData;
00652 DcmFileCache FileCache;
00654 Uint32 CurrentFragment;
00655
00656
00657
00658 DiImage(const DiImage &);
00659 DiImage &operator=(const DiImage &);
00660 };
00661
00662
00663 #endif
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
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857