Bibliothèque de traitements d'images en virgule flottante. http://la.buvette.org/photos/cumul/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
7.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
6 months ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
8 months ago
6 months ago
3 years ago
3 years ago
1 year ago
10 months ago
12 months ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. /*
  2. * floatimg.h
  3. * ugly code from tTh
  4. * http://la.buvette.org/photos/cumul
  5. */
  6. #define FIMG_VERSION 153
  7. /*
  8. * in memory descriptor
  9. */
  10. #define MAGIC_FIMG 0x00F11F00
  11. typedef struct {
  12. uint32_t magic;
  13. int width;
  14. int height;
  15. int type;
  16. float fval;
  17. int count;
  18. float *R, *G, *B, *A;
  19. int reserved;
  20. } FloatImg;
  21. /*
  22. * fimg file header
  23. */
  24. typedef struct {
  25. char magic[8];
  26. int32_t w, h, t;
  27. } FimgFileHead;
  28. #define MAGIC_AREA51 0xA5EA0051
  29. typedef struct {
  30. uint32_t magic;
  31. int w, h;
  32. int x, y;
  33. int flags;
  34. } FimgArea51;
  35. #define FIMG_TYPE_GRAY 1
  36. #define FIMG_TYPE_RGB 3
  37. #define FIMG_TYPE_RGBA 4
  38. #define FIMG_TYPE_RGBZ 99
  39. #define FILE_TYPE_FIMG 1
  40. #define FILE_TYPE_PNM 2
  41. #define FILE_TYPE_PNG 3
  42. #define FILE_TYPE_TGA 4
  43. #define FILE_TYPE_TIFF 5
  44. #define FILE_TYPE_FITS 6
  45. #define FILE_TYPE_BMP 7
  46. #define FILE_TYPE_EXR 8
  47. /* lib/contrast.c */
  48. #define CONTRAST_NONE 0
  49. #define CONTRAST_SQRT 1
  50. #define CONTRAST_POW2 2
  51. #define CONTRAST_COS01 3
  52. #define CONTRAST_COS010 4
  53. #define CONTRAST_XPER 5 /* use with caution */
  54. /*
  55. * core module
  56. */
  57. int fimg_create(FloatImg *fimg, int w, int h, int t);
  58. int fimg_destroy(FloatImg *fimg);
  59. int fimg_clone(FloatImg *fimg, FloatImg *newpic, int flags);
  60. int fimg_copy_data(FloatImg *from, FloatImg *to);
  61. int fimg_type_is_valid(int type);
  62. int fimg_print_version(int k);
  63. void fimg_print_sizeof(void);
  64. void fimg_printhead(FloatImg *h);
  65. void fimg_printdims(char *txt, FloatImg *pi);
  66. int fimg_describe(FloatImg *head, char *txt);
  67. char *fimg_str_type(int type);
  68. int fimg_plot_rgb (FloatImg *head, int x, int y,
  69. float r, float g, float b);
  70. int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
  71. int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
  72. int fimg_clear(FloatImg *fimg);
  73. int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
  74. int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
  75. /* --> lib/fimg-compare.c */
  76. int fimg_images_not_compatible(FloatImg *a, FloatImg *b);
  77. int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef);
  78. /* 'operats' module */
  79. int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d);
  80. int fimg_add_2(FloatImg *a, FloatImg *b); /* B+=A */
  81. int fimg_sub_3(FloatImg *a, FloatImg *b, FloatImg *d);
  82. int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
  83. int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
  84. int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
  85. /* funcs/filtrage.c */
  86. typedef struct {
  87. float matrix[9];
  88. float mult;
  89. float offset;
  90. } FimgFilter3x3;
  91. int fimg_killborders(FloatImg *img);
  92. int fimg_lissage_2x2(FloatImg *img);
  93. int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
  94. int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse);
  95. /* module sfx0.c */
  96. int fimg_killcolors_a(FloatImg *fimg, float fval);
  97. int fimg_killcolors_b(FloatImg *fimg, float fval);
  98. int fimg_colors_mixer_a(FloatImg *fimg, float fval);
  99. /* module sfx1.c */
  100. int fimg_highlight_color(FloatImg *src, FloatImg *dst,
  101. char color, float fval);
  102. /* module sfx2.c */
  103. int fimg_binarize(FloatImg *pimg, int notused);
  104. int fimg_trinarize(FloatImg *pimg, int notused);
  105. /* module sfx3.c */
  106. int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused);
  107. /* module sfx4.c */
  108. int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
  109. /* funcs/rotate.c module */
  110. /* #coronamaison */
  111. int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
  112. /* universal exporter XXX */
  113. int fimg_export_picture(FloatImg *pic, char *fname, int flags);
  114. /* PNM files module */
  115. int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
  116. int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
  117. double fimg_timer_set(int whot);
  118. double fimg_timer_get(int whot);
  119. /* --> lib/contrast.c */
  120. int fimg_id_contraste(char *name);
  121. int fimg_square_root(FloatImg *s, FloatImg *d, double maxval);
  122. int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
  123. int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
  124. int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
  125. int fimg_mix_rgb_gray(FloatImg *img, float mix);
  126. /* funcs/saturation.c */
  127. int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
  128. int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
  129. /* --> funcs/plasmas.c */
  130. int fimg_prototype_plasma(FloatImg *img, double time, int type);
  131. /* * * * experimental ! */
  132. int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
  133. int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
  134. int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
  135. /* module funcs/??????.c */
  136. int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
  137. int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
  138. int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
  139. /* module funcs/geometry.c */
  140. /* warning, this module is a mess */
  141. int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
  142. int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
  143. int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
  144. int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
  145. int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
  146. int xpos, int ypos, int flags);
  147. int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
  148. /* module funcs/rampes.c */
  149. int fimg_hdeg_a(FloatImg *img, double dcoef);
  150. int fimg_vdeg_a(FloatImg *img, double dcoef);
  151. /* FIMG files module */
  152. int fimg_fileinfos(char *fname, int *datas);
  153. int fimg_dump_to_file(FloatImg *head, char *fname, int notused);
  154. int fimg_load_from_dump(char *fname, FloatImg *where);
  155. int fimg_create_from_dump(char *fname, FloatImg *head);
  156. int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
  157. int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
  158. int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
  159. int fimg_save_plane_as_fits(FloatImg *src, char *oname, char plane, int flags);
  160. int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
  161. int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
  162. /* mathematics operations */
  163. float fimg_get_maxvalue(FloatImg *head);
  164. int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]);
  165. int fimg_meanvalues(FloatImg *head, float means[4]);
  166. int fimg_to_gray(FloatImg *head);
  167. int fimg_add_cste(FloatImg *fi, float value);
  168. int fimg_mul_cste(FloatImg *fi, float value);
  169. int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
  170. void fimg_drand48(FloatImg *fi, float kmul);
  171. long fimg_count_negativ(FloatImg *fi);
  172. long fimg_clamp_negativ(FloatImg *fi);
  173. /* various funcs modules */
  174. int fimg_load_from_png(char *filename, FloatImg *fimg);
  175. int fimg_create_from_png(char *filename, FloatImg *fimg);
  176. int fimg_save_as_png(FloatImg *src, char *outname, int flags);
  177. int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
  178. int fimg_test_pattern(FloatImg *fimg, int type, double dval);
  179. int fimg_draw_something(FloatImg *fimg);
  180. int fimg_mircol_1(FloatImg *dst, float mval);
  181. int fimg_multirandom(FloatImg *fimg, long nbpass);
  182. /* file is 'funcs/utils.c' */
  183. void fimg_print_minmax(float minmax[6], char *titre);
  184. int parse_WxH(char *str, int *pw, int *ph);
  185. int parse_double(char *str, double *dptr);
  186. int print_rectangle(char *str, FimgArea51 *rect);
  187. int parse_rectangle(char *str, FimgArea51 *r, int notused);
  188. int format_from_extension(char *fname);
  189. char * extension_from_format(int fmt);