Compare commits

..

No commits in common. "56073c0c80273432e22236ea780285cd17ed4500" and "e6379f633886fb8d17bf5ff181467329fd6edd8e" have entirely different histories.

6 changed files with 28 additions and 112 deletions

View File

@ -20,7 +20,7 @@
* https://git.tetalab.org/tTh/FloatImg
*/
#define FIMG_VERSION (202)
#define FIMG_VERSION (198)
#define RELEASE_NAME ("noname")
/* XXX add a test for stdint.h / uint32_t XXX */
@ -233,7 +233,7 @@ int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
/* module funcs/equalize.c */
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
int fimg_equalize(FloatImg *src, double vmax);
int fimg_equalize(FloatImg *src, float vmax);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
@ -254,7 +254,6 @@ int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
/* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef);
int fimg_do_stripes(FloatImg *img, int mode);
/* FIMG native file module */
int fimg_fileinfos(char *fname, int *datas);
@ -286,7 +285,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);
int fimg_div_cste(FloatImg *fi, float value);
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
int fimg_absolute(FloatImg *fimg);
void fimg_drand48(FloatImg *fi, float kmul);

View File

@ -16,10 +16,9 @@ extern int verbosity;
/* --------------------------------------------------------------------- */
/* new func: Wed 14 Sep 2022 11:28:04 AM CEST
*/
int fimg_equalize(FloatImg *src, double vmax)
int fimg_equalize(FloatImg *src, float vmax)
{
float mm[6];
double maxi, coef;
float mm[6], maxi, coef;
int foo;
#if DEBUG_LEVEL
@ -32,8 +31,8 @@ if (foo) {
fprintf(stderr, "%s: err %d get_minmax\n", __func__, foo);
return foo;
}
maxi = mm[1] > mm[3] ? (double)mm[1] : (double)mm[3];
maxi = maxi > mm[5] ? maxi : (double)mm[5];
maxi = mm[1] > mm[3] ? mm[1] : mm[3];
maxi = maxi > mm[5] ? maxi : mm[5];
coef = vmax / maxi;
if (verbosity) {
@ -42,7 +41,7 @@ if (verbosity) {
fprintf(stderr, "vmax %f maxi %f multcoef = %g\n", vmax, maxi, coef);
}
foo = fimg_mul_cste(src, (float)coef);
foo = fimg_mul_cste(src, coef);
if (foo) {
fprintf(stderr, "%s: err %d mul_cste\n", __func__, foo);
return foo;

View File

@ -5,7 +5,6 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include "../floatimg.h"
@ -24,7 +23,8 @@ if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (x=0; x<img->width; x++) {
for (x=0; x<img->width; x++)
{
value = (float)x / (float)img->width;
value *= dcoef;
for (y=0; y<img->height; y++) {
@ -51,10 +51,11 @@ if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (x=0; x<img->width; x++) {
value = (float)x / (float)img->width;
for (y=0; y<img->height; y++)
{
value = (float)y / (float)img->height;
value *= dcoef;
for (y=0; y<img->height; y++) {
for (x=0; x<img->width; x++) {
fimg_plot_rgb(img, x, y, value, value, value);
}
}
@ -62,47 +63,3 @@ for (x=0; x<img->width; x++) {
return 0;
}
/* --------------------------------------------------------------------- */
/* nouveau 19 septembre 2022 */
int fimg_do_stripes(FloatImg *img, int mode)
{
int x, y, quad;
float *ligne;
float fr, fg, fb;
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, img, mode);
/*
* allocate and fill a lookup table
*/
if (NULL==(ligne=malloc(img->width*sizeof(float)))) {
fprintf(stderr, "%s: malloc fail\n", __func__);
exit(1);
}
for (x=0; x<img->width; x++)
ligne[x] = (float)x / (float)img->width;
/*
* build the pixels
*/
for (y=0; y<img->height; y++)
{
quad = (y*4) / img->height ;
for (x=0; x<img->width; x++) {
fr = fg = fb = ligne[x];
switch(quad) {
case 0: fg = fb = 0; break;
case 1: fr = fb = 0; break;
case 2: fr = fg = 0; break;
case 3: break;
default: abort(); break;
}
fimg_plot_rgb(img, x, y, fr, fg, fb);
}
}
free(ligne);
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -296,33 +296,6 @@ if (fi->type == FIMG_TYPE_GRAY) {
return 0;
}
/* ---------------------------------------------------------------- */
/* nouveau 17 septembre 2022 */
int fimg_div_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;
}
nbre = fi->width * fi->height;
if (fi->type == FIMG_TYPE_RGB) {
for (idx=0; idx<nbre; idx++) {
fi->R[idx] /= value;
fi->G[idx] /= value;
fi->B[idx] /= value;
}
}
if (fi->type == FIMG_TYPE_GRAY) {
for (idx=0; idx<nbre; idx++) {
fi->R[idx] /= value;
}
}
return 0;
}
/* ---------------------------------------------------------------- */
/*
* oh, please explain the usecase of this function !
*/

View File

@ -40,10 +40,9 @@ void help(int v)
puts("");
puts("$ cumulfimgs a.fimg b.fimg c-fimg ...");
puts("cumulator options :");
puts("\t-g\tconvert to gray level");
puts("\t-o\tname of output file");
puts("\t-s\trescale end image");
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(v); }
exit(0);
@ -53,25 +52,22 @@ int main(int argc, char *argv[])
{
int foo, idx;
int opt;
int compte = 0;
int to_gray = 0;
int experiment = 0;
int rescale = 0;
int src_loaded = 0;
char *output_file = "out.fimg";
FloatImg accu, temp;
int src_loaded = 0;
float vals[6];
g_width = g_height = 0;
while ((opt = getopt(argc, argv, "gho:svx")) != -1) {
while ((opt = getopt(argc, argv, "gho:vx")) != -1) {
switch(opt) {
case 'g': to_gray = 1; break;
case 'h': help(1); break;
case 'o': output_file = optarg; break;
case 's': rescale = 1; break;
case 'v': verbosity++; break;
case 'x': experiment++; break;
}
@ -88,7 +84,7 @@ for (idx=optind; idx<argc; idx++) {
#endif
foo = testfile(argv[idx]);
if (foo) {
fprintf(stderr, "testfile %s -> %d\n", argv[idx], foo);
fprintf(stderr, "testfile %s -> %d\n", argv[idx],foo);
exit(1);
}
@ -108,11 +104,6 @@ for (idx=optind; idx<argc; idx++) {
compte++;
}
if (rescale) {
fprintf(stderr, "cumulfimg: count = %d\n", compte);
fimg_div_cste(&accu, (float)compte);
}
/* XXX */
if (experiment) {

View File

@ -154,8 +154,8 @@ fname = argv[optind];
if (verbosity>1) fprintf(stderr, "*** mkfimg *** %s %s *** pid %ld\n",
__DATE__, __TIME__, (long)getpid());
if (verbosity) fprintf(stderr, "::: %s is making '%s' %dx%d, type %d\n",
argv[0], fname, width, height, type);
if (verbosity) fprintf(stderr, "making '%s' %dx%d, type %d\n",
fname, width, height, type);
srand48(getpid() ^ time(NULL));
@ -176,7 +176,6 @@ switch(type) {
case T_TPAT0: fimg_test_pattern(&fimg, 0, fvalue); break;
case T_MIRCOL1: fimg_mircol_1(&fimg, fvalue); break;
case T_BLOUP: fimg_draw_something(&fimg); break;
case T_STRIPES: fimg_do_stripes(&fimg, 0); break;
case -1: exit(1);
}
@ -192,9 +191,8 @@ if (wrmdata) {
else {
foo = fimg_dump_to_file(&fimg, fname, 0);
}
if (foo) {
fprintf(stderr, "*** dump fimg to %s error -> %d\n", fname, foo);
fprintf(stderr, "dump fimg to %s error -> %d\n", fname, foo);
exit(1);
}