1 /*=========================================================================
2 
3   Program: GDCM (Grassroots DICOM). A DICOM library
4 
5   Copyright (c) 2006-2011 Mathieu Malaterre
6   All rights reserved.
7   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9      This software is distributed WITHOUT ANY WARRANTY; without even
10      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11      PURPOSE.  See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef GDCMSPACING_H
15 #define GDCMSPACING_H
16 
17 #include "gdcmTypes.h"
18 #include "gdcmAttribute.h"
19 
20 namespace gdcm
21 {
22 /**
23   It all began with a mail to WG6:
24 
25 Subject: 	Imager Pixel Spacing vs Pixel Spacing
26 Body: 	[Apologies for the duplicate post, namely to David Clunie & OFFIS team]
27 
28 I have been trying to understand CP-586 in the following two cases:
29 
30 On the one hand:
31 - DISCIMG/IMAGES/CRIMAGE taken from
32 http://dclunie.com/images/pixelspacingtestimages.zip
33 
34 And on the other hand:
35 - http://gdcm.sourceforge.net/thingies/cr_pixelspacing.dcm
36 
37 If I understand correctly the CP, one is required to use Pixel Spacing
38 for measurement ('true size' print) instead of Imager Pixel Spacing,
39 since the two attributes are present and Pixel Spacing is different from
40 Imager Pixel Spacing.
41 
42 If this is correct, then the test data DISCIMG/IMAGES/CRIMAGE is
43 incorrect. If this is incorrect (ie. I need to use Imager Pixel
44 Spacing), then the display of cr_pixelspacing.dcm for measurement will
45 be incorrect.
46 
47 Could someone please let me know what am I missing here? I could not
48 find any information in any header that would allow me to differentiate
49 those.
50 
51 Thank you for your time,
52 
53 Ref:
54   http://lists.nema.org/scripts/lyris.pl?sub=488573&id=400720477
55 */
56 
57 /**
58  * \brief Class for Spacing
59  * \details
60  * See PS 3.3-2008, Table C.7-11b IMAGE PIXEL MACRO ATTRIBUTES
61 
62 Ratio of the vertical size and horizontal size
63 of the pixels in the image specified by a
64 pair of integer values where the first value
65 is the vertical pixel size, and the second
66 value is the horizontal pixel size. Required
67 if the aspect ratio values do not have a
68 ratio of 1:1 and the physical pixel spacing is
69 not specified by Pixel Spacing (0028,0030),
70 or Imager Pixel Spacing (0018,1164) or
71 Nominal Scanned Pixel Spacing
72 (0018,2010), either for the entire Image or
73 per-frame in a Functional Group Macro.
74 See C.7.6.3.1.7.
75 
76 
77 PS 3.3-2008
78 10.7.1.3 Pixel Spacing Value Order and Valid Values
79 All pixel spacing related attributes shall have non-zero values, except when there is only a single row or
80 column or pixel of data present, in which case the corresponding value may be zero.
81 
82 Ref:
83 http://gdcm.sourceforge.net/wiki/index.php/Imager_Pixel_Spacing
84  */
85 class GDCM_EXPORT Spacing
86 {
87 public :
88   Spacing();
89   ~Spacing();
90 
91   // Here are the list of spacing we support:
92   // (0018,0088) DS [1.500000]                                         # 8,1 Spacing Between Slices
93   // (0018,1164) DS [0.5\0.5 ]                                         # 8,2 Imager Pixel Spacing
94   // (0018,2010) DS [0.664062\0.664062 ]                               # 18,2 Nominal Scanned Pixel Spacing
95   // (0018,7022) DS [0.125\0.125 ]                                     # 12,2 Detector Element Spacing
96   // (0028,0030) DS [0.25\0.25 ]                                       # 10,2 Pixel Spacing
97   // > (0028,0a02) CS [FIDUCIAL]                                         # 8,1 Pixel Spacing Calibration Type
98   // > (0028,0a04) LO [Used fiducial ]                                   # 14,1 Pixel Spacing Calibration Description
99   // (0028,0034) IS [4\3 ]                                             # 4,2 Pixel Aspect Ratio
100   // (3002,0011) DS [0.8\0.8 ]                                         # 8,2 Image Plane Pixel Spacing
101 
102   // Here is the list of Spacing we do not support:
103   // <entry group="0018" element="7041" vr="LT" vm="1" name="Grid Spacing Material"/>
104   // <entry group="0018" element="9030" vr="FD" vm="1" name="Tag Spacing First Dimension"/>
105   // <entry group="0018" element="9218" vr="FD" vm="1" name="Tag Spacing Second Dimension"/>
106   // <entry group="0018" element="9322" vr="FD" vm="2" name="Reconstruction Pixel Spacing"/>
107   // <entry group="0018" element="9404" vr="FL" vm="2" name="Object Pixel Spacing in Center of Beam"/>
108   // <entry group="0040" element="08d8" vr="SQ" vm="1" name="Pixel Spacing Sequence"/>
109   // <entry group="0070" element="0101" vr="DS" vm="2" name="Presentation Pixel Spacing"/>
110   // <entry group="2010" element="0376" vr="DS" vm="2" name="Printer Pixel Spacing"/>
111   // <entry group="300a" element="00e9" vr="DS" vm="2" name="Compensator Pixel Spacing"/>
112 
113   typedef enum {
114     DETECTOR = 0, // (0018,1164) Imager Pixel Spacing
115     MAGNIFIED,    // (0018,1114) (IHE Mammo)
116     CALIBRATED,   // (0028,0030) Pixel Spacing -> (0028,0a04) Pixel Spacing Calibration Description
117     UNKNOWN
118   } SpacingType;
119 
120   static Attribute<0x28,0x34> ComputePixelAspectRatioFromPixelSpacing(const Attribute<0x28,0x30>& pixelspacing);
121 };
122 } // end namespace gdcm
123 //-----------------------------------------------------------------------------
124 #endif //GDCMSPACING_H
125