little refactoring
This commit is contained in:
parent
3fd604b14a
commit
e9ca450584
@ -13,12 +13,34 @@
|
|||||||
|
|
||||||
int verbosity;
|
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 */
|
/* for debug purpose */
|
||||||
int calcul_histo_gray(FloatImg *img, char *fname, int nbslots, float *pmax)
|
int calcul_histo_gray(FloatImg *img, char *fname, int nbslots, float *pmax)
|
||||||
{
|
{
|
||||||
int offset, nbpix, ival;
|
int offset, nbpix, ival;
|
||||||
FILE *fp;
|
|
||||||
float pixel, minp, maxp;
|
float pixel, minp, maxp;
|
||||||
int *counts;
|
int *counts;
|
||||||
|
|
||||||
@ -59,14 +81,10 @@ for (offset=0; offset<nbpix; offset++) {
|
|||||||
// fprintf(stderr, "%6d %10.6f %i\n", offset, pixel, ival);
|
// fprintf(stderr, "%6d %10.6f %i\n", offset, pixel, ival);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == (fp = fopen(fname, "w"))) {
|
if (NULL != fname)
|
||||||
perror(fname);
|
{
|
||||||
exit(1);
|
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 */
|
/* garbage collect stuff */
|
||||||
free(counts);
|
free(counts);
|
||||||
|
Loading…
Reference in New Issue
Block a user