forked from tTh/FloatImg
		
	a new sfx func is born
This commit is contained in:
		
							parent
							
								
									0aba64181c
								
							
						
					
					
						commit
						64c1383283
					
				| @ -4,7 +4,7 @@ | ||||
|  *	http://la.buvette.org/photos/cumul
 | ||||
|  */ | ||||
| 
 | ||||
| #define		FIMG_VERSION	124 | ||||
| #define		FIMG_VERSION	125 | ||||
| 
 | ||||
| /*
 | ||||
|  *	in memory descriptor | ||||
| @ -102,11 +102,16 @@ int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); | ||||
| 
 | ||||
| int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse); | ||||
| 
 | ||||
| /*	'sfx0' module 			*/ | ||||
| /*	 module sfx0.c			*/ | ||||
| int fimg_killcolors_a(FloatImg *fimg, float fval); | ||||
| int fimg_killcolors_b(FloatImg *fimg, float fval); | ||||
| int fimg_colors_mixer_a(FloatImg *fimg, float fval); | ||||
| 
 | ||||
| /*	 module sfx1.c			*/ | ||||
| int fimg_highlight_color(FloatImg *src, FloatImg *dst, | ||||
| 					char color, float fval); | ||||
| 
 | ||||
| 
 | ||||
| /*	funcs/rotate.c module		*/ | ||||
| /*	#coronamaison			*/ | ||||
| int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused); | ||||
|  | ||||
| @ -4,7 +4,8 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0 | ||||
| DEPS = ../floatimg.h Makefile | ||||
| 
 | ||||
| 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 sfx1.o			\
 | ||||
| 	geometry.o rotate.o					\
 | ||||
| 	equalize.o fimg-fits.o saturation.o histogram.o		\
 | ||||
| 	hsv.o classif.o contour2x2.o qsortrgb.o exporter.o	\
 | ||||
| 	displacement.o dithering.o plasmas.o | ||||
| @ -77,6 +78,9 @@ plasmas.o:		plasmas.c $(DEPS) | ||||
| sfx0.o:			sfx0.c $(DEPS) | ||||
| 	gcc $(COPT) -c $< | ||||
| 
 | ||||
| sfx1.o:			sfx1.c $(DEPS) | ||||
| 	gcc $(COPT) -c $< | ||||
| 
 | ||||
| contour2x2.o:		contour2x2.c $(DEPS) | ||||
| 	gcc $(COPT) -c $< | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										107
									
								
								funcs/sfx1.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								funcs/sfx1.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,107 @@ | ||||
| /*
 | ||||
|  *		FLOATIMG - a kluge from tTh | ||||
|  *	effets spéciaux bizarres sur les couleurs. | ||||
|  *	nouveau pour un truc chelou avec Maëva | ||||
|  */ | ||||
| 
 | ||||
| #include  <stdio.h> | ||||
| #include  <string.h> | ||||
| 
 | ||||
| #include  "../floatimg.h" | ||||
| 
 | ||||
| /*			WARNING
 | ||||
| 		some crapy code cuted & pasted here			*/ | ||||
| 
 | ||||
| /* --------------------------------------------------------------------- */ | ||||
| static void highlight_red(FloatImg *src, FloatImg *dst, float fval) | ||||
| { | ||||
| int		sz, idx; | ||||
| 
 | ||||
| sz = src->width * src->height; | ||||
| for (idx=0; idx<sz; idx++) { | ||||
| 	dst->G[idx] = src->G[idx]; | ||||
| 	dst->B[idx] = src->B[idx]; | ||||
| 	if ( 	(src->G[idx] < src->R[idx])	&& | ||||
| 		(src->B[idx] < src->R[idx])	) { | ||||
| 		dst->R[idx] = src->R[idx] * fval; | ||||
| 		} | ||||
| 	else	{ | ||||
| 		dst->R[idx] = src->R[idx]; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| static void highlight_green(FloatImg *src, FloatImg *dst, float fval) | ||||
| { | ||||
| int		sz, idx; | ||||
| 
 | ||||
| sz = src->width * src->height; | ||||
| for (idx=0; idx<sz; idx++) { | ||||
| 	dst->R[idx] = src->R[idx]; | ||||
| 	dst->B[idx] = src->B[idx]; | ||||
| 	if ( 	(src->R[idx] < src->R[idx])	&& | ||||
| 		(src->B[idx] < src->R[idx])	) { | ||||
| 		dst->G[idx] = src->G[idx] * fval; | ||||
| 		} | ||||
| 	else	{ | ||||
| 		dst->G[idx] = src->G[idx]; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| static void highlight_blue(FloatImg *src, FloatImg *dst, float fval) | ||||
| { | ||||
| int		sz, idx; | ||||
| 
 | ||||
| sz = src->width * src->height; | ||||
| for (idx=0; idx<sz; idx++) { | ||||
| 	dst->G[idx] = src->G[idx]; | ||||
| 	dst->R[idx] = src->R[idx]; | ||||
| 	if ( 	(src->G[idx] < src->B[idx])	&& | ||||
| 		(src->R[idx] < src->B[idx])	) { | ||||
| 		dst->B[idx] = src->B[idx] * fval; | ||||
| 		} | ||||
| 	else	{ | ||||
| 		dst->B[idx] = src->B[idx]; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| int fimg_highlight_color(FloatImg *src, FloatImg *dst, char color, float fval) | ||||
| { | ||||
| int		sz; | ||||
| 
 | ||||
| #ifdef DEBUG_LEVEL | ||||
| fprintf(stderr, ">>> %s ( %p %p [%c] %f )\n", __func__, | ||||
| 			src, dst, color, fval); | ||||
| #endif | ||||
| 
 | ||||
| if (FIMG_TYPE_RGB != src->type) { | ||||
| 	fprintf(stderr, "%s: bad src type %d on %p\n", __func__, | ||||
| 					src->type, src); | ||||
| 	return -8; | ||||
| 	} | ||||
| if (fimg_images_not_compatible(src, dst)) { | ||||
| 	fprintf(stderr, "oh fuck in %s\n", __func__); | ||||
| 	return -9; | ||||
| 	} | ||||
| 
 | ||||
| switch (color) { | ||||
| 
 | ||||
| 	case 'r': case 'R': | ||||
| 		highlight_red(src, dst, fval);			break; | ||||
| 	case 'g': case 'G': | ||||
| 		highlight_green(src, dst, fval);		break; | ||||
| 	case 'b': case 'B': | ||||
| 		highlight_blue(src, dst, fval);			break; | ||||
| 
 | ||||
| 	default: | ||||
| 		fprintf(stderr, "%s: '%c' is invalid\n", __func__, color); | ||||
| 		return -11; | ||||
| 		break;			/* nottreached */ | ||||
| 	} | ||||
| 
 | ||||
| return 0; | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| /* --------------------------------------------------------------------- */ | ||||
| @ -21,7 +21,7 @@ float		global_fvalue; | ||||
| /* --------------------------------------------------------------------- */ | ||||
| enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, | ||||
| 			Histo, Hsv, Classif, Ctr2x2, Qsortrgb, | ||||
| 			Displace, ReadPNG, Plasmas  }; | ||||
| 			Displace, ReadPNG, Plasmas, Hilight  }; | ||||
| typedef struct { | ||||
| 	char	*name; | ||||
| 	int	Cmd; | ||||
| @ -44,6 +44,7 @@ Command commands[] = { | ||||
| 	{ "displace",	Displace	}, | ||||
| 	{ "readpng",	ReadPNG		}, | ||||
| 	{ "plasma",	Plasmas		}, | ||||
| 	{ "hilight",	Hilight		}, | ||||
| 	{ NULL,		0		} | ||||
| 	} ; | ||||
| 
 | ||||
| @ -194,6 +195,9 @@ switch(opt) { | ||||
| 		fprintf(stderr, "rotate not implemented (%d)\n", rand()); | ||||
| 		foo = 0; | ||||
| 		break; | ||||
| 	case Hilight: | ||||
| 		foo = essai_highlights(filename, outfile, 0, global_fvalue); | ||||
| 		break; | ||||
| 	default: | ||||
| 		fprintf(stderr, "'%s' is a bad command\n", command); | ||||
| 		exit(1); | ||||
|  | ||||
| @ -16,6 +16,39 @@ | ||||
| 
 | ||||
| extern int		verbosity; | ||||
| 
 | ||||
| /* --------------------------------------------------------------------- */ | ||||
| /* nouveau 20 mars 2021 - rue d'Aragon */ | ||||
| int essai_highlights(char *inf, char *outf, int ikoef, float fkoef) | ||||
| { | ||||
| FloatImg	src, dst; | ||||
| int		foo; | ||||
| 
 | ||||
| fprintf(stderr, ">>> %s ( '%s' '%s' %d %g )\n", __func__, | ||||
| 				inf, outf, ikoef, fkoef); | ||||
| 
 | ||||
| foo = fimg_create_from_dump(inf, &src); | ||||
| if (0 != foo) { | ||||
| 	fprintf(stderr, "%s: err %d loading image '%s'\n", __func__, | ||||
| 				foo, 		inf); | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| fimg_clone(&src, &dst, 0); | ||||
| 
 | ||||
| foo = fimg_highlight_color(&src, &dst, 'R', fkoef); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s: err %d ?\n", __func__, foo); | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| foo = fimg_export_picture(&dst, outf, 0); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s : err %d saving result\n", __func__, foo); | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| return 0; | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| 
 | ||||
| int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef) | ||||
|  | ||||
| @ -25,4 +25,5 @@ int essai_histogramme(char *fname, int k); | ||||
| 
 | ||||
| int essai_lecture_png(char *fname, char *outfile, int notused); | ||||
| 
 | ||||
| int essai_highlights(char *inf, char *outf, int ikoef, float fkoef); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 tth
						tth