added a mirror function
This commit is contained in:
parent
b3de3b96f7
commit
9ddbef4e91
@ -4,7 +4,7 @@
|
||||
* http://la.buvette.org/photos/cumul
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 135
|
||||
#define FIMG_VERSION 137
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
@ -157,7 +157,7 @@ int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
|
||||
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
|
||||
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
|
||||
|
||||
/* module funcs/geometry.c */
|
||||
/* module funcs/??????.c */
|
||||
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
|
||||
|
||||
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
|
||||
@ -167,6 +167,7 @@ int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
|
||||
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
|
||||
int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
|
||||
int fimg_extractor(FloatImg *in, FloatImg *out, Rectangle *rect);
|
||||
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
|
||||
|
||||
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
@ -135,4 +136,43 @@ for (yd=0; yd<rect->h; yd++) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused)
|
||||
{
|
||||
float *fptr;
|
||||
int line, col, offl;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__,
|
||||
src, dst, notused);
|
||||
#endif
|
||||
|
||||
if (fimg_images_not_compatible(src, dst)) {
|
||||
fprintf(stderr, "bad karma in %s\n", __func__);
|
||||
return -9;
|
||||
}
|
||||
|
||||
if (NULL == (fptr=alloca(src->width*sizeof(float)))) {
|
||||
fprintf(stderr, "%s: no mem available\n", __func__);
|
||||
#if MUST_ABORT
|
||||
abort();
|
||||
#endif
|
||||
return -11;
|
||||
}
|
||||
|
||||
for (line=0; line<src->height; line++) {
|
||||
offl = line * src->width;
|
||||
for (col=0; col<src->width; col++)
|
||||
fptr[(src->width-1) - col] = src->R[offl+col];
|
||||
memcpy(dst->R+offl, fptr, src->width*sizeof(float));
|
||||
for (col=0; col<src->width; col++)
|
||||
fptr[(src->width-1) - col] = src->G[offl+col];
|
||||
memcpy(dst->G+offl, fptr, src->width*sizeof(float));
|
||||
for (col=0; col<src->width; col++)
|
||||
fptr[(src->width-1) - col] = src->B[offl+col];
|
||||
memcpy(dst->B+offl, fptr, src->width*sizeof(float));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
@ -22,7 +22,7 @@ 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 };
|
||||
Geometrie, FileType, Mirror };
|
||||
typedef struct {
|
||||
char *name;
|
||||
int Cmd;
|
||||
@ -49,6 +49,7 @@ Command commands[] = {
|
||||
{ "openexr", OpenEXR },
|
||||
{ "geometrie", Geometrie, },
|
||||
{ "filetype", FileType },
|
||||
{ "mirror", Mirror },
|
||||
{ NULL, 0 }
|
||||
} ;
|
||||
|
||||
@ -211,6 +212,9 @@ switch(opt) {
|
||||
case FileType:
|
||||
foo = essai_detect_type();
|
||||
break;
|
||||
case Mirror:
|
||||
foo = essai_miroir(filename, outfile, 0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "'%s' is a bad command\n", command);
|
||||
exit(1);
|
||||
|
@ -16,6 +16,39 @@
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_miroir(char *inf, char *outf, int flags)
|
||||
{
|
||||
int foo;
|
||||
FloatImg src, dst;
|
||||
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' 0x%X )\n", __func__,
|
||||
inf, outf, flags);
|
||||
|
||||
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);
|
||||
|
||||
/* run the crappy code */
|
||||
foo = fimg_mirror(&src, &dst, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "err %d in fimg_mirrot\n", foo);
|
||||
return -6;
|
||||
}
|
||||
|
||||
foo = fimg_export_picture(&dst, outf, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* nouveau 21 mars 2021 - rue d'Aragon */
|
||||
int essai_openexr(char *inf, char *outf, int flags)
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef);
|
||||
int essai_miroir(char *inf, char *outf, int flags);
|
||||
|
||||
int essai_displacement(char *infile, char *outfile);
|
||||
int essai_qsort_rgb(char *infile, char *outfile);
|
||||
|
@ -22,7 +22,7 @@ typedef struct {
|
||||
|
||||
enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
|
||||
Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
|
||||
Fx_classtrial,
|
||||
Fx_classtrial, Fx_mirror,
|
||||
Fx_xper, Fx_binarize, Fx_trinarize,Fx_hilight_R };
|
||||
|
||||
Fx fx_list[] = {
|
||||
@ -37,6 +37,7 @@ Fx fx_list[] = {
|
||||
{ "xper", Fx_xper, 0, 1 },
|
||||
{ "desat", Fx_desat, 0, 1 },
|
||||
{ "ctr2x2", Fx_ctr2x2, 0, 1 },
|
||||
{ "mirror", Fx_mirror, 0, 1 },
|
||||
// { "norm", Fx_norm, 0, 1 },
|
||||
{ "classtrial", Fx_classtrial, 0, 1 },
|
||||
{ "binarize", Fx_binarize, 0, 1 },
|
||||
@ -204,7 +205,9 @@ switch (action) {
|
||||
fimg_copy_data(&src, &dest);
|
||||
foo = fimg_mix_rgb_gray(&dest, global_fvalue);
|
||||
break;
|
||||
|
||||
case Fx_mirror:
|
||||
foo = fimg_mirror(&src, &dest, 0);
|
||||
break;
|
||||
case Fx_ctr2x2:
|
||||
foo = fimg_contour_2x2(&src, &dest, 0);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user