Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

output.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: output.c,v 1.7 2005/09/09 11:42:31 yougz Exp $ 00003 ************************************************************************** 00004 This software is governed by the CeCILL license under French law and 00005 abiding by the rules of distribution of free software. You can use, 00006 modify and/ or redistribute the software under the terms of the CeCILL 00007 license as circulated by CEA, CNRS and INRIA at the following URL 00008 "http://www.cecill.info". 00009 00010 As a counterpart to the access to the source code and rights to copy, 00011 modify and redistribute granted by the license, users are provided only 00012 with a limited warranty and the software's author, the holder of the 00013 economic rights, and the successive licensors have only limited 00014 liability. 00015 00016 In this respect, the user's attention is drawn to the risks associated 00017 with loading, using, modifying and/or developing or reproducing the 00018 software by the user in light of its specific status of free software, 00019 that may mean that it is complicated to manipulate, and that also 00020 therefore means that it is reserved for developers and experienced 00021 professionals having in-depth computer knowledge. Users are therefore 00022 encouraged to load and test the software's suitability as regards their 00023 requirements in conditions enabling the security of their systems and/or 00024 data to be ensured and, more generally, to use and operate it in the 00025 same conditions as regards security. 00026 00027 The fact that you are presently reading this means that you have had 00028 knowledge of the CeCILL license and that you accept its terms. 00029 00030 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00031 l'Image). All rights reserved. See License.txt for details. 00032 00033 Version 1.0 05/09/2005 00034 *************************************************************************/ 00035 00036 #include "output.h" 00037 00045 void WriteVolRF(PPPVOLUME_COMPLEX_DOUBLE volrf) 00046 { 00047 PPPVOLUME_DOUBLE re,im; 00048 int i,j,k; 00049 int X,Y,Z; 00050 00051 X=IdVolDimX(volrf); 00052 Y=IdVolDimY(volrf); 00053 Z=IdVolDimZ(volrf); 00054 00055 re = (PPPVOLUME_DOUBLE) IdVolAlloc(X,Y,Z,VOL_DOUBLE); 00056 im = (PPPVOLUME_DOUBLE) IdVolAlloc(X,Y,Z,VOL_DOUBLE); 00057 for (k=0;k<Z;k++) for (i=0;i<Y;i++) for (j=0;j<X;j++) 00058 { 00059 re[k][i][j] = volrf[k][i][j].re; 00060 im[k][i][j] = volrf[k][i][j].im; 00061 } 00062 IdVolWriteRawFile("rf_re.vol",(PPPVOLUME)re); 00063 IdVolWriteRawFile("rf_im.vol",(PPPVOLUME)im); 00064 00065 IdVolFree(re); 00066 IdVolFree(im); 00067 00068 } 00069 00078 void WriteVolRecUchar(PPPVOLUME_FLOAT volrec, char * volname) 00079 { 00080 int X,Y,Z; 00081 PPPVOLUME_UCHAR voluchar; 00082 PPIMAGE_UCHAR imauchar; 00083 double min=0.0; 00084 double max=0.0; 00085 double dyn; 00086 int i,j,k; 00087 00088 IdVolWriteRawFile("recfloat.raw",(PPPVOLUME)volrec); 00089 X=IdVolDimX(volrec); 00090 Y=IdVolDimY(volrec); 00091 Z=IdVolDimZ(volrec); 00092 00093 IdVolMinMax((PPPVOLUME)volrec,&min,&max); 00094 dyn=(max-min); 00095 if (Z==1) /* Writing a 2D image */ 00096 { 00097 imauchar = (PPIMAGE_UCHAR) IdImaAlloc(X,Y,IMA_UCHAR); 00098 for (i=0;i<Y;i++) for (j=0;j<X;j++) 00099 imauchar[i][j]=(unsigned char)(((volrec[0][i][j]-min)/dyn)*255.0+0.5); 00100 IdImaWriteRawFile(volname,(PPIMAGE)imauchar); 00101 IdImaFree(imauchar); 00102 } 00103 else 00104 { 00105 voluchar = (PPPVOLUME_UCHAR) IdVolAlloc(X,Y,Z,VOL_UCHAR); 00106 for (k=0;k<Z;k++) for (i=0;i<Y;i++) for (j=0;j<X;j++) 00107 voluchar[k][i][j]=(unsigned char)(((volrec[k][i][j]-min)/dyn)*255.0+0.5); 00108 IdVolWriteRawFile(volname,(PPPVOLUME)voluchar); 00109 IdVolFree(voluchar); 00110 } 00111 } 00112 00120 void WriteSignalRFModule(EXPERIENCE3D * expr, char * volname) 00121 { 00122 PPPVOLUME_FLOAT rfmod; 00123 00124 rfmod = (PPPVOLUME_FLOAT) GetSignalRFModuleFromExperience(expr); 00125 IdVolWriteRawFile(volname,(PPPVOLUME_FLOAT)rfmod); 00126 IdVolFree(rfmod); 00127 } 00128 00136 void WriteRecIFFTVolumeModule(EXPERIENCE3D * expr, char * volname) 00137 { 00138 PPPVOLUME_FLOAT module; 00139 00140 module= (PPPVOLUME_FLOAT) RecVolIFFTModule(expr); 00141 IdVolWriteRawFile(volname,module); 00142 00143 IdVolFree(module); 00144 } 00145 00153 void WriteRecIFFTVolumePhase(EXPERIENCE3D * expr, char * volname) 00154 { 00155 PPPVOLUME_FLOAT phase; 00156 00157 phase= (PPPVOLUME_FLOAT) RecVolIFFTPhase(expr); 00158 IdVolWriteRawFile(volname,phase); 00159 00160 IdVolFree(phase); 00161 } 00162 00171 void MagstateWatch(EXPERIENCE3D* expr,char * filename) 00172 { 00173 int g,ii; 00174 FILE *fic; 00175 int x,y; 00176 00177 x=expr->nfovx/2; 00178 y=expr->nfovy/2; 00179 fic=fopen(filename,"w"); 00180 for(g=0;g<expr->nfovz;g++) 00181 { 00182 for(ii=0;ii<=2;ii++) 00183 { 00184 fprintf(fic,"%lf ",expr->magstate[ii][x][y][g]); 00185 } 00186 fprintf(fic,"%lf ",sqrt(expr->magstate[0][x][y][g]*expr->magstate[0][x][y][g]+expr->magstate[1][x][y][g]*expr->magstate[1][x][y][g])); 00187 fprintf(fic,"%lf ",atan2(expr->magstate[1][x][y][g],expr->magstate[0][x][y][g])*180/M_PI); 00188 fprintf(fic,"\n"); 00189 } 00190 fclose(fic); 00191 }

Generated on Wed Oct 19 09:28:34 2005 for SIMRI3D by doxygen 1.3.7