Compare commits

..

No commits in common. "a811beee8ab0d047f2a35a5486afb2d677f94539" and "6ac0caa54a207c35d31f4a76d1d81fd6c7e3f511" have entirely different histories.

5 changed files with 12 additions and 62 deletions

View File

@ -2,7 +2,7 @@
* floatimg.h * floatimg.h
*/ */
#define FIMG_VERSION 88 #define FIMG_VERSION 87
/* /*
* in memory descriptor * in memory descriptor
@ -57,6 +57,7 @@ int fimg_print_version(int k);
void fimg_printhead(FloatImg *h); void fimg_printhead(FloatImg *h);
int fimg_describe(FloatImg *head, char *txt); int fimg_describe(FloatImg *head, char *txt);
char *fimg_str_type(int type); char *fimg_str_type(int type);
int fimg_fileinfo(char *fname, int *datas);
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b); int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b);
int fimg_clear(FloatImg *fimg); int fimg_clear(FloatImg *fimg);
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b); int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
@ -90,7 +91,6 @@ int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
int fimg_desaturate(FloatImg *src, FloatImg *dst, int k);
/* module funcs/rampes.c */ /* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef); int fimg_hdeg_a(FloatImg *img, double dcoef);

View File

@ -52,28 +52,6 @@ for (foo=0; foo<nbb; foo++) {
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int fimg_desaturate(FloatImg *src, FloatImg *dst, int k)
{
int foo, nbb;
float fval;
/* we must check the validity of our parameters */
if (FIMG_TYPE_RGB != src->type || FIMG_TYPE_RGB != dst->type) {
fprintf(stderr, "%s : bad image type\n", __func__, src->type, src);
return -18;
}
/* entering the main processing loop */
nbb = src->width * src->height;
for (foo=0; foo<nbb; foo++) {
dst->R[foo] = dst->G[foo] = dst->B[foo] =
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
}
return -99;
}
/* --------------------------------------------------------------------- */

View File

@ -10,7 +10,7 @@
#include "../floatimg.h" #include "../floatimg.h"
extern int verbosity; int verbosity;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
static int gray_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef) static int gray_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
@ -18,6 +18,7 @@ static int gray_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
int picsize, idx; int picsize, idx;
picsize = d->width * d->height; picsize = d->width * d->height;
for (idx=0; idx<picsize; idx++) { for (idx=0; idx<picsize; idx++) {
d->R[idx] = (coef * s1->R[idx]) + ((1.0-coef) * s2->R[idx]); d->R[idx] = (coef * s1->R[idx]) + ((1.0-coef) * s2->R[idx]);
} }

View File

@ -11,7 +11,7 @@
int verbosity; int verbosity;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
int convertir_fimg_en_PNG(char *srcname, char *dstname, int grisaille) int convertir_fimg_en_PNG(char *srcname, char *dstname, int notused)
{ {
int foo, infos[3]; int foo, infos[3];
FloatImg fimg; FloatImg fimg;
@ -22,10 +22,7 @@ fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__,
#endif #endif
foo = fimg_fileinfos(srcname, infos); foo = fimg_fileinfos(srcname, infos);
if (foo) { if (foo) { fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo); }
if (verbosity) fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo);
return foo;
}
if (verbosity) { if (verbosity) {
fprintf(stderr, "image '%s' is %d x %d %s\n", fprintf(stderr, "image '%s' is %d x %d %s\n",
@ -39,10 +36,6 @@ if (foo) {
return -1; return -1;
} }
if (grisaille) {
foo = fimg_desaturate(&fimg, &fimg, 0);
}
foo = fimg_save_as_png(&fimg, dstname, 0); foo = fimg_save_as_png(&fimg, dstname, 0);
if (foo) { if (foo) {
fprintf(stderr, "saving as png '%s' -> %d\n", dstname, foo); fprintf(stderr, "saving as png '%s' -> %d\n", dstname, foo);
@ -54,40 +47,19 @@ fimg_destroy(&fimg);
return 0; return 0;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
void help(int k)
{
puts("usage:\n\tfimg2png [options] foo.fimg bar.png");
puts("options:");
puts("\t-g\tconvert to gray");
puts("\t-v\tincrease verbosity");
if (verbosity) fimg_print_version(1);
exit(0);
}
/* ----------------------------------------------------------------- */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo, opt; int foo;
int to_gray = 0;
while ((opt = getopt(argc, argv, "ghv")) != -1) { if (3 != argc) {
switch(opt) { fimg_print_version(1);
case 'g': to_gray = 1; break; fprintf(stderr, "usage:\n\t%s foo.fimg bar.pnm\n", argv[0]);
case 'v': verbosity++; break;
case 'h': help(1); exit(1);
}
}
if (2 != argc-optind) {
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
exit(1); exit(1);
} }
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray); foo = convertir_fimg_en_PNG(argv[1], argv[2], 0);
if (verbosity) fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
return 0; return 0;
} }

View File

@ -43,7 +43,6 @@ if (0 != foo) {
pr_v4l2_format("after ioctl VIDIOC_G_FMT", &fmt); pr_v4l2_format("after ioctl VIDIOC_G_FMT", &fmt);
/* this function is bugged */
return k; return k;
} }