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

imaclear.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: imaclear.c,v 1.1 2005/09/09 08:22:45 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 * 00038 * Description : initialisation d'images. 00039 * 00040 **************************************************************************/ 00041 #include <string.h> // For memcpy and memset 00042 #include "idima.h" 00043 #include "iderr.h" 00044 #include "idprint.h" 00045 00046 /* FUNCTION DESCRIPTION ************************************************** 00047 * 00048 * IdImaClear (fonction) 00049 * 00050 * RESUME: initialisation d'une image a 0 00051 * 00052 * DESCRIPTION: Initialisation d'une image a 0. 00053 * 00054 * SYNTAXE: PPIMAGE imResult = IdImaClear (PPIMAGE imResult); 00055 * 00056 * RETOUR: type : PPIMAGE 00057 * role : Pointeur vers l'image initialisee. Zero si echec. 00058 * 00059 * PARAMETRES: nom : imResult 00060 * type : PPIMAGE 00061 * role : Pointeur vers l'image a initialiser. 00062 * 00063 * FICHIER: imaclear.c 00064 * 00065 * EXEMPLE: if ( IdImaClear(image)==0 ) 00066 * IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00067 * 00068 ******************************************************** END DESCRIPTION */ 00069 00070 PPIMAGE IdImaClear ( PPIMAGE image ) 00071 { 00072 int y; 00073 int taille_ligne; 00074 /* Controle de l'image **/ 00075 if ( !image ) { /* Alloc. si necessaire ***/ 00076 IdErrno = IDERR_POINTER_IS_NULL; 00077 return 0; 00078 }else if ( IdLibidoType(image) != IMA) { 00079 IdErrno = IDERR_WRONG_TYPE; 00080 return 0; 00081 } 00082 taille_ligne = (IdImaType(image)==IMA_BIT) 00083 ? ( (IdImaDimX(image)+7)>>3 ) 00084 : (IdImaDimX(image)*IdSizeOfType(image)) ; 00085 /* Calcul du resultat *****/ 00086 for ( y=0; y<IdImaDimY(image); y++ ) 00087 memset( image[y], 0, taille_ligne ); 00088 00089 IdImaSetUsedNbX(image,0); 00090 IdImaSetUsedNbY(image,0); 00091 00092 return image; 00093 } 00094 00095 00096 /* FUNCTION DESCRIPTION ************************************************** 00097 00098 IdImaSetValueAnyType (fonction) 00099 00100 RESUME: Initialisation d'une image UCHAR a une valeur donnee 00101 00102 DESCRIPTION: Initialisation d'une image (non COMPLEX) a une valeur donnee 00103 00104 SYNTAXE: PPIMAGE imResult = IdImaSetValueAnyType (PPIMAGE imResult, double valeur); 00105 00106 RETOUR: type : PPIMAG 00107 role : Pointeur vers l'image initialisee. Zero si echec. 00108 00109 PARAMETRES: nom : imResult 00110 type : PPIMAGE 00111 role : Pointeur vers l'image a initialiser. 00112 00113 nom : valeur 00114 type : double 00115 role : valeur avec laquelle l'image sera initialisee. 00116 00117 FICHIER: imaclear.c 00118 00119 EXEMPLE: if ( IdImaSetValueAnyType(image,128)==0 ) 00120 IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00121 00122 ******************************************************** END DESCRIPTION */ 00123 00124 #define TT(t1) \ 00125 for (j=0;j<IdImaDimX(image);j++) \ 00126 { \ 00127 ((t1)image)[0][j]= valeur; \ 00128 } 00129 00130 PPIMAGE IdImaSetValueAnyType(image, valeur) 00131 PPIMAGE image; 00132 double valeur; 00133 { 00134 int y; 00135 int j = 0; /* FB 24-01-2000 */ 00136 int taille_ligne; 00137 /* Controle de l'image **/ 00138 if ( !image ) { 00139 IdErrno = IDERR_POINTER_IS_NULL; 00140 return (PPIMAGE)0; 00141 } 00142 00143 taille_ligne = IdImaDimX(image)*IdSizeOfType(image) ; 00144 00145 if ( (IdImaType(image) == IMA_UCHAR) || (IdImaType(image) == IMA_CHAR) ) 00146 { 00147 00148 for ( y=0; y<IdImaDimY(image); y++ ) 00149 memset( image[y], valeur, taille_ligne ); 00150 } 00151 00152 else /* autres Types */ 00153 { 00154 00155 switch(IdImaType(image)) 00156 { 00157 case IMA_UCHAR: TT(PPIMAGE_UCHAR); break; 00158 case IMA_CHAR: TT(PPIMAGE_CHAR); break; 00159 case IMA_USHORT: TT(PPIMAGE_USHORT); break; 00160 case IMA_SHORT: TT(PPIMAGE_SHORT); break; 00161 case IMA_LONG: TT(PPIMAGE_LONG); break; 00162 case IMA_ULONG: TT(PPIMAGE_ULONG); break; 00163 case IMA_FLOAT: TT(PPIMAGE_FLOAT); break; 00164 case IMA_DOUBLE: TT(PPIMAGE_DOUBLE); break; 00165 default: 00166 { 00167 IdPrintf("Type %d non traitable par la fonction IdImaSetValueAnyType !\n",IdImaType(image)); 00168 } 00169 } /* Fin du switch */ 00170 00171 } /*fin else */ 00172 00173 00174 for ( y=0; y<IdImaDimY(image); y++ ) 00175 memcpy( image[y], image[0], taille_ligne ); 00176 00177 IdImaSetUsedNbX(image,IdImaDimX(image)); 00178 IdImaSetUsedNbY(image,IdImaDimY(image)); 00179 00180 return image; 00181 } 00182 00183 00184 /* FUNCTION DESCRIPTION ************************************************** 00185 00186 IdImaSetValue (fonction) 00187 00188 RESUME: Initialisation d'une image UCHAR a une valeur donnee 00189 00190 DESCRIPTION: Initialisation d'une image UCHAR a une valeur donnee 00191 00192 SYNTAXE: PPIMAGE_UCHAR imResult = IdImaSetValue (PPIMAGE_UCHAR imResult, int valeur); 00193 00194 RETOUR: type : PPIMAGE_UCHAR 00195 role : Pointeur vers l'image initialisee. Zero si echec. 00196 00197 PARAMETRES: nom : imResult 00198 type : PPIMAGE_UCHAR 00199 role : Pointeur vers l'image a initialiser. 00200 00201 nom : valeur 00202 type : int 00203 role : valeur avec laquelle l'image sera initialisee. 00204 00205 FICHIER: imaclear.c 00206 00207 EXEMPLE: if ( IdImaSetValue(image,128)==0 ) 00208 IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00209 00210 ******************************************************** END DESCRIPTION */ 00211 00212 PPIMAGE_UCHAR IdImaSetValue ( image , valeur) 00213 PPIMAGE_UCHAR image; 00214 { 00215 int y; 00216 int taille_ligne; 00217 /* Controle de l'image **/ 00218 if ( !image ) { /* Alloc. si necessaire ***/ 00219 IdErrno = IDERR_POINTER_IS_NULL; 00220 return (PPIMAGE_UCHAR)0; 00221 } else if ( IdImaType(image) != IMA_UCHAR) { 00222 IdErrno = IDERR_WRONG_TYPE; 00223 return (PPIMAGE_UCHAR)0; 00224 } 00225 00226 taille_ligne = IdImaDimX(image)*IdSizeOfType(image) ; 00227 /* Calcul du resultat *****/ 00228 for ( y=0; y<IdImaDimY(image); y++ ) 00229 memset( image[y], valeur, taille_ligne ); 00230 00231 IdImaSetUsedNbX(image,IdImaDimX(image)); 00232 IdImaSetUsedNbY(image,IdImaDimY(image)); 00233 00234 return image; 00235 } 00236 00237 00238 /* FUNCTION DESCRIPTION ************************************************** 00239 00240 IdImaCopy (fonction) 00241 00242 RESUME: Copie une image ds une autre 00243 00244 DESCRIPTION: Copie les pixels d'une image dans une autre de meme type et 00245 memes dimensions. 00246 00247 SYNTAXE: PPIMAGE imDest = IdImaCopy(PPIMAGE imSource, PPIMAGE imDest); 00248 00249 RETOUR: type : PPIMAGE 00250 role : Pointeur vers l'image resultat (imd). 00251 00252 PARAMETRES: 00253 nom : imSource 00254 type : PPIMAGE 00255 role : Image d'origine. 00256 00257 nom : imDest 00258 type : PPIMAGE 00259 role : Image destination de meme type et dim. que ims. 00260 00261 FICHIER: imacast.c 00262 00263 EXEMPLE: if( !IdImaCopy (ims,imd) ) IdErrPrintf(IdErrMsg(IdErrno)); 00264 00265 ******************************************************** END DESCRIPTION */ 00266 PPIMAGE IdImaCopy (ims,imd) 00267 PPIMAGE ims,imd; 00268 { 00269 int i; 00270 if ( !IdImaSameSizeAndType(ims,imd) ) { 00271 IdErrno = IDERR_WRONG_DIM; 00272 return 0; 00273 } 00274 for(i=0;i<IdImaDimY(imd);i++) 00275 memcpy (imd[i],ims[i],IdImaDimX(imd)*IdSizeOfType(imd)); 00276 return imd; 00277 }

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