this is romulian saturation control

This commit is contained in:
tth 2020-07-28 08:19:38 +02:00
parent fd10739cc7
commit 4fec59ec64
3 changed files with 54 additions and 2 deletions

View File

@ -63,7 +63,8 @@ void fimg_print_sizeof(void);
void fimg_printhead(FloatImg *h); void fimg_printhead(FloatImg *h);
int fimg_describe(FloatImg *head, char *txt); int fimg_describe(FloatImg *head, char *txt);
char *fimg_str_type(int type); char *fimg_str_type(int type);
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b); int fimg_plot_rgb (FloatImg *head, int x, int y,
float r, float g, float b);
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb); int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb); int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
int fimg_clear(FloatImg *fimg); int fimg_clear(FloatImg *fimg);
@ -119,6 +120,10 @@ int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
int fimg_mix_rgb_gray(FloatImg *img, float mix);
/* module funcs/geometry.c */ /* module funcs/geometry.c */
int fimg_equalize_compute(FloatImg *src, void *vptr); int fimg_equalize_compute(FloatImg *src, void *vptr);

View File

@ -4,7 +4,7 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
DEPS = ../floatimg.h Makefile DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \ fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \
equalize.o fimg-fits.o equalize.o fimg-fits.o saturation.o
#--------------------------------------------------------------- #---------------------------------------------------------------
@ -41,6 +41,9 @@ geometry.o: geometry.c $(DEPS)
rotate.o: rotate.c $(DEPS) rotate.o: rotate.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
saturation.o: saturation.c $(DEPS)
gcc $(COPT) -c $<
equalize.o: equalize.c $(DEPS) equalize.o: equalize.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

44
funcs/saturation.c Normal file
View File

@ -0,0 +1,44 @@
/*
* FloatImg library from tTh
*/
#include <stdio.h>
#include "../floatimg.h"
/* -------------------------------------------------------------- */
/* global vars from main
*/
extern int verbosity;
/* -------------------------------------------------------------- */
int fimg_mix_rgb_gray(FloatImg *img, float mix)
{
int x, y, p;
float gr;
if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (y=0; y<img->height; y++) {
p = y * img->width;
for (x=0; x<img->width; x++) {
gr = (img->R[p] + img->G[p] + img->R[p]) / 3.0;
img->R[p] = ((gr * mix) + (img->R[p] * (1.0-mix))) / 2.0;
img->G[p] = ((gr * mix) + (img->G[p] * (1.0-mix))) / 2.0;
img->B[p] = ((gr * mix) + (img->B[p] * (1.0-mix))) / 2.0;
p++; /* next pixel in the row */
}
}
return 0;
}
/* -------------------------------------------------------------- */