OFFIS DCMTK
Version 3.6.0
Main Page
Related Pages
Classes
Files
File List
File Members
dcmimgle
include
dcmtk
dcmimgle
diimage.h
1
/*
2
*
3
* Copyright (C) 1996-2010, OFFIS e.V.
4
* All rights reserved. See COPYRIGHT file for details.
5
*
6
* This software and supporting documentation were developed by
7
*
8
* OFFIS e.V.
9
* R&D Division Health
10
* Escherweg 2
11
* D-26121 Oldenburg, Germany
12
*
13
*
14
* Module: dcmimgle
15
*
16
* Author: Joerg Riesmeier
17
*
18
* Purpose: DicomImage (Header)
19
*
20
* Last Update: $Author: joergr $
21
* Update Date: $Date: 2010-10-14 13:16:26 $
22
* CVS/RCS Revision: $Revision: 1.47 $
23
* Status: $State: Exp $
24
*
25
* CVS/RCS Log at end of file
26
*
27
*/
28
29
30
#ifndef DIIMAGE_H
31
#define DIIMAGE_H
32
33
#include "dcmtk/config/osconfig.h"
34
35
#include "dcmtk/dcmdata/dcitem.h"
36
#include "dcmtk/dcmdata/dcfcache.h"
37
38
#ifdef SUNCC
39
#include "dcmtk/dcmimgle/didocu.h"
40
#endif
41
42
#include "dcmtk/dcmimgle/diovlay.h"
43
#include "dcmtk/dcmimgle/diutils.h"
44
45
#define INCLUDE_CSTDIO
46
#include "dcmtk/ofstd/ofstdinc.h"
47
48
#include "dcmtk/ofstd/ofstream.h"
49
50
51
/*------------------------*
52
* forward declarations *
53
*------------------------*/
54
55
class
DcmPixelData
;
56
class
DcmUnsignedShort
;
57
58
#ifndef SUNCC
59
class
DiDocument
;
60
#endif
61
62
class
DiPixel
;
63
class
DiMonoImage
;
64
class
DiInputPixel
;
65
66
67
/*---------------------*
68
* class declaration *
69
*---------------------*/
70
75
class
DiImage
76
{
77
78
public
:
79
86
DiImage
(
const
DiDocument
*docu,
87
const
EI_Status status,
88
const
int
spp);
89
92
virtual
~DiImage
();
93
100
virtual
int
processNextFrames
(
const
unsigned
long
fcount);
101
106
inline
EI_Status
getStatus
()
const
107
{
108
return
ImageStatus
;
109
}
110
115
inline
Uint32
getNumberOfFrames
()
const
116
{
117
return
NumberOfFrames
;
118
}
119
124
inline
Uint32
getFirstFrame
()
const
125
{
126
return
FirstFrame
;
127
}
128
133
inline
Uint32
getRepresentativeFrame
()
const
134
{
135
return
RepresentativeFrame
;
136
}
137
142
inline
Uint16
getRows
()
const
143
{
144
return
Rows
;
145
}
146
151
inline
Uint16
getColumns
()
const
152
{
153
return
Columns
;
154
}
155
160
inline
double
getPixelWidth
()
const
161
{
162
return
(
PixelWidth
> 0) ?
PixelWidth
: 1;
163
}
164
169
inline
double
getPixelHeight
()
const
170
{
171
return
(
PixelHeight
> 0) ?
PixelHeight
: 1;
172
}
173
178
inline
double
getRowColumnRatio
()
const
179
{
180
return
getPixelHeight
() /
getPixelWidth
();
181
}
182
187
inline
double
getColumnRowRatio
()
const
188
{
189
return
getPixelWidth
() /
getPixelHeight
();
190
}
191
198
int
setRowColumnRatio
(
const
double
ratio);
199
206
int
setColumnRowRatio
(
const
double
ratio);
207
213
inline
EP_Polarity
getPolarity
()
const
214
{
215
return
Polarity
;
216
}
217
226
int
setPolarity
(
const
EP_Polarity polarity);
227
238
virtual
int
getBits
(
const
int
bits = 0)
const
239
{
240
return
((bits < 1) || (bits > MAX_BITS)) ?
BitsPerSample
: bits;
241
}
242
248
virtual
EP_Interpretation
getInternalColorModel
()
const
= 0;
249
254
virtual
const
DiPixel
*
getInterData
()
const
= 0;
255
262
virtual
unsigned
long
getOutputDataSize
(
const
int
bits = 0)
const
= 0;
263
273
virtual
const
void
*
getOutputData
(
const
unsigned
long
frame,
274
const
int
bits,
275
const
int
planar) = 0;
276
288
virtual
int
getOutputData
(
void
*buffer,
289
const
unsigned
long
size,
290
const
unsigned
long
frame,
291
const
int
bits,
292
const
int
planar) = 0;
293
301
virtual
const
void
*
getOutputPlane
(
const
int
plane)
const
= 0;
302
305
virtual
void
deleteOutputData
() = 0;
306
313
virtual
DiOverlay
*
getOverlayPtr
(
const
unsigned
int
/*idx*/
)
314
{
315
return
NULL;
316
}
317
322
virtual
DiMonoImage
*
getMonoImagePtr
()
323
{
324
return
NULL;
325
}
326
334
virtual
DiImage
*
createImage
(
const
unsigned
long
fstart,
335
const
unsigned
long
fcount)
const
= 0;
336
357
virtual
DiImage
*
createScale
(
const
signed
long
left_pos,
358
const
signed
long
top_pos,
359
const
unsigned
long
clip_width,
360
const
unsigned
long
clip_height,
361
const
unsigned
long
scale_width,
362
const
unsigned
long
scale_height,
363
const
int
interpolate,
364
const
int
aspect,
365
const
Uint16 pvalue)
const
= 0;
366
374
virtual
int
flip
(
const
int
horz,
375
const
int
vert) = 0;
376
384
virtual
DiImage
*
createFlip
(
const
int
horz,
385
const
int
vert)
const
= 0;
386
393
virtual
int
rotate
(
const
int
degree);
394
401
virtual
DiImage
*
createRotate
(
const
int
degree)
const
= 0;
402
411
virtual
DiImage
*
createMono
(
const
double
red,
412
const
double
green,
413
const
double
blue)
const
= 0;
414
426
virtual
unsigned
long
createDIB
(
void
*&data,
427
const
unsigned
long
size,
428
const
unsigned
long
frame,
429
const
int
bits,
430
const
int
upsideDown,
431
const
int
padding = 1) = 0;
432
441
virtual
unsigned
long
createAWTBitmap
(
void
*&data,
442
const
unsigned
long
frame,
443
const
int
bits) = 0;
444
454
int
writeFrameToDataset
(
DcmItem
&dataset,
455
const
unsigned
long
frame = 0,
456
const
int
bits = 0,
457
const
int
planar = 0);
458
467
virtual
int
writeImageToDataset
(
DcmItem
&dataset,
468
const
int
mode = 0,
469
const
int
planar = 2) = 0;
470
480
virtual
int
writePPM
(STD_NAMESPACE ostream& stream,
481
const
unsigned
long
frame,
482
const
int
bits) = 0;
483
493
virtual
int
writePPM
(FILE *stream,
494
const
unsigned
long
frame,
495
const
int
bits) = 0;
496
505
virtual
int
writeRawPPM
(FILE *stream,
506
const
unsigned
long
frame,
507
const
int
bits) = 0;
508
517
virtual
int
writeBMP
(FILE *stream,
518
const
unsigned
long
frame,
519
const
int
bits);
520
521
522
protected
:
523
529
DiImage
(
const
DiDocument
*docu,
530
const
EI_Status status);
531
538
DiImage
(
const
DiImage
*image,
539
const
unsigned
long
fstart,
540
const
unsigned
long
fcount);
541
549
DiImage
(
const
DiImage
*image,
550
const
Uint16 width,
551
const
Uint16 height,
552
const
int
aspect = 0);
553
559
DiImage
(
const
DiImage
*image,
560
const
int
degree = 0);
561
569
DiImage
(
const
DiImage
*image,
570
const
unsigned
long
frame,
571
const
int
stored,
572
const
int
alloc);
573
576
void
deleteInputData
();
577
580
void
checkPixelExtension
();
581
584
void
convertPixelData
();
585
593
virtual
void
updateImagePixelModuleAttributes
(
DcmItem
&dataset);
594
598
int
detachPixelData
();
599
601
EI_Status
ImageStatus
;
603
const
DiDocument
*
Document
;
604
606
Uint32
FirstFrame
;
608
Uint32
NumberOfFrames
;
610
Uint32
TotalNumberOfFrames
;
612
Uint32
RepresentativeFrame
;
614
Uint16
Rows
;
616
Uint16
Columns
;
618
double
PixelWidth
;
620
double
PixelHeight
;
622
Uint16
BitsAllocated
;
624
Uint16
BitsStored
;
626
Uint16
HighBit
;
627
629
int
BitsPerSample
;
631
int
SamplesPerPixel
;
632
634
EP_Polarity
Polarity
;
635
637
int
hasSignedRepresentation
;
639
int
hasPixelSpacing
;
641
int
hasImagerPixelSpacing
;
643
int
hasNominalScannedPixelSpacing
;
645
int
hasPixelAspectRatio
;
647
int
isOriginal
;
648
650
DiInputPixel
*
InputData
;
652
DcmFileCache
FileCache
;
654
Uint32
CurrentFragment
;
655
656
// --- declarations to avoid compiler warnings
657
658
DiImage
(
const
DiImage
&);
659
DiImage
&operator=(
const
DiImage
&);
660
};
661
662
663
#endif
664
665
666
/*
667
*
668
* CVS/RCS Log:
669
* $Log: diimage.h,v $
670
* Revision 1.47 2010-10-14 13:16:26 joergr
671
* Updated copyright header. Added reference to COPYRIGHT file.
672
*
673
* Revision 1.46 2010-10-05 15:26:28 joergr
674
* Fixed various Doxygen API documentation issues.
675
*
676
* Revision 1.45 2010-03-01 09:08:46 uli
677
* Removed some unnecessary include directives in the headers.
678
*
679
* Revision 1.44 2009-11-25 15:59:10 joergr
680
* Adapted code for new approach to access individual frames of a DICOM image.
681
*
682
* Revision 1.43 2009-02-12 12:01:17 joergr
683
* Added support for NominalScannedPixelSpacing in order to determine the pixel
684
* aspect ratio (used for the new SC image IODs).
685
*
686
* Revision 1.42 2008-05-20 10:03:53 joergr
687
* Added new bilinear and bicubic scaling algorithms for image magnification.
688
*
689
* Revision 1.41 2008-05-13 09:54:40 joergr
690
* Added new parameter to writeImageToDataset() in order to affect the planar
691
* configuration of the output image/dataset. Changed behaviour: By default,
692
* the output now uses the same planar configuration as the "original" image
693
* (previously: always color-by-plane).
694
*
695
* Revision 1.40 2006/08/15 16:30:11 meichel
696
* Updated the code in module dcmimgle to correctly compile when
697
* all standard C++ classes remain in namespace std.
698
*
699
* Revision 1.39 2006/07/10 10:52:27 joergr
700
* Added support for 32-bit BMP images.
701
*
702
* Revision 1.38 2005/12/08 16:47:42 meichel
703
* Changed include path schema for all DCMTK header files
704
*
705
* Revision 1.37 2005/03/09 17:32:35 joergr
706
* Added mode to writeImageToDataset() which allows the value of BitsStored to
707
* be determined either from 'used' or from 'possible' pixel values.
708
*
709
* Revision 1.36 2004/09/22 11:33:14 joergr
710
* Introduced new member variable "TotalNumberOfFrames".
711
*
712
* Revision 1.35 2004/07/20 18:12:16 joergr
713
* Added API method to "officially" access the internal intermediate pixel data
714
* representation (e.g. to get Hounsfield Units for CT images).
715
*
716
* Revision 1.34 2004/02/06 11:07:50 joergr
717
* Distinguish more clearly between const and non-const access to pixel data.
718
*
719
* Revision 1.33 2004/01/05 14:52:20 joergr
720
* Removed acknowledgements with e-mail addresses from CVS log.
721
*
722
* Revision 1.32 2003/12/08 18:22:26 joergr
723
* Removed leading underscore characters from preprocessor symbols (reserved
724
* symbols). Updated CVS header.
725
*
726
* Revision 1.31 2003/06/12 15:08:34 joergr
727
* Fixed inconsistent API documentation reported by Doxygen.
728
*
729
* Revision 1.30 2003/05/20 09:20:41 joergr
730
* Added method returning the number of bytes required to store a single
731
* rendered frame: getOutputDataSize().
732
*
733
* Revision 1.29 2002/12/09 13:32:51 joergr
734
* Renamed parameter/local variable to avoid name clashes with global
735
* declaration left and/or right (used for as iostream manipulators).
736
*
737
* Revision 1.28 2002/11/27 14:08:04 meichel
738
* Adapted module dcmimgle to use of new header file ofstdinc.h
739
*
740
* Revision 1.27 2002/11/26 14:48:32 joergr
741
* Added Smallest/LargestImagePixelValue to the list of attributes to be
742
* removed from a newly created dataset.
743
*
744
* Revision 1.26 2002/08/02 15:03:20 joergr
745
* Enhanced writeFrameToDataset() routine (remove out-data DICOM attributes
746
* from the dataset).
747
* Added function to write the current image (not only a selected frame) to a
748
* DICOM dataset.
749
*
750
* Revision 1.25 2002/06/26 16:01:55 joergr
751
* Added support for polarity flag to color images.
752
* Added new method to write a selected frame to a DICOM dataset (incl. required
753
* attributes from the "Image Pixel Module").
754
*
755
* Revision 1.24 2002/04/16 13:53:11 joergr
756
* Added configurable support for C++ ANSI standard includes (e.g. streams).
757
*
758
* Revision 1.23 2002/01/29 17:05:50 joergr
759
* Added optional flag to the "Windows DIB" methods allowing to switch off the
760
* scanline padding.
761
*
762
* Revision 1.22 2001/11/27 18:18:22 joergr
763
* Added support for plugable output formats in class DicomImage. First
764
* implementation is JPEG.
765
*
766
* Revision 1.21 2001/11/09 16:26:37 joergr
767
* Added support for Window BMP file format.
768
* Enhanced and renamed createTrueColorDIB() method.
769
*
770
* Revision 1.20 2001/06/20 15:12:49 joergr
771
* Enhanced multi-frame support for command line tool 'dcm2pnm': extract all
772
* or a range of frames with one call.
773
*
774
* Revision 1.19 2001/06/01 15:49:42 meichel
775
* Updated copyright header
776
*
777
* Revision 1.18 2000/03/08 16:24:16 meichel
778
* Updated copyright header.
779
*
780
* Revision 1.17 2000/02/02 11:02:38 joergr
781
* Removed space characters before preprocessor directives.
782
*
783
* Revision 1.16 1999/10/06 13:28:21 joergr
784
* Corrected creation of PrintBitmap pixel data: VOI windows should be applied
785
* before clipping to avoid that the region outside the image (border) is also
786
* windowed (this requires a new method in dcmimgle to create a DicomImage
787
* with the grayscale transformations already applied).
788
*
789
* Revision 1.15 1999/09/17 12:12:18 joergr
790
* Added/changed/completed DOC++ style comments in the header files.
791
*
792
* Revision 1.14 1999/08/25 16:39:31 joergr
793
* Allow clipping region to be outside the image (overlapping).
794
*
795
* Revision 1.13 1999/07/23 13:53:00 joergr
796
* Added support for attribute 'ImagerPixelSpacing'.
797
* Added support for attribute 'RepresentativeFrameNumber'.
798
* Added methods to set 'PixelAspectRatio'.
799
*
800
* Revision 1.12 1999/04/28 14:47:34 joergr
801
* Added experimental support to create grayscale images with more than 256
802
* shades of gray to be displayed on a consumer monitor (use pastel colors).
803
*
804
* Revision 1.11 1999/03/24 17:20:01 joergr
805
* Added/Modified comments and formatting.
806
*
807
* Revision 1.10 1999/02/08 12:38:12 joergr
808
* Added parameter 'idx' to some overlay methods to distinguish between
809
* built-in and additional overlay planes.
810
*
811
* Revision 1.9 1999/02/03 17:01:45 joergr
812
* Added BEGIN_EXTERN_C and END_EXTERN_C to some C includes.
813
*
814
* Revision 1.8 1999/01/20 14:59:37 joergr
815
* Added new output method to fill external memory buffer with rendered pixel
816
* data.
817
*
818
* Revision 1.7 1999/01/11 09:32:32 joergr
819
* Removed method 'getMinMaxValues()' in class 'DicomImage'.
820
*
821
* Revision 1.6 1998/12/23 11:33:08 joergr
822
* Corrected some typos and formatting.
823
*
824
* Revision 1.5 1998/12/22 14:03:53 joergr
825
* Changed parameter declaration to avoid compiler warnings (hide parameter
826
* name).
827
*
828
* Revision 1.4 1998/12/16 16:29:04 joergr
829
* Removed several methods used for monochrome images only in base class
830
* 'DiImage'. Introduced mechanism to use the methods directly.
831
*
832
* Revision 1.3 1998/12/14 17:17:29 joergr
833
* Added methods to add and remove additional overlay planes (still untested).
834
*
835
* Revision 1.2 1998/11/30 12:24:07 joergr
836
* Added const type qualifier to some parameters to avoid errors with MSVC5
837
* (couldn't create instance of abstract class).
838
*
839
* Revision 1.1 1998/11/27 15:06:08 joergr
840
* Added copyright message.
841
* Added methods and constructors for flipping and rotating, changed for
842
* scaling and clipping.
843
* Added method to directly create java AWT bitmaps.
844
* Renamed variable 'Status' to 'ImageStatus' because of possible conflicts
845
* with X windows systems.
846
* Added method to detach pixel data if it is no longer needed.
847
* Added methods to support presentation LUTs and shapes.
848
*
849
* Revision 1.6 1998/07/01 08:39:21 joergr
850
* Minor changes to avoid compiler warnings (gcc 2.8.1 with additional
851
* options), e.g. add copy constructors.
852
*
853
* Revision 1.5 1998/05/11 14:53:16 joergr
854
* Added CVS/RCS header to each file.
855
*
856
*
857
*/
Generated on Thu Dec 20 2012 for
OFFIS DCMTK
Version 3.6.0 by
Doxygen
1.8.2