diff --git a/lib/README.md b/lib/README.md index a35b9ae..6f113ee 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,4 +1,25 @@ -# Floatimg, the base library +# Floatimg, the base/core library + +## Data structures + +Image's pixels (floating point number, a `float` for C) +are ordonned as an array of lines of single +componant values. Every componant is in a separate array, +who are *glued* together by an in-memory image descriptor. + +``` +#define MAGIC_FIMG 0x00F11F00 +typedef struct { + uint32_t magic; + int width; + int height; + int type; + float fval; + int count; + float *R, *G, *B, *A; + FimgMetaData mdatas; // added 20230912 + int reserved; + } FloatImg; +``` -Need more explanations... diff --git a/lib/fimg-2gray.c b/lib/fimg-2gray.c index a83d714..6db15d4 100644 --- a/lib/fimg-2gray.c +++ b/lib/fimg-2gray.c @@ -17,6 +17,7 @@ extern int verbosity; /* must be declared around main() */ /* --------------------------------------------------------------------- */ /* * floating resultat img MUST be allocated before calling this func. + * and MUST be of type 'gray image'. */ int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k) { @@ -43,15 +44,12 @@ if (FIMG_TYPE_RGB != src->type) { if (FIMG_TYPE_GRAY != dst->type) { fprintf(stderr, "%s : bad dst type %d on %p\n", __func__, dst->type, dst); - /* - * may be we can convert dst picture on the fly ? - */ + /* may be we can convert dst picture on the fly ? */ return -9; } /* entering the main processing loop */ nbb = src->width * src->height; - for (foo=0; fooR[foo] = ( (src->R[foo] * kr) + (src->G[foo] * kg) + @@ -79,7 +77,6 @@ if (FIMG_TYPE_RGB != src->type || FIMG_TYPE_RGB != dst->type) { /* entering the main processing loop */ nbb = src->width * src->height; - for (foo=0; fooR[foo] = dst->G[foo] = dst->B[foo] = (src->R[foo] + src->G[foo] + src->B[foo]) / 3.0; diff --git a/lib/fimg-file.c b/lib/fimg-file.c index 4b1e071..da54676 100644 --- a/lib/fimg-file.c +++ b/lib/fimg-file.c @@ -87,15 +87,15 @@ if (FIMG_TYPE_RGB != fimg->type) { /* OK, we have to make a fake metadata chunk, if the caller * don't have one. Ugly, and nice */ if (NULL == pmd) { - fprintf(stderr, ">>> %s making faked metadata\n", __func__); + // fprintf(stderr, ">>> %s making faked metadata\n", __func__); foo = fimg_default_metadata(&fakemd, 3); - fprintf(stderr, "fakemd is at %p\n", &fakemd); + // fprintf(stderr, "fakemd is at %p\n", &fakemd); pmd = &fakemd; } else { /* OK, get some funky metadatas */ - // fprintf(stderr, "%s get metadatas\n", __func__); - fprintf(stderr, "acqu fval=%f count=%d\n", pmd->fval, pmd->count); + fprintf(stderr, "%s: acqu fval=%f count=%d\n", __func__, + pmd->fval, pmd->count); } fp = fopen(fname, "w"); diff --git a/lib/fimg-math.c b/lib/fimg-math.c index 29cdb73..0122088 100644 --- a/lib/fimg-math.c +++ b/lib/fimg-math.c @@ -201,9 +201,7 @@ if (head->type != FIMG_TYPE_RGB) { } for (foo=0; foo<(head->width*head->height); foo++) { - add = head->R[foo]; - add += head->G[foo]; - add += head->B[foo]; + add = head->R[foo] + head->G[foo] + head->B[foo]; head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0; } return 0; @@ -410,7 +408,6 @@ for (idx=0; idxG[idx] = drand48() * kmul; fi->B[idx] = drand48() * kmul; } - } /* ---------------------------------------------------------------- */ diff --git a/lib/metadata.c b/lib/metadata.c index 53a2fba..c01b9a5 100644 --- a/lib/metadata.c +++ b/lib/metadata.c @@ -35,7 +35,7 @@ if (notused) { notused, __func__); } if (NULL != title) { - fprintf(stderr, "==== metadate for %s\n", title); + fprintf(stderr, "======== metadata for %s\n", title); } if (verbosity) { fprintf(stderr, "sizeof(metadata) = %ld\n", \ @@ -98,7 +98,7 @@ pmd->magic = MAGIC_MDATA; pmd->cpid = getpid(); // we are the creator, no ? pmd->count = 1; // mmmm... pmd->fval = 255.0; // Ok -strcpy(pmd->idcam, ""); +strcpy(pmd->idcam, ""); pmd->origin = 0xdeadbeef; // classic joke, sorry pmd->reserved[0] = bla; pmd->reserved[7] = 0x55445544; // magic number is a crime