2019-09-10 01:02:44 +11:00
|
|
|
/*
|
|
|
|
* programme de test pour
|
|
|
|
* les fonctions de base.
|
|
|
|
*/
|
|
|
|
|
2019-06-30 08:50:03 +11:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2019-08-07 20:55:29 +11:00
|
|
|
#include <string.h>
|
2019-08-09 02:16:20 +11:00
|
|
|
#include <math.h>
|
2019-06-30 08:50:03 +11:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
2019-08-09 02:16:20 +11:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
int petit_dessin(FloatImg *img)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
float r, g, b;
|
|
|
|
|
|
|
|
for (y=0; y<img->height; y++) {
|
|
|
|
|
|
|
|
r = (float)y / (float)img->height;
|
|
|
|
|
|
|
|
for (x=0; x<img->width; x++) {
|
|
|
|
|
|
|
|
g = (float)x / (float)img->width;
|
|
|
|
b = 0.0;;
|
|
|
|
|
|
|
|
fimg_plot_rgb(img, x, y, r, g, b);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2019-08-24 22:06:51 +11:00
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int essai_2gray(FloatImg *picz, char *outname)
|
|
|
|
{
|
2019-08-26 10:47:05 +11:00
|
|
|
int foo;
|
|
|
|
FloatImg gray;
|
2019-08-24 22:06:51 +11:00
|
|
|
|
2019-08-26 10:47:05 +11:00
|
|
|
fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, picz, outname);
|
2019-08-24 22:06:51 +11:00
|
|
|
|
2019-08-26 10:47:05 +11:00
|
|
|
foo = fimg_create(&gray, picz->width, picz->height, FIMG_TYPE_GRAY);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s : err %d on fimg create\n", __func__, foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
foo = fimg_mk_gray_from(picz, &gray, 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s : err %d on fimg mk_gray_from\n", __func__, foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
2019-08-24 22:06:51 +11:00
|
|
|
|
2019-08-26 10:47:05 +11:00
|
|
|
foo = fimg_save_as_pnm(&gray, outname, 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s : err %d on save_as_pnm\n", __func__, foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
fimg_destroy(&gray);
|
2019-08-24 22:06:51 +11:00
|
|
|
|
2019-08-26 10:47:05 +11:00
|
|
|
return 0;
|
2019-08-09 02:16:20 +11:00
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
2019-11-12 10:20:28 +11:00
|
|
|
|
|
|
|
int fimg_square_root(FloatImg *s, FloatImg *d, double maxval);
|
|
|
|
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
|
|
|
|
|
|
|
|
int essai_contraste(char *fname)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
FloatImg dessin;
|
|
|
|
double maxi;
|
|
|
|
|
|
|
|
foo = fimg_create_from_dump(fname, &dessin);
|
|
|
|
|
|
|
|
maxi = (double)fimg_get_maxvalue(&dessin);
|
|
|
|
fprintf(stderr, "avant valeur maxi = %f\n", maxi);
|
|
|
|
|
|
|
|
fimg_power_2(&dessin, NULL, maxi);
|
|
|
|
|
|
|
|
maxi = (double)fimg_get_maxvalue(&dessin);
|
|
|
|
fprintf(stderr, "apres valeur maxi = %f\n", maxi);
|
|
|
|
|
|
|
|
fimg_dump_to_file(&dessin, "dst.fimg", 0);
|
|
|
|
|
|
|
|
fimg_destroy(&dessin);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2019-09-10 01:02:44 +11:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define W 320
|
|
|
|
#define H 240
|
2019-06-30 08:50:03 +11:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-09-10 10:31:48 +11:00
|
|
|
int foo, idx, opt;
|
2019-11-12 10:20:28 +11:00
|
|
|
// char outname[100];
|
2019-09-10 10:31:48 +11:00
|
|
|
int gray = 0;
|
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "gn:v")) != -1) {
|
|
|
|
switch(opt) {
|
|
|
|
case 'g': gray++; break;
|
2019-11-12 10:20:28 +11:00
|
|
|
case 'n': foo=atoi(optarg); break;
|
2019-09-10 10:31:48 +11:00
|
|
|
case 'v': verbosity++; break;
|
|
|
|
}
|
|
|
|
}
|
2019-06-30 08:50:03 +11:00
|
|
|
|
2019-09-10 10:31:48 +11:00
|
|
|
if (verbosity) fimg_print_version(0);
|
2019-08-07 20:55:29 +11:00
|
|
|
|
2019-11-12 10:20:28 +11:00
|
|
|
foo = essai_contraste("src.fimg");
|
2019-06-30 08:50:03 +11:00
|
|
|
|
2019-08-08 02:30:16 +11:00
|
|
|
|
2019-06-30 08:50:03 +11:00
|
|
|
return 0;
|
2019-07-08 15:28:04 +11:00
|
|
|
}
|