This file is indexed.

/usr/include/gdcm-2.6/gdcmPixelFormat.h is in libgdcm2-dev 2.6.6-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#ifndef GDCMPIXELFORMAT_H
#define GDCMPIXELFORMAT_H

#include "gdcmTypes.h"
#include <iostream>
#include <assert.h>

namespace gdcm
{

class TransferSyntax;

/**
 * \brief PixelFormat
 * \details 
 * By default the Pixel Type will be instanciated with the following
 * parameters:
 * - SamplesPerPixel : 1
 * - BitsAllocated : 8
 * - BitsStored : 8
 * - HighBit : 7
 * - PixelRepresentation : 0
 *
 * Fundamentally PixelFormat is very close to what DICOM allows. It will be
 * very hard to extend this class for the upcoming DICOM standard where
 * Floating 32 and 64bits will be allowed.
 *
 * It is also very hard for this class to fully support 64bits integer type
 * (see GetMin / GetMax signature restricted to 64bits signed).
 */
class GDCM_EXPORT PixelFormat
{
  friend class Bitmap;
  friend std::ostream& operator<<(std::ostream &_os, const PixelFormat &pf);
public:
  // When adding a type please add its dual type (its unsigned conterpart)
  typedef enum {
    UINT8,
    INT8,
    UINT12,
    INT12,
    UINT16,
    INT16,
    UINT32,  // For some DICOM files (RT or SC)
    INT32,   //                        "   "
    UINT64,  // Needed when input is 32bits + intercept/slope (incomplete support)
    INT64,   //                        "   "
    FLOAT16, // sure why not...
    FLOAT32, // good ol' 'float'
    FLOAT64, // aka 'double'
    SINGLEBIT, // bool / monochrome
    UNKNOWN // aka BitsAllocated == 0 && PixelRepresentation == 0
  } ScalarType;

  // default cstor:
  explicit PixelFormat (
    unsigned short samplesperpixel = 1,
    unsigned short bitsallocated = 8,
    unsigned short bitsstored = 8,
    unsigned short highbit = 7,
    unsigned short pixelrepresentation = 0 ) :
  SamplesPerPixel(samplesperpixel),
  BitsAllocated(bitsallocated),
  BitsStored(bitsstored),
  HighBit(highbit),
  PixelRepresentation(pixelrepresentation) {}
  // helper, for the common case
  PixelFormat(ScalarType st);

  // For transparency of use
  operator ScalarType() const { return GetScalarType(); }

  /// Samples Per Pixel see (0028,0002) US Samples Per Pixel
  /// DICOM - only allows 1, 3 and 4 as valid value. Other value are undefined behavior.
  unsigned short GetSamplesPerPixel() const;
  void SetSamplesPerPixel(unsigned short spp)
    {
    gdcmAssertMacro( spp <= 4 );
    SamplesPerPixel = spp;
    assert( SamplesPerPixel == 1 || SamplesPerPixel == 3 || SamplesPerPixel == 4 );
    }

  /// BitsAllocated see Tag (0028,0100) US Bits Allocated
  unsigned short GetBitsAllocated() const
    {
    return BitsAllocated;
    }
  void SetBitsAllocated(unsigned short ba)
    {
    if( ba )
      {
      BitsAllocated = ba;
      BitsStored = ba;
      HighBit = (unsigned short)(ba - 1);
      }
    else // Make the PixelFormat as UNKNOWN
      {
      BitsAllocated = 0;
      PixelRepresentation = 0;
      }
    }

  /// BitsStored see Tag (0028,0101) US Bits Stored
  unsigned short GetBitsStored() const
    {
    assert( BitsStored <= BitsAllocated );
    return BitsStored;
    }
  void SetBitsStored(unsigned short bs)
    {
    if( bs <= BitsAllocated && bs )
      {
      BitsStored = bs;
      SetHighBit( (unsigned short) (bs - 1) );
      }
    }

  /// HighBit see Tag (0028,0102) US High Bit
  unsigned short GetHighBit() const
    {
    assert( HighBit < BitsStored );
    return HighBit;
    }
  void SetHighBit(unsigned short hb)
    {
    if( hb < BitsStored )
      HighBit = hb;
    }

  /// PixelRepresentation: 0 or 1, see Tag (0028,0103) US Pixel Representation
  unsigned short GetPixelRepresentation() const
    {
    return (unsigned short)(PixelRepresentation ? 1 : 0);
    }
  void SetPixelRepresentation(unsigned short pr)
    {
    PixelRepresentation = (unsigned short)(pr ? 1 : 0);
    }

  /// ScalarType does not take into account the sample per pixel
  ScalarType GetScalarType() const;

  /// Set PixelFormat based only on the ScalarType
  /// \warning: You need to call SetScalarType *before* SetSamplesPerPixel
  void SetScalarType(ScalarType st);
  const char *GetScalarTypeAsString() const;

  /// return the size of the pixel
  /// This is the number of words it would take to store one pixel
  /// \warning the return value takes into account the SamplesPerPixel
  /// \warning in the rare case when BitsAllocated == 12, the function
  /// assume word padding and value returned will be identical as if BitsAllocated == 16
  uint8_t GetPixelSize() const;

  /// Print
  void Print(std::ostream &os) const;

  /// return the min possible of the pixel
  int64_t GetMin() const;

  /// return the max possible of the pixel
  int64_t GetMax() const;

  /// return IsValid
  bool IsValid() const;

  bool operator==(ScalarType st) const
    {
    return GetScalarType() == st;
    }
  bool operator!=(ScalarType st) const
    {
    return GetScalarType() != st;
    }
  bool operator==(const PixelFormat &pf) const
    {
    return
      SamplesPerPixel     == pf.SamplesPerPixel &&
      BitsAllocated       == pf.BitsAllocated &&
      BitsStored          == pf.BitsStored &&
      HighBit             == pf.HighBit &&
      PixelRepresentation == pf.PixelRepresentation;
    }
  bool operator!=(const PixelFormat &pf) const
    {
    return
      SamplesPerPixel     != pf.SamplesPerPixel ||
      BitsAllocated       != pf.BitsAllocated ||
      BitsStored          != pf.BitsStored ||
      HighBit             != pf.HighBit ||
      PixelRepresentation != pf.PixelRepresentation;
    }

  bool IsCompatible(const TransferSyntax & ts ) const;
protected:
  /// When image with 24/24/23 was read, need to validate
  bool Validate();

private:
  // D 0028|0002 [US] [Samples per Pixel] [1]
  unsigned short SamplesPerPixel;
  // D 0028|0100 [US] [Bits Allocated] [8]
  unsigned short BitsAllocated;
  // D 0028|0101 [US] [Bits Stored] [8]
  unsigned short BitsStored;
  // D 0028|0102 [US] [High Bit] [7]
  unsigned short HighBit;
  // D 0028|0103 [US] [Pixel Representation] [0]
  unsigned short PixelRepresentation;
};
//-----------------------------------------------------------------------------
inline std::ostream& operator<<(std::ostream &os, const PixelFormat &pf)
{
  pf.Print( os );
  return os;
}

} // end namespace gdcm

#endif //GDCMPIXELFORMAT_H