Compare commits
No commits in common. "3632dc1680700ab0b28abe2dc7de197007fd8690" and "e410b645146ebf62438866f47574da4b64c26f4d" have entirely different histories.
3632dc1680
...
e410b64514
@ -156,14 +156,17 @@ if (FIMG_TYPE_RGB != iarray[2]) {
|
||||
w = iarray[0], h = iarray[1];
|
||||
fprintf(stderr, "first image size : %dx%d\n", w, h);
|
||||
|
||||
fimg_create(&A, w, h, 3); pFirst = &A; fimg_clear(&A);
|
||||
fimg_create(&B, w, h, 3); pSecond = &B; fimg_clear(&B);
|
||||
fimg_create(&A, w, h, 3); pFirst = &A;
|
||||
fimg_vdeg_a(&A, idx_values[0].value);
|
||||
|
||||
fimg_create(&B, w, h, 3); pSecond = &B;
|
||||
fimg_create(&Out, w, h, 3);
|
||||
|
||||
ipng = 0;
|
||||
for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
||||
|
||||
curpix = idx_values[idx].idx;
|
||||
|
||||
cptr = globbuf.gl_pathv[curpix]; /* aliasing filename */
|
||||
|
||||
/* read the next file in B */
|
||||
@ -212,6 +215,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
||||
pFirst = pTmp;
|
||||
/* XXX THIS CODE DON'T WORK !!! */
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
fprintf(stderr, "\ngenerated %d png files\n", ipng);
|
||||
|
12
floatimg.h
12
floatimg.h
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* floatimg.h
|
||||
* ugly code from tTh
|
||||
* http://la.buvette.org/photos/cumul
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 124
|
||||
#define FIMG_VERSION 122
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
@ -175,12 +174,12 @@ float fimg_get_maxvalue(FloatImg *head);
|
||||
int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]);
|
||||
int fimg_meanvalues(FloatImg *head, float means[4]);
|
||||
int fimg_to_gray(FloatImg *head);
|
||||
int fimg_add_cste(FloatImg *fi, float value);
|
||||
int fimg_mul_cste(FloatImg *fi, float value);
|
||||
void fimg_add_cste(FloatImg *fi, float value);
|
||||
void fimg_mul_cste(FloatImg *fi, float value);
|
||||
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
|
||||
void fimg_drand48(FloatImg *fi, float kmul);
|
||||
long fimg_count_negativ(FloatImg *fi);
|
||||
long fimg_clamp_negativ(FloatImg *fi);
|
||||
int fimg_count_negativ(FloatImg *fi);
|
||||
int fimg_clamp_negativ(FloatImg *fi);
|
||||
|
||||
/* various funcs modules */
|
||||
int fimg_load_from_png(char *filename, FloatImg *fimg);
|
||||
@ -191,7 +190,6 @@ int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
|
||||
|
||||
int fimg_test_pattern(FloatImg *fimg, int type, double dval);
|
||||
int fimg_draw_something(FloatImg *fimg);
|
||||
int fimg_multirandom(FloatImg *fimg, long nbpass);
|
||||
|
||||
/* file is 'funcs/utils.c' */
|
||||
void fimg_print_minmax(float minmax[6], char *titre);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Detection de contours
|
||||
* classif.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -26,7 +26,7 @@ int tbl[] = /* deep magic inside */
|
||||
1, 1, 0, 1,
|
||||
1, 0, 1, 1,
|
||||
1, 1, 1, 0
|
||||
}; /* please explain */
|
||||
};
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, reverse);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
|
||||
|
||||
@ -47,11 +48,7 @@ dltg = minmax[3] - minmax[2];
|
||||
dltb = minmax[5] - minmax[4];
|
||||
|
||||
in = out = 0;
|
||||
/*
|
||||
* BE WARNED !
|
||||
* This code doesn't work as expected, so I have to
|
||||
* rewrite it, maybe when the pandemic is closed...
|
||||
*/
|
||||
|
||||
for (y=0; y<psrc->height; y++) {
|
||||
|
||||
for (x=0; x<psrc->width; x++) {
|
||||
|
@ -26,36 +26,45 @@ fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__,
|
||||
|
||||
filetype = format_from_extension(fname);
|
||||
if (verbosity > 1) {
|
||||
fprintf(stderr, "file %s have type %d\n", fname, filetype);
|
||||
fprintf(stderr, "file %s : type %d\n", fname, filetype);
|
||||
}
|
||||
|
||||
switch(filetype) {
|
||||
|
||||
case FILE_TYPE_FIMG:
|
||||
foo = fimg_dump_to_file(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_PNM:
|
||||
foo = fimg_save_as_pnm(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_PNG:
|
||||
foo = fimg_save_as_png(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_TGA:
|
||||
fprintf(stderr, "%s: FILE_TYPE_TGA not implemented\n",
|
||||
__func__);
|
||||
foo = -666;
|
||||
break;
|
||||
|
||||
case FILE_TYPE_TIFF:
|
||||
foo = fimg_write_as_tiff(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_FITS:
|
||||
foo = fimg_save_R_as_fits(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_BMP:
|
||||
fprintf(stderr, "%s: file type BMP not implemented\n", __func__);
|
||||
foo = -666;
|
||||
|
||||
default:
|
||||
foo = -1789;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (foo) {
|
||||
|
@ -26,10 +26,6 @@ if (dst->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s: dst type %d invalid\n", __func__, dst->type);
|
||||
return -99;
|
||||
}
|
||||
if (fimg_images_not_compatible(src, dst)) {
|
||||
fprintf(stderr, "%s: src & dst not comatibles\n", __func__);
|
||||
return -98;
|
||||
}
|
||||
|
||||
/* aliasing some vars for cleaner code */
|
||||
pr = src->R; pg = src->G; pb = src->B;
|
||||
@ -150,6 +146,7 @@ h = img->height; w = img->width;
|
||||
for (idx=0; idx<h; idx++) {
|
||||
|
||||
#define FAST 1
|
||||
|
||||
#if FAST
|
||||
img->R[idx*w] = 0.0;
|
||||
img->G[idx*w] = 0.0;
|
||||
|
@ -43,6 +43,7 @@ switch (plane) {
|
||||
return -66;
|
||||
}
|
||||
|
||||
|
||||
remove(outname); /* Delete old file if it already exists */
|
||||
if (fits_create_file(&fptr, outname, &status)) {
|
||||
fits_report_error(stderr, status);
|
||||
@ -52,6 +53,7 @@ if (fits_create_file(&fptr, outname, &status)) {
|
||||
naxes[0] = src->width; naxes[1] = src->height;
|
||||
if (verbosity) fimg_describe(src, "to be saved as FITS");
|
||||
|
||||
|
||||
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
|
||||
fits_report_error(stderr, status);
|
||||
return -10;
|
||||
|
@ -56,7 +56,7 @@ TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 16); // 0->65535
|
||||
TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||
|
||||
sprintf(ligne, "lib FloatImg v %d by tTh", FIMG_VERSION);
|
||||
sprintf(ligne, "lib FloatImg %d by tTh", FIMG_VERSION);
|
||||
TIFFSetField(tiff, TIFFTAG_SOFTWARE, ligne);
|
||||
|
||||
foo = src->width * 3;
|
||||
@ -66,6 +66,7 @@ if (verbosity) fprintf(stderr, "default strip size %d\n", foo);
|
||||
TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, foo);
|
||||
|
||||
for (y=0; y<src->height; y++) {
|
||||
|
||||
ptr = linebuff;
|
||||
idx = y * src->width;
|
||||
|
||||
@ -77,6 +78,7 @@ for (y=0; y<src->height; y++) {
|
||||
}
|
||||
|
||||
TIFFWriteScanline(tiff, linebuff, y, 0);
|
||||
|
||||
idx += src->width;
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,6 @@ float rgb[3], moy;
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, ghist, sz);
|
||||
#endif
|
||||
|
||||
if (FIMG_TYPE_RGB != src->type) {
|
||||
fprintf(stderr, "%s: bad type %d of image\n", __func__, src->type);
|
||||
return -97;
|
||||
}
|
||||
|
||||
maxval = fimg_get_maxvalue(src);
|
||||
|
||||
fprintf(stderr, "maximum is %f\n", maxval);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* This is an eternal WIP, sorry...
|
||||
*/
|
||||
testing some random funcs.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -55,6 +56,7 @@ for (x=0; x<fimg->width; x++) {
|
||||
// fprintf(stderr, " %6d %f\n", x, val);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
@ -86,14 +88,14 @@ for (y=1; y<fimg->height; y++) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_multirandom(FloatImg *fimg, long nbpass)
|
||||
int fimg_multirandom(FloatImg *fimg)
|
||||
{
|
||||
int foo, x, y;
|
||||
|
||||
#define RI ( (rand()/7) + (rand()/9) )
|
||||
#define RD ( (drand48()/7) + (drand48()/7) )
|
||||
|
||||
for (foo=0; foo<nbpass; foo++)
|
||||
for (foo=0; foo<100000000; foo++)
|
||||
{
|
||||
x = RI % fimg->width;
|
||||
y = RI % fimg->height;
|
||||
|
@ -34,7 +34,7 @@ return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* To have the black at the bottom, use a negative dcoef
|
||||
* wtf ? ther's no way to have the black at the bottom ?
|
||||
*/
|
||||
int fimg_vdeg_a(FloatImg *img, double dcoef)
|
||||
{
|
||||
|
@ -33,9 +33,6 @@ for (foo=0; foo<nbpix; foo++) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* parameter fval is not used, why ?
|
||||
*/
|
||||
int fimg_killcolors_b(FloatImg *fimg, float fval)
|
||||
{
|
||||
int nbpix, foo;
|
||||
|
@ -145,10 +145,12 @@ opt = lookup_cmd(command);
|
||||
switch(opt) {
|
||||
case Equalize:
|
||||
foo = essai_equalize(filename); break;
|
||||
|
||||
case Sfx0:
|
||||
foo = essai_sfx0(filename); break;
|
||||
case F3x3:
|
||||
foo = essai_filtrage_3x3(filename); break;
|
||||
|
||||
case MIRE:
|
||||
foo = essai_mire(filename, 0);
|
||||
break;
|
||||
|
@ -17,7 +17,8 @@
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
*/
|
||||
int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
@ -272,9 +273,6 @@ else {
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX need more work on this function !
|
||||
*/
|
||||
foo = fimg_equalize_compute(&src, NULL, 666.666);
|
||||
fprintf(stderr, "equalize compute --> %d\n", foo);
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
/*
|
||||
* FloatImg from tTh - 2021
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -17,6 +15,7 @@ fprintf(stderr, "\t\tminmax %s\n", titre);
|
||||
fprintf(stderr, "red\t\t%10f %10f\n", minmax[0], minmax[1]);
|
||||
fprintf(stderr, "green\t\t%10f %10f\n", minmax[2], minmax[3]);
|
||||
fprintf(stderr, "blue\t\t%10f %10f\n", minmax[4], minmax[5]);
|
||||
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int parse_WxH(char *str, int *pw, int *ph)
|
||||
@ -34,6 +33,7 @@ if (2 != foo) {
|
||||
fprintf(stderr, "%s : arg '%s' is invalid\n", __func__, str);
|
||||
return foo;
|
||||
}
|
||||
|
||||
*pw = w; *ph = h;
|
||||
|
||||
return 2;
|
||||
|
@ -39,7 +39,9 @@ if (s->type != FIMG_TYPE_RGB) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (NULL==d) { d = s; }
|
||||
if (NULL==d) {
|
||||
d = s;
|
||||
}
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : dst type %d invalide\n",
|
||||
@ -74,7 +76,9 @@ if (s->type != FIMG_TYPE_RGB) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (NULL==d) { d = s; }
|
||||
if (NULL==d) {
|
||||
d = s;
|
||||
}
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s: dst type %d invalide\n",
|
||||
@ -115,7 +119,9 @@ if (s->type != FIMG_TYPE_RGB) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (NULL==d) { d = s; }
|
||||
if (NULL==d) {
|
||||
d = s;
|
||||
}
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : dst type %d invalide\n",
|
||||
@ -149,7 +155,9 @@ if (s->type != FIMG_TYPE_RGB) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (NULL==d) { d = s; }
|
||||
if (NULL==d) {
|
||||
d = s;
|
||||
}
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : dst type %d invalide\n",
|
||||
|
@ -42,9 +42,9 @@ fprintf(stderr, "*** FloatImg library, alpha %d (%s, %s)\n",
|
||||
FIMG_VERSION, __DATE__, __TIME__);
|
||||
|
||||
if (51 == k) {
|
||||
puts("+------------------------+");
|
||||
puts("| Pastis is coming soon |");
|
||||
puts("+------------------------+");
|
||||
puts("+--------------------+");
|
||||
puts("| Pastis is coming. |");
|
||||
puts("+--------------------+");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -118,7 +118,7 @@ if ( ! fimg_type_is_valid(type) ) {
|
||||
|
||||
/*
|
||||
* what to do if we've got a descriptor for an image
|
||||
* already allocated ? and how to check that ?
|
||||
* already allocated ?
|
||||
*/
|
||||
memset(fimg, 0, sizeof(FloatImg));
|
||||
|
||||
@ -135,11 +135,10 @@ if (FIMG_TYPE_RGB == type) {
|
||||
}
|
||||
|
||||
if (FIMG_TYPE_RGBA == type) {
|
||||
fimg->G = (float *)plane_alloc(size);
|
||||
fimg->B = (float *)plane_alloc(size);
|
||||
fimg->A = (float *)plane_alloc(size);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -166,8 +165,9 @@ if (NULL == fimg->R) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
||||
free(fimg->R);
|
||||
if (FIMG_TYPE_RGB == fimg->type) {
|
||||
if (FIMG_TYPE_RGB==fimg->type) {
|
||||
free(fimg->G);
|
||||
free(fimg->B);
|
||||
}
|
||||
@ -178,7 +178,7 @@ return 0;
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_clone(FloatImg *old, FloatImg *new, int flags)
|
||||
{
|
||||
int foo, size;
|
||||
int foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p 0x%x )\n", __func__, old, new, flags);
|
||||
@ -197,11 +197,9 @@ if (foo) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (flags & 0x01) { /* copy pixels values */
|
||||
size = old->width * old->height * sizeof(float);
|
||||
memcpy(new->R, old->R, size);
|
||||
memcpy(new->G, old->G, size);
|
||||
memcpy(new->B, old->B, size);
|
||||
if (flags & 0x01) {
|
||||
/* XXX copy all the pixels's datas */
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -242,7 +240,7 @@ if ( ! fimg_type_is_valid(fimg->type) ) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
size = fimg->width * fimg->height * sizeof(float);
|
||||
size = fimg->width * fimg->height * fimg->type * sizeof(float);
|
||||
memset(fimg->R, 0, size);
|
||||
|
||||
return 0;
|
||||
|
@ -40,7 +40,7 @@ fclose(fp);
|
||||
fprintf(stderr, " magic [%s]\n", filehead.magic);
|
||||
#endif
|
||||
|
||||
if (memcmp(filehead.magic, "FIMG", 4)) {
|
||||
if (strncmp(filehead.magic, "FIMG", 4)) {
|
||||
fprintf(stderr, "'%s' is not a fimg file.\n", fname);
|
||||
return -3;
|
||||
}
|
||||
@ -169,7 +169,6 @@ int fimg_create_from_dump(char *fname, FloatImg *head)
|
||||
{
|
||||
FILE *fp;
|
||||
int foo, size;
|
||||
long nbread;
|
||||
FimgFileHead filehead;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
@ -206,10 +205,10 @@ if (foo) {
|
||||
}
|
||||
|
||||
size = filehead.w * filehead.h;
|
||||
nbread = 0;
|
||||
nbread += fread(head->R, sizeof(float), size, fp);
|
||||
nbread += fread(head->G, sizeof(float), size, fp);
|
||||
nbread += fread(head->B, sizeof(float), size, fp);
|
||||
foo = 0;
|
||||
foo += fread(head->R, sizeof(float), size, fp);
|
||||
foo += fread(head->G, sizeof(float), size, fp);
|
||||
foo += fread(head->B, sizeof(float), size, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
|
@ -77,6 +77,11 @@ for (idx=0; idx<surface; idx++) {
|
||||
if (fval < mmvals[4]) mmvals[4] = fval;
|
||||
else if (fval > mmvals[5]) mmvals[5] = fval;
|
||||
}
|
||||
#if 0
|
||||
for (foo=0; foo<6; foo++) {
|
||||
fprintf(stderr, "%3d %g\n", foo, mmvals[foo]);
|
||||
}
|
||||
#endif
|
||||
|
||||
return -0;
|
||||
}
|
||||
@ -92,10 +97,10 @@ if (surface < 1) return -1;
|
||||
memset(accus, 0, 4*sizeof(double));
|
||||
|
||||
for (idx=0; idx<surface; idx++) {
|
||||
accus[0] += (double)head->R[idx];
|
||||
accus[0] += head->R[idx];
|
||||
if (head->type > 2) { /* WTF ? */
|
||||
accus[1] += (double)head->G[idx];
|
||||
accus[2] += (double)head->B[idx];
|
||||
accus[1] += head->G[idx];
|
||||
accus[2] += head->B[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +122,7 @@ return 0;
|
||||
Mais c,a ne semble pas etre la bonne methode. Il faut aller voir :
|
||||
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/*
|
||||
* more elaborate functions are in fimg-2gray.c
|
||||
@ -138,17 +144,17 @@ for (foo=0; foo<(head->width*head->height); foo++) {
|
||||
add += head->B[foo];
|
||||
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
int fimg_add_cste(FloatImg *fi, float value)
|
||||
void fimg_add_cste(FloatImg *fi, float value)
|
||||
{
|
||||
int nbre, idx;
|
||||
|
||||
if (fi->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
__func__, fi->type);
|
||||
return -44;
|
||||
return;
|
||||
}
|
||||
|
||||
nbre = fi->width * fi->height ;
|
||||
@ -160,13 +166,12 @@ for (idx=0; idx<nbre; idx++) {
|
||||
fi->G[idx] += value;
|
||||
fi->B[idx] += value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
long fimg_count_negativ(FloatImg *fi)
|
||||
int fimg_count_negativ(FloatImg *fi)
|
||||
{
|
||||
int nbre, idx;
|
||||
long count;
|
||||
int count;
|
||||
|
||||
if (fi->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
@ -187,10 +192,10 @@ return count;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* nouveau 29 fevrier 2020 */
|
||||
long fimg_clamp_negativ(FloatImg *fi)
|
||||
int fimg_clamp_negativ(FloatImg *fi)
|
||||
{
|
||||
int nbre, idx;
|
||||
long count;
|
||||
int count;
|
||||
|
||||
if (fi->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
@ -198,18 +203,13 @@ if (fi->type != FIMG_TYPE_RGB) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
nbre = fi->width * fi->height;
|
||||
nbre = fi->width * fi->height * fi->type;
|
||||
|
||||
count = 0;
|
||||
for (idx=0; idx<nbre; idx++) {
|
||||
if (fi->R[idx] < 0.0) {
|
||||
fi->R[idx] = 0.0; count++;
|
||||
}
|
||||
if (fi->G[idx] < 0.0) {
|
||||
fi->G[idx] = 0.0; count++;
|
||||
}
|
||||
if (fi->B[idx] < 0.0) {
|
||||
fi->B[idx] = 0.0; count++;
|
||||
fi->R[idx] = 0.0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,14 +229,14 @@ for (idx=0; idx<nbre; idx++) {
|
||||
return count;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
int fimg_mul_cste(FloatImg *fi, float value)
|
||||
void fimg_mul_cste(FloatImg *fi, float value)
|
||||
{
|
||||
int nbre, idx;
|
||||
|
||||
if ( (fi->type != FIMG_TYPE_RGB) && (fi->type != FIMG_TYPE_GRAY) ) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
__func__, fi->type);
|
||||
return -44;
|
||||
return;
|
||||
}
|
||||
|
||||
nbre = fi->width * fi->height;
|
||||
@ -255,12 +255,8 @@ if (fi->type == FIMG_TYPE_GRAY) {
|
||||
fi->R[idx] *= value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
/*
|
||||
* oh, please explain the usecase of this function !
|
||||
*/
|
||||
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused)
|
||||
{
|
||||
double coef;
|
||||
|
@ -190,7 +190,9 @@ switch(head->type) {
|
||||
break;
|
||||
}
|
||||
|
||||
fputs("\n", fp); fclose(fp);
|
||||
fputs("\n", fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* timers.c BUGS INSIDE ?
|
||||
* timers.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -29,11 +29,9 @@ static int rgb_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef)
|
||||
{
|
||||
int picsize, idx;
|
||||
|
||||
picsize = d->width * d->height;
|
||||
picsize = d->width * d->height * 3; /* rude hack ? */
|
||||
for (idx=0; idx<picsize; idx++) {
|
||||
d->R[idx] = (coef * s1->R[idx]) + ((1.0-coef) * s2->R[idx]);
|
||||
d->G[idx] = (coef * s1->G[idx]) + ((1.0-coef) * s2->G[idx]);
|
||||
d->B[idx] = (coef * s1->B[idx]) + ((1.0-coef) * s2->B[idx]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -17,6 +17,7 @@ extern int verbosity; /* must be declared around main() */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/*
|
||||
* A + B -> D
|
||||
* why is this func so slow ?
|
||||
*/
|
||||
int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d)
|
||||
{
|
||||
@ -62,6 +63,9 @@ if (FIMG_TYPE_RGB != a->type || FIMG_TYPE_RGB != b->type) {
|
||||
|
||||
nbpixels = a->width * a->height;
|
||||
|
||||
/* are we cache-friendly here ?
|
||||
* we need an accurate benchmarking... */
|
||||
|
||||
for (idx=0; idx<nbpixels; idx++) {
|
||||
b->R[idx] += a->R[idx];
|
||||
b->G[idx] += a->G[idx];
|
||||
|
35
lib/t.c
35
lib/t.c
@ -26,9 +26,44 @@ B = fimg_timer_get(uuuh);
|
||||
|
||||
fprintf(stderr, " %f %f\n", A, B);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
int essai_normalize(void)
|
||||
{
|
||||
FloatImg A;
|
||||
float val;
|
||||
int foo;
|
||||
|
||||
#if 0
|
||||
foo = fimg_create(&A, 512, 512, FIMG_TYPE_RGB);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s err create A %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
fimg_drand48(&A, 255.0);
|
||||
val = fimg_get_maxvalue(&A);
|
||||
fprintf(stderr, "BEFORE max pixel %f\n", val);
|
||||
|
||||
A.fval = 255.0; A.count = 1;
|
||||
|
||||
foo = fimg_normalize(&A, 1.0, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s err normalize A %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
val = fimg_get_maxvalue(&A);
|
||||
fprintf(stderr, "AFTER max pixel %f\n", val);
|
||||
|
||||
fimg_destroy(&A);
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
#define WI 1024
|
||||
#define HI 768
|
||||
|
Loading…
Reference in New Issue
Block a user