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.

214 lines
6.3 KiB

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