Fct_Metrics_Get_Res

 

The function pointed to by Fct_Metrics_Get_Res() returns the horizontal (x) and vertical (y) resolution of the images associated with the class.

 

If your class modify the image's resolution (such as the ROI class), then you need to have your own function hooked to the callback.

 

 

Syntax

 

int  (*Fct_Metrics_Get_Res)(

          SliceO_Class *pt,

          void *ima,

          int *x, int *y

)

 

 

Parameters

 

pt

Pointer to the class calling the function.

 

ima

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

 

x, y

New image resolution.

 

 

 

Return value

 

This function return "1" if successful.

 

 

Remarks

 

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

Default callback for all classes except "Root"

 

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

//

//          Class_Class_Metrics_Get_Res

//

//          Get the image's resolution

//

//   We did until we reach "Root". 

//   The root callback will return the actual values.

//

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

int          Class_Class_Metrics_Get_Res( SliceO_Class *pt, void *ima, int *x, int *y )

{

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

          SliceO_Class *parent = pt->Parent_Get_Pt() ;

          return( parent->Fct_Metrics_Get_Res( parent, ima, x, y ) ) ;

}

 

Default callback for "Root" class

 

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

//

//          Class_Root_Metrics_Get_Res

//

//          Get the image's resolution

//

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

int          Class_Root_Metrics_Get_Res( SliceO_Class *pt, void *ima, int *x, int *y )

{

          Tomo_Image *pt_ima = (Tomo_Image *) ima ;

 

          *x = pt_ima->x ;

          *y = pt_ima->y ;

 

          return( 1 ) ;

}

 

The "ROI" class callback

 

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

//          Constructor for the ROI class

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

inline          SliceO_ROI::SliceO_ROI( SliceO_Class *parent, unsigned short id, SliceO_File *file, int bunch, int slice )

{

          this->Class_Id_Set( CLASS_ID_ROI ) ;

          this->Class_Instance_Set( id ) ;

          this->Title_Set( "ROI" ) ;

 

          ...

 

          // ====================================================================

          // ===              Set the callbacks for the Metrics functions                        ===

          // ====================================================================

          Fct_Metrics_Get_Res = Class_ROI_Metrics_Get_Res ;

}

 

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

//

//          Class_ROI_Metrics_Get_Res

//

//          Get the image's resolution

//

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

int          Class_ROI_Metrics_Get_Res( SliceO_Class *pt, void *ima, int *x, int *y )

{

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

          SliceO_Class *parent = pt->Parent_Get_Pt() ;

          if ( parent && parent->Fct_Metrics_Get_Res )

              parent->Fct_Metrics_Get_Res( parent, ima, x, y ) ;

 

          // --- now correct with the values of the ROI ---

          // The "min" and "max" values have been provided

          // by the user through the interface

          SliceO_ROI *roi = (SliceO_ROI *) pt ;          

 

          int max_x = (int) roi->roi_real.max_x ;

          int min_x = (int) roi->roi_real.min_x ;

 

          max_x = CLIP( 0, max_x, *x -1 ) ;

          min_x = CLIP( 0, min_x, *x -1 ) ;

 

          *x = max_x - min_x + 1 ;

 

          int max_y = (int) roi->roi_real.max_y ;

          int min_y = (int) roi->roi_real.min_y ;

 

          max_y = CLIP( 0, max_y, *y -1 ) ;

          min_y = CLIP( 0, min_y, *y -1 ) ;

 

          *y = max_y - min_y + 1 ;

 

          return( 1 ) ;

}

 

See also