#include "Niveaugris.h"

//Fonction renvoyant dans un fichier les niveaux de gris
void Histo(Piquesel** tableau,char* sortie,int taille0,int taille1){
	int i,j;
	int hist[255];
	int taille[2] = {0};
	taille[0]=taille0;
	taille[1]=taille1;
	for (i=0; i<256; i++){
		hist[i]=0;
	}
	for (i=0 ; i<taille[1] ; i++){
		for (j=0; j<taille[0]; j++){
			hist[tableau[i][j].Red]=hist[tableau[i][j].Red]+1;
		}
	}
	printf("\n%s\n",sortie);
	FILE* meow = NULL;
	meow = fopen(sortie,"w+");
	if (meow == NULL){
		printf("Impossible d ouvrir le fichier\n");
	}else{
		for (i=0; i<256; i++){
			fprintf(meow, "%d %d\n", i,hist[i]);
		}
		fclose(meow);
	}
}

