Public Member Functions

mitk::ScalarBinaryColorToRGBAConverter< T, B > Class Template Reference

List of all members.

Public Member Functions

 ScalarBinaryColorToRGBAConverter (const T *_dataPtr, const B *_data2Ptr, unsigned char *_tmpPtr, int _sizeX, int _sizeY, int _sizeZ, mitk::TransferFunction::Pointer _tf, int *_color)
float sample (int x, int y, int z)
bool sampleBinary (int x, int y, int z)
int clamp (int x)
void write (int x, int y, int z, float grayValue, float gx, float gy, float gz)
void compute (int x, int y, int z)
void computeClamp (int x, int y, int z)
void compute1D (int y, int z)
void computeClamp1D (int y, int z)
void computeClamp2D (int z)
void compute2D (int z)
void fillSlices ()

Detailed Description

template<class T, class B>
class mitk::ScalarBinaryColorToRGBAConverter< T, B >

Definition at line 582 of file mitkColourImageProcessor.cpp.


Constructor & Destructor Documentation

template<class T , class B >
mitk::ScalarBinaryColorToRGBAConverter< T, B >::ScalarBinaryColorToRGBAConverter ( const T *  _dataPtr,
const B *  _data2Ptr,
unsigned char *  _tmpPtr,
int  _sizeX,
int  _sizeY,
int  _sizeZ,
mitk::TransferFunction::Pointer  _tf,
int *  _color 
) [inline]

Definition at line 599 of file mitkColourImageProcessor.cpp.

        :

  ScalarBinaryColorToRGBAConverter( const T *_dataPtr,const B *_data2Ptr,unsigned char *_tmpPtr,int _sizeX,int _sizeY,int _sizeZ,mitk::TransferFunction::Pointer _tf ,int *_color)
  {
    dataPtr=_dataPtr;
    data2Ptr=_data2Ptr;
    tmpPtr=_tmpPtr;
    sizeX=_sizeX;
    sizeY=_sizeY;
    sizeZ=_sizeZ;

    sizeXY=sizeX*sizeY;
    sizeXm1=sizeX-1;

Member Function Documentation

template<class T , class B >
int mitk::ScalarBinaryColorToRGBAConverter< T, B >::clamp ( int  x ) [inline]

Definition at line 628 of file mitkColourImageProcessor.cpp.

  {
    return data2Ptr[ x + y * sizeX + z * sizeXY ];
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::compute ( int  x,
int  y,
int  z 
) [inline]

Definition at line 681 of file mitkColourImageProcessor.cpp.

  {
    float grayValue = sample(x,y,z);
    float gx,gy,gz;

template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::compute1D ( int  y,
int  z 
) [inline]

Definition at line 714 of file mitkColourImageProcessor.cpp.

  {
    int x;
    
    x=0;
    computeClamp(x,y,z);
    x++;
    
    while(x<sizeX-1)
    {
      compute(x,y,z);     
      x++;
    }
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::compute2D ( int  z ) [inline]

Definition at line 761 of file mitkColourImageProcessor.cpp.

References mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp1D().

    {
      computeClamp1D(y,z);     
      y++;
    }
  }
  
  inline void compute2D(int z)
  {
    int y;

    y=0;
    computeClamp1D(y,z);     
    y++;
    
    while(y<sizeY-1)
    {
      compute1D(y,z);     
      y++;
    }
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp ( int  x,
int  y,
int  z 
) [inline]

Definition at line 694 of file mitkColourImageProcessor.cpp.

Referenced by mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp1D(), and mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp2D().

  {
    float grayValue = sample(x,y,z);
    float gx,gy,gz;

    if(x==0)            gx = 2.0f * ( sample(x+1,y,z) - grayValue       );
    else if(x==sizeXm1) gx = 2.0f * ( grayValue       - sample(x-1,y,z) );
    else                gx =          sample(x+1,y,z) - sample(x-1,y,z);
    
    if(y==0)            gy = 2.0f * ( sample(x,y+1,z) - grayValue       );
    else if(y==sizeYm1) gy = 2.0f * ( grayValue       - sample(x,y-1,z) );
    else                gy =          sample(x,y+1,z) - sample(x,y-1,z);
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp1D ( int  y,
int  z 
) [inline]
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp2D ( int  z ) [inline]

Definition at line 748 of file mitkColourImageProcessor.cpp.

References mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp().

    {
      computeClamp(x,y,z);     
      x++;
    }
  }      
        
  inline void computeClamp2D(int z)
  {
    int y;

    y=0;
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::fillSlices (  ) [inline]

Definition at line 782 of file mitkColourImageProcessor.cpp.

References mitk::ScalarBinaryColorToRGBAConverter< T, B >::computeClamp1D().

    {
      computeClamp1D(y,z);
      y++;
    }
  }
  
  inline void fillSlices()
  {
    int z;

    for(z=0;z<sizeZ;z++)
template<class T , class B >
float mitk::ScalarBinaryColorToRGBAConverter< T, B >::sample ( int  x,
int  y,
int  z 
) [inline]

Definition at line 618 of file mitkColourImageProcessor.cpp.

  {
template<class T , class B >
bool mitk::ScalarBinaryColorToRGBAConverter< T, B >::sampleBinary ( int  x,
int  y,
int  z 
) [inline]

Definition at line 623 of file mitkColourImageProcessor.cpp.

  {
template<class T , class B >
void mitk::ScalarBinaryColorToRGBAConverter< T, B >::write ( int  x,
int  y,
int  z,
float  grayValue,
float  gx,
float  gy,
float  gz 
) [inline]

Definition at line 634 of file mitkColourImageProcessor.cpp.

  {
    if(x<0) x=0; else if(x>255) x=255;
    return x;
  }
  
  inline void write(int x,int y,int z,float grayValue,float gx,float gy,float gz)
  {
    if(sampleBinary(x,y,z))
    {
      
   /*       
      gx /= aspect[0];
      gy /= aspect[1];
      gz /= aspect[2];
   */
      // Compute the gradient magnitude

      float t = sqrtf( gx*gx + gy*gy + gz*gz );

      int doff = x + y * sizeX + z * sizeXY;
      
      vtkPiecewiseFunction* opacityTransferFunction = tf->GetScalarOpacityFunction();
      vtkPiecewiseFunction* gradientTransferFunction = tf->GetGradientOpacityFunction();
      vtkColorTransferFunction* colorTransferFunction = tf->GetColorTransferFunction();

      double rgb[3];
      colorTransferFunction->GetColor( double(grayValue), rgb);
      
      double opacity= opacityTransferFunction->GetValue( double(grayValue) );
      
      opacity *= gradientTransferFunction->GetValue( double(0.5f*t) );
      
      tmpPtr[doff*4+0] = int( rgb[0]*255 + 0.5 );
      tmpPtr[doff*4+1] = int( rgb[1]*255 + 0.5 );
      tmpPtr[doff*4+2] = int( rgb[2]*255 + 0.5 );
      tmpPtr[doff*4+3] = int( opacity*255 + 0.5 );

      tmpPtr[doff*4+0] = color[0];
      tmpPtr[doff*4+1] = color[1];
      tmpPtr[doff*4+2] = color[2];
    }
    else
    {

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines