/usr/include/InsightToolkit/Review/itkLabelOverlayFunctor.h is in libinsighttoolkit3-dev 3.20.1-1.
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 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkLabelOverlayFunctor.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 notices for more information.
=========================================================================*/
#ifndef __itkLabelOverlayFunctor_h
#define __itkLabelOverlayFunctor_h
#include "itkLabelToRGBFunctor.h"
namespace itk
{
namespace Functor {
/** \class LabelOverlayFunctor
* \brief Functor for applying a colormap to a label image and combine it
* with a grayscale image
*
* This functor class used internally by LabelOverlayImageFilter
*
* \author Gaetan Lehmann. Biologie du Developpement et de la Reproduction,
* INRA de Jouy-en-Josas, France.
*
* \sa LabelOverlayImageFilter LabelToRGBFunctor
*
*/
template< class TInputPixel, class TLabel, class TRGBPixel >
class LabelOverlayFunctor
{
public:
LabelOverlayFunctor()
{
// provide some default value for external use (outside
// LabelOverlayFunctorImageFilter) Inside LabelOverlayFunctorImageFilter,
// the values are always initialized
m_BackgroundValue = NumericTraits<TLabel>::Zero;
}
inline TRGBPixel operator()( const TInputPixel & p1, const TLabel & p2) const
{
TRGBPixel rgbPixel;
if( p2 == m_BackgroundValue )
{
// value is background
// return a gray pixel with the same intensity than the input pixel
typename TRGBPixel::ValueType p =
static_cast< typename TRGBPixel::ValueType >( p1 );
rgbPixel[0] = p;
rgbPixel[1] = p;
rgbPixel[2] = p;
return rgbPixel;
}
// taint the input pixel with the colored one returned by
// the color functor.
TRGBPixel opaque = m_RGBFunctor(p2);
for( unsigned int i = 0; i<3; i++ )
{
rgbPixel[i] = static_cast< typename TRGBPixel::ValueType >(
opaque[i] * m_Opacity + p1 * ( 1.0 - m_Opacity ) );
}
return rgbPixel;
}
bool operator != (const LabelOverlayFunctor &l) const
{
bool value = l.m_Opacity != m_Opacity ||
m_BackgroundValue != l.m_BackgroundValue;
return value;
}
~LabelOverlayFunctor() {}
void SetOpacity( double opacity )
{
m_Opacity = opacity;
}
void SetBackgroundValue( TLabel v )
{
m_BackgroundValue = v;
m_RGBFunctor.SetBackgroundValue( v );
}
void ResetColors()
{
m_RGBFunctor.ResetColors();
}
unsigned int GetNumberOfColors() const
{
return m_RGBFunctor.GetNumberOfColors();
}
/** type of the color component */
typedef typename TRGBPixel::ComponentType ComponentType;
void AddColor( ComponentType r, ComponentType g, ComponentType b )
{
m_RGBFunctor.AddColor( r, g, b );
}
protected:
private:
double m_Opacity;
TLabel m_BackgroundValue;
typename Functor::LabelToRGBFunctor<TLabel, TRGBPixel> m_RGBFunctor;
};
} // end namespace functor
} // end namespace itk
#endif
|