introduction des ajustements de contraste

This commit is contained in:
2019-11-15 10:39:22 +01:00
parent 210af322b0
commit c7a428c5f0
6 changed files with 60 additions and 33 deletions

View File

@@ -64,6 +64,16 @@ if (r == -1) {
}
}
/* --------------------------------------------------------------------- */
int contraste(char *str)
{
if (!strcmp(str, "sqrt")) return CONTRAST_SQRT;
if (!strcmp(str, "pow2")) return CONTRAST_POW2;
if (!strcmp(str, "cos01")) return CONTRAST_COS01;
return -1;
}
/* --------------------------------------------------------------------- */
void help(int v)
{
if (verbosity) {
@@ -74,9 +84,10 @@ puts("\t-d /dev/?\tselect video device");
puts("\t-g\t\tconvert to gray");
puts("\t-n NNN\t\thow many frames ?");
puts("\t-O ./\t\tset Output dir");
puts("\t-o bla\t\tset output filename");
puts("\t-o bla.xxx\tset output filename");
puts("\t-p NN.N\t\tperiod in seconds");
puts("\t-s WxH\t\tsize of capture");
puts("\t-c mode\t\tcontrast enhancement");
puts("\t-u\t\ttry upscaling...");
puts("\t-v\t\tincrease verbosity");
exit(0);
@@ -104,9 +115,10 @@ int nbre_capt = 1; /* nombre de captures */
int opt;
int width = 640;
int height = 480;
double t_final;
double t_final, maxvalue;
int to_gray = 0;
int upscaling = 0;
int contrast = 0;
char *dest_dir = "."; /* no trailing slash */
char *outfile = "out.pnm";
@@ -114,8 +126,9 @@ char *outfile = "out.pnm";
FloatImg cumul;
#endif
while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s:uv")) != -1) {
while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:s:uv")) != -1) {
switch(opt) {
case 'c': contrast = contraste(optarg); break;
case 'd': dev_name = optarg; break;
case 'g': to_gray = 1; break;
case 'h': help(0); break;
@@ -317,6 +330,29 @@ if (to_gray) {
// save cumul to file
if (verbosity) fprintf(stderr, "saving cumul to '%s'\n", outfile);
/* ----- nouveau 15 nov 2019 */
maxvalue = cumul.fval * cumul.count;
if (verbosity) {
fprintf(stderr, "computed maxvalue = %g\n", maxvalue);
}
switch (contrast) {
case CONTRAST_NONE:
fprintf(stderr, "contrast: none\n");
break;
case CONTRAST_SQRT:
fimg_square_root(&cumul, NULL, maxvalue);
break;
case CONTRAST_POW2:
fimg_power_2(&cumul, NULL, maxvalue);
break;
case CONTRAST_COS01:
fimg_cos_01(&cumul, NULL, maxvalue);
break;
default:
fprintf(stderr, "bad contrast method\n");
break;
}
foo = format_from_extension(outfile);
switch (foo) {
case FILE_TYPE_FIMG: