1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| /* Fonction */
void minmax(double *buff,int len,
double *min, double *max){
int i;
*max=0;
*min=100000000;
unsigned char *toto;
for (i=0;i<len;i++){
toto = (unsigned char *)&buff[i];
printf("toto: %x %x %x %x %x %x %x %x\n", toto[0], toto[1], toto[2], toto[3], toto[4], toto[5], toto[6], toto[7]);
printf("buff, i: %e, %d\n", buff[i], i);
if (buff[i] < *min)
*min = buff[i];
printf("min, i: %1.7e , %d\n",*min, i);
if (buff[i] > *max)
*max = buff[i];
printf("max, i: %1.7e , %d\n\n",*max, i);
}
}
int main(int argv, char* argc []) {
double *buff;
int img_size;
double min;
double max;
int i,n;
FILE *fdFic;
if (argv != 3) {
/* traitement d'erreur */
}
if ((img_size = atoi(argc[1]))==0) {
/* traitement d'erreur */
}
printf("img_size: %d\n", img_size);
printf("filename: %s\n", argc[2]);
if ((fdFic=fopen(argc[2],"rb"))==NULL)
{
/* traitement d'erreur */
}
buff= malloc(img_size*sizeof(double));
if((n=fread(buff,sizeof(double),img_size,fdFic)) != img_size)
{
/* Traitement d'erreur */
}
/* Appel de la fonction de recherche min et max */
minmax(buff,img_size,&min,&max);
printf("%1.7e \n%1.7e\n",min,max);
free(buff);
fclose(fdFic);
return 0;
}
/* On passe en paramètres la taille de l'image et le nom du fichier */ |
Partager