forked from tTh/FloatImg
cosmetic
This commit is contained in:
parent
11e87efd67
commit
4f27e491b1
@ -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...
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ extern int verbosity; /* must be declared around main() */
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
* floating resultat img MUST be allocated before calling this func.
|
* 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)
|
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) {
|
if (FIMG_TYPE_GRAY != dst->type) {
|
||||||
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
|
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
|
||||||
dst->type, dst);
|
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;
|
return -9;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* entering the main processing loop */
|
/* entering the main processing loop */
|
||||||
nbb = src->width * src->height;
|
nbb = src->width * src->height;
|
||||||
|
|
||||||
for (foo=0; foo<nbb; foo++) {
|
for (foo=0; foo<nbb; foo++) {
|
||||||
dst->R[foo] = ( (src->R[foo] * kr) +
|
dst->R[foo] = ( (src->R[foo] * kr) +
|
||||||
(src->G[foo] * kg) +
|
(src->G[foo] * kg) +
|
||||||
@ -79,7 +77,6 @@ if (FIMG_TYPE_RGB != src->type || FIMG_TYPE_RGB != dst->type) {
|
|||||||
|
|
||||||
/* entering the main processing loop */
|
/* entering the main processing loop */
|
||||||
nbb = src->width * src->height;
|
nbb = src->width * src->height;
|
||||||
|
|
||||||
for (foo=0; foo<nbb; foo++) {
|
for (foo=0; foo<nbb; foo++) {
|
||||||
dst->R[foo] = dst->G[foo] = dst->B[foo] =
|
dst->R[foo] = dst->G[foo] = dst->B[foo] =
|
||||||
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
|
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
|
||||||
|
@ -87,15 +87,15 @@ if (FIMG_TYPE_RGB != fimg->type) {
|
|||||||
/* OK, we have to make a fake metadata chunk, if the caller
|
/* OK, we have to make a fake metadata chunk, if the caller
|
||||||
* don't have one. Ugly, and nice */
|
* don't have one. Ugly, and nice */
|
||||||
if (NULL == pmd) {
|
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);
|
foo = fimg_default_metadata(&fakemd, 3);
|
||||||
fprintf(stderr, "fakemd is at %p\n", &fakemd);
|
// fprintf(stderr, "fakemd is at %p\n", &fakemd);
|
||||||
pmd = &fakemd;
|
pmd = &fakemd;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* OK, get some funky metadatas */
|
/* OK, get some funky metadatas */
|
||||||
// fprintf(stderr, "%s get metadatas\n", __func__);
|
fprintf(stderr, "%s: acqu fval=%f count=%d\n", __func__,
|
||||||
fprintf(stderr, "acqu fval=%f count=%d\n", pmd->fval, pmd->count);
|
pmd->fval, pmd->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen(fname, "w");
|
fp = fopen(fname, "w");
|
||||||
|
@ -201,9 +201,7 @@ if (head->type != FIMG_TYPE_RGB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (foo=0; foo<(head->width*head->height); foo++) {
|
for (foo=0; foo<(head->width*head->height); foo++) {
|
||||||
add = head->R[foo];
|
add = head->R[foo] + head->G[foo] + head->B[foo];
|
||||||
add += head->G[foo];
|
|
||||||
add += head->B[foo];
|
|
||||||
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
|
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -410,7 +408,6 @@ for (idx=0; idx<surface; idx++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Warning: this function is _very_ slow */
|
/* Warning: this function is _very_ slow */
|
||||||
void fimg_drand48(FloatImg *fi, float kmul)
|
void fimg_drand48(FloatImg *fi, float kmul)
|
||||||
{
|
{
|
||||||
@ -434,7 +431,6 @@ for (idx=0; idx<nbre; idx++) {
|
|||||||
fi->G[idx] = drand48() * kmul;
|
fi->G[idx] = drand48() * kmul;
|
||||||
fi->B[idx] = drand48() * kmul;
|
fi->B[idx] = drand48() * kmul;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ if (notused) {
|
|||||||
notused, __func__);
|
notused, __func__);
|
||||||
}
|
}
|
||||||
if (NULL != title) {
|
if (NULL != title) {
|
||||||
fprintf(stderr, "==== metadate for %s\n", title);
|
fprintf(stderr, "======== metadata for %s\n", title);
|
||||||
}
|
}
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fprintf(stderr, "sizeof(metadata) = %ld\n", \
|
fprintf(stderr, "sizeof(metadata) = %ld\n", \
|
||||||
@ -98,7 +98,7 @@ pmd->magic = MAGIC_MDATA;
|
|||||||
pmd->cpid = getpid(); // we are the creator, no ?
|
pmd->cpid = getpid(); // we are the creator, no ?
|
||||||
pmd->count = 1; // mmmm...
|
pmd->count = 1; // mmmm...
|
||||||
pmd->fval = 255.0; // Ok
|
pmd->fval = 255.0; // Ok
|
||||||
strcpy(pmd->idcam, "<noname>");
|
strcpy(pmd->idcam, "<noname camera>");
|
||||||
pmd->origin = 0xdeadbeef; // classic joke, sorry
|
pmd->origin = 0xdeadbeef; // classic joke, sorry
|
||||||
pmd->reserved[0] = bla;
|
pmd->reserved[0] = bla;
|
||||||
pmd->reserved[7] = 0x55445544; // magic number is a crime
|
pmd->reserved[7] = 0x55445544; // magic number is a crime
|
||||||
|
Loading…
Reference in New Issue
Block a user