OFFIS DCMTK  Version 3.6.0
dicmypxt.h
1 /*
2  *
3  * Copyright (C) 1996-2011, 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: dcmimage
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose: DicomCMYKPixelTemplate (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2011-11-17 16:13:14 $
22  * CVS/RCS Revision: $Revision: 1.21 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DICMYPXT_H
31 #define DICMYPXT_H
32 
33 #include "dcmtk/config/osconfig.h"
34 
35 #include "dcmtk/dcmimage/dicopxt.h"
36 #include "dcmtk/dcmimgle/diinpx.h" /* gcc 3.4 needs this */
37 
38 
39 /*---------------------*
40  * class declaration *
41  *---------------------*/
42 
45 template<class T1, class T2>
47  : public DiColorPixelTemplate<T2>
48 {
49 
50  public:
51 
61  const DiInputPixel *pixel,
62  EI_Status &status,
63  const unsigned long planeSize,
64  const int bits)
65  : DiColorPixelTemplate<T2>(docu, pixel, 4, status)
66  {
67  if ((pixel != NULL) && (this->Count > 0) && (status == EIS_Normal))
68  convert(OFstatic_cast(const T1 *, pixel->getData()) + pixel->getPixelStart(), planeSize, bits);
69  }
70 
74  {
75  }
76 
77 
78  private:
79 
86  void convert(const T1 *pixel,
87  const unsigned long planeSize,
88  const int bits)
89  {
90  if (this->Init(pixel))
91  {
92  // use the number of input pixels derived from the length of the 'PixelData'
93  // attribute), but not more than the size of the intermediate buffer
94  const unsigned long count = (this->InputCount < this->Count) ? this->InputCount : this->Count;
95  const T2 maxvalue = OFstatic_cast(T2, DicomImageClass::maxval(bits));
96  const T1 offset = OFstatic_cast(T1, DicomImageClass::maxval(bits - 1));
97  register const T1 *p = pixel;
98  if (this->PlanarConfiguration)
99  {
100 /*
101  register const T1 *k;
102  register T2 *q;
103  for (int j = 0; j < 3; ++j)
104  {
105  q = this->Data[j];
106  k = pixel + 3 * this->InputCount; // beginning of 'black' plane
107  for (i = count; i != 0; --i)
108  *(q++) = maxvalue - removeSign(*(p++), offset) - removeSign(*(k++), offset);
109  }
110 */
111  register const T1 *k;
112  register T2 *q;
113  register unsigned long l;
114  register unsigned long i = 0;
115  while (i < count)
116  {
117  /* store current pixel index */
118  const unsigned long iStart = i;
119  /* beginning of 'black' plane */
120  const T1 *kStart = p + 3 * planeSize;
121  /* for all planes ... */
122  for (int j = 0; j < 3; ++j)
123  {
124  q = this->Data[j] + iStart;
125  /* reset to beginning of 'black' plane */
126  k = kStart;
127  /* convert a single plane */
128  for (l = planeSize, i = iStart; (l != 0) && (i < count); --l, ++i)
129  *(q++) = maxvalue - removeSign(*(p++), offset) - removeSign(*(k++), offset);
130  }
131  /* skip black plane */
132  p += planeSize;
133  }
134  }
135  else
136  {
137  register T1 k;
138  register int j;
139  register unsigned long i;
140  for (i = 0; i < count; ++i)
141  {
142  k = *(p + 3);
143  for (j = 0; j < 3; ++j)
144  this->Data[j][i] = maxvalue - removeSign(*(p++), offset) - removeSign(k, offset);
145  ++p; // skip 'black'
146  }
147  }
148  }
149  }
150 };
151 
152 
153 #endif
154 
155 
156 /*
157  *
158  * CVS/RCS Log:
159  * $Log: dicmypxt.h,v $
160  * Revision 1.21 2011-11-17 16:13:14 joergr
161  * Minor fixes to keep XCode 4.2 on Mac OS X Lion (clang compiler) quiet.
162  *
163  * Revision 1.20 2010-10-14 13:16:29 joergr
164  * Updated copyright header. Added reference to COPYRIGHT file.
165  *
166  * Revision 1.19 2005/12/08 16:01:27 meichel
167  * Changed include path schema for all DCMTK header files
168  *
169  * Revision 1.18 2004/04/21 10:00:31 meichel
170  * Minor modifications for compilation with gcc 3.4.0
171  *
172  * Revision 1.17 2003/12/23 16:06:21 joergr
173  * Replaced additional post-increment/decrement operators by pre-increment/
174  * decrement operators.
175  *
176  * Revision 1.16 2003/12/23 12:38:51 joergr
177  * Replaced post-increment/decrement operators by pre-increment/decrement
178  * operators where appropriate (e.g. 'i++' by '++i').
179  *
180  * Revision 1.15 2003/12/23 11:17:23 joergr
181  * Adapted type casts to new-style typecast operators defined in ofcast.h.
182  * Removed leading underscore characters from preprocessor symbols (reserved
183  * symbols). Updated copyright header.
184  *
185  * Revision 1.14 2002/06/26 16:16:38 joergr
186  * Enhanced handling of corrupted pixel data and/or length.
187  * Corrected decoding of multi-frame, planar images.
188  *
189  * Revision 1.13 2001/11/09 16:40:16 joergr
190  * Removed 'inline' specifier from certain methods.
191  *
192  * Revision 1.12 2001/06/01 15:49:27 meichel
193  * Updated copyright header
194  *
195  * Revision 1.11 2000/04/27 13:15:13 joergr
196  * Dcmimage library code now consistently uses ofConsole for error output.
197  *
198  * Revision 1.10 2000/03/08 16:21:49 meichel
199  * Updated copyright header.
200  *
201  * Revision 1.9 1999/09/17 14:03:42 joergr
202  * Enhanced efficiency of some "for" loops.
203  *
204  * Revision 1.8 1999/04/28 12:51:56 joergr
205  * Corrected some typos, comments and formatting.
206  *
207  * Revision 1.7 1999/02/03 16:48:32 joergr
208  * Moved global functions maxval() and determineRepresentation() to class
209  * DicomImageClass (as static methods).
210  *
211  * Revision 1.6 1999/01/20 14:37:05 joergr
212  * Replaced invocation of getCount() by member variable Count where possible.
213  *
214  * Revision 1.5 1998/11/27 13:41:04 joergr
215  * Added copyright message.
216  *
217  * Revision 1.4 1998/05/11 14:53:10 joergr
218  * Added CVS/RCS header to each file.
219  *
220  *
221  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2