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.

751 lines
16 KiB

12 months ago
12 months ago
12 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. /*
  2. * tests des fonctions diverses - subroutines
  3. see also: t.c
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <pam.h>
  9. #undef DEBUG_LEVEL
  10. #define DEBUG_LEVEL 1
  11. #include "../floatimg.h"
  12. #include "tests.h"
  13. extern int verbosity;
  14. /* --------------------------------------------------------------------- */
  15. /* nouveau 21 mars 2021 - rue d'Aragon */
  16. int essai_openexr(char *inf, char *outf, int flags)
  17. {
  18. FloatImg src;
  19. int foo;
  20. fprintf(stderr, ">>> %s ( '%s' '%s' 0x%X )\n", __func__,
  21. inf, outf, flags);
  22. foo = fimg_create_from_dump(inf, &src);
  23. if (0 != foo) {
  24. fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
  25. foo, inf);
  26. return foo;
  27. }
  28. // fprintf(stderr, "image loaded at %p\n", &src);
  29. fimg_describe(&src, "for save EXR test");
  30. foo = fimg_save_as_exr(&src, outf, flags);
  31. fimg_destroy(&src);
  32. return -2;
  33. }
  34. /* --------------------------------------------------------------------- */
  35. /* nouveau 20 mars 2021 - rue d'Aragon */
  36. int essai_highlights(char *inf, char *outf, int ikoef, float fkoef)
  37. {
  38. FloatImg src, dst;
  39. int foo;
  40. fprintf(stderr, ">>> %s ( '%s' '%s' %d %g )\n", __func__,
  41. inf, outf, ikoef, fkoef);
  42. foo = fimg_create_from_dump(inf, &src);
  43. if (0 != foo) {
  44. fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
  45. foo, inf);
  46. return foo;
  47. }
  48. fimg_clone(&src, &dst, 0);
  49. foo = fimg_highlight_color(&src, &dst, 'R', fkoef);
  50. if (foo) {
  51. fprintf(stderr, "%s: err %d ?\n", __func__, foo);
  52. return foo;
  53. }
  54. foo = fimg_export_picture(&dst, outf, 0);
  55. if (foo) {
  56. fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
  57. return foo;
  58. }
  59. return 0;
  60. }
  61. /* --------------------------------------------------------------------- */
  62. int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef)
  63. {
  64. FloatImg src, dst;
  65. int foo;
  66. fprintf(stderr, ">>> %s ( '%s' '%s' %d %g )\n", __func__,
  67. infile, outfile, ikoef, fkoef);
  68. /* if infile is loadable, use it for background */
  69. foo = fimg_create_from_dump(infile, &src);
  70. if (0 == foo) {
  71. fprintf(stderr, "%s: image '%s' loaded\n", __func__, infile);
  72. }
  73. else {
  74. /* make a fancy synthetic picture */
  75. foo = fimg_create(&src, 800, 600, FIMG_TYPE_RGB);
  76. }
  77. fimg_printhead(&src);
  78. fimg_clone(&src, &dst, 1);
  79. foo = fimg_prototype_plasma(&dst, fkoef, 0);
  80. if (foo) {
  81. fprintf(stderr, "%s: err %d on plasma proto\n", __func__, foo);
  82. return -88;
  83. }
  84. fimg_mul_3(&src, &dst, &dst);
  85. foo = fimg_export_picture(&dst, outfile, 0);
  86. if (foo) {
  87. fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
  88. return foo;
  89. }
  90. return -1;
  91. }
  92. /* --------------------------------------------------------------------- */
  93. /* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
  94. int essai_displacement(char *infile, char *outfile)
  95. {
  96. int foo;
  97. FloatImg src, dst;
  98. fprintf(stderr, "%s : loading %s\n", __func__, infile);
  99. foo = fimg_create_from_dump(infile, &src);
  100. if (foo) {
  101. fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
  102. return foo;
  103. }
  104. fimg_clone(&src, &dst, 1);
  105. foo = fimg_displacement_0(&src, &dst, 0);
  106. if (foo) {
  107. fprintf(stderr, "%s: err %d in disp map 0\n", __func__, foo);
  108. return foo;
  109. }
  110. foo = fimg_export_picture(&dst, outfile, 0);
  111. if (foo) {
  112. fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
  113. return foo;
  114. }
  115. return 0;
  116. }
  117. /* --------------------------------------------------------------------- */
  118. /*
  119. * nouveau 7 octobre 2020 pendant sonoptic
  120. *
  121. * inspiration: Olivier Baudu
  122. */
  123. int essai_qsort_rgb(char *infile, char *outfile)
  124. {
  125. FloatImg src, dst;
  126. int foo;
  127. if (NULL != infile) {
  128. fprintf(stderr, "%s : loading %s\n", __func__, infile);
  129. foo = fimg_create_from_dump(infile, &src);
  130. if (foo) {
  131. fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
  132. return foo;
  133. }
  134. }
  135. else {
  136. fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
  137. abort();
  138. }
  139. fimg_clone(&src, &dst, 1);
  140. foo = fimg_qsort_rgb_b(&src, &dst, 0);
  141. if (foo) {
  142. fprintf(stderr, "%s: err %d in qsort_rgb\n", __func__, foo);
  143. return foo;
  144. }
  145. foo = fimg_export_picture(&dst, outfile, 0);
  146. if (foo) {
  147. fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
  148. return foo;
  149. }
  150. fimg_destroy(&src); fimg_destroy(&dst);
  151. return 0;
  152. }
  153. /* --------------------------------------------------------------------- */
  154. /*
  155. * nouveau 5 octobre 2020 pendant sonoptic
  156. */
  157. int essai_contour_2x2(char *infile, char *outfile)
  158. {
  159. FloatImg src, dst;
  160. int foo;
  161. if (NULL != infile) {
  162. fprintf(stderr, "%s : loading %s\n", __func__, infile);
  163. foo = fimg_create_from_dump(infile, &src);
  164. if (foo) {
  165. fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
  166. return foo;
  167. }
  168. }
  169. else {
  170. fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
  171. abort();
  172. }
  173. fimg_clone(&src, &dst, 1);
  174. foo = fimg_contour_2x2(&src, &dst, 0);
  175. if (foo) {
  176. fprintf(stderr, "%s: err %d in contour_2x2\n", __func__, foo);
  177. return foo;
  178. }
  179. foo = fimg_export_picture(&dst, outfile, 0);
  180. if (foo) {
  181. fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
  182. return foo;
  183. }
  184. fimg_destroy(&src); fimg_destroy(&dst);
  185. return 0;
  186. }
  187. /* --------------------------------------------------------------------- */
  188. /*
  189. * nouveau 5 octobre 2020 pendant sonoptic
  190. */
  191. int essai_classif(char *infile, char *outfile, float fvalue)
  192. {
  193. FloatImg src, dst;
  194. int foo;
  195. if (NULL != infile) {
  196. fprintf(stderr, "%s : loading %s\n", __func__, infile);
  197. foo = fimg_create_from_dump(infile, &src);
  198. if (foo) {
  199. fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
  200. return foo;
  201. }
  202. }
  203. else {
  204. fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
  205. abort();
  206. }
  207. fimg_clone(&src, &dst, 1);
  208. fprintf(stderr, "%s : fvalue is %f\n", __func__, fvalue);
  209. foo = fimg_classif_trial(&src, &dst, fvalue, 0);
  210. if (foo) {
  211. fprintf(stderr, "%s: err %d in classif_trial\n", __func__, foo);
  212. return foo;
  213. }
  214. foo = fimg_export_picture(&dst, outfile, 0);
  215. if (foo) {
  216. fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
  217. return foo;
  218. }
  219. fimg_destroy(&src); fimg_destroy(&dst);
  220. return 0;
  221. }
  222. /* --------------------------------------------------------------------- */
  223. /* nouveau 19 aout 2020, le matin avant la canicule */
  224. int essai_ecriture_tiff(char *outname)
  225. {
  226. int foo;
  227. FloatImg picz;
  228. fimg_create(&picz, 800, 600, FIMG_TYPE_RGB);
  229. fimg_test_pattern(&picz, 0, 22222);
  230. foo = fimg_write_as_tiff(&picz, outname, 0);
  231. if (foo) {
  232. fprintf(stderr, "%s got a %d\n", __func__, foo);
  233. return foo;
  234. }
  235. return 0;
  236. }
  237. /* --------------------------------------------------------------------- */
  238. /* essai de fichiers FITS (astronomie) */
  239. int essai_ecriture_fits(char *outname)
  240. {
  241. FloatImg src;
  242. int foo;
  243. fprintf(stderr, "%s is creating the picz\n", __func__);
  244. fimg_create(&src, 512, 512, FIMG_TYPE_RGB);
  245. fimg_test_pattern(&src, 0, 255.0);
  246. foo = fimg_save_R_as_fits(&src, outname, 0);
  247. fprintf(stderr, "saving '%s' to fits --> %d\n", outname, foo);
  248. return -1;
  249. }
  250. /* --------------------------------------------------------------------- */
  251. /*
  252. * egalisation dynamique approximative
  253. * #coronamaison Thu 09 Apr 2020 03:37:10 PM CEST
  254. */
  255. int essai_equalize(char *infile)
  256. {
  257. FloatImg src;
  258. int foo;
  259. if (NULL != infile) {
  260. fprintf(stderr, "%s: loading %s\n", __func__, infile);
  261. foo = fimg_create_from_dump(infile, &src);
  262. if (foo) {
  263. fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
  264. return foo;
  265. }
  266. }
  267. else {
  268. fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
  269. abort();
  270. }
  271. /*
  272. * XXX need more work on this function !
  273. */
  274. foo = fimg_equalize_compute(&src, NULL, 666.666);
  275. fprintf(stderr, "equalize compute --> %d\n", foo);
  276. fimg_destroy(&src);
  277. return 0;
  278. }
  279. /* --------------------------------------------------------------------- */
  280. int essai_rotate(char *infile)
  281. {
  282. FloatImg src, dst;
  283. int foo;
  284. if (NULL != infile) {
  285. fprintf(stderr, "%s: loading %s\n", __func__, infile);
  286. foo = fimg_create_from_dump(infile, &src);
  287. if (foo) {
  288. fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
  289. return foo;
  290. }
  291. }
  292. else {
  293. fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
  294. abort();
  295. }
  296. fimg_save_as_png(&src, "test.png", 0);
  297. foo = fimg_rotate_90(&src, &dst, 0);
  298. fprintf(stderr, "rotate 90 -> %d\n", foo);
  299. foo = fimg_export_picture(&dst, "rotated90.png", 0);
  300. foo = fimg_export_picture(&dst, "rotated90.pnm", 0);
  301. fimg_destroy(&src);
  302. return -1;
  303. }
  304. /* --------------------------------------------------------------------- */
  305. int essai_filtrage_3x3(char *infile)
  306. {
  307. FloatImg src, dst;
  308. int foo; /// , idx;
  309. // char buffer[100];
  310. FimgFilter3x3 filter_a = {
  311. { 1.0, 1.0, 1.0,
  312. 1.0, -3.0, 1.0,
  313. 1.0, 1.0, 1.0 },
  314. 9.0, 0.0
  315. };
  316. FimgFilter3x3 filter_b = {
  317. { -2.0, -1.0, 0.0,
  318. -1.0, 3.0, 1.0,
  319. 0.0, 1.0, 2.0 },
  320. 8.0, 0.0
  321. };
  322. FimgFilter3x3 filter_c = {
  323. {
  324. 2.0, 1.0, 0.0,
  325. 1.0, 0.0, -1.0,
  326. 0.0, -1.0, -2.0,
  327. },
  328. 1.0, 8.0
  329. };
  330. if (NULL != infile) {
  331. fprintf(stderr, "%s: loading %s\n", __func__, infile);
  332. foo = fimg_create_from_dump(infile, &src);
  333. if (foo) {
  334. fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
  335. return foo;
  336. }
  337. }
  338. else {
  339. fprintf(stderr, "%s is creating the picz\n", __func__);
  340. fimg_create(&src, 640, 480, FIMG_TYPE_RGB);
  341. fimg_test_pattern(&src, 0, 255.0);
  342. }
  343. // fimg_save_as_png(&src, "test.png", 0);
  344. foo = fimg_count_negativ(&src);
  345. fprintf(stderr, "%s: source have %d negs\n", __func__, foo);
  346. foo = fimg_clone(&src, &dst, 0);
  347. if (foo) {
  348. fprintf(stderr, "%s: err clone %p\n", __func__, &src);
  349. return -44;
  350. }
  351. fimg_filter_3x3(&src, &dst, &filter_a);
  352. foo = fimg_clamp_negativ(&dst);
  353. if (foo) {
  354. fprintf(stderr, "A clamped %d negative pixels\n", foo);
  355. }
  356. foo = fimg_save_as_png(&dst, "f3x3a.png", 0);
  357. // foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
  358. fimg_filter_3x3(&src, &dst, &filter_b);
  359. foo = fimg_clamp_negativ(&dst);
  360. if (foo) {
  361. fprintf(stderr, "B clamped %d negative pixels\n", foo);
  362. }
  363. foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
  364. // foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
  365. fimg_filter_3x3(&src, &dst, &filter_c);
  366. foo = fimg_clamp_negativ(&dst);
  367. if (foo) {
  368. fprintf(stderr, "C clamped %d negative pixels\n", foo);
  369. }
  370. foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
  371. // foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
  372. fimg_destroy(&src); fimg_destroy(&dst);
  373. return 0;
  374. }
  375. /* --------------------------------------------------------------------- */
  376. int essai_filtrage_2x2(char *infile)
  377. {
  378. FloatImg fimg;
  379. int foo, idx;
  380. char buffer[100];
  381. if (NULL != infile) {
  382. fprintf(stderr, "%s: loading %s\n", __func__, infile);
  383. foo = fimg_create_from_dump(infile, &fimg);
  384. if (foo) {
  385. fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
  386. return foo;
  387. }
  388. }
  389. else {
  390. fprintf(stderr, "%s is creating the picz\n", __func__);
  391. fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
  392. fimg_draw_something(&fimg);
  393. }
  394. foo = fimg_save_as_pnm(&fimg, "source.pnm", 0);
  395. /*
  396. * running multiple filters so you can
  397. * watch the up-left shift :)
  398. */
  399. for (idx=0; idx<5; idx++) {
  400. foo = fimg_lissage_2x2(&fimg);
  401. sprintf(buffer, "filter%03d.png", idx);
  402. foo = fimg_save_as_png(&fimg, buffer, 0);
  403. if (verbosity) {
  404. fprintf(stderr, "%s %d\n", buffer, foo);
  405. }
  406. }
  407. fimg_destroy(&fimg);
  408. return 0;
  409. }
  410. /* --------------------------------------------------------------------- */
  411. int essai_geometrie(char *infile)
  412. {
  413. FloatImg fimg, result;
  414. int foo;
  415. if (NULL != infile) {
  416. fprintf(stderr, "loading %s\n", infile);
  417. foo = fimg_create_from_dump(infile, &fimg);
  418. if (foo) {
  419. fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
  420. return foo;
  421. }
  422. }
  423. else {
  424. fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
  425. fimg_draw_something(&fimg);
  426. }
  427. foo = fimg_save_as_pnm(&fimg, "source.pnm", 0);
  428. memset(&result, 0, sizeof(FloatImg));
  429. foo = fimg_halfsize_0(&fimg, &result, 0);
  430. fprintf(stderr, "retour halfsize -> %d\n", foo);
  431. if (foo) {
  432. return -2;
  433. }
  434. if (verbosity) fimg_describe(&result, "result after halfsize");
  435. foo = fimg_save_as_pnm(&result, "something.pnm", 0);
  436. return 0;
  437. }
  438. /* --------------------------------------------------------------------- */
  439. int essai_sfx0(char *infile)
  440. {
  441. FloatImg fimg;
  442. int foo;
  443. if (NULL != infile) {
  444. fprintf(stderr, "loading %s\n", infile);
  445. foo = fimg_create_from_dump(infile, &fimg);
  446. if (foo) {
  447. fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
  448. return foo;
  449. }
  450. }
  451. else {
  452. fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
  453. fimg_draw_something(&fimg);
  454. }
  455. foo = fimg_save_as_pnm(&fimg, "something.pnm", 0);
  456. if (foo) {
  457. fprintf(stderr, "%s: err save %d\n", __func__, foo);
  458. return -6;
  459. }
  460. foo = fimg_killcolors_a(&fimg, 0.0);
  461. foo = fimg_save_as_pnm(&fimg, "colorskilled-a.pnm", 0);
  462. if (foo) {
  463. fprintf(stderr, "%s: err save %d\n", __func__, foo);
  464. return -6;
  465. }
  466. foo = fimg_killcolors_b(&fimg, 0.0);
  467. foo = fimg_save_as_pnm(&fimg, "colorskilled-b.pnm", 0);
  468. if (foo) {
  469. fprintf(stderr, "%s: err save %d\n", __func__, foo);
  470. return -6;
  471. }
  472. fimg_destroy(&fimg);
  473. return 0;
  474. }
  475. /* --------------------------------------------------------------------- */
  476. int essai_parse_double(void)
  477. {
  478. int foo;
  479. double dval;
  480. char *str;
  481. str = "12.34"; dval = 0.0;
  482. foo = parse_double(str, &dval);
  483. printf("%-10s -> %3d %g\n", str, foo, dval);
  484. str = "12e4"; dval = 0.0;
  485. foo = parse_double(str, &dval);
  486. printf("%-10s -> %3d %g\n", str, foo, dval);
  487. str = "5s"; dval = 0.0;
  488. foo = parse_double(str, &dval);
  489. printf("%-10s -> %3d %g\n", str, foo, dval);
  490. str = "PORN"; dval = 0.0;
  491. foo = parse_double(str, &dval);
  492. printf("%-10s -> %3d %g\n", str, foo, dval);
  493. return 0;
  494. }
  495. /* --------------------------------------------------------------------- */
  496. int essai_detect_type(void)
  497. {
  498. int foo;
  499. char *fname;
  500. foo = format_from_extension(fname="foo.fimg");
  501. printf("%-10s %d\n\n", fname, foo);
  502. foo = format_from_extension(fname="foo.pnm");
  503. printf("%-10s %d\n\n", fname, foo);
  504. foo = format_from_extension(fname="foo.png");
  505. printf("%-10s %d\n\n", fname, foo);
  506. foo = format_from_extension(fname="foo.tiff");
  507. printf("%-10s %d\n\n", fname, foo);
  508. foo = format_from_extension(fname="foo.fits");
  509. printf("%-10s %d\n\n", fname, foo);
  510. foo = format_from_extension(fname="foo.xyzzy");
  511. printf("%-10s %d\n\n", fname, foo);
  512. return 0;
  513. }
  514. /* --------------------------------------------------------------------- */
  515. int essai_mire(char *outname, int notused)
  516. {
  517. FloatImg fimg;
  518. int re;
  519. fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB);
  520. re = fimg_test_pattern(&fimg, 9, 1.0);
  521. if (re) {
  522. fprintf(stderr, "fimg_test_pattern -> %d\n", re);
  523. }
  524. fimg_export_picture(&fimg, "mire.pnm", 0);
  525. return -1;
  526. }
  527. /* --------------------------------------------------------------------- */
  528. int essai_rampes(void)
  529. {
  530. FloatImg fimg;
  531. int foo;
  532. fimg_create(&fimg, 640, 480, FIMG_TYPE_RGB);
  533. #define V ((double)3.141592654)
  534. foo = fimg_hdeg_a(&fimg, V);
  535. fprintf(stderr, "make h deg -> %d\n", foo);
  536. foo = fimg_save_as_pnm(&fimg, "hdeg.pnm", 0);
  537. fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
  538. foo = fimg_vdeg_a(&fimg, V);
  539. fprintf(stderr, "make h deg -> %d\n", foo);
  540. foo = fimg_save_as_pnm(&fimg, "vdeg_a.pnm", 0);
  541. fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
  542. foo = fimg_vdeg_a(&fimg, -V);
  543. fprintf(stderr, "make h deg -> %d\n", foo);
  544. foo = fimg_save_as_pnm(&fimg, "vdeg_b.pnm", 0);
  545. fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
  546. #undef V
  547. return 0;
  548. }
  549. /* --------------------------------------------------------------------- */
  550. int essai_lecture_png(char *fname, char *outfile, int notused)
  551. {
  552. FloatImg fimg;
  553. int foo;
  554. fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
  555. memset(&fimg, 0, sizeof(FloatImg));
  556. foo = fimg_create_from_png(fname, &fimg);
  557. if (foo) {
  558. fprintf(stderr, "%s: createfrom -> %d\n", __func__, foo);
  559. return foo;
  560. }
  561. fimg_describe(&fimg, "created from png");
  562. foo = fimg_export_picture(&fimg, outfile, 0);
  563. if (foo) {
  564. fprintf(stderr, "%s : err %d saving result to %s\n", __func__,
  565. foo, outfile);
  566. return foo;
  567. }
  568. return 0;
  569. }
  570. /* --------------------------------------------------------------------- */
  571. int essai_ecriture_png(char *fname)
  572. {
  573. FloatImg fimg;
  574. int foo;
  575. fimg_create(&fimg, 800, 600, FIMG_TYPE_RGB);
  576. fimg_draw_something(&fimg);
  577. if (verbosity) {
  578. foo = fimg_save_as_pnm(&fimg, "quux.pnm", 0);
  579. fprintf(stderr, "%s: saved as pnm -> %d\n", __func__, foo);
  580. }
  581. foo = fimg_save_as_png(&fimg, fname, 0);
  582. fprintf(stderr, "save as png -> %d\n", foo);
  583. fimg_destroy(&fimg);
  584. return 0;
  585. }
  586. /* --------------------------------------------------------------------- */
  587. int fimg_essai_hsv(char *fname); /* hsv.c */
  588. int essai_histogramme(char *fname, int k)
  589. {
  590. FloatImg fimg;
  591. int foo;
  592. fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, k);
  593. foo = fimg_create_from_dump(fname, &fimg);
  594. if (foo) {
  595. fprintf(stderr, "%s: err load '%s'\n", __func__, fname);
  596. return foo;
  597. }
  598. foo = fimg_essai_histo(&fimg, "out.png", k);
  599. if (foo) {
  600. fprintf(stderr, "essai_histo -> error %d\n", foo);
  601. return foo;
  602. }
  603. fimg_destroy(&fimg);
  604. fprintf(stderr, "\\o/ end of %s\n", __func__);
  605. return 0;
  606. }
  607. /* --------------------------------------------------------------------- */
  608. /* --------------------------------------------------------------------- */