Compare commits

..

No commits in common. "6ffc08188d1eaf081b7898e6b85efb099311ba41" and "4597598b0293c6e719f187110bca4666333bda47" have entirely different histories.

10 changed files with 13 additions and 87 deletions

1
.gitignore vendored
View File

@ -12,7 +12,6 @@ gmon.out
*.swp
*.pnm
*.pgm
*.fimg
essai
MANIFEST

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 169
#define FIMG_VERSION 167
/*
* in memory descriptor
@ -54,7 +54,6 @@ typedef struct {
#define FILE_TYPE_BMP 7
#define FILE_TYPE_EXR 8
#define FILE_TYPE_DICOM 9
#define FILE_TYPE_PGM 10
/* lib/contrast.c */
#define CONTRAST_NONE 0
@ -152,7 +151,6 @@ int fimg_export_picture(FloatImg *pic, char *fname, int flags);
/* PNM files module */
int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
int fimg_save_as_pgm(FloatImg *head, char *fname, int flags);
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
double fimg_timer_set(int whot);

View File

@ -59,10 +59,6 @@ switch(filetype) {
fprintf(stderr, "%s: file type EXR experimental\n", __func__);
foo = fimg_save_as_exr(pic, fname, 0);
break;
case FILE_TYPE_PGM:
fprintf(stderr, "XXX %s EXPERIMENT!\n", __func__);
foo = fimg_save_as_pgm(pic, fname, 0);
break;
default:
foo = -1789;
break;

View File

@ -100,7 +100,6 @@ if (!strcasecmp(name, "tif" )) return FILE_TYPE_TIFF;
if (!strcasecmp(name, "fits")) return FILE_TYPE_FITS;
if (!strcasecmp(name, "exr")) return FILE_TYPE_EXR;
if (!strcasecmp(name, "dicom")) return FILE_TYPE_EXR;
if (!strcasecmp(name, "pgm" )) return FILE_TYPE_PGM;
return -1;
}

View File

@ -196,51 +196,3 @@ fputs("\n", fp); fclose(fp);
return 0;
}
/* ---------------------------------------------------------------- */
/* nouveau 10 fevrier 2022 */
int fimg_save_as_pgm(FloatImg *src, char *fname, int flags)
{
FILE *fp;
float maximum, fk;
int area, idx, printed;
float accu;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %s %d )\n", __func__, src, fname, flags);
#endif
if ( src->type != FIMG_TYPE_RGB ) {
#if DEBUG_LEVEL
fprintf(stderr, "%s : type %d is bad.\n", __func__, src->type);
#endif
return -1;
}
if (NULL==(fp=fopen(fname, "w"))) {
perror(fname);
return -2;
}
fprintf(fp, "P2\n%d\n%d\n65532\n\n", src->width, src->height);
area = src->width * src->height;
maximum = fimg_get_maxvalue(src);
fk = maximum / 65535.0;
printed = 0;
for (idx=0; idx<area; idx++) {
accu = (src->R[idx] + src->G[idx] + src->B[idx]) / 3.0;
printed += fprintf(fp, "%d ", (int)(accu/fk));
if (printed > 72) {
fputs("\n", fp);
printed = 0;
}
}
fclose(fp);
return 0;
}

18
lib/t.c
View File

@ -83,13 +83,12 @@ return 0;
}
/* ---------------------------------------------------------------- */
int essai_2gray(FloatImg *picz, char *basename)
int essai_2gray(FloatImg *picz, char *outname)
{
int foo;
FloatImg gray;
char outname[200];
fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, picz, basename);
fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, picz, outname);
foo = fimg_create(&gray, picz->width, picz->height, FIMG_TYPE_GRAY);
if (foo) {
@ -102,16 +101,9 @@ if (foo) {
exit(1);
}
strcpy(outname,basename); strcat(outname, ".pnm");
foo = fimg_save_as_pnm(&gray, outname, 0);
if (foo) {
fprintf(stderr, "%s : err %d on save_as_PNM\n", __func__, foo);
exit(1);
}
strcpy(outname,basename); strcat(outname, ".pgm");
foo = fimg_save_as_pgm(&gray, outname, 0);
if (foo) {
fprintf(stderr, "%s : err %d on save_as_PGM\n", __func__, foo);
fprintf(stderr, "%s : err %d on save_as_pnm\n", __func__, foo);
exit(1);
}
@ -269,8 +261,8 @@ if (verbosity) {
fimg_print_sizeof();
}
foo = essai_2gray(NULL, "quux");
fprintf(stderr, "retour essai -> %d\n", foo);
foo = essai_contraste("quux.fimg");
fprintf(stderr, "retour essai contraste -> %d\n", foo);
// foo = essai_clone_et_copy(0);
// fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo);

View File

@ -43,7 +43,7 @@ puts("\t-v\tincrease verbosity");
puts("\t-o\tname of output file");
puts("\t-g\tconvert to gray level");
puts("");
if (verbosity) { puts("Xperiment"); fimg_print_version(1); }
if (verbosity) { puts(""); fimg_print_version(1); }
exit(0);
}
/* --------------------------------------------------------------------- */
@ -54,7 +54,6 @@ int opt;
int compte = 0;
int to_gray = 0;
int experiment = 0;
char *output_file = "out.fimg";
FloatImg accu, temp;
int src_loaded = 0;
@ -62,13 +61,12 @@ float vals[6];
g_width = g_height = 0;
while ((opt = getopt(argc, argv, "gho:vx")) != -1) {
while ((opt = getopt(argc, argv, "gho:v")) != -1) {
switch(opt) {
case 'g': to_gray = 1; break;
case 'h': help(0); break;
case 'o': output_file = optarg; break;
case 'v': verbosity++; break;
case 'x': experiment++; break;
}
}
@ -103,13 +101,6 @@ for (idx=optind; idx<argc; idx++) {
compte++;
}
/* XXX */
if (experiment) {
}
/* XXX */
if (to_gray) {
foo = fimg_desaturate(&accu, &accu, 0);
if (foo) {
@ -117,8 +108,7 @@ if (to_gray) {
}
}
/* PLEASE CHECK IF EXPORT TO GRAY MAKE A REAL .pgm FILE */
// XXX foo = fimg_dump_to_file(&accu, output_file, 0);
foo = fimg_export_picture(&accu, output_file, 0);
if (foo) {
fprintf(stderr, "error %d while saving '%s'\n", foo, output_file);

View File

@ -19,7 +19,7 @@ FloatImg fimg;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
srcname, dstname, grisaille);
srcname, dstname, notused);
#endif
foo = fimg_fileinfos(srcname, infos);

View File

@ -87,8 +87,8 @@ int foo, infos[3];
FloatImg fimg;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %25s ( '%s' '%s' %d %f )\n", __func__,
srcname, dstname, steps, norm);
fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
srcname, dstname, notused);
#endif
if (steps < 1) {

View File

@ -19,7 +19,7 @@ FloatImg fimg;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
srcname, dstname, grisaille);
srcname, dstname, notused);
#endif
foo = fimg_fileinfos(srcname, infos);