Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

mri_scalize.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

MRI_IMAGEmri_scalize (MRI_IMAGE *inim, int kind, float *sfac)

Function Documentation

MRI_IMAGE* mri_scalize MRI_IMAGE   inim,
int    kind,
float *    sfac
 

Scale a float image to an integer type [20 Oct 2003]:

  • inim = MRI_float image
  • kind = integer type to scale to (MRI_byte, MRI_short, MRI_int)
  • return = scaled image
  • *sfac = scale factor (nonzero on input ==> smallest value allowed)

Definition at line 10 of file mri_scalize.c.

References EDIT_coerce_scale_type(), ENTRY, MRI_IMAGE::kind, MCW_vol_amax(), MRI_IS_INT_TYPE, mri_new_conforming, MRI_IMAGE::nvox, and RETURN.

Referenced by THD_warp3D().

00011 {
00012    float gtop , fac , fimfac ;
00013    MRI_IMAGE *outim ;
00014 
00015 ENTRY("mri_scalize") ;
00016 
00017    if( inim == NULL            ||
00018        inim->kind != MRI_float ||
00019       sfac == NULL             ||
00020       !MRI_IS_INT_TYPE(kind)     ) RETURN(NULL) ;
00021 
00022    fac = *sfac ; if( fac < 0.0 ) fac = 0.0 ;
00023 
00024    gtop = MCW_vol_amax( inim->nvox,1,1,MRI_float,MRI_FLOAT_PTR(inim) ) ;
00025    if( gtop == 0.0 ){
00026      fimfac = fac ;
00027    } else {
00028      fimfac = gtop / MRI_TYPE_maxval[kind] ;
00029      if( fimfac < fac ) fimfac = fac ;
00030    }
00031    outim = mri_new_conforming( inim , kind ) ;
00032    if( fimfac > 0.0 )
00033      EDIT_coerce_scale_type( inim->nvox , 1.0/fimfac ,
00034                              MRI_float , MRI_FLOAT_PTR(inim) ,
00035                              outim->kind , mri_data_pointer(outim) ) ;
00036    *sfac = fimfac ; RETURN(outim) ;
00037 }
 

Powered by Plone

This site conforms to the following standards: