Fct_Pixel_Get_GLI

 

These function return the GLI  pixel value of a pixel identified by its 3D position.

 

 

Syntax

 

int  (*Fct_Pixel_Get_GLI)(

          SliceO_Class *pt,

          void *ima,

          Vect pos

)

 

 

Parameters

 

pt

Pointer to the class calling the function.

 

ima

Pointer to a Tomo_Image structure, as defined in the SliceO_File class.

 

pos

position of a point in the image plane.

 

 

Return value

 

This function return the GLI value of the pixel at the location. "pos".

 

 

Remarks

 

By default, the function will apply the local transformation to the position and call the same function for the parent class in the tree.  The "root" class will return the actual value.

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

Default callback for all classes except "Root"

 

// ----------------------------------------------------------------------------

//

//          Class_Class_Pixel_Get_GLI

//

//          Get one pixel from the original GLI image

//

// ----------------------------------------------------------------------------

int          Class_Class_Pixel_Get_GLI( SliceO_Class *pt, void *ima, Vect pos )

{

          // --- Apply the current transformation to the pixel's coord ---

          if ( ! pt->m_ident )

              pos *= pt->m_new2old ;

 

          // --- if a parent function exist, use it! ---

          SliceO_Class *parent = pt->Parent_Get_Pt() ;

 

          return( parent->Fct_Pixel_Get_GLI( parent, ima, pos ) ) ;

}

 

Default callback for "Root" class

 

// ----------------------------------------------------------------------------

//

//          Class_Root_Pixel_Get_GLI

//

//          Get one pixel from the original GLI image

//

// ----------------------------------------------------------------------------

int          Class_Root_Pixel_Get_GLI( SliceO_Class *pt, void *ima, Vect pos )

{

          // --- get the associated image and make sure we are inside it ---

          if ( ! ima )

              return( PIXEL_GLI_INVALID ) ;

 

          Tomo_Image *pt_ima = (Tomo_Image *) ima ;

 

          if ( ! pt_ima->data )

              return( PIXEL_GLI_INVALID ) ;

 

          short x = (int) pos.x ;

          short y = (int) pos.y ;

          short z = (int) pos.z ;

          short t = (int) pos.t ;

          if ( x < 0 || x >= pt_ima->x

            || y < 0 || y >= pt_ima->y

            || z < 0 || z >= pt_ima->z

            || t < 0 || t >= pt_ima->t )

              return( PIXEL_GLI_INVALID ) ;

 

          // --- Get the GLI value of th epixel ---

          int GLI_val = Tomo_Image_Pixel_Get_Int( NULL, pt_ima, x, y, z, t )  ;

 

          // --- if this value is outside the FOV mark it as "OUTSIDE" ---

          switch( pt_ima->g2.pix_data_type ) {

          case DATA_TYPE_SHORT :

          case DATA_TYPE_INT :

              if ( GLI_val == pt_ima->g2.pix_fill )

                    return( PIXEL_GLI_OUTSIDE ) ;

              break ;

          case DATA_TYPE_USHORT :

          case DATA_TYPE_UINT :

              if ( (unsigned int) GLI_val == (unsigned int) pt_ima->g2.pix_fill )

                    return( PIXEL_GLI_OUTSIDE ) ;

              break ;

          case DATA_TYPE_COLOR :

              if ( ! INT_BYTE(GLI_val) )

                    return( PIXEL_GLI_OUTSIDE ) ;

              break ;

          }

 

          // --- if we got here, we are not outside, so make sure the "OUTSIDE"

          // value is not used by mistake ---

          if ( GLI_val == PIXEL_GLI_INVALID )

              GLI_val = 0x07FFFFFFD ;

          if ( GLI_val == PIXEL_GLI_OUTSIDE )

              GLI_val = 0x07FFFFFFD ;

 

          return( GLI_val ) ;

}

 

See also