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

sigmm.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: sigmm.c,v 1.1 2005/09/09 08:22:53 bellet 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 /* 00037 * Calcule le max et le min d'un signal non COMPLEX 00038 */ 00039 #include <stdio.h> 00040 #include <float.h> 00041 #include "idsig.h" 00042 #include "iderr.h" 00043 #include "idprint.h" 00044 00045 00054 double 00055 IdSigMax(PSIGNAL sig) 00056 { 00057 #define CC(t1) { for (i=0;i<X;i++) \ 00058 if (((t1)sig)[i]>maxi) \ 00059 {maxi = (double) ((t1)sig)[i]; \ 00060 } \ 00061 } 00062 00063 double maxi; 00064 int i, X; 00065 00066 X = IdSigDimX(sig); 00067 maxi = -999999.99; 00068 switch (IdSigType(sig)) { 00069 case SIG_CHAR: 00070 CC(PSIGNAL_CHAR); 00071 break; 00072 case SIG_UCHAR: 00073 CC(PSIGNAL_UCHAR); 00074 break; 00075 case SIG_SHORT: 00076 CC(PSIGNAL_SHORT); 00077 break; 00078 case SIG_USHORT: 00079 CC(PSIGNAL_USHORT); 00080 break; 00081 case SIG_LONG: 00082 CC(PSIGNAL_LONG); 00083 break; 00084 case SIG_ULONG: 00085 CC(PSIGNAL_ULONG); 00086 break; 00087 case SIG_FLOAT: 00088 CC(PSIGNAL_FLOAT); 00089 break; 00090 case SIG_DOUBLE: 00091 CC(PSIGNAL_DOUBLE); 00092 break; 00093 default: 00094 IdErrPrintf 00095 ("Type %d non traitable par la fonction IdSigMax !\n", 00096 IdSigType(sig)); 00097 IdExit(0); 00098 } 00099 00100 return (maxi); 00101 } 00102 00103 #define BB(t1) { for (i=0;i<X;i++) \ 00104 if (((t1)sig)[i]<mini) \ 00105 {mini = (double) ((t1)sig)[i]; \ 00106 } \ 00107 } 00108 00117 double 00118 IdSigMin(PSIGNAL sig) 00119 { 00120 double mini; 00121 int i, X; 00122 00123 X = IdSigDimX(sig); 00124 mini = 999999.99; 00125 switch (IdSigType(sig)) { 00126 case SIG_CHAR: 00127 BB(PSIGNAL_CHAR); 00128 break; 00129 case SIG_UCHAR: 00130 BB(PSIGNAL_UCHAR); 00131 break; 00132 case SIG_SHORT: 00133 BB(PSIGNAL_SHORT); 00134 break; 00135 case SIG_USHORT: 00136 BB(PSIGNAL_USHORT); 00137 break; 00138 case SIG_LONG: 00139 BB(PSIGNAL_LONG); 00140 break; 00141 case SIG_ULONG: 00142 BB(PSIGNAL_ULONG); 00143 break; 00144 case SIG_FLOAT: 00145 BB(PSIGNAL_FLOAT); 00146 break; 00147 case SIG_DOUBLE: 00148 BB(PSIGNAL_DOUBLE); 00149 break; 00150 default: 00151 IdErrPrintf 00152 ("Type %d non traitable par la fonction IdSigMin !\n", 00153 IdSigType(sig)); 00154 IdExit(0); 00155 } 00156 return (mini); 00157 } 00158 00159 #define BB2(t1) { for (i=0;i<X;i++) { \ 00160 if ((double)((t1)sig)[i]<*mini) \ 00161 {*mini = (double) ((t1)sig)[i]; \ 00162 } \ 00163 if ((double)((t1)sig)[i]>*maxi) \ 00164 {*maxi = (double) ((t1)sig)[i]; \ 00165 } } \ 00166 } 00167 00178 int 00179 IdSigMinMax(PSIGNAL sig, double *mini, double *maxi) 00180 { 00181 int i, X, retCode = 1; 00182 X = IdSigDimX(sig); 00183 00184 *mini = FLT_MAX; 00185 *maxi = -FLT_MAX; 00186 switch (IdSigType(sig)) { 00187 case SIG_CHAR: 00188 BB2(PSIGNAL_CHAR); 00189 break; 00190 case SIG_UCHAR: 00191 BB2(PSIGNAL_UCHAR); 00192 break; 00193 case SIG_SHORT: 00194 BB2(PSIGNAL_SHORT); 00195 break; 00196 case SIG_USHORT: 00197 BB2(PSIGNAL_USHORT); 00198 break; 00199 case SIG_LONG: 00200 BB2(PSIGNAL_LONG); 00201 break; 00202 case SIG_ULONG: 00203 BB2(PSIGNAL_ULONG); 00204 break; 00205 case SIG_FLOAT: 00206 BB2(PSIGNAL_FLOAT); 00207 break; 00208 case SIG_DOUBLE: 00209 BB2(PSIGNAL_DOUBLE); 00210 break; 00211 default: 00212 IdErrPrintf 00213 ("Type %d non traitable par la fonction IdSigMinMax !\n", 00214 IdSigType(sig)); 00215 retCode = 0; 00216 } 00217 return (retCode); 00218 } 00219 00220 #define BB3(t1) { for (i=deb;i<fin;i++) { \ 00221 if ((double)((t1)sig)[i]<*mini) \ 00222 {*mini = (double) ((t1)sig)[i]; \ 00223 } \ 00224 if ((double)((t1)sig)[i]>*maxi) \ 00225 {*maxi = (double) ((t1)sig)[i]; \ 00226 } } \ 00227 } 00228 00241 int 00242 IdSigMinMaxInterv(PSIGNAL sig, int deb, int fin, double *mini, double *maxi) 00243 { 00244 int i, X, retCode = 1; 00245 00246 X = IdSigDimX(sig); 00247 00248 if (deb < 0) 00249 deb = 0; 00250 if (fin > X) 00251 fin = X; 00252 00253 *mini = FLT_MAX; 00254 *maxi = -FLT_MAX; 00255 switch (IdSigType(sig)) { 00256 case SIG_CHAR: 00257 BB3(PSIGNAL_CHAR); 00258 break; 00259 case SIG_UCHAR: 00260 BB3(PSIGNAL_UCHAR); 00261 break; 00262 case SIG_SHORT: 00263 BB3(PSIGNAL_SHORT); 00264 break; 00265 case SIG_USHORT: 00266 BB3(PSIGNAL_USHORT); 00267 break; 00268 case SIG_LONG: 00269 BB3(PSIGNAL_LONG); 00270 break; 00271 case SIG_ULONG: 00272 BB3(PSIGNAL_ULONG); 00273 break; 00274 case SIG_FLOAT: 00275 BB3(PSIGNAL_FLOAT); 00276 break; 00277 case SIG_DOUBLE: 00278 BB3(PSIGNAL_DOUBLE); 00279 break; 00280 default: 00281 IdErrPrintf 00282 ("Type %d non traitable par la fonction IdSigMinMaxInterv !\n", 00283 IdSigType(sig)); 00284 retCode = 0; 00285 } 00286 return (retCode); 00287 }

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