FloatImg4PythonBinding/floatimg.h

234 lines
7.0 KiB
C
Raw Normal View History

2019-03-04 02:22:55 +11:00
/*
2020-04-12 08:18:33 +11:00
* floatimg.h
* ugly code from tTh
2021-03-18 04:32:51 +11:00
* http://la.buvette.org/photos/cumul
2019-03-04 02:22:55 +11:00
*/
2021-05-05 19:02:23 +11:00
#define FIMG_VERSION 144
2019-03-04 02:22:55 +11:00
/*
* in memory descriptor
*/
2021-05-04 18:56:18 +11:00
#define MAGIC_FIMG 0x00F11F00
2019-03-04 02:22:55 +11:00
typedef struct {
2021-04-25 21:51:01 +11:00
unsigned long magic;
2019-03-04 02:22:55 +11:00
int width;
int height;
int type;
float fval;
int count;
float *R, *G, *B, *A;
int reserved;
} FloatImg;
/*
* fimg file header
*/
typedef struct {
2019-07-08 15:28:04 +11:00
char magic[8];
2019-03-04 02:22:55 +11:00
int w, h, t;
2019-07-08 15:28:04 +11:00
} FimgFileHead;
2019-03-04 02:22:55 +11:00
2021-05-04 18:56:18 +11:00
#define MAGIC_AREA51 0xA5EA0051
2021-04-25 21:51:01 +11:00
typedef struct {
unsigned long magic;
int w, h;
int x, y;
int flags;
2021-04-28 09:21:45 +11:00
} FimgArea51;
2019-08-07 20:55:29 +11:00
#define FIMG_TYPE_GRAY 1
#define FIMG_TYPE_RGB 3
#define FIMG_TYPE_RGBA 4
2020-02-14 06:44:22 +11:00
#define FIMG_TYPE_RGBZ 99
2019-08-07 20:55:29 +11:00
2019-10-31 01:49:53 +11:00
#define FILE_TYPE_FIMG 1
#define FILE_TYPE_PNM 2
#define FILE_TYPE_PNG 3
2019-12-27 22:25:33 +11:00
#define FILE_TYPE_TGA 4
#define FILE_TYPE_TIFF 5
2020-07-24 19:38:13 +11:00
#define FILE_TYPE_FITS 6
2021-02-20 13:31:09 +11:00
#define FILE_TYPE_BMP 7
2021-03-21 19:02:55 +11:00
#define FILE_TYPE_EXR 8
2019-10-31 01:49:53 +11:00
/* lib/contrast.c */
#define CONTRAST_NONE 0
#define CONTRAST_SQRT 1
#define CONTRAST_POW2 2
#define CONTRAST_COS01 3
#define CONTRAST_COS010 4
2019-03-04 02:22:55 +11:00
/*
* core module
*/
int fimg_create(FloatImg *fimg, int w, int h, int t);
int fimg_destroy(FloatImg *fimg);
2019-11-12 23:57:32 +11:00
int fimg_clone(FloatImg *fimg, FloatImg *newpic, int flags);
int fimg_copy_data(FloatImg *from, FloatImg *to);
2020-02-20 08:36:58 +11:00
int fimg_type_is_valid(int type);
2019-03-04 02:22:55 +11:00
int fimg_print_version(int k);
2020-10-07 20:32:23 +11:00
void fimg_print_sizeof(void);
2019-03-04 02:22:55 +11:00
void fimg_printhead(FloatImg *h);
2021-03-31 04:48:55 +11:00
void fimg_printdims(char *txt, FloatImg *pi);
2019-03-04 02:22:55 +11:00
int fimg_describe(FloatImg *head, char *txt);
2019-09-10 21:18:02 +11:00
char *fimg_str_type(int type);
2020-07-28 17:19:38 +11:00
int fimg_plot_rgb (FloatImg *head, int x, int y,
float r, float g, float b);
2020-02-14 06:44:22 +11:00
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
2020-03-24 20:41:57 +11:00
int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
2019-03-04 02:22:55 +11:00
int fimg_clear(FloatImg *fimg);
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
2019-09-29 08:55:45 +11:00
int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
2019-03-04 02:22:55 +11:00
2019-12-27 22:25:33 +11:00
/* --> lib/fimg-compare.c */
2020-04-07 05:09:11 +11:00
int fimg_images_not_compatible(FloatImg *a, FloatImg *b);
2019-09-10 10:31:48 +11:00
2019-09-10 01:02:44 +11:00
int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef);
2019-08-09 02:16:20 +11:00
/* 'operats' module */
int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_add_2(FloatImg *a, FloatImg *b); /* B+=A */
int fimg_sub_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
2019-11-20 21:12:16 +11:00
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
2019-08-09 02:16:20 +11:00
2020-02-08 04:01:28 +11:00
2020-03-01 06:01:11 +11:00
/* funcs/filtrage.c */
typedef struct {
float matrix[9];
float mult;
float offset;
} FimgFilter3x3;
int fimg_killborders(FloatImg *img);
int fimg_lissage_2x2(FloatImg *img);
2020-03-01 06:01:11 +11:00
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
2020-10-07 20:32:23 +11:00
2020-10-10 21:34:29 +11:00
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse);
2020-10-07 20:32:23 +11:00
2021-03-21 05:47:42 +11:00
/* module sfx0.c */
2020-02-08 04:01:28 +11:00
int fimg_killcolors_a(FloatImg *fimg, float fval);
2020-02-08 06:09:03 +11:00
int fimg_killcolors_b(FloatImg *fimg, float fval);
2020-06-22 21:15:01 +11:00
int fimg_colors_mixer_a(FloatImg *fimg, float fval);
2020-02-08 04:01:28 +11:00
2021-03-21 05:47:42 +11:00
/* module sfx1.c */
int fimg_highlight_color(FloatImg *src, FloatImg *dst,
char color, float fval);
2021-03-21 15:08:35 +11:00
/* module sfx2.c */
int fimg_binarize(FloatImg *pimg, int notused);
2021-03-26 15:40:45 +11:00
int fimg_trinarize(FloatImg *pimg, int notused);
2021-03-21 05:47:42 +11:00
/* funcs/rotate.c module */
/* #coronamaison */
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
2020-02-08 04:01:28 +11:00
2020-10-16 20:20:10 +11:00
/* universal exporter XXX */
int fimg_export_picture(FloatImg *pic, char *fname, int flags);
2019-03-04 02:22:55 +11:00
/* PNM files module */
2019-09-17 20:22:00 +11:00
int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
2019-03-04 02:22:55 +11:00
double fimg_timer_set(int whot);
double fimg_timer_get(int whot);
2019-11-12 23:57:32 +11:00
/* --> lib/contrast.c */
2019-11-18 20:18:30 +11:00
int fimg_id_contraste(char *name);
2019-11-12 23:57:32 +11:00
int fimg_square_root(FloatImg *s, FloatImg *d, double maxval);
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
2019-11-15 00:23:12 +11:00
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
2020-07-28 17:19:38 +11:00
int fimg_mix_rgb_gray(FloatImg *img, float mix);
2021-02-24 22:11:59 +11:00
/* funcs/saturation.c */
2020-08-06 22:13:10 +11:00
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
2021-02-24 22:11:59 +11:00
int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
2020-07-28 17:19:38 +11:00
2021-02-04 05:33:38 +11:00
/* --> funcs/plasmas.c */
2021-02-11 02:19:15 +11:00
int fimg_prototype_plasma(FloatImg *img, double time, int type);
2021-02-04 05:33:38 +11:00
2020-10-09 10:26:07 +11:00
/* * * * experimental ! */
2020-10-06 21:48:17 +11:00
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
2020-10-09 10:26:07 +11:00
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
2020-07-28 17:19:38 +11:00
2021-04-26 20:43:42 +11:00
/* module funcs/??????.c */
2020-08-13 16:25:55 +11:00
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
2020-04-12 08:18:33 +11:00
2019-08-24 22:06:51 +11:00
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
2020-12-07 21:16:26 +11:00
int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
2019-08-24 22:06:51 +11:00
2020-02-14 06:44:22 +11:00
/* module funcs/geometry.c */
2021-04-28 09:21:45 +11:00
/* warning, this module is a mess */
2020-02-14 06:44:22 +11:00
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
2021-04-10 04:04:59 +11:00
int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
2021-04-28 09:21:45 +11:00
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
2021-04-26 20:43:42 +11:00
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
2020-02-14 06:44:22 +11:00
2021-04-28 09:21:45 +11:00
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags);
2020-10-27 04:49:37 +11:00
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
2020-01-04 04:21:43 +11:00
/* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef);
2019-03-04 02:22:55 +11:00
/* FIMG files module */
int fimg_fileinfos(char *fname, int *datas);
int fimg_dump_to_file(FloatImg *head, char *fname, int notused);
2019-12-19 00:39:47 +11:00
int fimg_load_from_dump(char *fname, FloatImg *where);
2019-03-04 02:22:55 +11:00
int fimg_create_from_dump(char *fname, FloatImg *head);
2020-07-24 19:38:13 +11:00
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
2020-07-25 07:32:19 +11:00
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
2021-04-03 19:46:00 +11:00
int fimg_save_plane_as_fits(FloatImg *src, char *oname, char plane, int flags);
2020-07-24 19:38:13 +11:00
2020-08-22 11:16:13 +11:00
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
2021-03-21 19:02:55 +11:00
int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
2020-08-22 11:16:13 +11:00
2020-07-24 19:38:13 +11:00
2020-03-02 11:19:57 +11:00
/* mathematics operations */
2019-03-04 02:22:55 +11:00
float fimg_get_maxvalue(FloatImg *head);
2020-03-02 11:19:57 +11:00
int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]);
2019-03-04 02:22:55 +11:00
int fimg_meanvalues(FloatImg *head, float means[4]);
int fimg_to_gray(FloatImg *head);
2021-03-18 04:32:51 +11:00
int fimg_add_cste(FloatImg *fi, float value);
int fimg_mul_cste(FloatImg *fi, float value);
2020-10-09 10:26:07 +11:00
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
2019-03-04 02:22:55 +11:00
void fimg_drand48(FloatImg *fi, float kmul);
2021-03-18 04:32:51 +11:00
long fimg_count_negativ(FloatImg *fi);
long fimg_clamp_negativ(FloatImg *fi);
2019-03-04 02:22:55 +11:00
2019-05-20 17:47:13 +11:00
/* various funcs modules */
2019-03-04 02:22:55 +11:00
int fimg_load_from_png(char *filename, FloatImg *fimg);
int fimg_create_from_png(char *filename, FloatImg *fimg);
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
2021-02-20 13:31:09 +11:00
int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
2020-03-01 06:52:06 +11:00
int fimg_test_pattern(FloatImg *fimg, int type, double dval);
2019-03-04 02:22:55 +11:00
int fimg_draw_something(FloatImg *fimg);
2021-03-18 04:32:51 +11:00
int fimg_multirandom(FloatImg *fimg, long nbpass);
2019-03-04 02:22:55 +11:00
2020-10-27 02:19:51 +11:00
/* file is 'funcs/utils.c' */
void fimg_print_minmax(float minmax[6], char *titre);
2019-08-29 06:08:59 +11:00
int parse_WxH(char *str, int *pw, int *ph);
2019-09-16 21:28:47 +11:00
int parse_double(char *str, double *dptr);
2021-04-28 09:21:45 +11:00
int parse_rectangle(char *str, FimgArea51 *r, int notused);
2019-10-31 01:49:53 +11:00
int format_from_extension(char *fname);
2021-04-21 02:46:54 +11:00
char * extension_from_format(int fmt);
2019-09-16 21:28:47 +11:00
2019-03-04 02:22:55 +11:00