This file is indexed.

/usr/include/gdcm-2.6/gdcmImageChangePhotometricInterpretation.h is in libgdcm2-dev 2.6.3-3ubuntu3.

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
/*=========================================================================

  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 GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H
#define GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H

#include "gdcmImageToImageFilter.h"
#include "gdcmPhotometricInterpretation.h"

namespace gdcm
{

class DataElement;
/**
 * \brief ImageChangePhotometricInterpretation class
 * Class to change the Photometric Interpetation of an input DICOM
 */
class GDCM_EXPORT ImageChangePhotometricInterpretation : public ImageToImageFilter
{
public:
  ImageChangePhotometricInterpretation():PI() {}
  ~ImageChangePhotometricInterpretation() {}

  /// Set/Get requested PhotometricInterpretation
  void SetPhotometricInterpretation(PhotometricInterpretation const &pi) { PI = pi; }
  const PhotometricInterpretation &GetPhotometricInterpretation() const { return PI; }

  /// Change
  bool Change();

  /// colorspace converstion (based on CCIR Recommendation 601-2)
  template <typename T>
  static void RGB2YBR(T ybr[3], const T rgb[3]);
  template <typename T>
  static void YBR2RGB(T rgb[3], const T ybr[3]);

protected:
  bool ChangeMonochrome();

private:
  PhotometricInterpretation PI;
};


// http://en.wikipedia.org/wiki/YCbCr
template <typename T>
void ImageChangePhotometricInterpretation::RGB2YBR(T ybr[3], const T rgb[3])
{
#if 1
  ybr[0] =   65.738 * rgb[0] +    129.057 * rgb[1] +    25.064 * rgb[2] + 16;
  ybr[1] =  -37.945 * rgb[0] +    -74.494 * rgb[1] +   112.439 * rgb[2] + 128;
  ybr[2] =  112.439 * rgb[0] +    -94.154 * rgb[1] +   -18.285 * rgb[2] + 128;
#else

  const double R = rgb[0];
  const double G = rgb[1];
  const double B = rgb[2];
  const double Y  =  .2990 * R + .5870 * G + .1140 * B;
  const double CB = -.168736 * R - .331264 * G + .5000 * B + 128;
  const double CR =  .5000 * R - .418688 * G - .081312 * B + 128;
  //assert( Y >= 0  && Y <= 255 );
  //assert( CB >= 0 && CB <= 255 );
  //assert( CR >= 0 && CR <= 255 );
  ybr[0] = Y  /*+ 0.5*/;
  ybr[1] = CB /*+ 0.5*/;
  ybr[2] = CR /*+ 0.5*/;
#endif
}

template <typename T>
void ImageChangePhotometricInterpretation::YBR2RGB(T rgb[3], const T ybr[3])
{

#if 1
 rgb[0] = 298.082 * ((int)ybr[0]-16) +     0.    * ((int)ybr[1]-128) +   408.583 * ((int)ybr[2]-128) - 1. / 256;
 rgb[1] = 298.082 * ((int)ybr[0]-16) +  -100.291 * ((int)ybr[1]-128) +  -208.12  * ((int)ybr[2]-128) - 1. / 256;
 rgb[2] = 298.082 * ((int)ybr[0]-16) +   516.411 * ((int)ybr[1]-128) +     0.    * ((int)ybr[2]-128) - 1. / 256;

#else
  const double Y  = ybr[0];
  const double Cb = ybr[1];
  const double Cr = ybr[2];
  //const double R =  1.0000e+00 * Y - 3.6820e-05 * CB + 1.4020e+00 * CR;
  //const double G =  1.0000e+00 * Y - 3.4411e-01 * CB - 7.1410e-01 * CR;
  //const double B =  1.0000e+00 * Y + 1.7720e+00 * CB - 1.3458e-04 * CR;
  const double r = Y                    + 1.402   * (Cr-128);
  const double g = Y - 0.344136 * (Cb-128) - 0.714136 * (Cr-128);
  const double b = Y + 1.772   * (Cb-128);
  double R = r < 0 ? 0 : r;
  R = R > 255 ? 255 : R;
  double G = g < 0 ? 0 : g;
  G = G > 255 ? 255 : G;
  double B = b < 0 ? 0 : b;
  B = B > 255 ? 255 : B;
  assert( R >= 0 && R <= 255 );
  assert( G >= 0 && G <= 255 );
  assert( B >= 0 && B <= 255 );
  rgb[0] = ((R < 0 ? 0 : R) > 255 ? 255 : R);
  rgb[1] = G;
  rgb[2] = B;
#endif

}

} // end namespace gdcm

#endif //GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H