first version of pixelize_h
This commit is contained in:
parent
f3dc73782a
commit
9bde22f560
@ -160,6 +160,9 @@ int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
|
||||
/* --> funcs/plasmas.c */
|
||||
int fimg_prototype_plasma(FloatImg *img, double time, int type);
|
||||
|
||||
|
||||
int fimg_pixelize_h_0(FloatImg *psrc, FloatImg *pdst, int k);
|
||||
|
||||
/* * * * experimental ! */
|
||||
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
|
||||
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
|
||||
|
@ -13,7 +13,7 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.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 incrustator.o \
|
||||
killrgb.o recurse.o
|
||||
killrgb.o recurse.o pixelize.o
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
@ -37,6 +37,9 @@ tests.o: tests.c tests.h $(DEPS)
|
||||
|
||||
# ###
|
||||
|
||||
pixelize.o: pixelize.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
killrgb.o: killrgb.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
|
47
funcs/pixelize.c
Normal file
47
funcs/pixelize.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* P I X E L I Z E
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
int fimg_pixelize_h_0(FloatImg *psrc, FloatImg *pdst, int k)
|
||||
{
|
||||
int line, col, loop, idx;
|
||||
float cr, cg, cb; /* cumuls */
|
||||
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, k);
|
||||
|
||||
if (fimg_images_not_compatible(psrc, pdst)) {
|
||||
fprintf(stderr, "%s: err compatibility\n", __func__);
|
||||
return -8;
|
||||
}
|
||||
|
||||
for (line=0; line<psrc->height; line++) {
|
||||
for (col=0; col<psrc->width; col+=8) {
|
||||
cr = cg = cb = 0.0;
|
||||
idx = line * psrc->width + col;
|
||||
for (loop=0; loop<8; loop++) {
|
||||
cr += psrc->R[idx+loop];
|
||||
cg += psrc->G[idx+loop];
|
||||
cb += psrc->B[idx+loop];
|
||||
}
|
||||
for (loop=0; loop<8; loop++) {
|
||||
pdst->R[idx+loop] = cr / 8.0;
|
||||
pdst->G[idx+loop] = cg / 8.0;
|
||||
pdst->B[idx+loop] = cb / 8.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* -------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------- */
|
@ -23,7 +23,8 @@ float global_fvalue;
|
||||
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
|
||||
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
|
||||
Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
|
||||
Geometrie, FileType, Mirror, KillRGB };
|
||||
Geometrie, FileType, Mirror, KillRGB,
|
||||
Pixelize };
|
||||
typedef struct {
|
||||
char *name;
|
||||
int Cmd;
|
||||
@ -52,6 +53,7 @@ Command commands[] = {
|
||||
{ "filetype", FileType },
|
||||
{ "mirror", Mirror },
|
||||
{ "killrgb", KillRGB },
|
||||
{ "pixelize", Pixelize },
|
||||
{ NULL, 0 }
|
||||
} ;
|
||||
|
||||
@ -220,6 +222,10 @@ switch(opt) {
|
||||
case KillRGB:
|
||||
foo = essai_killrgb(filename, outfile);
|
||||
break;
|
||||
case Pixelize:
|
||||
foo = essai_pixelize(filename, outfile);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "'%s' is a bad command\n", command);
|
||||
exit(1);
|
||||
|
@ -830,7 +830,7 @@ return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
int fimg_essai_hsv(char *fname); /* hsv.c */
|
||||
int fimg_essai_hsv(char *fname); /* hsv.c */
|
||||
|
||||
|
||||
int essai_histogramme(char *fname, int k)
|
||||
@ -859,4 +859,43 @@ fprintf(stderr, "\\o/ end of %s\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* dans la roulotte de terreblanque
|
||||
*/
|
||||
int essai_pixelize(char *infile, char *outfile)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
int foo;
|
||||
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, infile, outfile);
|
||||
|
||||
memset(&src, 0, sizeof(FloatImg));
|
||||
foo = fimg_create_from_dump(infile, &src);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
|
||||
return foo;
|
||||
}
|
||||
|
||||
memset(&dst, 0, sizeof(FloatImg));
|
||||
foo = fimg_clone(&src, &dst, 0);
|
||||
if (foo) return -888;
|
||||
|
||||
foo = fimg_pixelize_h_0(&src, &dst, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "in %s, pixelize give us a %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = fimg_export_picture(&dst, outfile, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : err %d saving result to %s\n", __func__,
|
||||
foo, outfile);
|
||||
return foo;
|
||||
}
|
||||
|
||||
fimg_destroy(&src);
|
||||
fimg_destroy(&dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
@ -31,3 +31,5 @@ int essai_lecture_png(char *fname, char *outfile, int notused);
|
||||
int essai_highlights(char *inf, char *outf, int ikoef, float fkoef);
|
||||
int essai_openexr(char *inf, char *outf, int flags);
|
||||
|
||||
int essai_pixelize(char *infile, char *outfile);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user