dimomod.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. *
  3. * Copyright (C) 1996-2016, 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: DicomMonochromeModality (Header)
  19. *
  20. */
  21. #ifndef DIMOMOD_H
  22. #define DIMOMOD_H
  23. #include "dcmtk/config/osconfig.h"
  24. #include "dcmtk/ofstd/ofcast.h"
  25. #include "dcmtk/dcmimgle/diluptab.h"
  26. #include "dcmtk/dcmimgle/diobjcou.h"
  27. /*------------------------*
  28. * forward declarations *
  29. *------------------------*/
  30. class DiDocument;
  31. class DiInputPixel;
  32. /*---------------------*
  33. * class declaration *
  34. *---------------------*/
  35. /** Class to handle modality specific transformations (incl. modality LUT)
  36. */
  37. class DCMTK_DCMIMGLE_EXPORT DiMonoModality
  38. : public DiObjectCounter
  39. {
  40. public:
  41. /** constructor
  42. *
  43. ** @param docu pointer to dataset (encapsulated)
  44. * @param pixel pointer to input pixel data
  45. */
  46. DiMonoModality(const DiDocument *docu,
  47. DiInputPixel *pixel);
  48. /** constructor, rescale
  49. *
  50. ** @param docu pointer to dataset (encapsulated)
  51. * @param pixel pointer to input pixel data
  52. * @param slope rescale slope (<> 0)
  53. * @param intercept rescale intercept
  54. */
  55. DiMonoModality(const DiDocument *docu,
  56. DiInputPixel *pixel,
  57. const double slope,
  58. const double intercept);
  59. /** constructor, LUT
  60. *
  61. ** @param docu pointer to dataset (encapsulated)
  62. * @param pixel pointer to input pixel data
  63. * @param data element containing the modality LUT data
  64. * @param descriptor element containing the modality LUT descriptor
  65. * @param explanation element containing the modality LUT explanation (optional)
  66. */
  67. DiMonoModality(const DiDocument *docu,
  68. DiInputPixel *pixel,
  69. const DcmUnsignedShort &data,
  70. const DcmUnsignedShort &descriptor,
  71. const DcmLongString *explanation);
  72. /** constructor, no modality transform
  73. *
  74. ** @param bits number of bits per pixel
  75. */
  76. DiMonoModality(const int bits);
  77. /** destructor
  78. */
  79. virtual ~DiMonoModality();
  80. /** get integer representation
  81. *
  82. ** @return integer representation
  83. */
  84. inline EP_Representation getRepresentation() const
  85. {
  86. return Representation;
  87. }
  88. /** get minimum pixel value after modality transform
  89. *
  90. ** @return minimum pixel value
  91. */
  92. inline double getMinValue() const
  93. {
  94. return MinValue;
  95. }
  96. /** get maximum pixel value after modality transform
  97. *
  98. ** @return maximum pixel value
  99. */
  100. inline double getMaxValue() const
  101. {
  102. return MaxValue;
  103. }
  104. /** get number of bits describing the width of output data
  105. *
  106. ** @return number of bits (might be 0)
  107. */
  108. inline unsigned int getBits() const
  109. {
  110. return Bits;
  111. }
  112. /** get number of bits actually used to store the output data.
  113. * (based on the range given by 'MinValue' and 'MaxValue')
  114. *
  115. ** @return number of used bits (might be 0)
  116. */
  117. inline unsigned int getUsedBits() const
  118. {
  119. return UsedBits;
  120. }
  121. /** get absolute (possible) minimum pixel value after modality transform
  122. *
  123. ** @return absolute minimum pixel value
  124. */
  125. inline double getAbsMinimum() const
  126. {
  127. return AbsMinimum;
  128. }
  129. /** get absolute (possible) maximum pixel value after modality transform
  130. *
  131. ** @return absolute maximum pixel value
  132. */
  133. inline double getAbsMaximum() const
  134. {
  135. return AbsMaximum;
  136. }
  137. /** get rescale intercept value
  138. *
  139. ** @return rescale intercept value
  140. */
  141. inline double getRescaleIntercept() const
  142. {
  143. return RescaleIntercept;
  144. }
  145. /** get rescale slope value
  146. *
  147. ** @return rescale slope value
  148. */
  149. inline double getRescaleSlope() const
  150. {
  151. return RescaleSlope;
  152. }
  153. /** get pointer to lookup table data
  154. *
  155. ** @return pointer to lookup table data or NULL if absent
  156. */
  157. inline const DiLookupTable *getTableData() const
  158. {
  159. return TableData;
  160. }
  161. /** get modality LUT explanation
  162. *
  163. ** @return modality LUT explanation or NULL if absent
  164. */
  165. inline const char *getExplanation() const
  166. {
  167. return (TableData != NULL) ? TableData->getExplanation() : OFstatic_cast(const char *, NULL);
  168. }
  169. /** check whether lookup table is present
  170. *
  171. ** @return true if lookup table is present, false otherwise
  172. */
  173. inline int hasLookupTable() const
  174. {
  175. return LookupTable;
  176. }
  177. /** check whether rescaling is present
  178. *
  179. ** @return true if rescaling is present, false otherwise
  180. */
  181. inline int hasRescaling() const
  182. {
  183. return Rescaling;
  184. }
  185. protected:
  186. /** initialize internal data structures and values
  187. *
  188. ** @param docu pointer to dataset (encapsulated)
  189. * @param pixel pointer to input pixel data
  190. *
  191. ** @return status, true if successful, false otherwise
  192. */
  193. int Init(const DiDocument *docu,
  194. DiInputPixel *pixel);
  195. /** check lookup table for validity (and possibly correct it)
  196. */
  197. void checkTable();
  198. /** check rescaling for validity (and possibly correct it)
  199. *
  200. ** @param pixel pointer to input pixel data
  201. */
  202. void checkRescaling(const DiInputPixel *pixel);
  203. /** determine integer representation used for the output data
  204. *
  205. ** @param docu pointer to dataset (encapsulated)
  206. */
  207. void determineRepresentation(const DiDocument *docu);
  208. private:
  209. /// integer representation
  210. EP_Representation Representation;
  211. /// minimum pixel value
  212. double MinValue;
  213. /// maximum pixel value
  214. double MaxValue;
  215. /// number of bits
  216. unsigned int Bits;
  217. /// number of used bits
  218. unsigned int UsedBits;
  219. /// absolute minimum pixel value
  220. double AbsMinimum;
  221. /// absolute maximum pixel value
  222. double AbsMaximum;
  223. /// rescale intercept
  224. double RescaleIntercept;
  225. /// rescale slope
  226. double RescaleSlope;
  227. /// status flag: lookup table present
  228. int LookupTable;
  229. /// status flag: rescaling present
  230. int Rescaling;
  231. /// pointer to modality lookup table
  232. DiLookupTable *TableData;
  233. // --- declarations to avoid compiler warnings
  234. DiMonoModality(const DiMonoModality &);
  235. DiMonoModality &operator=(const DiMonoModality &);
  236. };
  237. #endif