little refactoring

This commit is contained in:
tTh 2023-07-07 10:08:57 +02:00
parent 3fd604b14a
commit e9ca450584

View File

@ -13,12 +13,34 @@
int verbosity;
/* ------------------------------------------------------------------- */
/* for debug purpose */
int printf_histo_gray(char *fname, int histo[], int nbre)
{
FILE *fp;
int idx;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__,
fname, histo, nbre);
#endif
if (NULL == (fp = fopen(fname, "w"))) {
perror(fname);
exit(1);
}
for (idx=0; idx<nbre; idx++) {
fprintf(fp, "%6d %8d\n", idx, histo[idx]);
}
fclose(fp);
return -1;
}
/* ------------------------------------------------------------------- */
/* for debug purpose */
int calcul_histo_gray(FloatImg *img, char *fname, int nbslots, float *pmax)
{
int offset, nbpix, ival;
FILE *fp;
float pixel, minp, maxp;
int *counts;
@ -59,14 +81,10 @@ for (offset=0; offset<nbpix; offset++) {
// fprintf(stderr, "%6d %10.6f %i\n", offset, pixel, ival);
}
if (NULL == (fp = fopen(fname, "w"))) {
perror(fname);
exit(1);
if (NULL != fname)
{
printf_histo_gray(fname, counts, nbslots);
}
for (ival=0; ival<nbslots; ival++) {
fprintf(fp, "%6d %8d\n", ival, counts[ival]);
}
fclose(fp);
/* garbage collect stuff */
free(counts);