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_transpose.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006    
00007 #include "mrilib.h"
00008 
00009 /** Only for 2D images **/
00010 
00011 MRI_IMAGE * mri_transpose_float( MRI_IMAGE * im )
00012 {
00013    MRI_IMAGE * om ;
00014    float * iar , * oar ;
00015    int ii,jj,nx,ny ;
00016 
00017 ENTRY("mri_transpose_float") ;
00018 
00019    if( im == NULL || im->kind != MRI_float ) RETURN(NULL) ;
00020 
00021    nx  = im->nx ; ny = im->ny ;
00022    om  = mri_new( ny , nx , MRI_float ) ;
00023    iar = MRI_FLOAT_PTR(im) ;
00024    oar = MRI_FLOAT_PTR(om) ;
00025 
00026    for( jj=0 ; jj < ny ; jj++ )
00027       for( ii=0 ; ii < nx ; ii++ )
00028          oar[jj+ii*ny] = iar[ii+jj*nx] ;
00029 
00030    MRI_COPY_AUX(om,im) ;
00031    RETURN(om) ;
00032 }
00033 
00034 MRI_IMAGE * mri_transpose_short( MRI_IMAGE * im )
00035 {
00036    MRI_IMAGE * om ;
00037    short * iar , * oar ;
00038    int ii,jj,nx,ny ;
00039 
00040 ENTRY("mri_transpose_short") ;
00041 
00042    if( im == NULL || im->kind != MRI_short ) RETURN(NULL) ;
00043 
00044    nx  = im->nx ; ny = im->ny ;
00045    om  = mri_new( ny , nx , MRI_short ) ;
00046    iar = MRI_SHORT_PTR(im) ;
00047    oar = MRI_SHORT_PTR(om) ;
00048 
00049    for( jj=0 ; jj < ny ; jj++ )
00050       for( ii=0 ; ii < nx ; ii++ )
00051          oar[jj+ii*ny] = iar[ii+jj*nx] ;
00052 
00053    MRI_COPY_AUX(om,im) ;
00054    RETURN(om) ;
00055 }
00056 
00057 MRI_IMAGE * mri_transpose_byte( MRI_IMAGE * im )
00058 {
00059    MRI_IMAGE * om ;
00060    byte * iar , * oar ;
00061    int ii,jj,nx,ny ;
00062 
00063 ENTRY("mri_transpose_byte") ;
00064 
00065    if( im == NULL || im->kind != MRI_byte ) RETURN(NULL) ;
00066 
00067    nx  = im->nx ; ny = im->ny ;
00068    om  = mri_new( ny , nx , MRI_byte ) ;
00069    iar = MRI_BYTE_PTR(im) ;
00070    oar = MRI_BYTE_PTR(om) ;
00071 
00072    for( jj=0 ; jj < ny ; jj++ )
00073       for( ii=0 ; ii < nx ; ii++ )
00074          oar[jj+ii*ny] = iar[ii+jj*nx] ;
00075 
00076    MRI_COPY_AUX(om,im) ;
00077    RETURN(om) ;
00078 }
00079 
00080 MRI_IMAGE * mri_transpose_int( MRI_IMAGE * im )
00081 {
00082    MRI_IMAGE * om ;
00083    int * iar , * oar ;
00084    int ii,jj,nx,ny ;
00085 
00086 ENTRY("mri_transpose_int") ;
00087 
00088    if( im == NULL || im->kind != MRI_int ) RETURN(NULL) ;
00089 
00090    nx  = im->nx ; ny = im->ny ;
00091    om  = mri_new( ny , nx , MRI_int ) ;
00092    iar = MRI_INT_PTR(im) ;
00093    oar = MRI_INT_PTR(om) ;
00094 
00095    for( jj=0 ; jj < ny ; jj++ )
00096       for( ii=0 ; ii < nx ; ii++ )
00097          oar[jj+ii*ny] = iar[ii+jj*nx] ;
00098 
00099    MRI_COPY_AUX(om,im) ;
00100    RETURN(om) ;
00101 }
00102 
00103 MRI_IMAGE * mri_transpose_complex( MRI_IMAGE * im )
00104 {
00105    MRI_IMAGE * om ;
00106    complex * iar , * oar ;
00107    int ii,jj,nx,ny ;
00108 
00109 ENTRY("mri_transpose_complex") ;
00110 
00111    if( im == NULL || im->kind != MRI_complex ) RETURN(NULL) ;
00112 
00113    nx  = im->nx ; ny = im->ny ;
00114    om  = mri_new( ny , nx , MRI_complex ) ;
00115    iar = MRI_COMPLEX_PTR(im) ;
00116    oar = MRI_COMPLEX_PTR(om) ;
00117 
00118    for( jj=0 ; jj < ny ; jj++ )
00119       for( ii=0 ; ii < nx ; ii++ )
00120          oar[jj+ii*ny] = iar[ii+jj*nx] ;
00121 
00122    MRI_COPY_AUX(om,im) ;
00123    RETURN(om) ;
00124 }
00125 
00126 MRI_IMAGE * mri_transpose_rgbyte( MRI_IMAGE * im )
00127 {
00128    MRI_IMAGE * om ;
00129    rgbyte * iar , * oar ;
00130    int ii,jj,nx,ny ;
00131 
00132 ENTRY("mri_transpose_rgbyte") ;
00133 
00134    if( im == NULL || im->kind != MRI_rgb ) RETURN(NULL) ;
00135 
00136    nx  = im->nx ; ny = im->ny ;
00137    om  = mri_new( ny , nx , MRI_rgb ) ;
00138    iar = (rgbyte *) MRI_RGB_PTR(im) ;
00139    oar = (rgbyte *) MRI_RGB_PTR(om) ;
00140 
00141    for( jj=0 ; jj < ny ; jj++ )
00142       for( ii=0 ; ii < nx ; ii++ )
00143          oar[jj+ii*ny] = iar[ii+jj*nx] ;
00144 
00145    MRI_COPY_AUX(om,im) ;
00146    RETURN(om) ;
00147 }
00148 
00149 
00150 MRI_IMAGE * mri_transpose( MRI_IMAGE * im )
00151 {
00152    if( im == NULL ) return NULL ;
00153 
00154    switch( im->kind ){
00155       case MRI_float  : return mri_transpose_float  (im) ;
00156       case MRI_short  : return mri_transpose_short  (im) ;
00157       case MRI_byte   : return mri_transpose_byte   (im) ;
00158       case MRI_int    : return mri_transpose_int    (im) ;
00159       case MRI_complex: return mri_transpose_complex(im) ;
00160       case MRI_rgb:     return mri_transpose_rgbyte (im) ;
00161    }
00162    return NULL ;
00163 }
 

Powered by Plone

This site conforms to the following standards: