Compare commits

..

258 Commits

Author SHA1 Message Date
tTh
8202df9a63 check for the export directory (singlepass) 2024-11-13 13:37:54 +01:00
tTh
67ba638690 check for the export directory (interpolator) 2024-11-13 13:35:22 +01:00
tTh
e8a7bf28e3 check for the export directory (fonderie) 2024-11-12 22:58:55 +01:00
tTh
b19107d71b add two molly-guard 2024-11-12 12:50:31 +01:00
tTh
fabe94792b add two molly-guard 2024-11-12 12:49:43 +01:00
tTh
d1e67f7397 add a missing exit() 2024-11-12 11:36:57 +01:00
tTh
28453e862a msg when export dir not writable 2024-11-11 17:24:03 +01:00
tTh
2147d4b164 tweaking help text 2024-11-11 17:15:53 +01:00
tTh
b0983ab18b msg bug + better exit 2024-11-11 17:13:20 +01:00
tTh
08fcf513cc checking export directory, first try 2024-11-10 13:55:25 +01:00
tTh
e6b72e5faa minor changes 2024-10-27 16:37:10 +01:00
tTh
756766ca42 + libncurses-dev 2024-10-12 00:34:27 +02:00
tTh
9ede78fa5d signaler création répertoire pour export 2024-10-11 23:54:23 +02:00
tTh
506bf39393 cosmetic 2024-10-11 23:30:41 +02:00
tTh
26e82619fb little tweak 2024-09-29 20:14:13 +02:00
tTh
91440e7ea5 add shift to zero filter 2024-09-29 19:04:10 +02:00
tTh
5fbff721d8 cosmetic 2024-09-29 18:46:38 +02:00
tTh
d510e56d44 various enhancements 2024-08-29 18:24:01 +02:00
tTh
2a8348f0f9 hide a non-essential msg 2024-08-29 18:23:03 +02:00
tTh
f473a58f75 cosmetic + bla 2024-08-28 22:41:47 +02:00
tTh
556e1ad825 bump the version 2024-08-28 22:24:18 +02:00
tTh
23842595fd add a default target 2024-08-28 21:23:55 +02:00
tTh
6069c45b5a working on readme files 2024-08-28 21:23:09 +02:00
tTh
4e7debaae6 better doc for the tools 2024-05-26 01:38:30 +02:00
tTh
b7c32d24f3 mkfimg gradient now use the cli parameter 2024-05-01 21:42:55 +02:00
tTh
4f27e491b1 cosmetic 2024-05-01 21:40:44 +02:00
tTh
11e87efd67 cosmetic 2024-05-01 21:38:19 +02:00
tTh
85dbf384bd bla 2024-05-01 12:32:06 +02:00
tTh
8c4b9a6aa0 bla 2024-05-01 12:30:53 +02:00
tTh
bb2b3b72de add -a option for absolute value of op result 2024-05-01 12:28:23 +02:00
tTh
7586423d23 display reserved words of metadata 2024-04-08 12:35:51 +02:00
tTh
bdfb3e279d fimgextract can now copy metadata 2024-04-08 11:52:42 +02:00
tTh
e00c6b8fb2 add togray filter 2024-04-06 20:25:51 +02:00
tTh
cce8e0b86c cleanup 2024-04-04 02:21:41 +02:00
tTh
f5ce5a3699 oups... 2024-04-04 02:17:50 +02:00
tTh
0d092f89af add missing proto 2024-04-01 18:10:07 +02:00
tTh
79f4e011a5 add triptyq effect to fonderie 2024-04-01 18:04:40 +02:00
tTh
a433176c54 added the triptyq fx to library 2024-04-01 17:49:14 +02:00
tTh
02b4493659 minor changes 2024-04-01 00:07:34 +02:00
tTh
fe3bc9d64c better messages 2024-03-31 00:15:47 +01:00
tTh
346ea08aba fix two error messages 2024-03-28 16:01:58 +01:00
tTh
e0c5695ab8 better messages 2024-03-27 12:20:28 +01:00
tTh
3604f41a57 better messages 2024-03-27 12:19:41 +01:00
tTh
953462eb6e thermocolr updated 2024-03-27 08:50:17 +01:00
tTh
4ecce5bdc0 maybe fix a bug in trinitron 2024-03-27 08:36:18 +01:00
tTh
65c0212108 update fx demo script 2024-03-27 07:27:52 +01:00
tTh
681899b06d less verbosity is better 2024-03-25 12:45:15 +01:00
tTh
fc9b6571f3 add a little warning 2024-03-24 15:24:09 +01:00
tTh
f1d42c74a6 add deoc and warning 2024-03-24 15:20:04 +01:00
tTh
36c9dc3e88 add warning messages 2024-03-24 15:15:42 +01:00
tTh
fa5e4d5acd add thermocol fx to fonderie 2024-03-24 15:07:29 +01:00
tTh
5afb90bedf small clean 2024-03-21 16:10:39 +01:00
tTh
387c25401c fix typo in debug code 2024-03-21 16:10:06 +01:00
tTh
9fb09f401f thermocol is in fimgfx 2024-03-20 20:07:48 +01:00
tTh
83e577b89a thermocolor, first try 2024-03-20 18:44:06 +01:00
tTh
c598c4a2c0 ok boomer 2023-11-29 11:28:21 +01:00
tTh
b33a752af7 bla 2023-11-29 11:26:56 +01:00
tTh
9c5849e299 filter is coming again 2023-11-29 11:25:43 +01:00
tTh
9dd2064b7a nano cleanup 2023-11-29 11:24:58 +01:00
tTh
a438ab9362 better error message 2023-10-29 00:47:25 +02:00
tTh
381f329810 mute an useless message 2023-10-18 17:27:38 +02:00
tTh
3bd387f0a9 tuning of the "normalize" option 2023-10-18 16:08:51 +02:00
tTh
085e19942a cosmetic 2023-10-10 23:51:56 +02:00
tTh
152beddcb7 fimg2text can now add column names 2023-10-09 10:48:39 +02:00
tTh
c1b6f9ae40 cosmetic 2023-10-09 03:13:50 +02:00
tTh
2c407e5dd9 silent a message 2023-10-08 10:26:03 +02:00
tTh
c6b75d3bba working on lowpass filter 2023-10-08 09:38:42 +02:00
tTh
12347e9066 add a molly guard 2023-10-08 07:28:57 +02:00
tTh
9e9535221f enhanced mkfimg: do_stripe take a maxlevel parameter 2023-10-08 07:10:02 +02:00
tTh
1f1398f9f2 cosmetic 2023-10-07 21:05:55 +02:00
tTh
2699476135 new func: the max of max 2023-10-07 19:19:49 +02:00
tTh
cfe9f8cdae small patches 2023-10-06 21:34:11 +02:00
tTh
5d139312e2 enhance fimgmetadata -h 2023-09-11 11:09:31 +02:00
tTh
2c14368cd5 more work on cachengn 2023-07-20 12:03:43 +02:00
tTh
658ef3ab08 bla 2023-07-17 14:59:48 +02:00
tTh
8b8c1b466f cosmetic 2023-07-17 13:52:47 +02:00
tTh
817982c074 tweak 2023-07-17 13:43:31 +02:00
tTh
6a4b2f7c32 change blanks count default 2023-07-17 09:47:56 +02:00
tTh
36fcc15b0a cosmetic 2023-07-17 08:56:23 +02:00
tTh
8c0f55b7cb *OUPS!* 2023-07-17 07:44:39 +02:00
tTh
ee5e081031 new effect 'suprbg' added to Fonderie 2023-07-16 14:14:29 +02:00
tTh
d23a35849a trying a new effect 2023-07-16 12:39:49 +02:00
tTh
82ffe1c2cc bla du dimanche soir 2023-07-10 02:26:57 +02:00
tTh
0a482a7316 fixed 2023-07-08 13:10:47 +02:00
tTh
2c1687f82b a few oops... 2023-07-08 12:43:00 +02:00
tTh
0f245582d5 a few doc/exemples for blz 2023-07-08 12:18:55 +02:00
tTh
c8faa77904 img path is now 5 digits 2023-07-08 12:17:16 +02:00
tTh
03763a4dfb scories clean 2023-07-07 12:36:29 +02:00
tTh
54d9a9939d big clean on extractor 2023-07-07 12:27:48 +02:00
tTh
488893f6a3 bla 2023-07-07 12:25:47 +02:00
tTh
e9ca450584 little refactoring 2023-07-07 10:08:57 +02:00
tTh
3fd604b14a better message 2023-07-06 19:43:47 +02:00
tTh
0169fbade7 bla 2023-07-06 10:54:18 +02:00
tTh
0e00e00df5 remove an useless keyword 2023-07-06 09:06:31 +02:00
tTh
6e9aa75694 bla 2023-07-06 09:02:32 +02:00
tTh
603194451a debug debug messages 2023-07-06 08:59:10 +02:00
tTh
3ef1fdf02e bla 2023-07-06 08:58:20 +02:00
tTh
ad93b7935c add a remember 2023-07-05 16:48:55 +02:00
tTh
cd6f045789 tweaking 2023-07-05 16:47:43 +02:00
tTh
99bbd20b47 add 'fimg_lissage_3x3' function 2023-07-05 10:59:06 +02:00
tTh
54b061232d useless fine tuning and a little oups 2023-07-04 17:26:46 +02:00
tTh
b0fc5107c9 add a molly guard 2023-07-04 17:25:12 +02:00
tTh
9e36c8b64c cosmetic 2023-07-04 13:23:15 +02:00
tTh
0a5f58867c cosmetic 2023-07-03 00:14:22 +02:00
tTh
5c59dc7ef7 tweaking the doc 2023-07-02 21:21:21 +02:00
tTh
7244b4c829 NEED MORE DEBUG 2023-07-01 00:48:50 +02:00
tTh
17a4cc4dd2 bla 2023-06-29 15:40:59 +02:00
tTh
3949d147ef bump version 2023-06-29 14:30:41 +02:00
tTh
72cb5aa0f6 need more work 2023-06-29 14:29:59 +02:00
tTh
2ff17fc54b chasse au bug 2023-06-29 14:29:14 +02:00
tTh
ed227d6563 cosmetic 2023-06-29 14:14:47 +02:00
tTh
90b9d4e37a add *.data 2023-06-29 13:39:26 +02:00
tTh
253647c008 krkrkr 2023-06-26 17:34:53 +02:00
tTh
67cb70fa3b oups... 2023-05-29 22:02:15 +02:00
tTh
1d356a6f12 don't use filter numbers 2023-05-29 10:51:01 +02:00
tTh
cc647b43b4 bad option -> exit(1) 2023-05-29 09:06:57 +02:00
tTh
58e782de84 exit when a non-existent option was found 2023-05-28 10:49:12 +02:00
tTh
cb599a253c more experiments in progress 2023-04-29 19:29:45 +02:00
tTh
ff916c434c bien ranger ses .gitignore 2023-04-21 09:32:01 +02:00
tTh
11a1e95146 cosmetic changes 2023-04-09 05:28:07 +02:00
tTh
6e92252778 oups... 2023-04-08 06:55:38 +02:00
tTh
a4b7f5c21c nap time commit 2023-02-13 17:56:08 +01:00
tTh
36d30b76d7 fix bad parameters 2023-02-13 17:43:08 +01:00
tTh
e00423ed9b cosmetic 2023-02-13 14:27:01 +01:00
tTh
3e66e822f2 better err msg 2023-02-13 10:58:21 +01:00
tTh
a449c53592 cosmetic 2023-02-13 10:57:14 +01:00
tTh
154844c94d cosmetic 2023-02-12 13:15:03 +01:00
tTh
bf239a9004 add fluffy effect to the Fonderie 2023-02-12 11:41:26 +01:00
tTh
7d66b09635 add "fimg_make_rndfluffy_lines" function 2023-02-12 11:15:04 +01:00
tTh
70694cf592 silencing an useless code 2023-02-11 21:04:35 +01:00
tTh
a72f544b4b nice effects list with vidz 2023-02-11 21:03:33 +01:00
tTh
b3ca197b89 fix broken message 2023-02-11 19:23:43 +01:00
tTh
c1ce8f7696 silence a verbose warning 2023-02-11 18:04:38 +01:00
tTh
4ae4947fbe nice hack 2023-02-11 16:08:25 +01:00
tTh
af103abdcf minor tweaks 2023-01-31 00:14:56 +01:00
tTh
1ef877d947 small tweaking 2023-01-28 19:31:50 +01:00
tTh
1ad4b406d7 écrire un peu plus de doc... 2023-01-24 14:26:54 +01:00
tTh
c004f22b16 cosmetic 2023-01-22 15:32:09 +01:00
tTh
d58decefcb demo_fmorph: 1ere version 2023-01-22 15:26:55 +01:00
tTh
63bc4ed7af documentation++ 2023-01-21 11:49:11 +01:00
tTh
b79f6851f5 add an extractor 2023-01-21 09:06:36 +01:00
tTh
70dc8a7638 Oups... 2023-01-21 00:07:21 +01:00
tTh
63674c8eee good job, captain refactor 2022-11-07 12:48:21 +01:00
tTh
be4b6a774e added #include <stdint.h> 2022-11-07 12:39:07 +01:00
tTh
d750c027fa a little cleanup 2022-11-05 21:00:14 +01:00
tTh
7f3912a133 mollyguard & debug msg 2022-11-03 02:58:14 +01:00
tTh
1f4b424be7 cosmetic 2022-11-02 22:11:54 +01:00
tTh
d49b77a79f morpho0 filter in fimgfx 2022-11-01 21:18:09 +01:00
tTh
86a903360c fimg_filtre_morpho_0 up and running 2022-11-01 09:35:40 +01:00
tTh
5d18cb6c3f add a drand48 row 2022-10-30 22:03:34 +01:00
tTh
0e77fdeb7a cosmetic 2022-10-30 13:11:30 +01:00
tTh
0cb40ae2a0 add a bit-bang row 2022-10-30 13:06:36 +01:00
tTh
a02b725ae0 cosmetic 2022-10-27 21:32:02 +02:00
tTh
56073c0c80 new func: fimg_do_stripes(&fimg, 0); 2022-09-19 11:58:30 +02:00
tTh
eedc9197db are real numbers evil ? 2022-09-19 11:17:24 +02:00
tTh
feafd2799d a new "rescale" option in cumulfimgs 2022-09-17 19:18:45 +02:00
tTh
e6379f6338 birthday new func: fimg_equalize 2022-09-14 12:01:33 +02:00
tTh
1b598227c3 last commit from outerspace 2022-07-11 06:12:25 +02:00
tTh
3eed90c3e7 wtf? 2022-07-06 10:32:42 +02:00
tTh
c7a51ec7a0 big cleanup, word on metadata 2022-07-06 10:27:55 +02:00
tTh
aa2ced081a new target 2022-06-13 20:50:38 +02:00
tTh
b12151444b nasty bug 2022-06-11 12:43:55 +02:00
tTh
af41acba4a add debug code 2022-06-06 22:17:15 +02:00
tTh
f63f918530 changing host 2022-05-30 21:38:29 +02:00
tth
e224ab83b6 start of the fake colors module 2022-05-18 11:55:01 +02:00
tth
3c551b6c7c cosmetic 2022-05-18 10:27:15 +02:00
tth
fe9a14e2b5 small tuning... 2022-05-18 10:26:29 +02:00
tth
11082c0d08 add multiformat output to fimgfx 2022-05-17 08:30:20 +02:00
tth
615321eca8 a big commit of garbage 2022-05-14 20:49:59 +02:00
tth
4dcc524fc4 more fun with metadata 2022-04-17 04:25:31 +02:00
tth
263e254980 bla 2022-04-17 04:20:35 +02:00
tth
27e42a0ddd a little clean 2022-04-17 04:19:06 +02:00
tth
12c3218a93 renaming a member of the metadata struct 2022-04-17 04:03:38 +02:00
tth
8a663a95ee one more step : display metadata 2022-04-17 04:00:12 +02:00
tth
ddfadf9a67 /say /sieste 2022-04-12 14:54:07 +02:00
tth
455428f444 cosmetic 2022-04-12 14:49:00 +02:00
tth
6810783426 add fimgmetadata 2022-04-12 14:16:00 +02:00
tth
5064126da8 remove useless parameter 2022-04-12 14:15:08 +02:00
tth
2e6bff3f67 no more profiling 2022-04-12 14:14:13 +02:00
tth
a5fac7effd one more step on the metadata road 2022-04-09 23:18:14 +02:00
tth
4b64330884 try to get mdata from .fimg file 2022-04-08 03:10:43 +02:00
tth
f52e24b30c bump and run 2022-04-03 21:38:29 +02:00
tth
63e6dcd07b small tuning on the doc 2022-04-02 15:44:52 +02:00
tth
125383adf3 now displaying the source device with -vv 2022-04-01 15:25:37 +02:00
tth
be48fc6e84 metadata little change 2022-03-20 15:53:49 +01:00
tth
039d4cb77b metadata boilerplane, first milestone reached 2022-03-19 01:21:58 +01:00
tth
7ea77cc882 oups... 2022-03-10 18:04:50 +01:00
tth
60b4181f3c add machinable output 2022-03-10 17:25:19 +01:00
tth
3eb2f549ee cosmetic 2022-03-10 16:59:51 +01:00
tth
af92ce4e2e math error 2022-03-10 16:59:37 +01:00
tth
0cdb977a82 fine tuning 2022-03-06 04:47:58 +01:00
tth
b98c398c3c export planes as 16 bits PGM, second try 2022-03-02 00:59:36 +01:00
tth
c17132e969 export planes as 16 bits PGM, firt try 2022-02-28 20:00:20 +01:00
tth
6ffc08188d work on the real PGM export 2022-02-09 23:21:58 +01:00
tth
0da81df892 oups... 2022-02-09 22:59:58 +01:00
tth
4597598b02 konrad is up :) 2022-02-04 23:39:52 +01:00
tth
db7b740b2c add zero shift to fimgfx 2022-01-31 20:26:45 +01:00
tth
6aa802fde2 fix two missing break 2022-01-27 10:29:37 +01:00
tth
879e25463b DOUBLE OUPS ! 2022-01-24 12:58:05 +01:00
tTh
3f7abf4ea0 surveiller les warnings du gcc 2022-01-22 14:47:46 +01:00
tTh
af7266eb30 oups ! 2022-01-21 15:00:35 +01:00
tth
0dee6e0e46 is workaround correct ? 2022-01-21 14:49:52 +01:00
tth
fcd8b09029 tryint to repair a broken git 2022-01-21 14:48:45 +01:00
tth
f938bbc7bd ++ version 2022-01-21 14:44:58 +01:00
tTh
c61251ad53 adding -ln 2022-01-21 14:43:52 +01:00
tTh
e7e3713972 calm down a non essential message 2022-01-11 10:00:29 +01:00
tTh
4c38ff032a fine tuning the 3d contrib 2022-01-09 09:32:39 +01:00
tTh
a8d1e18650 Ok, this writz is working 2022-01-08 21:51:31 +01:00
tTh
ccd324749e first external contrib 2022-01-08 17:48:18 +01:00
tth
ab9e4b0250 bla 2021-11-28 14:39:35 +01:00
tth
6e896ee463 dicom boilerplate: [done] 2021-11-27 00:01:37 +01:00
tth
99187104ce preparing DICOM entry 2021-11-26 23:10:29 +01:00
tth
be4e6b0dc9 oups again 2021-11-02 19:27:19 +01:00
tth
8c514ffe99 added "abs" func to fimgfx 2021-11-02 16:01:11 +01:00
tth
2a1d74a83f oups 2021-11-02 15:38:10 +01:00
tth
f09162d4ce fixed a little brotch 2021-10-25 20:49:10 +02:00
tth
8dbe6dd5c1 patch the doc, luke 2021-10-25 20:04:32 +02:00
tth
86df4ef602 cumulfimgs can now export in all know formats 2021-10-25 18:17:38 +02:00
tth
5845ab7962 is _clear_rectangle working ? 2021-10-19 03:56:56 +02:00
tth
0e79b3e8fa hop hop hop le système de cache 2021-10-17 20:23:35 +02:00
tth
1b5186f4b3 NEW RELEASE for other systems 2021-10-17 18:32:53 +02:00
tth
6c92cca12c this is a big mess 2021-10-15 23:21:02 +02:00
tth
bc864a6acb + bla 2021-10-11 20:13:26 +02:00
tth
39f48a56b0 minor fix 2021-10-11 13:40:30 +02:00
tth
094b61ba39 fix a nasty bug in a Makefile 2021-10-11 09:23:17 +02:00
tth
9bde22f560 first version of pixelize_h 2021-10-10 23:38:10 +02:00
tth
f3dc73782a a small bla 2021-10-10 22:35:19 +02:00
tth
b93ec2e603 useless commit 2021-10-10 12:20:52 +02:00
tth
9124ab6434 adding killrgb experiments 2021-10-10 09:46:27 +02:00
tth
23908cb746 explicit error message 2021-10-10 09:25:59 +02:00
tth
f08f860daa killrgb: nice try, but... 2021-10-05 00:35:56 +02:00
tth
19c8f6aad5 do not use fimg_describe here ! 2021-06-12 13:54:35 +02:00
tth
30cb448642 small updates on doc 2021-06-11 06:56:59 +02:00
tth
40bf700a32 + movepixels experiment 2021-06-11 06:55:40 +02:00
tth
f24ad0d229 oups... 2021-06-11 06:50:13 +02:00
tth
19094fee24 moving IRC to libera.chat 2021-06-11 06:43:54 +02:00
tth
dbff8129b7 crumphard integrated in fonderie 2021-06-01 10:26:39 +02:00
tth
3b2be2e5dc less useless message 2021-06-01 10:03:09 +02:00
tth
e88ea153bd "img_crump_hard" was made in the bibcave 2021-06-01 09:44:48 +02:00
tth
49d2703612 + triplemul & little clean 2021-05-29 23:29:13 +02:00
tth
5a90dce59d doc + demo 2021-05-29 13:01:32 +02:00
tth
17955bd303 we can list all the garbage... 2021-05-29 09:33:38 +02:00
tth
865cc60ccf + stdint.h 2021-05-29 09:05:02 +02:00
tth
f77a63b08c bla 2021-05-27 17:57:35 +02:00
tth
389beea6cd + stdint.h / +debug code 2021-05-27 16:55:54 +02:00
tth
b2d2c45be1 planomuxer: step 1 2021-05-26 11:31:52 +02:00
tth
468b5feb74 + stdint.h 2021-05-25 12:01:56 +02:00
tth
fed3076b92 bla 2021-05-23 21:33:56 +02:00
tth
72e162e4cf use <stdint.h> everywhere 2021-05-20 09:31:28 +02:00
tth
802ec6e9c1 wtf? 2021-05-20 08:38:23 +02:00
tth
a87ad8dea2 put all the picz in the workspace 2021-05-20 08:36:55 +02:00
tth
41e77a5185 Zzzzz.... 2021-05-17 22:38:56 +02:00
tth
77e967cf38 link opt "-lm" at end of line 2021-05-16 12:18:26 +02:00
tth
20e2f1e71e fixed an useless bug 2021-05-15 19:41:42 +02:00
tth
92b7eb478c + bloup 2021-05-12 16:45:30 +02:00
tth
5b934abd0a oups... 2021-05-12 13:51:46 +02:00
tth
07dde749ed new pattern (mircol_1) in mkfimg 2021-05-12 12:04:55 +02:00
tth
4a52c16e40 minor fix 2021-05-11 14:12:10 +02:00
179 changed files with 6789 additions and 1134 deletions

91
.gitignore vendored
View File

@ -1,18 +1,23 @@
build lib/*.o
lib/t
lib/*.fimg
lib/*.png
lib/*.gif
# src/lib/*.o
src/lib/t
src/lib/*.fimg
src/lib/*.png
src/lib/*.gif
*.o
*.a *.a
gmon.out gmon.out
cscope.out
*.swp
*.pnm *.pnm
*.pgm
*.fimg *.fimg
essai
MANIFEST
tarball
*/*.ps */*.ps
doc/*.toc doc/*.toc
@ -25,62 +30,32 @@ doc/*.ind
doc/co*.tex doc/co*.tex
doc/foo.html doc/foo.html
src/funcs/t
src/funcs/*.o
src/funcs/*.png
src/funcs/V/*
src/src/funcs/*.gif
src/funcs/*.fits
src/funcs/*.tiff
src/funcs/toto
scripts/*.fimg scripts/*.fimg
scripts/*.pnm scripts/*.pnm
scripts/*.gif scripts/*.gif
src/v4l2/t v4l2/t
src/v4l2/capture v4l2/capture
src/v4l2/grabvidseq v4l2/grabvidseq
src/v4l2/*.o v4l2/*.o
src/v4l2/*.ppm v4l2/*.ppm
src/v4l2/*.png v4l2/*.png
src/v4l2/*.fits v4l2/*.fits
src/v4l2/*.tiff v4l2/*.tiff
src/v4l2/video-infos v4l2/video-infos
src/v4l2/nc-camcontrol v4l2/nc-camcontrol
# tools/fimg2png
# tools/fimg2pnm
# tools/fimg2tiff
# tools/fimg2fits
# tools/fimg2text
# tools/fimgstats
# tools/fimghalfsize
# tools/mkfimg
# tools/png2fimg
# tools/addtga2fimg
# tools/addpnm2fimg
# tools/cumulfimgs
# tools/fimgops
# tools/fimgfx
src/tools/*.png
src/tools/*.tiff
extras/Fonderie/*.o Fonderie/*.o
extras/Fonderie/*.png Fonderie/*.png
extras/Fonderie/*.pnm Fonderie/*.pnm
extras/Fonderie/*.gif Fonderie/*.gif
extras/Fonderie/*.fimg Fonderie/*.fimg
extras/extras/Fonderie/fonderie Fonderie/fonderie
extras/Fonderie/interpolator Fonderie/interpolator
extras/Fonderie/t Fonderie/t
extras/Fonderie/singlepass Fonderie/singlepass
extras/Fonderie/crapdef.h Fonderie/crapdef.h
extras/Fonderie/crapstr.h Fonderie/crapstr.h
extras/experiment/assemblage
extras/experiment/extracteur
extras/experiment/*.fimg
extras/experiment/*.pnm
extras/experiment/*.o

View File

@ -7,11 +7,12 @@ COPT = -g -fpic -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses
LIBS = ../libfloatimg.a -ltiff -lpnglite -lm -lz -lcfitsio LIBS = ../libfloatimg.a -ltiff -lpnglite -lm -lz -lcfitsio
OBJS = fifo.o sfx.o crapulator.o glitches.o metriques.o \ OBJS = fifo.o sfx.o crapulator.o glitches.o metriques.o \
filterstack.o single.o filterstack.o single.o utilfuncs.o
DEPS = ../floatimg.h \ DEPS = ../floatimg.h \
../libfloatimg.a \
fifo.h crapulator.h metriques.h glitches.h sfx.h \ fifo.h crapulator.h metriques.h glitches.h sfx.h \
filterstack.h crapdef.h crapstr.h single.h filterstack.h crapdef.h crapstr.h single.h utilfuncs.h
all: fonderie interpolator singlepass t all: fonderie interpolator singlepass t
@ -40,19 +41,19 @@ singlepass: singlepass.c ${DEPS} ${OBJS} Makefile
# some files are magically generated, sorry. # some files are magically generated, sorry.
# #
crapdef.h: crapulors.liste Makefile craplist2h.awk crapdef.h: crapulors.liste Makefile craplist2h.awk
./craplist2h.awk < $< | tee $@ < $< ./craplist2h.awk > $@
crapstr.h: crapulors.liste Makefile craplist2str.awk crapstr.h: crapulors.liste Makefile craplist2str.awk
./craplist2str.awk < $< | tee $@ < $< ./craplist2str.awk > $@
# --------------------------------------------------------- # ---------------------------------------------------------
# #
# a lot of silly functions # a lot of silly functions
# #
crapulator.o: crapulator.c ${DEPS} Makefile crapulator.o: crapulator.c $(DEPS) Makefile
gcc ${COPT} -c $< gcc ${COPT} -c $<
fifo.o: fifo.c fifo.h Makefile fifo.o: fifo.c fifo.h $(DEPS) Makefile
gcc ${COPT} -c $< gcc ${COPT} -c $<
sfx.o: sfx.c ${DEPS} Makefile sfx.o: sfx.c ${DEPS} Makefile
@ -70,4 +71,7 @@ metriques.o: metriques.c metriques.h Makefile
glitches.o: glitches.c glitches.h Makefile glitches.o: glitches.c glitches.h Makefile
gcc ${COPT} -c $< gcc ${COPT} -c $<
utilfuncs.o: utilfuncs.c utilfuncs.h Makefile
gcc ${COPT} -c $<
# --------------------------------------------------------- # ---------------------------------------------------------

View File

@ -3,12 +3,14 @@
Avec toutes ces fonctions disponibles et `grabvidseq`, nous Avec toutes ces fonctions disponibles et `grabvidseq`, nous
savons faire des images **floues**. L'étape suivante, les plus savons faire des images **floues**. L'étape suivante, les plus
pervers d'entre vous le savent déja, est celle de la création pervers d'entre vous le savent déja, est celle de la création
de **films flous** dans le domaine spacio-temporel. de **films flous** dans le domaine spatio-temporel.
À l'heure actuelle, il y a plusieurs programmes distincts. Le premier À l'heure actuelle, il y a plusieurs programmes distincts. Le premier
(fonderie) fait une moyenne mobile sur N images consécutives, (fonderie) fait une moyenne mobile sur N images consécutives,
et le second (interpolator) fait un fondu-enchainé de N pas le second (interpolator) fait un fondu-enchainé de N pas
entre deux images consécutives. entre deux images consécutives,
et le troisième (singlepass) fait d'autres trucs, comme
répéter N fois un image pour avoir une vidéo sacadée.
Mais avant et après un de ces deux traitements, il y a des chaines Mais avant et après un de ces deux traitements, il y a des chaines
de filtres... de filtres...
@ -20,16 +22,15 @@ destinés à augmenter la kitchitude du produit final. Ils peuvent être chainé
les uns après les autres, à l'entrée et à la sortie du process les uns après les autres, à l'entrée et à la sortie du process
de floutagement. de floutagement.
Ces filtres ont chacun un nom et un numéro. que l'on peut (en théorie) Ces filtres ont chacun un nom, utilisable dans une chaine de filtres.
utiliser indistinctement dans une chaine de filtres.
L'option `-L` de ces logiciels permet d'obtenir la liste des filtres. L'option `-L` de ces logiciels permet d'obtenir la liste des filtres.
Pour ne rien filtrer, utilisez le filtre `none`, il est là pour ça.
Une chaine de filtres est constituée d'une liste de nom ou de numéro Une chaine de filtres est constituée d'une liste de nom
de filtre, séparés par le caractère `:`, une façon de faire très de filtre, séparés par le caractère `:`, une façon de faire très
classique dans notre univers, en fait. Et si on veut prendre des risques, classique dans notre univers, en fait.
on doit continuer à appeler les filtres par leur numéro, jdçjdr.
`mirsplit:ctr2x2:3:killlines` `mirsplit:ctr2x2:killlines`
Nous allons donc voir quelques exemples un peu plus loin. Nous allons donc voir quelques exemples un peu plus loin.
@ -70,12 +71,14 @@ GRABDIR="/spool/tth/fonderie"
FONDEUR="$HOME/Devel/FloatImg/Fonderie/fonderie" FONDEUR="$HOME/Devel/FloatImg/Fonderie/fonderie"
GLOB=${GRABDIR}'/?????.fimg' GLOB=${GRABDIR}'/?????.fimg'
${FONDEUR} -I "$GLOB" -E cos01:25 -T 30 -F 2:classtrial ${FONDEUR} -I "$GLOB" -E cos01:trinitron -F classtrial -T 30
``` ```
Par défaut le répertoire où sont exportées les images est nommé
`p8/` et il doit être là, c'est donc à vous de le créer.
Votre machine va maintenant mouliner avec entrain et persévérance, Votre machine va maintenant mouliner avec entrain et persévérance,
puis puis
ensuite il suffit d'encoder toutes les images générées dans ensuite il vous suffira d'encoder toutes les images générées dans
`p8/` (répertoire de sortie par défaut) `p8/` (répertoire de sortie par défaut)
avec une incantation de ffmpeg : avec une incantation de ffmpeg :
@ -95,7 +98,7 @@ assez rudimentaire, avec un paramétrage simpliste, et un manque
criant de documentation... criant de documentation...
Dans la même équipe, vous pouvez aussi aller contempler `glitches.c` Dans la même équipe, vous pouvez aussi aller contempler `glitches.c`
pour voir le genre de traitement que l'on fait subir à nox pixels pour voir le genre de traitement que l'on fait subir à nos pixels
flottants. flottants.
## Interpolator ## Interpolator
@ -112,8 +115,8 @@ usage:
interpolator [options] <inglob> <outdir> <nbsteep> interpolator [options] <inglob> <outdir> <nbsteep>
options: options:
-S nn mysterious sort -S nn mysterious sort
-E i:bla:k input filter chain -E foo:bla:kr input filter chain
-F name:j output filter chain -F name:just output filter chain
-L list available filters -L list available filters
-v increase verbosity -v increase verbosity
``` ```
@ -130,12 +133,15 @@ usage:
-F define:the:filter:chain -F define:the:filter:chain
-g input glob pattern -g input glob pattern
-L list available filters -L list available filters
-r N repetiiing factor
-O /output/directory -O /output/directory
-v spit more messages -v spit more messages
``` ```
## Conclusion ## Conclusion
Tout cela est bien rigolo :)
**Use the source, Luke** **Use the source, Luke**

View File

@ -6,18 +6,19 @@
# #
BEGIN { BEGIN {
print "// -----------------------------------" print "// -------------------------------------"
print "// generated file, do not edit by hand !" print "// generated file, do not edit by hand !"
print "// -----------------------------------" print "// -------------------------------------"
} }
# $1 is the badly brain-designed numeric id # $1 is the badly brain-designed numeric id
# $2 is the user name of the filter # $2 is the user name of the filter
{ {
printf "#define CR_%s (%d)\n", $2, $1 name = sprintf("CR_%s", $2)
printf "#define %-15s (%d)\n", name, $1
} }
END { END {
print "// generated file, do not edit by hand !" print "\n// generated file, do not edit by hand !"
} }

28
Fonderie/craplist2str.awk Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/awk -f
#
# this utility script make a file who
# is includet by 'crapulator.c'
#
BEGIN {
print "// -------------------------------------"
print "// generated file, do not edit by hand !";
print "// -------------------------------------"
print "Crapulor CrapL[] = {";
}
# $1 is the badly brain-designed numeric id
# $2 is the user name of the filter
# $3 and $4 are two not used parameters
#
{
name = sprintf("CR_%s", $2)
printf " { %-14s, \"%s\", %d, %f }, // #%d\n",
name, $2, $3, $4, $1;
}
END {
print " { -1, NULL }"
print " };"
print "// ! generated file, do not edit by hand !"
}

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -81,7 +82,7 @@ FloatImg img;
int foo, retval; int foo, retval;
FimgFilter3x3 *pfiltre; FimgFilter3x3 *pfiltre;
FimgFilter3x3 lowpass = { static FimgFilter3x3 lowpass = {
{ {
1.0, 2.0, 1.0, 1.0, 2.0, 1.0,
2.0, 4.0, 2.0, 2.0, 4.0, 2.0,
@ -90,7 +91,8 @@ FimgFilter3x3 lowpass = {
16.0, 0.0 16.0, 0.0
}; };
FimgFilter3x3 hipass = { static FimgFilter3x3 hipass = {
/* there was a bug with this filter */
{ {
-1.0, -1.0, -1.0, -1.0, -1.0, -1.0,
-1.0, 9.0, -1.0, -1.0, 9.0, -1.0,
@ -99,11 +101,12 @@ FimgFilter3x3 hipass = {
1.0, 0.0 1.0, 0.0
}; };
FimgFilter3x3 diagonal = { static FimgFilter3x3 diagonal = {
/* there was a bug with this filter */
{ {
2.0, 1.0, 0.0, 4.0, 1.0, 0.0,
1.0, 0.0, -1.0, 1.0, 0.0, -1.0,
0.0, -1.0, -2.0, 0.0, -1.0, -4.0,
}, },
1.0, 0.0 1.0, 0.0
}; };
@ -151,6 +154,150 @@ fimg_destroy(&img);
return retval; return retval;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int run_killrgb_0(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
// fprintf(stderr, "----> %s\n", __func__);
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_killrgb_v(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
// fprintf(stderr, "%s ---->\n", __func__);
return ret;
}
/* -------------------------------------------------------------- */
static int run_pixelize_0(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_pixelize_h_0(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
static int run_pixelize_random(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_pixelize_h_rnd(img, &tmp, k);
if (verbosity > 1) fprintf(stderr, "in %s, pixelize H rnd -> %d\n",
__func__, ret);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* added Mon Apr 1 15:56:54 UTC 2024 */
static int run_triptyq(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_make_triptyq(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
static int run_decomprgbz_color(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_decomp_rgbz_color(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* nouveau 14 mai 2022 */
static int run_gr2popcol(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = graylevel2popcolors(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* new Sun Feb 12 11:30:02 CET 2023 */
static int run_rndfluffy(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_make_rndfluffy_lines(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
static int run_decomprgbz_gray(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
/* ugly code here */
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_decomp_rgbz_gray(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* new Sun Jul 16 11:27:43 UTC 2023 */
int run_suprbg(FloatImg *img, int notused)
{
FloatImg tmp;
int ret;
if (notused) {
fprintf(stderr, "FATAL: invalid notused in %s\n", __func__);
abort();
}
/* ugly code here */
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = poke_sup_rb_g(img, &tmp);
if (ret) {
fprintf(stderr, "%s: ret = %d\n", __func__, ret);
}
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* /*
* This is the main filter engine used both for input and * This is the main filter engine used both for input and
* output processing. It can be called by the filterstack * output processing. It can be called by the filterstack
@ -269,19 +416,28 @@ switch (idFx) {
retval = fimg_power_2(image, image, 1000.0); retval = fimg_power_2(image, image, 1000.0);
break; break;
case CR_triplemul:
retval = fimg_sfx_triplemul(image, image, 0);
break;
/* here are the glitches */ /* here are the glitches */
case CR_bsombra: /* experiment ! */ case CR_bsombra: /* experiment ! */
retval = des_bords_sombres_a(image, 160); retval = des_bords_sombres_a(image, 160);
break; break;
case CR_bsombrb: /* experiment ! */ case CR_bsombrb: /* experiment ! */
retval = des_bords_sombres_b(image, 160); retval = des_bords_sombres_b(image, 120);
break; break;
case CR_vsglitch: case CR_vsglitch:
/* please make this function more tweakable */ /* please make this function more tweakable */
retval = vertical_singlitch(image, 290+rand()%45, retval = vertical_singlitch(image, 290+rand()%45,
fval, 0.19, 0); fval, 0.19, 0);
break; break;
case CR_crumphard: /* new june 1st 2021, in the bibcave */
retval = fimg_crump_hard(image, image, fval, 0);
break;
case CR_rndblks: case CR_rndblks:
retval = random_blocks(image, 70); retval = random_blocks(image, 70);
break; break;
@ -298,22 +454,72 @@ switch (idFx) {
retval = plot_multidots(image, 42); retval = plot_multidots(image, 42);
break; break;
case CR_message:
fprintf(stderr, "### msg from pid %d, fval=%f ###\n",
getpid(), fval);
/* here, we can display stats ! */
fimg_describe(image, "in crapulator");
retval = 0;
break;
case CR_nothing: case CR_nothing:
retval = do_something(image, 3); retval = do_something(image, 3);
break; break;
case CR_killrgb0:
retval = run_killrgb_0(image, 0);
break;
case CR_pixelizh:
retval = run_pixelize_0(image, 8);
break;
case CR_pixelizv:
retval = run_pixelize_0(image, 32);
break;
case CR_pixelrand:
retval = run_pixelize_random(image, 16);
break;
case CR_splitlevel:
retval = fimg_split_level(image, image, 0);
break;
case CR_decrgbzc:
retval = run_decomprgbz_color(image, 0);
break;
case CR_decrgbzg:
retval = run_decomprgbz_gray(image, 0);
break;
case CR_hilightr: case CR_hilightr:
retval = fimg_highlight_color(image, image, 'R', 1.717); retval = fimg_highlight_color(image, image, 'R', 1.717);
break; break;
case CR_gr2popcol:
retval = run_gr2popcol(image, -1);
break;
case CR_fluffy:
retval = run_rndfluffy(image, 75);
break;
case CR_suprbg:
retval = run_suprbg(image, 0);
break;
case CR_thermocol:
/* new Wed Mar 20 19:42:42 UTC 2024 */
retval = fimg_auto_thermique(image, image, 0);
break;
case CR_triptyq:
/* added Mon Apr 1 15:52:32 UTC 2024*/
retval = run_triptyq(image, 0);
break;
case CR_togray:
retval = fimg_to_gray(image);
break;
case CR_shift0:
/* added Sun Sep 29 16:55:54 UTC 2024 */
retval = fimg_auto_shift_to_zero(image, image);
// fprintf(stderr, "******** Shift Zero -> %d\n", retval);
break;
default : default :
fprintf(stderr, "%s : effect #%d invalid\n", fprintf(stderr, "%s : effect #%d invalid\n",
__func__, idFx); __func__, idFx);
@ -349,13 +555,25 @@ void list_crapulors(char *texte)
int idx; int idx;
#define OUT stdout #define OUT stdout
fprintf(OUT, "______________. %s\n", texte);
if (verbosity) {
fprintf(stderr, "We have around %ld filters now !\n", NBCRAP);
}
if (NULL!=texte && verbosity)
fprintf(OUT, " _________ %s _________\n", texte);
for (idx=0; CrapL[idx].id!=-1; idx++) { for (idx=0; CrapL[idx].id!=-1; idx++) {
fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n", if (verbosity) {
fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n",
CrapL[idx].name, CrapL[idx].name,
CrapL[idx].id, CrapL[idx].id,
CrapL[idx].ipar, CrapL[idx].ipar,
CrapL[idx].fpar); CrapL[idx].fpar);
}
else {
fprintf(OUT, "%s\n", CrapL[idx].name);
}
} }
#undef OUT #undef OUT
} }

View File

@ -27,10 +27,26 @@
26 rndblks 1 1.0 26 rndblks 1 1.0
27 shiftln0 1 1.0 27 shiftln0 1 1.0
28 qsortrgb 2 1.0 28 qsortrgb 2 1.0
29 triplemul 3 1.0
30 multidots 100 1.333 30 multidots 100 1.333
31 diagonal 1 1.0 31 diagonal 1 1.0
32 vsglitch 1 1.0 32 vsglitch 1 1.0
33 crumphard 1 1.0
42 nothing 42 3.1415926 42 nothing 42 3.1415926
43 killrgb0 1 9
45 hilightr 1 1.717 45 hilightr 1 1.717
99 message 1 1.0 46 pixelizh 1 1.111
47 pixelizv 1 1.111
48 pixelrand 1 1
49 splitlevel 1 1
50 decrgbzc 1 99
51 decrgbzg 1 99
60 gr2popcol 1 99
61 fluffy 1 0.12
62 suprbg 1 0
80 thermocol 1 0
81 triptyq 1 0
90 togray 1 0
91 shift0 1 0
-1 end 1 1.0 -1 end 1 1.0

View File

@ -5,6 +5,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
@ -25,7 +26,7 @@ extern int verbosity;
static A_Fifo g_fifo; static A_Fifo g_fifo;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
static int big_adder(FloatImg *from, FloatImg *to) static inline int big_adder(FloatImg *from, FloatImg *to)
{ {
int size, idx; int size, idx;
@ -86,10 +87,10 @@ return 0;
*/ */
int export_fifo(char *fname, int notused) int export_fifo(char *fname, int notused)
{ {
int foo, type; int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, step); fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
#endif #endif
foo = faire_la_somme(&g_fifo, NULL, 1); foo = faire_la_somme(&g_fifo, NULL, 1);
@ -117,7 +118,7 @@ return 0;
int insert_picture(FloatImg *src) int insert_picture(FloatImg *src)
{ {
FloatImg *dst; FloatImg *dst;
int nbre, foo; int nbre;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, src); fprintf(stderr, ">>> %s ( %p )\n", __func__, src);

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <alloca.h> #include <alloca.h>

View File

@ -4,11 +4,13 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <glob.h> #include <glob.h>
#include "../floatimg.h" #include "../floatimg.h"
#include "utilfuncs.h"
#include "fifo.h" #include "fifo.h"
#include "glitches.h" #include "glitches.h"
#include "crapulator.h" #include "crapulator.h"
@ -107,7 +109,7 @@ fprintf(stderr, "glob '%s' -> %d, %d files found\n", pattern, foo,
/* get the size of the inputs images */ /* get the size of the inputs images */
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas); foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
width = datas[0]; height = datas[1]; width = datas[0]; height = datas[1];
fprintf(stderr, "first image size %dx%d\n", width, height); if (verbosity) fprintf(stderr, "first image size %dx%d\n", width, height);
fimg_create(&input, width, height, 3); fimg_create(&input, width, height, 3);
@ -119,10 +121,10 @@ if (foo) {
exit(1); exit(1);
} }
maxvalue = fimg_get_maxvalue(&input); maxvalue = fimg_get_maxvalue(&input);
fprintf(stderr, "first image maxvalue %f\n", maxvalue); if (verbosity) fprintf(stderr, "first image maxvalue %f\n", maxvalue);
foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB); foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo); if (verbosity) fprintf(stderr, "init fifo (%d slots) = %d\n", szfifo, foo);
/* XXX inject a few strange pics in the fifo */ /* XXX inject a few strange pics in the fifo */
insert_blank(&input, blk, outdir); insert_blank(&input, blk, outdir);
@ -185,10 +187,12 @@ puts("\t-F\toutput:filter:chain");
// puts("\t-g\tconvert to gray"); // puts("\t-g\tconvert to gray");
puts("\t-I\tinput glob pattern"); puts("\t-I\tinput glob pattern");
puts("\t-L\tlist available filters"); puts("\t-L\tlist available filters");
puts("\t-O\toutput directory"); puts("\t-O\toutput directory (default p8/)");
puts("\t-T\tfifo size"); puts("\t-T\tfifo size");
puts("\t-v\tincrease verbosity"); puts("\t-v\tincrease verbosity");
if (verbosity) { puts(""); fimg_print_version(2); puts(""); }
exit(0); exit(0);
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
@ -199,13 +203,12 @@ int fifosize = 10;
char *in_pattern = "capture/?????.fimg"; char *in_pattern = "capture/?????.fimg";
char *out_dir = "p8"; char *out_dir = "p8";
int outfmt = FILE_TYPE_PNG; int outfmt = FILE_TYPE_PNG;
int blanks = 20; int blanks = 10;
char *InFchain = "none"; char *InFchain = "none";
char *OutFchain = "none"; char *OutFchain = "none";
fprintf(stderr, "*** %s\n\tcompiled %s, %s, pid %d\n", fprintf(stderr, "*** %s\n\tcompiled %s, %s, pid %d\n",
argv[0], __DATE__, __TIME__, getpid()); argv[0], __DATE__, __TIME__, getpid());
fimg_print_version(2);
while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) { while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) {
switch(opt) { switch(opt) {
@ -228,6 +231,7 @@ while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) {
break; break;
case 'v': verbosity++; case 'v': verbosity++;
break; break;
default: exit(1);
} }
} }
@ -236,6 +240,16 @@ if (verbosity) {
fprintf(stderr, "\toutput dir '%s'\n", out_dir); fprintf(stderr, "\toutput dir '%s'\n", out_dir);
fprintf(stderr, "\tsrc filter '%s'\n", InFchain); fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
fprintf(stderr, "\tout filter '%s'\n", OutFchain); fprintf(stderr, "\tout filter '%s'\n", OutFchain);
fprintf(stderr, "\tfifo size %d\n", fifosize);
}
/*
* check for the export directory
*/
foo = check_if_export_dir_is_valid(out_dir, 0);
if ( !foo ) {
fprintf(stderr, "** export dir (%s) not valid\n", out_dir);
fprintf(stderr, "** may be you have to create it ?\n");
exit(1);
} }
foo = parse_filter_chain(0, InFchain); foo = parse_filter_chain(0, InFchain);
@ -257,7 +271,7 @@ if (verbosity > 1) {
foo = demarre_la_machine(in_pattern, out_dir, fifosize, outfmt, blanks); foo = demarre_la_machine(in_pattern, out_dir, fifosize, outfmt, blanks);
fprintf(stderr, "retour du big-run de la machine -> %d\n", foo); fprintf(stderr, "retour du bigrun de la machine -> %d\n", foo);
return 0; return 0;
} }

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -150,36 +151,38 @@ int pass, szimg, osrc, odst;
szimg = picture->width * picture->height; szimg = picture->width * picture->height;
for (pass=0; pass<szimg/32; pass++) { for (pass=0; pass<szimg/32; pass++) {
osrc = rand() % szimg; osrc = rand() % szimg;
odst = rand() % szimg; odst = rand() % szimg;
picture->R[odst] = (picture->R[osrc] + picture->R[odst]) / 2.0; picture->R[odst] = (picture->R[osrc] + picture->R[odst]) / 2.0;
picture->G[odst] = (picture->G[osrc] + picture->G[odst]) / 2.0; picture->G[odst] = (picture->G[osrc] + picture->G[odst]) / 2.0;
picture->B[odst] = (picture->B[osrc] + picture->B[odst]) / 2.0; picture->B[odst] = (picture->B[osrc] + picture->B[odst]) / 2.0;
} }
return 0; return 0;
} }
/* -------------------------------------------------------------- */
/*
* FIXME XXX
*/
int random_blocks(FloatImg *picture, int percent) int random_blocks(FloatImg *picture, int percent)
{ {
int x, y; int x, y;
if ( (picture->width%16) || (picture->height%16) ) if ( (picture->width%16) || (picture->height%16) )
{ {
fprintf(stderr, "%s: %d%d bad dims\n", __func__, fprintf(stderr, "WARNING %s: %dx%d bad dims\n", __func__,
picture->width, picture->height); picture->width, picture->height);
// return -1;
} }
for (y=0; y<picture->height; y+=16) { for (y=16; y<picture->height-16; y+=16) {
for (x=0; x<picture->width; x+=16) { for (x=16; x<picture->width-16; x+=16) {
if (percent < (rand()%100) ) { if (percent < (rand()%100) ) {
un_petit_flou_8x8(picture, x, y); un_petit_flou_8x8(picture, x, y);
un_petit_flou_8x8(picture, x+8, y); un_petit_flou_8x8(picture, x+8, y);
un_petit_flou_8x8(picture, x, y+8); un_petit_flou_8x8(picture, x, y+8);
un_petit_flou_8x8(picture, x+8, y+8); un_petit_flou_8x8(picture, x+8, y+8);
} }
} }
} }

View File

@ -10,12 +10,14 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <glob.h> #include <glob.h>
#include "../floatimg.h" #include "../floatimg.h"
#include "utilfuncs.h"
#include "fifo.h" #include "fifo.h"
#include "glitches.h" #include "glitches.h"
#include "crapulator.h" #include "crapulator.h"
@ -53,10 +55,14 @@ char *filename;
IdxValue *idxvalues; IdxValue *idxvalues;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, ptr_glob, fprintf(stderr, ">>> %s ( %p %p %d %p)\n", __func__, ptr_glob,
ptr_idxval, method); ptr_idxval, method, p_average);
#endif #endif
if (0==method && verbosity) {
fprintf(stderr, "\tWTF? in %s, sort method was ZERO?\n", __func__);
}
nombre = ptr_glob->gl_pathc; nombre = ptr_glob->gl_pathc;
/* allocate the array for the sorting action */ /* allocate the array for the sorting action */
@ -65,7 +71,7 @@ if (NULL==idxvalues) {
fprintf(stderr, "MEMORY ERROR in %s\n", __func__); fprintf(stderr, "MEMORY ERROR in %s\n", __func__);
exit(1); exit(1);
} }
fprintf(stderr, "IdxValues array at %p\n", idxvalues); // fprintf(stderr, "IdxValues array at %p\n", idxvalues);
*ptr_idxval = idxvalues; *ptr_idxval = idxvalues;
average = 0.0; average = 0.0;
@ -103,7 +109,7 @@ if (verbosity > 1) {
average /= (double)nombre; average /= (double)nombre;
*p_average = average; *p_average = average;
fprintf(stderr, "\naverage %f\n", average); fprintf(stderr, "\naverage of ??? is %f\n", average);
return 0; return 0;
} }
@ -121,22 +127,22 @@ int foo, idx, ipng, w, h, step;
int curpix; int curpix;
int iarray[3]; int iarray[3];
char *cptr, line[200]; char *cptr, line[200];
float coef, value; float coef;
double meanmetric; double meanmetric;
IdxValue *idx_values; /* gni? */ IdxValue *idx_values; /* gni? */
fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n", fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n",
pattern, outdir, Nsteps); pattern, outdir, Nsteps);
if (negative) fprintf(stderr, "%s: negative ON\n", __func__); if (negative) fprintf(stderr, "%s: negative ON\n", __func__);
memset(&globbuf, 0, sizeof(glob_t)); memset(&globbuf, 0, sizeof(glob_t));
foo = glob(pattern, 0, NULL, &globbuf); foo = glob(pattern, 0, NULL, &globbuf);
fprintf(stderr, "globbing '%s' -> %d, %d files found\n", fprintf(stderr, " globbing '%s' -> %d, %d files found\n",
pattern, foo, (int)globbuf.gl_pathc); pattern, foo, (int)globbuf.gl_pathc);
if (0 == globbuf.gl_pathc) { if (0 == globbuf.gl_pathc) {
fprintf(stderr, "%s : no file found, aborting\n", __func__); fprintf(stderr, "%s : no file found, ABEND\n", __func__);
return -1; exit(1);
} }
idx_values = NULL; idx_values = NULL;
@ -154,7 +160,7 @@ if (FIMG_TYPE_RGB != iarray[2]) {
} }
w = iarray[0], h = iarray[1]; w = iarray[0], h = iarray[1];
fprintf(stderr, "first image size : %dx%d\n", w, h); if (verbosity) fprintf(stderr, "first image size : %dx%d\n", w, h);
fimg_create(&A, w, h, 3); pFirst = &A; fimg_clear(&A); fimg_create(&A, w, h, 3); pFirst = &A; fimg_clear(&A);
fimg_create(&B, w, h, 3); pSecond = &B; fimg_clear(&B); fimg_create(&B, w, h, 3); pSecond = &B; fimg_clear(&B);
@ -171,10 +177,10 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
(int)globbuf.gl_pathc, cptr); (int)globbuf.gl_pathc, cptr);
foo = fimg_load_from_dump(cptr, &B); foo = fimg_load_from_dump(cptr, &B);
if (foo) { if (foo) {
fprintf(stderr, "load %s from dump -> %d\n", cptr, foo); fprintf(stderr, "\n%s: load %s from dump -> %d\n", __func__,
cptr, foo);
continue; continue;
} }
value = idx_values[idx].value;
/* here was the input filter */ /* here was the input filter */
foo = filterstack_run(0, &B, 0); foo = filterstack_run(0, &B, 0);
@ -235,9 +241,7 @@ puts("\t-S nn\t\tmysterious sort");
puts("\t-L\t\tlist available filters"); puts("\t-L\t\tlist available filters");
puts("\t-v\t\tincrease verbosity"); puts("\t-v\t\tincrease verbosity");
if (verbosity) { if (verbosity) { puts(""); fimg_print_version(2); puts(""); }
list_crapulors("available filters");
}
exit(0); exit(0);
} }
@ -252,10 +256,11 @@ int opt;
int sort = 0; int sort = 0;
char *InFchain = "0"; char *InFchain = "0";
char *OutFchain = "0"; char *OutFchain = "0";
char *out_dir = "p8/";
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__, fprintf(stderr, "*** %s\n\tcompiled on %s %s\n", argv[0],
__DATE__, __TIME__); __DATE__, __TIME__);
fimg_print_version(2); if (verbosity) fimg_print_version(2);
#if DEBUG_LEVEL #if DEBUG_LEVEL
/* this is for the debug off calling shellscript */ /* this is for the debug off calling shellscript */
@ -274,6 +279,7 @@ while ((opt = getopt(argc, argv, "E:F:hLnS:v")) != -1) {
case 'S': sort = atoi(optarg); break; case 'S': sort = atoi(optarg); break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
case 'n': negative = 1; break; case 'n': negative = 1; break;
default: exit(1);
} }
} }
@ -286,6 +292,18 @@ if (3 != (argc-optind)) {
exit(1); exit(1);
} }
out_dir = argv[optind+1];
/*
* check for the export directory
*/
foo = check_if_export_dir_is_valid(out_dir, 0);
if ( !foo ) {
fprintf(stderr, "** export dir (%s) not valid\n", out_dir);
fprintf(stderr, "** may be you have to create it ?\n");
exit(1);
}
foo = parse_filter_chain(0, InFchain); foo = parse_filter_chain(0, InFchain);
if (foo) { if (foo) {
fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain); fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain);
@ -302,13 +320,14 @@ if (verbosity) {
fprintf(stderr, "\toutput dir '%s'\n", argv[optind+1]); fprintf(stderr, "\toutput dir '%s'\n", argv[optind+1]);
fprintf(stderr, "\tsrc filter '%s'\n", InFchain); fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
fprintf(stderr, "\tout filter '%s'\n", OutFchain); fprintf(stderr, "\tout filter '%s'\n", OutFchain);
fprintf(stderr, "\tsort %d\n", sort);
} }
if (verbosity > 1) { if (verbosity > 1) {
puts("========================="); fputs("=========================\n", stderr);
filterstack_list(0, __FILE__); filterstack_list(0, __FILE__);
filterstack_list(1, __FILE__); filterstack_list(1, __FILE__);
puts("========================="); fputs("=========================\n", stderr);
} }
nbrsteps = atoi(argv[optind+2]); nbrsteps = atoi(argv[optind+2]);

View File

@ -4,6 +4,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"
#include "metriques.h" #include "metriques.h"
@ -84,6 +86,9 @@ for (idx=20; idx < size; idx+=42) {
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/*
* LR mean left/right
*/
int get_float_metric_LR(FloatImg *pimg, float *where) int get_float_metric_LR(FloatImg *pimg, float *where)
{ {
int coords[4], foo; int coords[4], foo;
@ -95,8 +100,16 @@ coords[2] = pimg->width / 2; // W
coords[3] = pimg->height; // H coords[3] = pimg->height; // H
foo = stat_zone(pimg, coords, valL); foo = stat_zone(pimg, coords, valL);
if (foo) {
fprintf(stderr, "err %d stat zone in %s\n", foo, __func__);
return foo;
}
coords[1] = pimg->width / 2; coords[1] = pimg->width / 2;
foo = stat_zone(pimg, coords, valR); foo = stat_zone(pimg, coords, valR);
if (foo) {
fprintf(stderr, "err %d stat zone in %s\n", foo, __func__);
return foo;
}
*where = valL[1] - valR[1]; *where = valL[1] - valR[1];

View File

@ -5,6 +5,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <math.h> #include <math.h>
@ -20,6 +21,88 @@
*/ */
extern int verbosity; extern int verbosity;
/* -------------------------------------------------------------- */
/* new Sun Mar 31 22:31:31 UTC 2024 */
int add_a_border_0(FloatImg *src, FloatImg *dst)
{
fprintf(stderr, "****** %s:%s to be implemented\n", __FILE__, __func__);
exit(1);
}
/* -------------------------------------------------------------- */
/*
* nouveau Sun Jul 16 07:37:22 UTC 2023
*
* may-be this can be an on-place function ?
*
*/
int poke_sup_rb_g(FloatImg *src, FloatImg *dst)
{
int idx, nbpix, foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
#endif
if ( (foo=fimg_images_not_compatible(src, dst)) )
{
fprintf(stderr, "%s: no compat %d\n", __func__, foo);
return foo;
}
nbpix = src->width * src->height;
if (verbosity > 1)
fprintf(stderr, "%s work on %d pixels\n", __func__, nbpix);
for (idx=0; idx<nbpix; idx++) {
dst->R[idx] = src->R[idx];
dst->B[idx] = src->B[idx];
if (src->R[idx] < src->B[idx])
dst->G[idx] = src->R[idx];
else
dst->G[idx] = src->B[idx];
}
return 0;
}
/* -------------------------------------------------------------- */
/* nouveau 14 mai 2022 rue Ernest Renan */
int graylevel2popcolors(FloatImg *src, FloatImg *dst, int k)
{
int x, y;
float rgb[3];
float theoric_maxval, real_maxv;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, k);
#endif
theoric_maxval = src->fval * src->count;
real_maxv = fimg_get_maxvalue(src);
#if DEBUG_LEVEL
fprintf(stderr, "maxval: theoric= %.3f real= %.3f\n", \
theoric_maxval, real_maxv);
#endif
fimg_clear(dst);
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++)
{
fimg_get_rgb(src, x, y, rgb);
rgb[0] = real_maxv * fabs(cos(21.0 * rgb[0] / real_maxv));
rgb[1] = real_maxv * fabs(cos(31.0 * rgb[1] / real_maxv));
rgb[2] = real_maxv * fabs(cos(11.0 * rgb[2] / real_maxv));
fimg_put_rgb(dst, x, y, rgb);
}
}
return 0;
}
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* /*
* please, add some parameters ! * please, add some parameters !
@ -46,21 +129,47 @@ return -1;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* nouveau du premier dimanche de 2020 'nextgen' */ /* nouveau du premier dimanche de 2020 'nextgen' */
/* CE TRUC NE MARCHE PAS COMME PRÉVU */
static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals) static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals)
{ {
int x, y, pline, off; int x, y, pline, off;
int ym;
for (y=pos[1]; y<pos[1]+pos[3]; y++) { // fprintf(stderr, ">>> %s ( %p %d,%d,%d,%d )\n", __func__, pimg,
// pos[0], pos[1], pos[2], pos[3]);
fimg_clear_rectangle(pimg, pos);
ym = pos[1]+pos[3]-1;
#define FDIM 0.60
for (y=pos[1]; y<ym; y++) {
pline = y*pimg->width; pline = y*pimg->width;
for (x=pos[0]+2; x<pos[0]+pos[2]-2; x++) { for (x=0; x<5; x++) {
off = pline + x; off = pline + (x+pos[0]);
pimg->R[off] = fvals[0];
pimg->G[off] = fvals[1]; /* wtf i'm doing here ? */
pimg->B[off] = fvals[2]; if ( (pos[1]==y) || (ym-1==y) ) {
pimg->R[off] = fvals[0] * FDIM;
pimg->G[off+5] = fvals[1] * FDIM;
pimg->B[off+10] = fvals[2] * FDIM;
}
else {
pimg->R[off] = fvals[0];
pimg->G[off+5] = fvals[1];
pimg->B[off+10] = fvals[2];
}
} }
} }
return 0; return 0;
} }
/*
* need more explanation, need more work
*/
int trinitron(FloatImg *pimg, int notused) int trinitron(FloatImg *pimg, int notused)
{ {
int x, y, coo[4], foo; int x, y, coo[4], foo;
@ -70,20 +179,36 @@ float vals[3];
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused); fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
#endif #endif
#define STP 16 /* stepd for x & y axex */ /* XXX CRITICAL BUG XXX
*
* what to do if STP is not a modulo of
* the width (or size) of the picture ?
* why if img height is 600 and stp was 16 ?
tth@redlady:~/Devel/FloatImg/Fonderie$ bc -l
600/16
37.50000000000000000000
*
* And this mistake is all around the code /o\
*
*/
#define STP 15 /* stepd for x & y axex */
coo[2] = coo[3] = STP; coo[2] = coo[3] = STP;
for (y=0; y<pimg->height; y+=STP) { for (y=0; y < pimg->height-STP; y+=STP) {
coo[1] = y; coo[1] = y;
for (x=0; x<pimg->width; x+=STP) { for (x=0; x < pimg->width-STP; x+=STP) {
coo[0] = x; coo[0] = x;
foo = stat_zone(pimg, coo, vals); foo = stat_zone(pimg, coo, vals);
if (foo) abort(); if (foo) abort();
/* next step : plot the datas */
pixel_trinitron(pimg, coo, vals); pixel_trinitron(pimg, coo, vals);
} }
} }
#undef STP #undef STP
// fprintf(stderr, " end trinitron\n"); // XXX
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
@ -311,19 +436,40 @@ return 0;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* nouveau Mon 10 May 2021 08:46:02 PM CEST /* nouveau Mon 10 May 2021 08:46:02 PM CEST
* chez Eric 1KA */ * chez Eric 1KA */
int des_bords_sombres_b(FloatImg *pimg, int offset) int des_bords_sombres_b(FloatImg *pimg, int nbre)
{ {
int idx, x, foo;
float coef, *fptr;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, offset); fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, nbre);
#endif #endif
if (offset<0 || offset>=pimg->width) { for (idx=0; idx<nbre; idx++) {
fprintf(stderr, "%s: offset %d is bad\n", __func__, offset);
return -66; coef = (float)idx / (float)nbre;
fptr = pimg->R + (idx*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->G + (idx*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->B + (idx*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
foo = (pimg->height-idx) - 1;
fptr = pimg->R + (foo*pimg->width);
// fprintf(stderr, "%5d %9.3f %p\n", foo, coef, fptr);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->G + (foo*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->B + (foo*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
} }
return -1; // fprintf(stderr, "WARNING: %s badly implemented\n", __func__);
return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* /*

View File

@ -3,8 +3,11 @@
* --------------------------------------------------- * ---------------------------------------------------
*/ */
int graylevel2popcolors(FloatImg *src, FloatImg *dst, int k);
int incrustation_vignette(FloatImg *src, FloatImg *dst, int k); int incrustation_vignette(FloatImg *src, FloatImg *dst, int k);
int poke_sup_rb_g(FloatImg *src, FloatImg *dst);
int trinitron(FloatImg *pimg, int notused); int trinitron(FloatImg *pimg, int notused);

View File

@ -1,5 +1,6 @@
/* /*
SINGLE SINGLE PICZ PROCESSOR
experimental and/or testing code, do not use in experimental and/or testing code, do not use in
production. production.
@ -8,6 +9,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -23,7 +26,7 @@
static int nextpng, counter; static int nextpng, counter;
static char *destination; static char *destination;
static int chainfilter; static int chainfilter;
static int outtype; // static int outtype;
/* and the classic global var */ /* and the classic global var */
extern int verbosity; extern int verbosity;
@ -48,7 +51,7 @@ if (foo) {
return -2; return -2;
} }
if (S_IFDIR != (stbuf.st_mode & S_IFMT)) { if (S_IFDIR != (stbuf.st_mode & S_IFMT)) {
fprintf(stderr, "! %s must be a directory\n", dest); fprintf(stderr, "%s: %s must be a directory\n", __func__, dest);
return -3; return -3;
} }
@ -98,7 +101,6 @@ fprintf(stderr, "%s : %s\n", __FILE__, title);
fprintf(stderr, " nextpng %d\n", nextpng); fprintf(stderr, " nextpng %d\n", nextpng);
fprintf(stderr, " counter %d\n", counter); fprintf(stderr, " counter %d\n", counter);
fprintf(stderr, " chainfilter %d\n", chainfilter); fprintf(stderr, " chainfilter %d\n", chainfilter);
fprintf(stderr, " destination %s\n", destination); fprintf(stderr, " destination %s\n", destination);
if (k) { if (k) {

View File

@ -6,12 +6,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <glob.h> #include <glob.h>
#include "../floatimg.h" #include "../floatimg.h"
#include "utilfuncs.h"
#include "crapulator.h" #include "crapulator.h"
#include "filterstack.h" #include "filterstack.h"
#include "single.h" #include "single.h"
@ -24,6 +26,9 @@
int verbosity; int verbosity;
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/*
* parameter 'duplic' is the repetition factor
*/
int run_the_singlepass(char *globber, char *destdir, int duplic, int run_the_singlepass(char *globber, char *destdir, int duplic,
int fchain, int outfmt) int fchain, int outfmt)
{ {
@ -34,11 +39,11 @@ char *fname;
double elapsed; double elapsed;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' '%s' %d %d )\n", __func__, fprintf(stderr, ">>> %s ( '%s' '%s' %d %d %d )\n", __func__,
globber, destdir, fchain, outfmt); globber, destdir, duplic, fchain, outfmt);
#endif #endif
// filterstack_list(fchain, "Run the single pass"); if (verbosity) filterstack_list(fchain, "Run the single pass");
(void)fimg_timer_set(0); (void)fimg_timer_set(0);
@ -80,17 +85,21 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
else { else {
foo = fimg_load_from_dump(fname, &image); foo = fimg_load_from_dump(fname, &image);
} }
if (verbosity > 1) {
fprintf(stderr, "%s: image '%s' loaded in %p\n",
__func__, fname, &image);
}
if (foo) { if (foo) {
fprintf(stderr, "get image -> %d\n", foo); fprintf(stderr, "get image -> %d\n", foo);
return -1; return -1;
} }
if (0 == idx) { if (0==idx && verbosity) {
fprintf(stderr, "image size %dx%d\n", fprintf(stderr, "\tfirst image size %dx%d\n",
image.width, image.height); image.width, image.height);
} }
fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname); // fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname);
foo = filterstack_run(fchain, &image, 0); foo = filterstack_run(fchain, &image, 0);
if (foo) { if (foo) {
@ -106,10 +115,6 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fprintf(stderr, "error %d on push_picture\n", foo); fprintf(stderr, "error %d on push_picture\n", foo);
return foo; return foo;
} }
if (loop) {
/* this is just a wip XXX */
microglitch(&image, loop);
}
} }
} }
@ -118,7 +123,7 @@ fprintf(stderr, "\n");
globfree(&globbuf); globfree(&globbuf);
fimg_destroy(&image); fimg_destroy(&image);
single_print_state("end of run", 0); // single_print_state("end of run", 0);
elapsed = fimg_timer_get(0); elapsed = fimg_timer_get(0);
fprintf(stderr, "%s: %ld frames, elapsed %.3f s, %.3f fps\n", fprintf(stderr, "%s: %ld frames, elapsed %.3f s, %.3f fps\n",
@ -155,9 +160,9 @@ char *outdir = "./p8";
int do_xper = 0; int do_xper = 0;
int repeat = 1; int repeat = 1;
fprintf(stderr, "*** %s : compiled %s %s\n", __FILE__, fprintf(stderr, "*** %s\n\tcompiled %s %s\n", argv[0],
__DATE__, __TIME__); __DATE__, __TIME__);
fimg_print_version(2); if (verbosity) fimg_print_version(2);
if (argc < 2) { if (argc < 2) {
fprintf(stderr, "\t/!\\ %s is option driven\n", argv[0]); fprintf(stderr, "\t/!\\ %s is option driven\n", argv[0]);
@ -187,7 +192,6 @@ while ((opt = getopt(argc, argv, "hF:g:LO:r:svx")) != -1) {
fprintf(stderr, "%s ABEND\n", argv[0]); fprintf(stderr, "%s ABEND\n", argv[0]);
exit(1); exit(1);
} }
} }
if (repeat < 1) { if (repeat < 1) {
@ -195,6 +199,13 @@ if (repeat < 1) {
exit(2); exit(2);
} }
foo = check_if_export_dir_is_valid(outdir, 0);
if ( !foo ) {
fprintf(stderr, "** export dir (%s) not valid\n", outdir);
fprintf(stderr, "** may be you have to create it ?\n");
exit(1);
}
foo = parse_filter_chain(FILTERS, filterchain); foo = parse_filter_chain(FILTERS, filterchain);
if (foo) { if (foo) {
fprintf(stderr, "err %d in parse_filter_chain\n", foo); fprintf(stderr, "err %d in parse_filter_chain\n", foo);
@ -211,9 +222,12 @@ if (verbosity) {
fprintf(stderr, "\tdo xper %d\n", do_xper); fprintf(stderr, "\tdo xper %d\n", do_xper);
} }
/*
* REAL action here
*/
foo = run_the_singlepass(globbing, outdir, repeat, foo = run_the_singlepass(globbing, outdir, repeat,
FILTERS, FILE_TYPE_PNG); FILTERS, FILE_TYPE_PNG);
fprintf(stderr, "\n\tRun the single pass --> %d\n", foo); fprintf(stderr, "\tRun the single pass --> %d\n", foo);
return 0; return 0;
} }

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <glob.h> #include <glob.h>
@ -15,6 +16,8 @@
#include "crapulator.h" #include "crapulator.h"
#include "single.h" #include "single.h"
#include "utilfuncs.h"
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
int verbosity; int verbosity;
@ -27,6 +30,30 @@ int verbosity;
#define STK 6 #define STK 6
/* ----------------------------------------------------------- */
/* new Sat Nov 9 22:17:46 UTC 2024 */
int essai_test_export_dir(char *footxt)
{
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, footxt);
#endif
foo = check_if_export_dir_is_valid("/tmp/quux", 0);
fprintf(stderr, " got %d\n\n", foo);
foo = check_if_export_dir_is_valid("/home", 0);
fprintf(stderr, " got %d\n\n", foo);
foo = check_if_export_dir_is_valid("./", 0);
fprintf(stderr, " got %d\n\n", foo);
foo = check_if_export_dir_is_valid("Makefile", 0);
fprintf(stderr, " got %d\n\n", foo);
return -1;
}
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
int essai_filterstack(char *fIname, char *fOname) int essai_filterstack(char *fIname, char *fOname)
@ -35,11 +62,16 @@ int foo;
FloatImg image; FloatImg image;
double debut, fin; double debut, fin;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, fIname, fOname);
#endif
// filterstack_list(STK, __func__); // filterstack_list(STK, __func__);
foo = fimg_create_from_dump(fIname, &image); foo = fimg_create_from_dump(fIname, &image);
if (foo) { if (foo) {
fprintf(stderr, "err %d create image\n", foo); fprintf(stderr, "%s: err %d create from dump\n", __func__, foo);
exit(1); exit(1);
} }
@ -72,8 +104,6 @@ return 0;
foo = essayer_single("capture/???42.fimg", "/tmp/x8/", STK); foo = essayer_single("capture/???42.fimg", "/tmp/x8/", STK);
fprintf(stderr, "essayer single -> %d\n", foo); fprintf(stderr, "essayer single -> %d\n", foo);
*/ */
int essayer_single(char *globpattern, char *destdir, int chain) int essayer_single(char *globpattern, char *destdir, int chain)
{ {
@ -160,23 +190,24 @@ puts("\t-s\tdo single test");
exit(0); exit(0);
} }
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
int experiment(void) int experiment(char *fname)
{ {
int foo; int foo;
FloatImg image, dest; FloatImg image, dest;
fprintf(stderr, "EXPERIMENT\n"); fprintf(stderr, "----- EXPERIMENT on '%s' -----\n", fname);
foo = fimg_create_from_dump("01137.fimg", &image); foo = fimg_create_from_dump(fname, &image);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d on create\n", __func__, foo); fprintf(stderr, "%s: err %d on create_from_dump\n",
__func__, foo);
return -1; return -1;
} }
foo = fimg_clone(&image, &dest, 1); foo = fimg_clone(&image, &dest, 0);
foo = fimg_copy_data(&image, &dest);
incrustation_vignette(&image, &dest, 0); foo = poke_sup_rb_g(&image, &dest);
fprintf(stderr, "poke sup rb g --> %d\n", foo);
fimg_export_picture(&dest, "foo.png", 0); fimg_export_picture(&dest, "foo.png", 0);
@ -218,17 +249,25 @@ while ((opt = getopt(argc, argv, "hF:g:i:Lo:O:svx")) != -1) {
} }
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind); fprintf(stderr, ">>> %s : argc=%d, optind=%d\n", argv[0], argc, optind);
#endif #endif
foo = essai_test_export_dir("bla bla");
if (foo) {
fprintf(stderr, "err %d in essai_test_export_dir\n", foo);
exit(1);
}
exit(0);
foo = parse_filter_chain(STK, filterchain); foo = parse_filter_chain(STK, filterchain);
if (foo) { if (foo) {
fprintf(stderr, "err %d in parse_filter_chain\n", foo); fprintf(stderr, "err %d in parse_filter_chain\n", foo);
exit(1); exit(1);
} }
if (do_xper) { if (do_xper) {
experiment(); experiment(infile);
return 0; return 0;
} }
if (do_single) { if (do_single) {

53
Fonderie/utilfuncs.c Normal file
View File

@ -0,0 +1,53 @@
/*
* utilfuncs.c
*
* new Sat Nov 9 22:15:15 UTC 2024
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "utilfuncs.h"
extern int verbosity;
/* -------------------------------------------------------------- */
int check_if_export_dir_is_valid(char *path, int action)
{
int foo;
struct stat statbuf;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s', %d )\n", __func__, path, action);
#endif
foo = stat(path, &statbuf);
if (foo) {
if (verbosity) perror(path);
return 0;
}
#if DEBUG_LEVEL
fprintf(stderr, " mode 0x%x\n", statbuf.st_mode);
#endif
if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
if (verbosity) fprintf(stderr, "%s: Not a directory\n", path);
return 0;
}
/* OK, c'est un repertoire, mais peut-on écrire dedans ? */
foo = access(path, W_OK);
#if DEBUG_LEVEL
fprintf(stderr, " access '%s' = %d\n", path, foo);
#endif
if (0 != foo) {
if (verbosity) fprintf(stderr, "%s: can't write\n", path);
return 0;
}
return 1; /* export dir is OK */
}
/* -------------------------------------------------------------- */

11
Fonderie/utilfuncs.h Normal file
View File

@ -0,0 +1,11 @@
/*
* utilfuncs.c
*
* new Sat Nov 9 22:15:49 UTC 2024
*/
/* -------------------------------------------------------------- */
int check_if_export_dir_is_valid(char *path, int action);
/* -------------------------------------------------------------- */

6
Global.makefile Normal file
View File

@ -0,0 +1,6 @@
#
# This file is the 'grandmasta' of the compilation process.
# for now, this is juste a wip idea.
#

14
LICENSE Normal file
View File

@ -0,0 +1,14 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@ -1,77 +1,37 @@
# CC_OPTS = -Wall -fpic -g -pg -no-pie -DDEBUG_LEVEL=0 ####################################################
# LD_OPTS = libfloatimg.a -pg -lm # Before running make, you must have #
# a look to the 'build.sh' script ! #
####################################################
LIB_DIR = build/lib COPT = -Wall -Wextra -fpic -g -no-pie -DDEBUG_LEVEL=0
LDOPT = libfloatimg.a -g -lm
OBJ_DIR = build/obj all: essai
STATIC_LIB = $(LIB_DIR)/libfloatimg-lib.a #---------------------------------------------------------------
DYN_LIB = $(LIB_DIR)/libfloatimg.so essai: essai.c libfloatimg.a floatimg.h Makefile
gcc $(COPT) $< $(LDOPT) -lpnglite -lz -o $@
VERBOSITY = 0 install:
@echo "=== Use the 'install.sh' script ==="
all: lib funcs tools v4l2 #---------------------------------------------------------------
# shared: $(DYN_LIB) TOTAR = *.[ch] Makefile *.sh *.md \
doc/the*.tex doc/mk*.sh doc/*.txt \
funcs/*.[ch] funcs/Makefile \
tools/*.[ch] tools/*.sh tools/README.md tools/Makefile \
v4l2/*.[ch] v4l2/Makefile \
scripts/*.sh scripts/README.md \
lib/*.[ch] lib/Makefile
# $(DYN_LIB): lib funcs lines: $(TOTAR)
@wc $(TOTAR) | sort -n
lib: tarball: $(TOTAR)
$(MAKE) -C src/lib all date > tarball
ls $(TOTAR) | sed 's/^/FloatImg\//' > MANIFEST
funcs: lib ( cd .. ; tar zcvf floatimg.tar.gz `cat FloatImg/MANIFEST` )
$(MAKE) -C src/funcs
# link lib & funcs for shared library
echo "int verbosity = $(VERBOSITY);" > $(OBJ_DIR)/verbosity.c
gcc -c $(OBJ_DIR)/verbosity.c -o $(OBJ_DIR)/verbosity.o
gcc -shared $(OBJ_DIR)/*.o -lnetpbm -lpnglite -lcfitsio -ltiff -lz -lm -o $(DYN_LIB)
tools: lib
mkdir -p build/bin
$(MAKE) -C src/tools
v4l2:
mkdir -p build/bin
$(MAKE) -C src/v4l2
clean:
$(MAKE) -C src/lib clean
$(MAKE) -C src/funcs clean
$(MAKE) -C src/tools clean
$(MAKE) -C src/v4l2 clean
rm -rf "./build"
install: all
cp src/floatimg.h /usr/local/include
cp build/lib/* /usr/local/lib
cp build/bin/* /usr/local/bin
# all: essai
# #---------------------------------------------------------------
# essai: essai.c libfloatimg.a floatimg.h Makefile
# gcc $(COPT) $< $(LDOPT) -lpnglite -lz -o $@
# #---------------------------------------------------------------
# TOTAR = *.[ch] Makefile *.sh *.md \
# doc/the*.tex doc/mk*.sh doc/*.txt \
# funcs/*.[ch] funcs/Makefile \
# tools/*.[ch] tools/*.sh tools/README.md tools/Makefile \
# v4l2/*.[ch] v4l2/Makefile \
# scripts/*.sh scripts/README.md \
# lib/*.[ch] lib/Makefile
# lines: $(TOTAR)
# @wc $(TOTAR) | sort -n
# tarball: $(TOTAR)
# date > tarball
# ls $(TOTAR) | sed 's/^/FloatImg\//' > MANIFEST
# ( cd .. ; tar zcvf floatimg.tar.gz `cat FloatImg/MANIFEST` )
# #---------------------------------------------------------------
#---------------------------------------------------------------

View File

@ -1,14 +1,3 @@
# FloatImg4PythonBinding
Un fork de la galactique bibliothèque FloatImg de tTh, réaménagé pour permettre une utilisation depuis Python avec l'embryonnaire binding https://git.tetalab.org/Mutah/python-FloatImg/ (seulement sur la branche develop pour le moment)
Pas de révolution mais :
- production d'une bibliothèque partagée
- arborescence remanié : les meubles ont changés de place : les sources sont dans `src`, les expérimentations dans `extra` et les binaires sont produits dans `build`
- build system : un Makefile racine avec des cibles générales : `all` pour tout builder, `lib` pour la bibliothèque de base, `funcs`
# Traitement des images en virgule flottante. # Traitement des images en virgule flottante.
C'est d"abord un ensemble de fonctions pour traiter des images avec une énorme dynamique C'est d"abord un ensemble de fonctions pour traiter des images avec une énorme dynamique
@ -18,7 +7,6 @@ voire même des [films flous](Fonderie/).
![horloge floue](http://la.buvette.org/photos/cumul/horloge.png "horloge floue") ![horloge floue](http://la.buvette.org/photos/cumul/horloge.png "horloge floue")
Il y a une [description](http://la.buvette.org/photos/cumul/) bien plus Il y a une [description](http://la.buvette.org/photos/cumul/) bien plus
pas trop longue pour les curieux, et un début de pas trop longue pour les curieux, et un début de
[documentation](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf) [documentation](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
@ -26,14 +14,27 @@ pour les codeurs.
Le service après-vente est (plus ou moins bien) assuré sur Le service après-vente est (plus ou moins bien) assuré sur
la [mailing list](https://lists.tetalab.org/mailman/listinfo/tetalab) et/ou la [mailing list](https://lists.tetalab.org/mailman/listinfo/tetalab) et/ou
le canal IRC #tetalab sur le réseau de le canal IRC #tetalab sur le réseau de
[Freenode](https://webchat.freenode.net/)... [Libera.Chat](https://libera.chat/)...
Par ailleurs, d'autres expérimentations sont Par ailleurs, d'autres expérimentations sont
[en cours](http://la.buvette.org/photos/cumul/fonderie/vidz.html#interpolator) [en cours](http://la.buvette.org/photos/cumul/fonderie/vidz.html#interpolator)
sur le traitement et l'assemblage de ces images floues dans le but de faire sur le traitement et l'assemblage de ces images floues dans le but de faire
des films flous. des films flous.
*En avant vers l'infini, et au-delà...* ## *Show us the code !*
Il y a plusieurs répertoires contenant le code source, en voici
la liste :
* [lib](lib/README.md) : le noyau du système, fonctions de base.
* [funcs](funcs/README.md) : fonctions de support : export, traitement
filtrage, effets...
* [tools](tools/README.md) : utilitaires divers, outils de debug et gadgets.
* [v4l2](v4l2/README.md): gestion des webcams sous Linux.
* [experiment](experiment/README.md) : fonctions en chantier, qui migreront
un jour dans d'autres catégories.
* [contrib](contrib/README.md) : des choses peu ou pas maintenues.
## Dépendances ## Dépendances
@ -41,22 +42,41 @@ Bien entendu, avant tout, il faut installer quelques outils et
dépendances. Je vais tenter de les lister dans le plus grand dépendances. Je vais tenter de les lister dans le plus grand
désordre (à la sauce Debian) : désordre (à la sauce Debian) :
```bash ```
sudo apt install libtiff-dev libpnglite-dev liblo-dev libv4l2-dev libcfitsio-dev libnetpbm-dev apt install libtiff-dev
``` apt install libpnglite-dev
apt install liblo-dev
Sauce Ubuntu : apt install libv4l2-dev
apt install libcfitsio-dev
```bash apt install libnetpbm-dev
sudo apt install libtiff-dev libpnglite-dev liblo-dev libv4l-dev libcfitsio-dev libnetpbm10-dev libncurses5-dev apt install libncurses-dev
```
Bon, OK, je suis en train de changer de machine, et ça serait vraiment
cool d'avoir juste une ligne à c'n'p, donc voila :
```
apt install libtiff-dev libpnglite-dev liblo-dev libv4l2-dev \
libcfitsio-dev libnetpbm-dev libncurses-dev
```
Il est probable que j'en oublie.
Et ya Debian qui change des trucs, alors, ça marche plus, du
genre que c'est la deuxième fois que ça m'arrive.
```
E: Unable to locate package libv4l2-dev
E: Unable to locate package libnetpbm-dev
``` ```
Ensuite, j'ai dans l'idée de construire
um meta-packet à la sauce Debian pour installer facilement tout ce
qui sert à faire fonctionner ce kluge. Ensuite, j'irais voir du
coté de pkg-config.
Certains outils externes sont aussi utiles : Certains outils externes sont aussi utiles :
- gnuplot - gnuplot, pour analyser des données,
- ImageMagick - ImageMagick, parce que Brunus aime ça,
- LaTeX - LaTeX, pour la (trop maigre) documentation.
## Documentation ## Documentation
@ -64,4 +84,10 @@ Encore trop légère, mais déja [présente](doc/).
C'est à vous de compiler le C'est à vous de compiler le
[PDF](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf) [PDF](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
## TODO
https://berthub.eu/articles/posts/always-do-this-floating-point/
## Conclusion
*Your mileage may vary...* *Your mileage may vary...*

41
build.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
set -e ; set -u
# ------------------------------------------------------------------
function build
{
echo "============= $1 =============="
curdir=${PWD}
cd $1
make
error=$?
cd ${curdir}
if [ ${error} -ne 0 ]
then
echo "=== error on $1 = ${error}"
exit 1
fi
}
# ------------------------------------------------------------------
build lib
build funcs
build tools
build v4l2
build Fonderie
# ------------------------------------------------------------------
echo "========== Project root ==============="
make
# ------------------------------------------------------------------

14
contrib/.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
fimg2povhf
demo_fmorph
toto
core
*.tga
*.png
*.pnm
*.gif
*.fimg
*.mp4

18
contrib/Makefile Normal file
View File

@ -0,0 +1,18 @@
DBGL = -DDEBUG_LEVEL=1 -g
fimg2povhf: fimg2povhf.c Makefile
gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@
# --------------------------------------------------------
demo_fmorph: demo_fmorph.c Makefile
gcc -Wall $(DBGL) $< -lfloatimg -lpnglite -lm -o $@
in.fimg: Makefile
mkfimg -t tpat0 -v $@ 640 480
out.png: in.fimg demo_fmorph
./demo_fmorph $< $@
# --------------------------------------------------------

14
contrib/README.md Normal file
View File

@ -0,0 +1,14 @@
# Contributions
## fimg2povhf
Need some external garbage, sorry.
## do_eff_spass.sh
Script shell permettant (en théorie) de faire un montage
d'une petite séquence de chacun des effets disponibles
dans la Fonderie. `singlepass` inside.

116
contrib/demo_fmorph.c Normal file
View File

@ -0,0 +1,116 @@
/*
* DEMONSTRATOR FOR FMORPHO
*/
#include <stdio.h>
#include <stdlib.h>
#include <floatimg.h>
int verbosity = 1;
#define DF_W 512
#define DF_H 128
/* ~~~ -------------------------------------------------------------- +++ */
int demo_fmorph(char *srcf, char *dsti, int mode)
{
FloatImg simg, // image source
timg, uimg, // intermediaires
dimg; // destination
FimgArea51 rect;
char line[200];
int foo, pass, hpos;
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, srcf, dsti, mode);
/*
* chargement image source
*/
foo = fimg_create_from_dump(srcf, &simg);
fprintf(stderr, " load of %s --> %d\n", srcf, foo);
if (foo) {
return foo;
}
/*
* images temporaires
*/
foo = fimg_create(&timg, DF_W, DF_H, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create T img\n", foo);
return foo;
}
foo = fimg_create(&uimg, DF_W, DF_H, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create U img\n", foo);
return foo;
}
/*
* image de destination
*/
foo = fimg_create(&dimg, DF_W, DF_H*9, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create D img\n", foo);
return foo;
}
/*
* this is an iterator
*/
rect.x = 20; rect.y = 20;
rect.w = DF_W; rect.h = DF_H;
for (pass=0; pass<9; pass++) {
hpos = pass * DF_H;
fprintf(stderr, "pass %d, hpos %d\n", pass, hpos);
foo = fimg_extractor(&simg, &timg, &rect);
// sprintf(line, "S_%02d.png", pass);
// foo = fimg_save_as_png(&timg, line, 0);
foo = fimg_filtre_morpho_0(&timg, &uimg, pass);
if (foo) {
fprintf(stderr, "err %d filtre morpho, pass %d\n",
foo, pass);
exit(1);
}
sprintf(line, "D_%02d.png", pass);
foo = fimg_save_as_png(&uimg, line, 0);
foo = fimg_incrustator_0(&uimg, &dimg, 0, hpos, 0);
if (foo) {
fprintf(stderr, "err %d incrustator\n", foo);
exit(1);
}
}
foo = fimg_save_as_png(&dimg, dsti, 0);
/*
* do some cleanup
*/
fimg_destroy(&simg); fimg_destroy(&timg); fimg_destroy(&dimg);
return 0;
}
/* ~~~ -------------------------------------------------------------- +++ */
int main(int argc, char *argv[])
{
int foo;
fimg_print_version(1);
if (3 != argc) {
fprintf(stderr, "usage:\n\t%s src.fimg dst.png\n", argv[0]);
exit(1);
}
foo = demo_fmorph(argv[1], argv[2], 0);
fprintf(stderr, " got --> %d\n", foo);
return 0;
}
/* ~~~ -------------------------------------------------------------- +++ */

163
contrib/do_eff_spass.sh Executable file
View File

@ -0,0 +1,163 @@
#!/bin/bash
set -e
SPASS="../Fonderie/singlepass"
SRCDIR=$HOME"/Essais/PS-eye/frames/"
DSTPOL=$HOME"/TMP/"
echo "source = " $SRCDIR
echo "spool = " $DSTPOL
LINKFARM=$DSTPOL"LinkFarm"
echo "linkfarm = " $LINKFARM
# VIDZ="$HOME/BU/vrac/all_effects.mp4"
VIDZ="foo.mp4"
echo "lolvidz = " $VIDZ
LINKNUM=0
# --------------------------------------------
do_an_effect_pass()
{
local effect=$1
local ddir=$2
figlet "$effect" ; echo
echo " files to ===> " $ddir
rm -f $ddir/?????.png
$SPASS -F $effect \
-g $SRCDIR/'?????.fimg' \
-O $ddir \
-r 1
}
# --------------------------------------------
insert_blank()
{
local count=$1
local imgname="$DSTPOL/blank.fimg"
if [ ! -r $imgname ] ; then
mkfimg -v -t black $imgname 640 480
fimg2png -v $imgname $DSTPOL/blank.png
echo "blankimage done" | boxes
# display $DSTPOL/blank.png &
# exit
fi
for foo in $(seq 0 $count)
do
linkname=$(printf "%s/L%05d.png" $LINKFARM $LINKNUM)
ln --force --symbolic $DSTPOL/blank.png $linkname
# file $linkname
LINKNUM=$(( LINKNUM + 1 ))
done
}
# --------------------------------------------
make_the_linkfarm_from()
{
local effname=$1
local sdir=$2
echo "====== Linkfarming from " $sdir \
"====== avec" $(ls $sdir | wc -l) "images"
mogrify \
-font Utopia-Bold \
-pointsize 64 \
-kerning 9 \
-fill Gray90 \
-stroke Gray10 \
-strokewidth 2 \
-gravity South-East \
-annotate +30+20 $effname \
$sdir/*.png
for img in $(ls -1 $sdir/?????.png)
do
linkname=$(printf "%s/L%05d.png" $LINKFARM $LINKNUM)
# echo "image = " $img
# echo "link = " $linkname
ln --force --symbolic $img $linkname
LINKNUM=$(( LINKNUM + 1 ))
done
echo " linkfarming done"
}
# --------------------------------------------
# traite tous les effets
do_all_the_effects()
{
EFFECTS=$( $SPASS -L | sort )
banner 'FULL RUN'
for effect in $EFFECTS
do
DDIR=$DSTPOL"/$effect"
if [ -d $DDIR ] ; then
rm -f $DDIR"/?????.png"
fi
if [ ! -r $DDIR ] ; then
mkdir -v $DDIR
fi
do_an_effect_pass $effect $DDIR
make_the_linkfarm_from $effect $DDIR
insert_blank 30
done
}
# --------------------------------------------
debug_run()
{
local eff=$1
local DDIR=$DSTPOL"/$eff"
banner 'DEBUG RUN'
echo "DDIR = " $DDIR
do_an_effect_pass $eff $DDIR
make_the_linkfarm_from $eff $DDIR
}
# --------------------------------------------
# MAIN
echo
rm -v -f $LINKFARM/L*.png ; echo
insert_blank 30
# debug_run 'rndblks'
do_all_the_effects
banner 'encoding'
ffmpeg -nostdin \
-loglevel warning \
-y -r 30 -f image2 -i ${LINKFARM}/L%05d.png \
-metadata artist='---[ tTh ]---' \
-metadata title='---[ All the 'Fonderie' effects ]---' \
-preset veryslow \
-c:v libx264 -pix_fmt yuv420p \
$VIDZ
echo " encoding of " $VIDZ " . . . . . [done]"

116
contrib/fimg2povhf.c Normal file
View File

@ -0,0 +1,116 @@
/*
* convertir une image flottante en champ d'altitude
*
* nouveau 64 ernest renan - 20220108
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "tthimage.h"
#include "floatimg.h"
int verbosity;
/* ------------------------------------------------------------------ */
int This_is_the_real_conversion(FloatImg *fimg, Image_Desc *hf, int k)
{
int foo;
float minmax[6];
int x, y, h;
float rgb[6], cumul;
float maxi;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, fimg, hf, k);
#endif
foo = fimg_get_minmax_rgb(fimg, minmax);
// fimg_print_minmax(minmax, "source");
maxi = 0.0;
for (y=0; y<fimg->height; y++) {
for (x=0; x<fimg->width; x++) {
foo = fimg_get_rgb(fimg, x, y, rgb);
/* non-magic nuabmer spotted */
cumul = 1.732 * (rgb[1] + rgb[3] + rgb[5]);
if (cumul > maxi) maxi = cumul;
h = (int)cumul;
foo = Image_hf15_plot(hf, x, y, h);
}
}
fprintf(stderr, "--- the critical maximum is %f\n", maxi);
return FULL_NUCKED;
}
/* ------------------------------------------------------------------ */
int Convertir_Fimg_to_Povhf(char *fimgname, char *hfname, int k)
{
FloatImg fimg;
Image_Desc *hf;
int wid, hei;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %s %s %d )\n", __func__, fimgname, hfname, k);
#endif
foo = fimg_create_from_dump(fimgname, &fimg);
fprintf(stderr, "load of %s --> %d\n", fimgname, foo);
if (foo) {
return foo;
}
wid = fimg.width; hei = fimg.height; // nice alias
fprintf(stderr, " source picture size %dx%d\n", wid, hei);
hf = Image_alloc(wid, hei, IMAGE_RGB);
fprintf(stderr, "hf alloc -> %p\n", hf);
if (NULL == hf) {
return NULL_POINTER;
}
foo = This_is_the_real_conversion(&fimg, hf, k);
fprintf(stderr, "real conversion -> %d\n", foo);
foo = Image_TGA_save(hfname, hf, 0);
fprintf(stderr, "export as tga -> %d\n", foo);
return FULL_NUCKED;
}
/* ------------------------------------------------------------------ */
void help(int nu)
{
printf("usage :\n");
printf("\t$ fimg2povhf src.fimg dst.tga\n");
}
/* ------------------------------------------------------------------ */
int main(int argc, char *argv[])
{
int foo;
verbosity = 1;
// printf("%s: argc = %d\n", argv[0], argc);
if (3 != argc) {
help(0);
exit(0);
}
if (verbosity > 1) {
Image_print_version(3);
fimg_print_version(3);
}
foo = Convertir_Fimg_to_Povhf(argv[1], argv[2], 0);
fprintf(stderr, "retour conversion was %d\n", foo);
fprintf(stderr, "end\n\n");
return 0;
}
/* ------------------------------------------------------------------ */

31
contrib/raytrace.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
src="/dev/shm/foo.fimg"
dst="hf.tga"
TMPDIR=${HOME}/TMP
POVOPT="-w512 -h342 +q9 -a "
rm $TMPDIR/hf???.png
for idx in $(seq 0 60)
do
echo "========================== " $idx
grabvidseq -v \
-d /dev/video0 -s 640x480 \
-n 60 -p 1.0 \
-o ${src}
./fimg2povhf $src $dst
out=$(printf "%s/hf%03d.png" $TMPDIR $idx)
echo "raytracing " ${POVOPT} $out
povray -iscene.pov ${POVOPT} -o${out} 2> pov.stderr
# tail -15 pov.stderr
done
convert -delay 10 -colors 240 $TMPDIR/hf???.png foo.gif

41
contrib/scene.pov Normal file
View File

@ -0,0 +1,41 @@
/* scene demo conversion floatimg -> height field */
#version 3.7;
global_settings {
ambient_light rgb <0.07, 0.07, 0.07>
assumed_gamma 1.0
}
#include "colors.inc"
height_field {
tga "hf.tga"
smooth
pigment { color Orange*0.7 }
translate <-0.5, 0, -0.5>
// scale 2
translate y*0.002
}
camera {
location <-0.86, 4, -6.20>
look_at <0, 0, 0>
angle 14
}
plane {
<0, 1, 0>, 0
pigment {
hexagon
pigment { color Gray20 },
pigment { color Gray10 },
pigment { color Gray30 }
}
scale 0.27
}
light_source { <-9, 2, 3> color White }

View File

@ -1,7 +1,14 @@
#!/bin/bash #!/bin/bash
#
# this script generate some picz for the PDF documentation
# and was called by mkdoc.sh
#
PI=" 3.141592654 " PI=" 3.141592654 "
# ---------------------------------------------------
OUT="cos01.tex" OUT="cos01.tex"
gnuplot << __EOF__ gnuplot << __EOF__
@ -24,6 +31,8 @@ __EOF__
wc $OUT wc $OUT
# ---------------------------------------------------
OUT="cos010.tex" OUT="cos010.tex"
gnuplot << __EOF__ gnuplot << __EOF__
@ -45,3 +54,5 @@ plot \
__EOF__ __EOF__
wc $OUT wc $OUT
# ---------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -17,14 +18,17 @@ int verbosity;
void fait_un_dessin(FloatImg *dessin) void fait_un_dessin(FloatImg *dessin)
{ {
// fprintf(stderr, "je dessine dans %p\n", dessin);
fimg_draw_something(dessin); fimg_draw_something(dessin);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
void help(int k) void help(void)
{ {
puts("Options :"); puts("Options :");
puts("\t-d WxH\timage size"); puts("\t-d WxH\timage size");
puts("\t-v\tincrease verbosity");
exit(0); exit(0);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -33,14 +37,14 @@ int main(int argc, char *argv[])
{ {
FloatImg fimgA, fimgB; FloatImg fimgA, fimgB;
int foo, opt; int foo, opt;
int W = 800, H = 600; int W = 640, H = 480;
double tb; double tb;
while ((opt = getopt(argc, argv, "d:hv")) != -1) { while ((opt = getopt(argc, argv, "d:hv")) != -1) {
switch(opt) { switch(opt) {
case 'd': parse_WxH(optarg, &W, &H); case 'd': parse_WxH(optarg, &W, &H);
break; break;
case 'h': help(0); break; case 'h': help(); break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
} }
} }
@ -56,19 +60,19 @@ fimg_drand48(&fimgB, 100.0);
foo = fimg_dump_to_file(&fimgB, "B.fimg", 0); foo = fimg_dump_to_file(&fimgB, "B.fimg", 0);
fimg_timer_set(0); fimg_timer_set(0);
#define NBP 500 #define NBP 5
for (foo=0; foo<NBP; foo++) { for (foo=0; foo<NBP; foo++) {
if (verbosity) { if (verbosity) {
printf("%5d / %5d\n", foo, NBP); printf("%5d / %5d\n", foo, NBP);
} }
fait_un_dessin(&fimgB); fait_un_dessin(&fimgB);
fimg_add_3(&fimgA, &fimgB, &fimgA); fimg_add_3(&fimgA, &fimgB, &fimgA);
// fimg_mul(&fimgA, &fimgB, &fimgA); // fimg_mul(&fimgA, &fimgB, &fimgA);
} }
tb = fimg_timer_get(0); tb = fimg_timer_get(0);
fprintf(stderr, "%s = %f seconds\n", __func__, tb); fprintf(stderr, "%s = %.2f seconds, %.2f s/p\n", __func__, tb, tb/(double)NBP);
foo = fimg_save_as_pnm(&fimgA, "drand48.pnm", 0); foo = fimg_save_as_pnm(&fimgA, "out.pnm", 0);
foo = fimg_dump_to_file(&fimgA, "drand48.fimg", 0); foo = fimg_dump_to_file(&fimgA, "out.fimg", 0);
fimg_destroy(&fimgA); fimg_destroy(&fimgA);
fimg_destroy(&fimgB); fimg_destroy(&fimgB);

14
experiment/.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
*.fimg
*.o
*.pnm
*.data
assemblage
extracteur
fimg2obj
mnt
movepixels
muxplanes
tcache

40
experiment/Makefile Normal file
View File

@ -0,0 +1,40 @@
#
#  some ugly experiments, do not use in production
#
COPT = -Wall -Wextra -fpic -g -DDEBUG_LEVEL=0 -lm
DEPS = ../floatimg.h ../libfloatimg.a Makefile
LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio -lm
all: assemblage muxplanes movepixels mnt
# ---------------------------------------------------------
assemblage: assemblage.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
muxplanes: muxplanes.c ${DEPS}
gcc $(COPT) $< ${LIBS} -o $@
movepixels: movepixels.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
mnt: mnt.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
fimg2obj: fimg2obj.c $(DEPS)
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
# ---------------------------------------------------------
# CACHE ENGINE (wip)
cachengn.o: cachengn.c cachengn.h Makefile
gcc $(COPT) -c $<
tcache.o: tcache.c cachengn.h Makefile
gcc $(COPT) -c $<
tcache: tcache.o cachengn.o Makefile
gcc $(COPT) tcache.o cachengn.o $(LIBS) -o $@

29
experiment/README.md Normal file
View File

@ -0,0 +1,29 @@
# Expérimentations ÀLC
Attention, tout ce qui se trouve dans ce répertoire ne sont que des
essais. Certains aboutissent, et sont migrés vers `lib/`, `funcs/` ou
`tools/`, d'autre échouent et restent trainer dans le coin en attente
du retour de l'inspiration.
Le contenu de ce répertoire doit donc être considéré comme
**volatile**. Si vous y trouvez votre bonheur, il serait sage
d'en faire une copie personnelle...
## MNT
Modèles numériques de terrain. Rien ne marche. Plein de maths.
Un [code](mnt.c) complexe.
## fimg2obj
Création d'un fichier .OBJ (de Wavefront) à partir d'une image
flottante afin d'avoir des vues en 3d pertinentes, bien qu'assez
futiles.
## système de cache
`new: Mon Jul 17 12:49:20 UTC 2023`
En cours : définition d'à peu-près tout ce qu'il reste à faire
pour avoir quelque chose qui fonctionne.
Plus d'information dans le [.h](cachengn.h).

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -50,7 +51,6 @@ if (foo) {
return -1; return -1;
} }
foo = fimg_export_picture(&grande, outname, 0); foo = fimg_export_picture(&grande, outname, 0);
if (foo) { if (foo) {
fprintf(stderr, "%s: error %d export '%s'\n", __func__, fprintf(stderr, "%s: error %d export '%s'\n", __func__,

145
experiment/cachengn.c Normal file
View File

@ -0,0 +1,145 @@
/*
* the chache engine - code
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
#include "../floatimg.h"
#include "cachengn.h"
extern int verbosity;
static int nombre_slots = -1;
static int index_slot = -1;
static FimgCacheEntry *le_cache = NULL;
/* ------------------------------------------------------------ */
void cachengn_print_version(int k)
{
printf("\t!!! this is the version ZERO !!!\n");
fprintf(stderr, "sizeof cache entry: %ld\n", sizeof(FimgCacheEntry));
if (k) fimg_print_version(0);
}
/* ------------------------------------------------------------ */
/*
*
*/
int init_empty_cache(int iw, int ih, int szc, int wtfparam)
{
int idx;
fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__,
iw, ih, szc, wtfparam);
/* MOLLYGUARD : don't init TWICE, please */
if (NULL != le_cache) {
fprintf(stderr, "%s: there is a cache at %p\n", __func__,
le_cache);
return -2;
}
/* allocate an prepare memory */
if ( NULL==(le_cache=calloc(szc, sizeof(FimgCacheEntry))) ) {
fprintf(stderr, "%s: no memory, sorry...\n", __func__);
return -3;
}
fprintf(stderr, " slot array at %p\n", le_cache);
for (idx=0; idx<szc; idx++) {
le_cache[idx].flags = 0xF0;
le_cache[idx].index = idx;
}
/* update private cache metadata */
nombre_slots = szc;
return 0;
}
/* ------------------------------------------------------------ */
/*
*
*/
FloatImg *give_me_thiz_picz(char *fname, int notused)
{
int idx, foo, freeslot;
FloatImg img;
char *nptr;
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
/* please add molly guard ! */
if (notused)
fprintf(stderr, "in %s, notused was %d\n", __func__, notused);
/* is the floatimg already in the cahce ? */
for (idx=0; idx<nombre_slots; idx++) {
nptr = le_cache[idx].filename;
if (NULL!=nptr && (! strcmp(fname, nptr))) {
fprintf(stderr, "found '%s' at %d\n", nptr, idx);
return le_cache[idx].image;
}
}
/* we not have this picture in our cache, so we need a free
slot for it */
freeslot = -1;
for (idx=0; idx<nombre_slots; idx++) {
if (NULL==le_cache[idx].image) {
freeslot = idx;
break;
}
}
fprintf(stderr, "freeslot = %d\n", freeslot);
/* check if we can read this file */
foo = access(fname, R_OK); /* XXX */
if (foo) {
perror("give_me_thiz_picz");
return NULL;
}
fprintf(stderr, "file '%s' is readble\n", fname);
/* try to load the requested file */
foo = fimg_create_from_dump(fname, &img);
if (foo) {
fprintf(stderr, "oups on %s\n", fname);
return NULL;
}
/* OK, we have all the pixels in core memory */
return NULL;
}
/* ------------------------------------------------------------ */
/*
*
*/
int liste_le_cache(unsigned int flags)
{
int idx;
fprintf(stderr, ">>> %s ( Ox%X )\n", __func__, flags);
/* please add molly guard here */
fprintf(stderr, "cache at %p : %d slots, idx = %d\n",
le_cache, nombre_slots, index_slot);
for (idx=0; idx<nombre_slots; idx++) {
fprintf(stderr, "%5d ", idx);
fprintf(stderr, "0x%02x ", le_cache[idx].flags);
fprintf(stderr, "%p ", le_cache[idx].image);
fprintf(stderr, "%s\n", le_cache[idx].filename);
}
return 0;
}
/* ------------------------------------------------------------ */

29
experiment/cachengn.h Normal file
View File

@ -0,0 +1,29 @@
/*
* the chache engine - header
*/
void cachengn_print_version(int k);
typedef struct {
int flags;
char *filename;
FloatImg *image;
int index;
} FimgCacheEntry;
/*
* parameters:
* - iw, ik : image size
* - szc : number of slots
* - nbre : WTF isthat?
*/
int init_empty_cache(int iw, int ih, int szc, int nbre);
/* /!\ the floatimg returned must be view as readonly */
FloatImg *give_me_thiz_picz(char *fname, int notused);
/* utilities functions */
int liste_le_cache(unsigned int flags);

67
experiment/fimg2obj.c Normal file
View File

@ -0,0 +1,67 @@
/*
* another ugly experiment
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include "../floatimg.h"
int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int convert_fimg_to_obj(char *fimgfname, char *objfname, int mode)
{
FloatImg src;
int foo, x, y;
FILE *fp;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
fimgfname, objfname, mode);
#endif
if (mode) {
fprintf(stderr, "in %s(), mode must be 0, was %d\n", __func__, mode);
}
foo = fimg_create_from_dump(fimgfname, &src);
if (foo) {
fprintf(stderr, "err %d loading %f\n", foo, fimgfname);
return foo;
}
return -1;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int main(int argc, char *argv[])
{
int foo, opt;
char *infile = "foo.fimg";
fprintf(stderr, "*** fimg2obj (%s %s)\n", __DATE__, __TIME__);
verbosity = 0;
#if 0
for (foo=0; foo<argc; foo++) {
fprintf(stderr, "%9d %s\n", foo, argv[foo]);
}
#endif
foo = convert_fimg_to_obj(infile, "foo.obj", 0);
if (foo) {
fprintf(stderr, "convertor give us %d\n", foo);
exit(1);
}
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */

239
experiment/mnt.c Normal file
View File

@ -0,0 +1,239 @@
/*
* Modeles Numeriques de Terrain -- UGLY CODE INSIDE !!
*
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "../floatimg.h"
int verbosity;
/* ------------------------------------------------------------------- */
/* for debug purpose */
int printf_histo_gray(char *fname, int histo[], int nbre)
{
FILE *fp;
int idx;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__,
fname, histo, nbre);
#endif
if (NULL == (fp = fopen(fname, "w"))) {
perror(fname);
exit(1);
}
for (idx=0; idx<nbre; idx++) {
fprintf(fp, "%6d %8d\n", idx, histo[idx]);
}
fclose(fp);
return -1;
}
/* ------------------------------------------------------------------- */
/* for debug purpose */
int calcul_histo_gray(FloatImg *img, char *fname, int nbslots, float *pmax)
{
int offset, nbpix, ival;
float pixel, minp, maxp;
int *counts;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__,
img, fname, nbslots);
#endif
if (FIMG_TYPE_GRAY != img->type) {
fprintf(stderr, "%s: image is not in greylevel\n", __func__);
return -2;
}
/* allocate memory for histogram computation */
counts = calloc(nbslots, sizeof(int));
if (NULL == counts) {
fprintf(stderr, "malloc fail in %s\n", __func__);
abort();
}
nbpix = img->width * img->height;
minp = 1e30, maxp = -1e30;
for (offset=0; offset<nbpix; offset++) {
pixel = img->R[offset];
if (pixel < minp) minp = pixel;
if (pixel > maxp) maxp = pixel;
}
// fprintf(stderr, " values = %g < %g\n", minp, maxp);
*pmax = maxp; /* copy value for the caller */
/* calcul de l'histogramme avec scaling */
for (offset=0; offset<nbpix; offset++) {
pixel = img->R[offset];
ival = (int)((pixel * (float)nbslots) / maxp);
counts[ival]++;
// fprintf(stderr, "%6d %10.6f %i\n", offset, pixel, ival);
}
if (NULL != fname)
{
printf_histo_gray(fname, counts, nbslots);
}
/* garbage collect stuff */
free(counts);
return 0;
}
/* ------------------------------------------------------------------- */
/*
* Second try - ahem?
*/
int brotche_mnt_style(FloatImg *src, FloatImg *dst)
{
FloatImg tmp;
int x, y, foo;
int offset;
float z1, z2, z3, z4;
float a, b, c;
float pente, minp, maxp, seuil;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
#endif
/*
* trying some preprocessor filters
*/
foo = fimg_lissage_3x3(src);
if (foo) fprintf(stderr, " lissage 1 -> %d\n", foo);
foo = fimg_lissage_3x3(src);
if (foo) fprintf(stderr, " lissage 2 -> %d\n", foo);
foo = fimg_killborders(src);
if (foo) fprintf(stderr, " killborder -> %d\n", foo);
#define W (src->width)
#define DX 1.0
#define DY 1.0
/* allocate a graylevel image for storing la 'pente' */
memset(&tmp, 0, sizeof(FloatImg));
foo = fimg_create(&tmp, src->width, src->height, FIMG_TYPE_GRAY);
if (foo) {
fprintf(stderr, "create tmp pic --> %d\n", foo);
return foo;
}
/* calcul de la pente : a vérifier ! */
for (y=0; y<(src->height-1); y++) {
for (x=0; x<(src->width-1); x++) {
offset = (y * W) + x;
z1 = src->R[offset];
z2 = src->R[offset+1];
z3 = src->R[offset+W];
z4 = src->R[offset+W+1];
a = ( z1 + z2 + z3 + z4) / 4.0;
b = (-z1 + z2 - z3 + z4) / 2.0 / DX;
c = (-z1 - z2 + z3 + z4) / 2.0 / DY;
pente = atanf(sqrt(b*b + c*c));
tmp.R[offset] = pente;
}
}
foo = calcul_histo_gray(&tmp, "histogramme.data", 499, &maxp);
if (foo) fprintf(stderr, "<<< calcul histo -> %d\n", foo);
minp = 1e10;
seuil = 0.700 * maxp;
fprintf(stderr, " seuil = %f\n", seuil);
/* ésotérisme, quand tu nous tiens... */
for (offset=0; offset<(src->width*src->height); offset++) {
pente = tmp.R[offset];
if (pente > seuil) {
if (pente < minp) minp = pente;
}
if (pente > maxp) maxp = pente;
}
// fprintf(stderr, " minp = %f maxp = %f\n", minp, maxp);
/* recopie dans l'image destination avec translation hauteur */
fimg_clear(dst);
for (offset=0; offset<(src->width*src->height); offset++) {
pente = tmp.R[offset] - minp;
if (pente < 0.0) {
dst->R[offset] = -pente;
dst->G[offset] = -pente;
}
else {
dst->B[offset] = pente;
dst->G[offset] = pente;
}
}
foo = fimg_killborders(dst);
if (foo) fprintf(stderr, " killborder -> %d\n", foo);
/* clean the memory */
fimg_destroy(&tmp);
return 0;
}
/* ------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
FloatImg src, dst;
char *infile, *outfile;
int foo;
verbosity = 1; /* FIXME */
if (3 != argc) {
fprintf(stderr, "'%s' need 2 args : infile & outfile\n", argv[0]);
fimg_print_version(0);
exit(1);
}
infile = argv[1]; outfile = argv[2];
if (verbosity) fprintf(stderr,"*** MNT %s -> %s\n", infile, outfile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "err %d loading image '%s'\n", foo, infile);
exit(1);
}
foo = fimg_clone(&src, &dst, 0);
if (foo) {
fprintf(stderr, "err %d cloning image\n", foo);
exit(1);
}
fimg_clear(&dst);
foo = brotche_mnt_style(&src, &dst);
if (foo) {
fprintf(stderr, "something weird happen %d\n", foo);
exit(1);
}
foo = fimg_export_picture(&dst, outfile, 0);
if (foo) {
fprintf(stderr, "err %d exporting to %s\n", foo, outfile);
exit(1);
}
/* clean the memory */
fimg_destroy(&src);
fimg_destroy(&dst);
return 0;
}
/* ------------------------------------------------------------------- */

156
experiment/movepixels.c Normal file
View File

@ -0,0 +1,156 @@
/*
* MOVEPIXELS
*
* This is experimental, do not use in production !
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <floatimg.h>
int verbosity;
/* ------------------------------------------------------------------- */
int displace(FloatImg *psrc, FloatImg *pshift, FloatImg *pdst, float k)
{
int xd, yd, xs, ys;
float rgb[3], disp[3], maxv;
float minmax[6];
int foo, inside, outside;
float dltr, dltg, dltb; /* delta des minmax */
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p %g )\n", __func__,
psrc, pshift, pdst, k);
#endif
if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7;
}
if (fimg_images_not_compatible(psrc, pshift)) {
fprintf(stderr, "%s: bad shift image %d\n", __func__, pshift->type);
return -8;
}
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: bad dst image %d\n", __func__, pdst->type);
return -8;
}
foo = fimg_get_minmax_rgb(pshift, minmax);
if (verbosity) {
fimg_print_minmax(minmax, (char *)__func__);
}
dltr = minmax[1] - minmax[0];
dltg = minmax[3] - minmax[2];
dltb = minmax[5] - minmax[4];
if (verbosity) fprintf(stderr, "delta shift %f %f %f\n", dltr, dltg, dltb);
maxv = fimg_get_maxvalue(psrc);
inside = outside = 0;
/* hardcoded parameters. this is very dirty :) */
#define MULT (140.0)
#define OFFS (70.0)
/* loop over all the pixels of the DESTINATION picture */
for (yd=0; yd<pdst->height; yd++) {
for (xd=0; xd<pdst->width; xd++) {
fimg_get_rgb(pshift, xd, yd, disp);
xs = xd + ((disp[0]/dltr*MULT) - OFFS);
ys = yd + ((disp[1]/dltb*MULT) - OFFS);
if ( xs<0 || xs>psrc->width ||
ys<0 || ys>psrc->height ) {
rgb[0] = rgb[1] = rgb[2] = 0.0;
outside++;
}
else {
fimg_get_rgb(psrc, xs, ys, rgb);
inside++;
}
fimg_put_rgb(pdst, xd, yd, rgb);
}
}
// fprintf(stderr, "%s: inside %d outside %d\n", __func__, inside, outside);
return 0;
}
/* ------------------------------------------------------------------- */
/*
* High level operateur, taking care of opening/closing
* files and doing memory management
*/
int move_the_pixels(char *infile, char *statfile, char *outfile, int k)
{
int foo;
FloatImg src, shift, dst;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %s %s 0x%04x )\n", __func__,
infile, outfile, k);
#endif
/* 'infile' contains the shifting values */
foo = fimg_create_from_dump(infile, &shift);
if (foo) {
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
return foo;
}
fimg_clone(&shift, &dst, 0);
foo = fimg_create_from_dump(statfile, &src);
if (foo) {
fprintf(stderr, "%s: error loading 'cumul.fimg'\n", __func__);
return foo;
}
foo = displace(&src, &shift, &dst, 42.42);
if (foo) {
fprintf(stderr, "%s: err %d in disp map 0\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dst, outfile, 0);
if (foo) {
fprintf(stderr, "%s: err %d saving result\n", __func__, foo);
return foo;
}
return 0;
}
/* ------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
char *srcfile, *dstfile;
if (3 != argc) {
fprintf(stderr, "usage:\n\t%s src.fimg dst.fimg\n", argv[0]);
exit(1);
}
srcfile = argv[1];
dstfile = argv[2];
verbosity = 0;
/* XXX the static picture file MUST be selectable by the yuser ! */
foo = move_the_pixels(srcfile, "reference.fimg", dstfile, 3);
fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo);
return 0;
}
/* ------------------------------------------------------------------- */

113
experiment/muxplanes.c Normal file
View File

@ -0,0 +1,113 @@
/*
* another ugly experiment (please explain)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include "../floatimg.h"
int verbosity;
/* --------------------------------------------------------------- */
int triplane_muxer(FloatImg *sr, FloatImg *sg, FloatImg *sb,
FloatImg *dst)
{
int sz;
if (FIMG_TYPE_RGB != dst->type) {
fprintf(stderr, "%s: dst picz must be RGB, was %d\n",
__func__, dst->type);
return -99;
}
if ( fimg_images_not_compatible(sr, sg) ||
fimg_images_not_compatible(sr, sb) ||
fimg_images_not_compatible(sr, dst) ) {
fprintf(stderr, "%s: compatibility error\n", __func__);
return -2;
}
sz = sr->width * sr->height * sizeof(float);
memcpy(dst->R, sr->R, sz);
memcpy(dst->G, sg->G, sz);
memcpy(dst->B, sb->B, sz);
return 0;
}
/* --------------------------------------------------------------- */
int try_this_muxplane(char *fr, char *fg, char *fb, char *dst, int flags)
{
int foo;
FloatImg imr, img, imb, dest;
fprintf(stderr, "muxing: %s %s %s -> %s\n", fr, fg, fb, dst);
if (flags) {
fprintf(stderr, "%s: flag non 0 ?\n", __FILE__);
}
foo = fimg_create_from_dump(fr, &imr);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
return -1;
}
foo = fimg_create_from_dump(fg, &img);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fg);
return -1;
}
foo = fimg_create_from_dump(fb, &imb);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fb);
return -1;
}
fimg_clone(&imr, &dest, 0);
foo = triplane_muxer(&imr, &img, &imb, &dest);
if (foo) {
fprintf(stderr, "%s: err %d\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dest, dst, 0);
if (foo) {
fprintf(stderr, "%s: err %d exporting to %s\n", __func__, foo, dst);
return foo;
}
fimg_destroy(&imr); fimg_destroy(&img);
fimg_destroy(&imb); fimg_destroy(&dest);
return 0;
}
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
if (5 != argc) {
fprintf(stderr, "ERROR: %s need four fimg files arguments\n",
argv[0]);
return 1;
}
/*
* and now, we have to decipher options on the
* command line.
*/
foo = try_this_muxplane(argv[1], argv[2], argv[3], argv[4], 0);
if (foo) {
fprintf(stderr, "oups %d\n", foo);
exit(1);
}
return 0;
}
/* --------------------------------------------------------------- */

0
experiment/remotegrab.c Normal file
View File

49
experiment/tcache.c Normal file
View File

@ -0,0 +1,49 @@
/*
* tests du systeme de cache
*/
#include <stdio.h>
#include <sys/time.h>
#include "../floatimg.h"
#include "cachengn.h"
int verbosity;
#define IMGW 320
#define IMGH 240
#define SIZE 5 // number of slots
#define NBRI 1000
/* ------------------------------------------------------------ */
int main(int argc, char *argv[])
{
int foo;
FloatImg *picz;
char *fname = "quux.fimg";
fprintf(stderr, "\nTest of the cache engin - %s %s\n",
__DATE__, __TIME__);
cachengn_print_version(1);
foo = init_empty_cache(IMGW, IMGH, SIZE, NBRI);
fprintf(stderr, " init_empty_cache --> %d\n", foo);
foo = liste_le_cache((unsigned int)'U');
fprintf(stderr, " liste le cache --> %d\n", foo);
picz = give_me_thiz_picz(fname, 0);
if (NULL == picz) {
fprintf(stderr, " error 'givemeapicz' on '%s'\n", fname);
}
picz = give_me_thiz_picz(fname, 0);
if (NULL == picz) {
fprintf(stderr, " error 'givemeapicz' on '%s'\n", fname);
}
return 0;
}
/* ------------------------------------------------------------ */

24
experiment/tripla.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
GRABOPT=" -vv -d /dev/video0 -n 400 -p 0.5 -u "
SPOOL=${HOME}/TMP
echo ; echo ; echo
for capture in red green blue
do
image=${SPOOL}/${capture}.fimg
echo grabbing $image
grabvidseq ${GRABOPT} -o $image
echo
done
./muxplanes "${SPOOL}/red.fimg" \
"${SPOOL}/green.fimg" \
"${SPOOL}/blue.fimg" \
yo.fimg
echo $0 "got a" $?
fimgstats -v yo.fimg

View File

@ -1,27 +0,0 @@
#!/usr/bin/awk -f
#
# this utility script make a file who
# is includet by 'crapulator.c'
#
BEGIN {
print "// -----------------------------------"
print "// generated file, do not edit by hand";
print "// -----------------------------------"
print "Crapulor CrapL[] = {";
}
# $1 is the badly brain-designed numeric id
# $2 is the user name of the filter
# $3 and $4 are two not used parameters
#
{
printf " { CR_%s, \"%s\", %d, %f }, // id=%d\n",
$2, $2, $3, $4, $1;
}
END {
print " { -1, NULL }"
print " };"
print "// generated file, do not edit by hand"
}

View File

@ -1,15 +0,0 @@
#  experiments
COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm
DEPS = ../floatimg.h ../libfloatimg.a Makefile
LIBS = -ltiff -lpnglite -lcfitsio
all: assemblage extracteur
assemblage: assemblage.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@
extracteur: extracteur.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@

View File

@ -1,6 +0,0 @@
# EXPÉRIMENTATION ÀLC
## ASSEMBLAGE
## EXTRACTEUR

View File

@ -1,131 +0,0 @@
/*
* another ugly experiment
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../floatimg.h"
// #include "incrustator.h"
int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int essai_extraction(FloatImg *in, FloatImg *out, FimgArea51 *rect)
{
int foo;
int xs, ys, xd, yd;
int count;
float rgb[3];
if (verbosity) {
fimg_describe(in, "source");
fimg_describe(out, "destination");
print_rectangle(__func__, rect);
}
count = 0;
for (yd=0; yd<rect->h; yd++) {
ys = yd + rect->y;
if ((ys<0) || (ys>=in->height)) continue;
for (xd=0; xd<rect->w; xd++) {
xs = xd + rect->x;
if ((xs<0) || (xs>=in->width)) continue;
fimg_get_rgb(in, xs, ys, rgb);
fimg_put_rgb(out, xd, yd, rgb);
count++;
}
}
// fprintf(stderr, "%s: %d pix moved\n", __func__, count);
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
void help(int k)
{
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int main(int argc, char *argv[])
{
int foo, opt;
FloatImg src, dst;
FimgArea51 zone;
char *infile = "foo.fimg";
char *outfile = "out.fimg";
verbosity = 0;
#if 0
for (foo=0; foo<argc; foo++) {
fprintf(stderr, "%9d %s\n", foo, argv[foo]);
}
#endif
while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) {
case 'h': help(0), exit(0); break;
case 'v': verbosity++; break;
default: break;
}
}
if (3 != argc-optind) {
fprintf(stderr, "---- %s errcli c=%d %d ----\n", argv[0],
argc, argc-optind);
help(1);
exit(1);
}
if (verbosity) {
fprintf(stderr, "*** %s %s %s\n", argv[0], __DATE__, __TIME__);
fimg_print_version(1);
}
infile = argv[optind]; outfile = argv[optind+2];
fprintf(stderr, "%s %s -> %s\n", argv[0], infile, outfile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
foo, infile);
exit(1);
}
if (4 != parse_rectangle( argv[optind+1], &zone, 0) ) {
fprintf(stderr, "%s: error in parsing of '%s'\n",
argv[0], argv[optind+1]);
exit(1);
}
// zone.w = src.width / 2; zone.h = src.height / 2;
// zone.x = src.width / 4 ; zone.y = src.height / 4;
if (verbosity) print_rectangle(argv[0], &zone);
foo = fimg_create(&dst, zone.w, zone.h, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "NO PICZ EPIC FAIL %d\n", foo);
exit(1);
}
foo = fimg_extractor(&src, &dst, &zone);
if (foo) {
fprintf(stderr, "EXTRACTOR EPIC FAIL %d\n", foo);
exit(1);
}
foo = fimg_export_picture(&dst, outfile, 0);
if (foo) {
fprintf(stderr, "export '%s' -> err %d\n", outfile, foo);
exit(1);
}
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */

View File

@ -1,37 +1,88 @@
/* /*
* floatimg.h * floatimg.h
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
* ugly code from tTh * ugly code from tTh
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul/
* https://git.tetalab.org/tTh/FloatImg
*/ */
#define FIMG_VERSION 150 #define FIMG_VERSION (245)
#define RELEASE_NAME ("noname")
#define PATCH_LEVEL ("aaaa")
/* XXX add a test for stdint.h / uint32_t XXX */
#include <stdint.h>
/* /*
* in memory descriptor * new 11 mars 2022, and a lot of iterations
* around the concept of metadata for my work.
*
* we MUST look at packing and endianess problems NOW
* and we can think about a fixed size of this datablock
*/
#define MAGIC_MDATA 0xfe007007
typedef struct {
uint32_t magic;
uint32_t padding;
struct timeval timestamp; // #include <stdlib.h>
uint64_t cpid; // process id of the creator
int32_t count;
float fval;
char idcam[32];
int32_t origin; // enum ?
uint32_t reserved[8];
} FimgMetaData;
/*
* in memory descriptor of a floating image
* ----------------------------------------
*/ */
#define MAGIC_FIMG 0x00F11F00 #define MAGIC_FIMG 0x00F11F00
typedef struct { typedef struct {
unsigned long magic; uint32_t magic;
int width; int width;
int height; int height;
int type; int type;
float fval; float fval;
int count; int count;
float *R, *G, *B, *A; float *R, *G, *B, *A;
FimgMetaData mdatas; // added 20230912
int reserved; int reserved;
} FloatImg; } FloatImg;
/* /*
* fimg file header * fimg file header (short version)
*/ */
typedef struct { typedef struct {
char magic[8]; char magic[8]; /* this is not an asciiz ! */
int32_t w, h, t; int32_t w, h, t;
/*
* what about the packing ?
*/
} FimgFileHead; } FimgFileHead;
#define MAGIC_AREA51 0xA5EA0051 #define MAGIC_AREA51 0xA5EA0051
typedef struct { typedef struct {
unsigned long magic; uint32_t magic;
int w, h; int w, h;
int x, y; int x, y;
int flags; int flags;
@ -50,6 +101,8 @@ typedef struct {
#define FILE_TYPE_FITS 6 #define FILE_TYPE_FITS 6
#define FILE_TYPE_BMP 7 #define FILE_TYPE_BMP 7
#define FILE_TYPE_EXR 8 #define FILE_TYPE_EXR 8
#define FILE_TYPE_DICOM 9
#define FILE_TYPE_PGM 10
/* lib/contrast.c */ /* lib/contrast.c */
#define CONTRAST_NONE 0 #define CONTRAST_NONE 0
@ -57,7 +110,7 @@ typedef struct {
#define CONTRAST_POW2 2 #define CONTRAST_POW2 2
#define CONTRAST_COS01 3 #define CONTRAST_COS01 3
#define CONTRAST_COS010 4 #define CONTRAST_COS010 4
#define CONTRAST_XPER 5 /* use with caution */
/* /*
* core module * core module
*/ */
@ -95,21 +148,27 @@ int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d); int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d); int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
/* funcs/filtrage.c */
/* ---------------------------------------------------- */
/* funcs/filtrage.c */
typedef struct { typedef struct {
float matrix[9]; float matrix[9];
float mult; float mult;
float offset; float offset;
} FimgFilter3x3; } FimgFilter3x3;
/*
* this module contains bugs...
*/
int fimg_killborders(FloatImg *img); int fimg_killborders(FloatImg *img);
int fimg_lissage_2x2(FloatImg *img); int fimg_lissage_2x2(FloatImg *img);
int fimg_lissage_3x3(FloatImg *img);
int fimg_show_filter(char *title, FimgFilter3x3 *filtr);
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse); int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse);
/* ---------------------------------------------------- */
/* module sfx0.c */ /* module sfx0.c */
int fimg_killcolors_a(FloatImg *fimg, float fval); int fimg_killcolors_a(FloatImg *fimg, float fval);
int fimg_killcolors_b(FloatImg *fimg, float fval); int fimg_killcolors_b(FloatImg *fimg, float fval);
@ -123,20 +182,33 @@ int fimg_highlight_color(FloatImg *src, FloatImg *dst,
int fimg_binarize(FloatImg *pimg, int notused); int fimg_binarize(FloatImg *pimg, int notused);
int fimg_trinarize(FloatImg *pimg, int notused); int fimg_trinarize(FloatImg *pimg, int notused);
/* module sfx3.c */
int fimg_make_rndfluffy_lines(FloatImg *src, FloatImg *dst, int rndt);
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused);
/* module sfx4.c */ /* module sfx4.c */
int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused); int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
int fimg_split_level(FloatImg *src, FloatImg *dst, int notused);
int fimg_make_triptyq(FloatImg *src, FloatImg *dst, int notused);
/* funcs/rotate.c module */ /* funcs/rotate.c module */
/* #coronamaison */
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused); int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k);
int fimg_decomp_rgbz_color(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_decomp_rgbz_gray(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_save_plane_as_dicom(FloatImg *src, char *outname,
char plane, int flags);
/* universal exporter XXX */ /* universal exporter XXX */
int fimg_export_picture(FloatImg *pic, char *fname, int flags); int fimg_export_picture(FloatImg *pic, char *fname, int flags);
/* PNM files module */ /* PNM files module */
int fimg_save_as_pnm(FloatImg *head, char *fname, int flags); int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
int fimg_save_as_pgm(FloatImg *head, char *fname, int flags);
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused); int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
int fimg_save_plane_as_pgm(FloatImg *psrc, char *fname, char plane);
double fimg_timer_set(int whot); double fimg_timer_set(int whot);
double fimg_timer_get(int whot); double fimg_timer_get(int whot);
@ -153,16 +225,30 @@ int fimg_mix_rgb_gray(FloatImg *img, float mix);
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]); int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d); int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
/* funcs/falsecolors.c */
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf);
/* funcs/fmorpho.c */
int fimg_filtre_morpho_0(FloatImg *sfimg, FloatImg *dfimg, int index);
int fimg_auto_thermique(FloatImg *src, FloatImg *dst, int k);
/* --> funcs/plasmas.c */ /* --> funcs/plasmas.c */
int fimg_prototype_plasma(FloatImg *img, double time, int type); int fimg_prototype_plasma(FloatImg *img, double time, int type);
/* --> funcs/pixelize.c
voir fimg_pixelize_h_rnd() */
int fimg_pixelize_h_0(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_pixelize_h_rnd(FloatImg *psrc, FloatImg *pdst, int largeur);
/* * * * experimental ! */ /* * * * experimental ! */
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused); 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_a(FloatImg *psrc, FloatImg *pdst, int notused);
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused); int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
/* module funcs/??????.c */ /* module funcs/equalize.c */
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax); int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
int fimg_equalize(FloatImg *src, double vmax);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused); int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
@ -174,7 +260,6 @@ int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect); int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused); int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst, int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags); int xpos, int ypos, int flags);
@ -183,13 +268,24 @@ int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
/* module funcs/rampes.c */ /* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef); int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef); int fimg_vdeg_a(FloatImg *img, double dcoef);
int fimg_do_stripes(FloatImg *img, float fmax, int mode);
/* FIMG files module */ /* FIMG native file module */
int fimg_fileinfos(char *fname, int *datas); int fimg_fileinfos(char *fname, int *datas);
int fimg_dump_to_file(FloatImg *head, char *fname, int notused); int fimg_dump_to_file(FloatImg *head, char *fname, int notused);
int fimg_dumpmd_to_file(FloatImg *fi, char *nm, FimgMetaData *pmd, int nu);
int fimg_load_from_dump(char *fname, FloatImg *where); int fimg_load_from_dump(char *fname, FloatImg *where);
int fimg_create_from_dump(char *fname, FloatImg *head); int fimg_create_from_dump(char *fname, FloatImg *head);
/* FIMG metadata module */
int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused);
int fimg_default_metadata(FimgMetaData *pmd, int bla);
int fimg_get_metadata_from_file(char *fname, FimgMetaData *pmd);
/*
* FITS, an image fileformat for astronomy
*/
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags); int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags); int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags); int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
@ -198,19 +294,23 @@ int fimg_save_plane_as_fits(FloatImg *src, char *oname, char plane, int flags);
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags); int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
int fimg_save_as_exr(FloatImg *src, char *outname, int flags); int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
/* mathematics operations */ /* mathematics operations */
float fimg_get_plane_maxvalue(FloatImg *psrc, char plane);
float fimg_get_maxvalue(FloatImg *head); float fimg_get_maxvalue(FloatImg *head);
int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]); int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]);
int fimg_meanvalues(FloatImg *head, float means[4]); int fimg_meanvalues(FloatImg *head, float means[4]);
int fimg_to_gray(FloatImg *head); int fimg_to_gray(FloatImg *head);
int fimg_add_cste(FloatImg *fi, float value); int fimg_add_cste(FloatImg *fi, float value);
int fimg_mul_cste(FloatImg *fi, float value); int fimg_mul_cste(FloatImg *fi, float value);
int fimg_div_cste(FloatImg *fi, float value);
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused); int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
int fimg_absolute(FloatImg *fimg);
void fimg_drand48(FloatImg *fi, float kmul); void fimg_drand48(FloatImg *fi, float kmul);
long fimg_count_negativ(FloatImg *fi); long fimg_count_negativ(FloatImg *fi);
long fimg_clamp_negativ(FloatImg *fi); long fimg_clamp_negativ(FloatImg *fi);
int fimg_max_of_max(FloatImg *img, float maxes[3]);
/* various funcs modules */ /* various funcs modules */
int fimg_load_from_png(char *filename, FloatImg *fimg); int fimg_load_from_png(char *filename, FloatImg *fimg);
int fimg_create_from_png(char *filename, FloatImg *fimg); int fimg_create_from_png(char *filename, FloatImg *fimg);
@ -225,13 +325,17 @@ int fimg_multirandom(FloatImg *fimg, long nbpass);
/* file is 'funcs/utils.c' */ /* file is 'funcs/utils.c' */
void fimg_print_minmax(float minmax[6], char *titre); void fimg_print_minmax(float minmax[6], char *titre);
float *charplane2int(char plane, FloatImg *img);
int parse_WxH(char *str, int *pw, int *ph); int parse_WxH(char *str, int *pw, int *ph);
int parse_double(char *str, double *dptr); int parse_double(char *str, double *dptr);
int irand2(int offset, int modulo);
int print_rectangle(char *str, FimgArea51 *rect); int print_rectangle(char *str, FimgArea51 *rect);
int parse_rectangle(char *str, FimgArea51 *r, int notused); int parse_rectangle(char *str, FimgArea51 *r, int notused);
int format_from_extension(char *fname); int format_from_extension(char *fname);
char * extension_from_format(int fmt); char * extension_from_format(int fmt);
int fimg_clear_rectangle(FloatImg *pimg, int rect[4]);

10
funcs/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
tpnm
t
*.o
*.png
*.gif
*.fits
*.tiff

View File

@ -2,30 +2,28 @@
# Please, use the 'Gloabl.makefile' system ! # Please, use the 'Gloabl.makefile' system !
LIB_DIR = ../../build/lib
OBJ_DIR = ../../build/obj
STATIC_LIB = $(LIB_DIR)/libfloatimg.a
DYN_OBJ = $(OBJ_DIR)/libfloatimg-funcs.o
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
COPT = -Wall -Wextra -fpic -g -no-pie -DDEBUG_LEVEL=0
DEPS = ../floatimg.h Makefile DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o sfx0.o sfx1.o sfx2.o sfx4.o \ fimg-libpnm.o rampes.o rectangle.o \
sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \
falsecolors.o thermocolor.o fmorpho.o \
geometry.o rotate.o fimg-openexr.o \ geometry.o rotate.o fimg-openexr.o \
equalize.o fimg-fits.o saturation.o histogram.o \ equalize.o fimg-fits.o saturation.o histogram.o \
fimg-dicom.o \
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \ hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
displacement.o dithering.o plasmas.o incrustator.o \ displacement.o dithering.o plasmas.o incrustator.o \
recurse.o killrgb.o recurse.o pixelize.o decomprgb.o
all: $(OBJS) $(STATIC_LIB) $(DYN_OBJ)
#--------------------------------------------------------------- #---------------------------------------------------------------
all: t
tests.o: tests.c tests.h $(DEPS)
gcc $(COPT) -I/usr/include/netpbm -c $<
t: t.c $(DEPS) ../libfloatimg.a tests.o t: t.c $(DEPS) ../libfloatimg.a tests.o
gcc $(COPT) $< \ gcc $(COPT) $< \
tests.o \ tests.o \
@ -35,22 +33,29 @@ t: t.c $(DEPS) ../libfloatimg.a tests.o
-ltiff \ -ltiff \
-lz -lm -o $@ -lz -lm -o $@
tests.o: tests.c tests.h $(DEPS) tpnm: tpnm.c Makefile fimg-libpnm.o
gcc $(COPT) -I/usr/include/netpbm -c $< gcc $(COPT) -I/usr/include/netpbm \
fimg-libpnm.o -lnetpbm $< -o $@
#--------------------------------------------------------------- #---------------------------------------------------------------
# upper-level functions # upper-level functions
$(STATIC_LIB): $(OBJS) ../libfloatimg.a: $(OBJS)
$(AR) r $@ $? $(AR) r $@ $?
# ###
$(DYN_OBJ): $(OBJS) rectangle.o: rectangle.c $(DEPS)
mkdir -p $(OBJ_DIR) gcc $(COPT) -c $<
ld -Ur -o $@ $?
clean: decomprgb.o: decomprgb.c $(DEPS)
rm -rf $(OBJS) $(STATIC_LIB) $(DYN_OBJ) gcc $(COPT) -c $<
pixelize.o: pixelize.c $(DEPS)
gcc $(COPT) -c $<
killrgb.o: killrgb.c $(DEPS)
gcc $(COPT) -c $<
recurse.o: recurse.c $(DEPS) recurse.o: recurse.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
@ -61,6 +66,9 @@ incrustator.o: incrustator.c $(DEPS)
displacement.o: displacement.c $(DEPS) displacement.o: displacement.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
fmorpho.o: fmorpho.c $(DEPS)
gcc $(COPT) -c $<
fimg-png.o: fimg-png.c $(DEPS) fimg-png.o: fimg-png.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
@ -73,6 +81,9 @@ fimg-tiff.o: fimg-tiff.c $(DEPS)
fimg-openexr.o: fimg-openexr.c $(DEPS) fimg-openexr.o: fimg-openexr.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
fimg-dicom.o: fimg-dicom.c $(DEPS)
gcc $(COPT) -c $<
fimg-fits.o: fimg-fits.c $(DEPS) fimg-fits.o: fimg-fits.c $(DEPS)
gcc $(COPT) -I/usr/include/cfitsio/ -c $< gcc $(COPT) -I/usr/include/cfitsio/ -c $<
@ -115,6 +126,9 @@ sfx1.o: sfx1.c $(DEPS)
sfx2.o: sfx2.c $(DEPS) sfx2.o: sfx2.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
sfx3.o: sfx3.c $(DEPS)
gcc $(COPT) -c $<
sfx4.o: sfx4.c $(DEPS) sfx4.o: sfx4.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
@ -133,6 +147,11 @@ qsortrgb.o: qsortrgb.c $(DEPS)
exporter.o: exporter.c $(DEPS) exporter.o: exporter.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
falsecolors.o: falsecolors.c $(DEPS)
gcc $(COPT) -c $<
thermocolor.o: thermocolor.c $(DEPS)
gcc $(COPT) -c $<
hsv.o: hsv.c $(DEPS) hsv.o: hsv.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

53
funcs/README.md Normal file
View File

@ -0,0 +1,53 @@
# Fonctions
Plein de fonctions qu'il serait bon de documenter :)
## Contours
Détecter des contours est une activité respectable. Mais difficile.
Une recherche dans la littérature s'impose.
## Exporter
`fimg_exporter` est une méta-fonction qui va sauvegarder (dans la mesure de ses conséquences)
une image en fonction de l'extension du nom de fichier fourni.
### PNG
__Attention__ : la bibliothèque `pnglite` actuellement utilisée pour lire
les fichiers PNG n'accepte que certains types de fichiers.
Et en particulier, elle brotche sur ceux produits par ImageMagick !
### FITS
Ce [format de fichier](https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node1.html)
est utilisé en astronomie.
Son support est actuellement minimaliste.
### DICOM
https://en.wikipedia.org/wiki/DICOM et ça semble bien compliqué,
donc ça reste pour le moment au stade de vague projet :(
## Sfx
Effets spéciaux divers. Ils sont répartis dans plusieurs fichiers
(`sfx[0-4].c`) sans raison de classement apparente.
Certains peuvent être directement utilisés
avec l'outil [../tools/fimgfx.c](fimgfx).
Leur paramétrage est trop sommaire.
La fonction `fimg_pixelize_h_rnd` est issue d'une idée qui m'est venue
dans la roulotte de TerreBlanque. Elle a besoin de recherches sur la
dynamique temporelle, et d'une FSM à trois états.
## Dithering
Work in progress...
Une difficulté dans ce domaine, c'est la *floattitude* des pixels,
sur laquelle il est difficile d'appliquer des operations binaires,
comme le XOR.

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <math.h> #include <math.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -14,7 +15,7 @@ extern int verbosity;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* nouveau 2 octobre 2020, juste avant sonoptic de la pluie craignos */ /* nouveau 2 octobre 2020, juste avant sonoptic de la pluie craignos */
int fimg_classif_trial(FloatImg *psrc, FloatImg *pdst, float fval, int notused) int fimg_classif_trial(FloatImg *psrc, FloatImg *pdst, float fval, int flags)
{ {
float minmax[6], delta[3], baryc[3]; float minmax[6], delta[3], baryc[3];
float range, dist, rgb[3], dr, dg, db; float range, dist, rgb[3], dr, dg, db;
@ -25,6 +26,8 @@ fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__,
psrc, pdst, fval, notused); psrc, pdst, fval, notused);
#endif #endif
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
if (FIMG_TYPE_RGB != psrc->type) { if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7; return -7;

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>

157
funcs/decomprgb.c Normal file
View File

@ -0,0 +1,157 @@
/*
* DECOMPOSITION RGB
*/
#include <stdio.h>
#include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h"
extern int verbosity;
/* == ---------------------------------------------------- == */
/* some dirty macros */
#define pixidx(fi,x,y) (((y)*fi->width)+(x))
#define getRpix(fi,x,y) (fi->R[ pixidx(fi,(x),(y)) ])
#define getGpix(fi,x,y) (fi->G[ pixidx(fi,(x),(y)) ])
#define getBpix(fi,x,y) (fi->B[ pixidx(fi,(x),(y)) ])
/* A lot of strange and usefull parenthesis */
/* == ---------------------------------------------------- == */
#if DEBUG_LEVEL
static float compute_z_value(float r, float g, float b)
{
double dval;
return 42.0;
}
#endif
/* == ---------------------------------------------------- == */
int fimg_decomp_rgbz_color(FloatImg *psrc, FloatImg *pdst, int k)
{
int x, y, x2, y2;
int w2, h2;
float cumul, vgray;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
psrc, pdst, k);
#endif
/*
* XXX useless message ?
*/
if (k) { fprintf(stderr, "k=%d in %s\n", k, __func__); }
fimg_clear(pdst);
w2 = psrc->width/2; h2 = psrc->height/2;
for (y=0; y<h2; y++)
{
y2 = y * 2;
for (x=0; x<w2; x++) {
x2 = x * 2;
cumul = getRpix(psrc, x2, y2) +
getRpix(psrc, x2, y2+1) +
getRpix(psrc, x2+1, y2) +
getRpix(psrc, x2+1, y2+1);
cumul /= 4, vgray = cumul;
pdst->R[pixidx(pdst,x,y)] = cumul;
pdst->R[pixidx(pdst,x+w2,y+h2)] = cumul;
cumul = getGpix(psrc, x2, y2) +
getGpix(psrc, x2, y2+1) +
getGpix(psrc, x2+1, y2) +
getGpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
pdst->G[pixidx(pdst,x+w2,y)] = cumul;
pdst->G[pixidx(pdst,x+w2,y+h2)] = cumul;
cumul = getBpix(psrc, x2, y2) +
getBpix(psrc, x2, y2+1) +
getBpix(psrc, x2+1, y2) +
getBpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
pdst->B[pixidx(pdst,x,y+h2)] = cumul;
pdst->B[pixidx(pdst,x+w2,y+h2)] = cumul;
}
}
return 0;
}
/* == ---------------------------------------------------- == */
/* PUTAIN LE COPIER/COLLÉ DE BATARD !!! */
int fimg_decomp_rgbz_gray(FloatImg *psrc, FloatImg *pdst, int k)
{
int x, y, x2, y2;
int w2, h2, idx;
float cumul, vgray;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
psrc, pdst, k);
#endif
/*
* XXX useless message ?
*/
if (k) { fprintf(stderr, "k=%d in %s\n", k, __func__); }
fimg_clear(pdst);
w2 = psrc->width/2; h2 = psrc->height/2;
for (y=0; y<h2; y++)
{
y2 = y * 2;
for (x=0; x<w2; x++) {
x2 = x * 2;
cumul = getRpix(psrc, x2, y2) +
getRpix(psrc, x2, y2+1) +
getRpix(psrc, x2+1, y2) +
getRpix(psrc, x2+1, y2+1);
cumul /= 4, vgray = cumul;
idx = pixidx(pdst,x,y);
pdst->R[idx] = pdst->G[idx] = pdst->B[idx] = cumul;
cumul = getGpix(psrc, x2, y2) +
getGpix(psrc, x2, y2+1) +
getGpix(psrc, x2+1, y2) +
getGpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
idx = pixidx(pdst,x+w2,y);
pdst->R[idx] = pdst->G[idx] = pdst->B[idx] = cumul;
cumul = getBpix(psrc, x2, y2) +
getBpix(psrc, x2, y2+1) +
getBpix(psrc, x2+1, y2) +
getBpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
idx = pixidx(pdst,x,y+h2);
pdst->R[idx] = pdst->G[idx] = pdst->B[idx] = cumul;
idx = pixidx(pdst,x+w2,y+h2);
pdst->R[idx] = pdst->G[idx] = \
pdst->B[idx] = vgray / 3.0;
}
}
return 0;
}
/* == ---------------------------------------------------- == */

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -21,7 +22,6 @@ float minmax[6];
float rgb[3]; float rgb[3];
float dltr, dltg, dltb; /* delta des minmax */ float dltr, dltg, dltb; /* delta des minmax */
float dispx, dispy; float dispx, dispy;
int dstx, dsty; int dstx, dsty;
int in, out; int in, out;
@ -39,10 +39,14 @@ if (fimg_images_not_compatible(psrc, pdst)) {
} }
foo = fimg_get_minmax_rgb(psrc, minmax); foo = fimg_get_minmax_rgb(psrc, minmax);
if (foo) {
fprintf(stderr, "%s : err %d on get minmax\n", __func__, foo);
return foo;
}
if (verbosity) { if (verbosity) {
fimg_print_minmax(minmax, (char *)__func__); fimg_print_minmax(minmax, (char *)__func__);
} }
dltr = minmax[1] - minmax[0]; // dltr = minmax[1] - minmax[0];
dltg = minmax[3] - minmax[2]; dltg = minmax[3] - minmax[2];
dltb = minmax[5] - minmax[4]; dltb = minmax[5] - minmax[4];
@ -78,9 +82,7 @@ for (y=0; y<psrc->height; y++) {
fimg_put_rgb(pdst, dstx, dsty, rgb); fimg_put_rgb(pdst, dstx, dsty, rgb);
in++; in++;
} }
} }
} }
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out); if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -16,11 +17,23 @@ int fimg_dither_0(FloatImg *psrc, FloatImg *pdst, int flags)
{ {
int x, y; int x, y;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, psrc, pdst, flags);
#endif
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: shit happen\n", __func__);
return -2;
}
for (y=0; y<psrc->height; y++) { for (y=0; y<psrc->height; y++) {
for (x=0; x<psrc->width; x++) for (x=0; x<psrc->width; x++)
{ {
/* PLEASE DO SOMETHING HERE */
} }
} }

View File

@ -7,12 +7,54 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"
extern int verbosity; extern int verbosity;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* new func: Wed 14 Sep 2022 11:28:04 AM CEST
*/
int fimg_equalize(FloatImg *src, double vmax)
{
float mm[6];
double maxi, coef;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f )\n", __func__, src, vmax);
#endif
memset(mm, 0, 6*sizeof(float));
foo = fimg_get_minmax_rgb(src, mm);
if (foo) {
fprintf(stderr, "%s: err %d get_minmax\n", __func__, foo);
return foo;
}
maxi = mm[1] > mm[3] ? (double)mm[1] : (double)mm[3];
maxi = maxi > mm[5] ? maxi : (double)mm[5];
coef = vmax / maxi;
if (verbosity) {
fprintf(stderr, "maximums %.3f %.3f %.3f %.3f\n",
mm[1], mm[3], mm[5], maxi);
fprintf(stderr, "vmax %f maxi %f multcoef = %g\n", vmax, maxi, coef);
}
foo = fimg_mul_cste(src, (float)coef);
if (foo) {
fprintf(stderr, "%s: err %d mul_cste\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */
/*
*
* - wtf is this "void *vptr" thing ?
*/
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax) int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax)
{ {
float minmax[6]; float minmax[6];
@ -31,6 +73,8 @@ if (foo) {
return foo; return foo;
} }
fprintf(stderr, "vptr is %p vmax is %f\n", vptr, vmax);
dr = minmax[1] - minmax[0]; dr = minmax[1] - minmax[0];
dg = minmax[3] - minmax[2]; dg = minmax[3] - minmax[2];
db = minmax[5] - minmax[4]; db = minmax[5] - minmax[4];
@ -44,7 +88,7 @@ if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) {
return -4; return -4;
} }
// printf("deltas %12.4g %12.4g %12.4g\n", dr, dg, db); fprintf(stderr, "deltas %12.4g %12.4g %12.4g\n", dr, dg, db);
return 0; return 0;
} }

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -24,6 +25,8 @@ fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__,
pic, fname, flags); pic, fname, flags);
#endif #endif
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
filetype = format_from_extension(fname); filetype = format_from_extension(fname);
if (verbosity > 1) { if (verbosity > 1) {
fprintf(stderr, "file %s have type %d\n", fname, filetype); fprintf(stderr, "file %s have type %d\n", fname, filetype);
@ -53,9 +56,15 @@ switch(filetype) {
case FILE_TYPE_BMP: case FILE_TYPE_BMP:
fprintf(stderr, "%s: file type BMP not implemented\n", __func__); fprintf(stderr, "%s: file type BMP not implemented\n", __func__);
foo = -666; foo = -666;
break;
case FILE_TYPE_EXR: case FILE_TYPE_EXR:
fprintf(stderr, "%s: file type EXR experimental\n", __func__); fprintf(stderr, "%s: file type EXR experimental\n", __func__);
foo = fimg_save_as_exr(pic, fname, 0); foo = fimg_save_as_exr(pic, fname, 0);
break;
case FILE_TYPE_PGM:
fprintf(stderr, "XXX %s EXPERIMENT!\n", __func__);
foo = fimg_save_as_pgm(pic, fname, 0);
break;
default: default:
foo = -1789; foo = -1789;
break; break;

83
funcs/falsecolors.c Normal file
View File

@ -0,0 +1,83 @@
/*
* FloatImg library from tTh - really ugly code inside
*
* F A L S E C O L O R S
* or fake colors ?
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <math.h>
#include "../floatimg.h"
/* -------------------------------------------------------------- */
/* this is a global vars exported from main */
extern int verbosity;
/* -------------------------------------------------------------- */
/* TRUCS A VOIR
f(x,y) = (((y & x) * (y - x)) % ((21 & x) * (y | 8))) ^ (~((x & 7) | (x % x)))
*/
/* -------------------------------------------------------------- */
/* nouveau 18 mai 2022 */
/* please explain the meaning of 'valf' parameter */
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf)
{
int x, y, offset;
float r, g, b, gray, maxv;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d %f )\n", __func__,
src, dst, k, valf);
#endif
if (k) {
fprintf(stderr, "%s : %d %f\n", __func__, k, valf);
}
/* check validity of parameters */
if (FIMG_TYPE_RGB != dst->type) {
fprintf(stderr, "in %s, picz at %p is not valid\n",
__func__, dst);
abort();
/* BLAM! */
}
maxv = fimg_get_plane_maxvalue(src, 'r');
fprintf(stderr, "%s: maxv of red plane = %f\n", __func__, maxv);
/* enter big loop */
offset = 0;
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) {
gray = src->R[offset];
if (gray < maxv/2.0) {
r = gray * 2.0;
g = 0.0;
}
else {
r = 0.0;
g = gray * 2.0;
}
b = fmodf(gray*8.0, maxv);
dst->R[offset] = r;
dst->G[offset] = g;
dst->B[offset] = b;
/* and GOTO next pixel */
offset++;
}
}
return 0;
}
/* -------------------------------------------------------------- */

View File

@ -1,11 +1,43 @@
/*
* Floating filters are all WIP !
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <float.h> #include <float.h>
#include "../floatimg.h" #include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------------- */
int fimg_show_filter(char *title, FimgFilter3x3 *filtr)
{
float *M; /* alias of filter matrix */
int idx;
float sum, value;
if (title) fprintf(stderr, "--------- %s ---------\n", title);
M = filtr->matrix; /* aliasing here */
fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[0], M[1], M[2]);
fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[3], M[4], M[5]);
fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[6], M[7], M[8]);
sum = 0.0;
for (idx=0; idx<9; idx++) sum += M[idx];
fprintf(stderr, " sum: %8.3f\n", sum);
fprintf(stderr, " mult: %8.3f\n", filtr->mult);
fprintf(stderr, " offset: %8.3f\n", filtr->offset);
value = (sum * filtr->mult) + filtr->offset;
fprintf(stderr, " value: %8.3f\n", value);
return 0;
}
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
int fimg_filter_3x3(FloatImg *src, FloatImg *dst, FimgFilter3x3 *filtr) int fimg_filter_3x3(FloatImg *src, FloatImg *dst, FimgFilter3x3 *filtr)
{ {
@ -15,7 +47,7 @@ float *M; /* alias of filter matrix */
double dval; double dval;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, src, dst, filtr); fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, src, dst, filtr);
#endif #endif
if (src->type != FIMG_TYPE_RGB) { if (src->type != FIMG_TYPE_RGB) {
@ -27,19 +59,21 @@ if (dst->type != FIMG_TYPE_RGB) {
return -99; return -99;
} }
if (fimg_images_not_compatible(src, dst)) { if (fimg_images_not_compatible(src, dst)) {
fprintf(stderr, "%s: src & dst not comatibles\n", __func__); fprintf(stderr, "%s: src & dst not compatibles\n", __func__);
return -98; return -98;
} }
if (verbosity > 1) {
fimg_show_filter((char *)__func__, filtr);
}
/* aliasing some vars for cleaner code */ /* aliasing some vars for cleaner code */
pr = src->R; pg = src->G; pb = src->B; pr = src->R; pg = src->G; pb = src->B;
w = src->width; h = src->height; w = src->width; h = src->height;
M = filtr->matrix; M = filtr->matrix;
for (y=1; y < h-1; y++) { for (y=1; y < h-1; y++) {
for (x=1; x < w-1; x++) { for (x=1; x < w-1; x++) {
of = x + (y * w); of = x + (y * w);
dval = M[0] * pr[of-(w+1)] + dval = M[0] * pr[of-(w+1)] +
@ -106,9 +140,7 @@ if (img->type != FIMG_TYPE_RGB) {
pr = img->R; pg = img->G; pb = img->B; pr = img->R; pg = img->G; pb = img->B;
for (y=1; y < img->height-1; y++) { for (y=1; y < img->height-1; y++) {
for (x=1; x < img->width-1; x++) { for (x=1; x < img->width-1; x++) {
offset = x + (y * img->width); offset = x + (y * img->width);
cr = pr[offset] + pr[offset+1] + cr = pr[offset] + pr[offset+1] +
@ -123,7 +155,6 @@ for (y=1; y < img->height-1; y++) {
pr[offset] = cr / 4.0; pr[offset] = cr / 4.0;
pg[offset] = cg / 4.0; pg[offset] = cg / 4.0;
pb[offset] = cb / 4.0; pb[offset] = cb / 4.0;
} }
} }
@ -164,7 +195,6 @@ for (idx=0; idx<h; idx++) {
} }
o = w * (h - 1); o = w * (h - 1);
for (idx=0; idx<w; idx++) { for (idx=0; idx<w; idx++) {
#if FAST #if FAST
img->R[idx] = 0.0; img->R[idx] = 0.0;
@ -186,6 +216,10 @@ int fimg_lissage_2x2(FloatImg *img)
{ {
int foo; int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
#endif
foo = fimg_lissage_2x2_a(img); foo = fimg_lissage_2x2_a(img);
if (foo) { if (foo) {
fprintf(stderr, "%s: fail %d\n", __func__, foo); fprintf(stderr, "%s: fail %d\n", __func__, foo);
@ -197,4 +231,54 @@ fimg_killborders(img);
return foo; return foo;
} }
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
/*
* XXX inplace filtering is a BAD IDEA
*/
int fimg_lissage_3x3(FloatImg *img)
{
int foo;
FloatImg tmp;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
#endif
static FimgFilter3x3 lowpass = {
{
1.0, 2.0, 1.0,
2.0, 4.0, 2.0,
1.0, 2.0, 1.0,
},
16.0, 0.0
};
foo = fimg_clone(img, &tmp, 1);
if (foo) {
fprintf(stderr, "%s: clone -> %d\n", __func__, foo);
abort();
}
foo = fimg_filter_3x3(&tmp, img, &lowpass);
if (foo) {
fprintf(stderr, "%s: lowpass -> %d\n", __func__, foo);
abort();
}
foo = fimg_copy_data(&tmp, img);
if (foo) {
fprintf(stderr, "%s: copy data -> %d\n", __func__, foo);
abort();
}
foo = fimg_destroy(&tmp);
if (foo) {
fprintf(stderr, "%s: destroy -> %d\n", __func__, foo);
abort();
}
fimg_killborders(img);
return 0;
}
/* -------------------------------------------------------------------- */

33
funcs/fimg-dicom.c Normal file
View File

@ -0,0 +1,33 @@
/*
Digital Imaging and Communications in Medicine
nouveau Fri 26 Nov 2021 11:12:44 PM CET - allée de Dinan
*/
#include <stdio.h>
#include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h"
extern int verbosity; /* must be declared around main() */
/* --------------------------------------------------------------------- */
int fimg_save_plane_as_dicom(FloatImg *src, char *outname,
char plane, int flags)
{
float *planeptr;
fprintf(stderr, ">>> %s ( %p %s %c %d )\n", __func__, src, outname, plane, flags);
planeptr = charplane2int(plane, src); /* please explain XXX */
fprintf(stderr, "planeptr is %p\n", planeptr);
if (verbosity) {
fimg_describe(src, outname);
}
return -1;
}
/* --------------------------------------------------------------------- */

View File

@ -8,6 +8,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <fitsio.h> #include <fitsio.h>
@ -30,6 +32,8 @@ long naxes[2];
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outname, flags); fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outname, flags);
#endif #endif
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
status = 0; status = 0;
switch (plane) { switch (plane) {
@ -50,7 +54,7 @@ if (fits_create_file(&fptr, outname, &status)) {
} }
naxes[0] = src->width; naxes[1] = src->height; naxes[0] = src->width; naxes[1] = src->height;
if (verbosity) fimg_describe(src, "to be saved as FITS"); if (verbosity > 1) fimg_describe(src, "to be saved as FITS");
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) { if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
fits_report_error(stderr, status); fits_report_error(stderr, status);

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <pam.h> #include <pam.h>
@ -13,17 +14,16 @@
extern int verbosity; extern int verbosity;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void print_struct_pam(struct pam *ppam, char *txt) static void print_struct_pam(struct pam *ppam, char *text)
{ {
printf("\ttext %s\n", text);
printf("\tsize %d\n", ppam->size);
printf(" size %d\n", ppam->size); printf("\tformat %d 0x%04x\n", ppam->format, ppam->format);
printf("\tplainformat %d\n", ppam->plainformat);
printf(" format %d\n", ppam->format); printf("\twidth & height %d %d\n", ppam->width, ppam->height);
printf(" plainformat %d\n", ppam->plainformat); printf("\tdepth %d\n", ppam->depth);
printf(" width & height %d %d\n", ppam->width, ppam->height); printf("\tmaxval %lu\n", ppam->maxval);
printf(" depth %d\n", ppam->depth);
printf(" maxval %lu\n", ppam->maxval);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -36,13 +36,14 @@ FILE *fp;
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname); fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname);
#endif #endif
printf(" --- infos for '%s' ------------\n", fname);
if (NULL==(fp=fopen(fname, "r"))) { if (NULL==(fp=fopen(fname, "r"))) {
perror(fname); perror(fname);
exit(1); exit(1);
} }
pnm_readpaminit(fp, &inpam, sizeof(inpam)); pnm_readpaminit(fp, &inpam, sizeof(inpam));
print_struct_pam(&inpam, fname); print_struct_pam(&inpam, fname);
fclose(fp); fclose(fp);

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <pnglite.h> #include <pnglite.h>
@ -86,7 +87,7 @@ if (PNG_NO_ERROR != foo) {
} }
ptr = datas; ptr = datas;
for (idx=0; idx<png.width * png.height; idx++) { for (idx=0; idx<(int)(png.width*png.height); idx++) {
fimg->R[idx] = (float)*ptr++; fimg->R[idx] = (float)*ptr++;
fimg->G[idx] = (float)*ptr++; fimg->G[idx] = (float)*ptr++;
fimg->B[idx] = (float)*ptr++; fimg->B[idx] = (float)*ptr++;
@ -131,7 +132,7 @@ if ( 3 != png.bpp ) { /* TO BE PATCHED */
} }
/* check if floatimg and PNG have the same size */ /* check if floatimg and PNG have the same size */
if ((fimg->width != png.width) || (fimg->height != png.height)) { if ((fimg->width != (int)png.width) || (fimg->height != (int)png.height)) {
fprintf(stderr, "%s : fatal error on images sizes\n", __func__); fprintf(stderr, "%s : fatal error on images sizes\n", __func__);
exit(1); exit(1);
} }
@ -150,7 +151,7 @@ if (PNG_NO_ERROR != foo) {
} }
ptr = datas; ptr = datas;
for (idx=0; idx<png.width * png.height; idx++) { for (idx=0; idx<(int)(png.width*png.height); idx++) {
fimg->R[idx] = (float)*ptr++; fimg->R[idx] = (float)*ptr++;
fimg->G[idx] = (float)*ptr++; fimg->G[idx] = (float)*ptr++;
fimg->B[idx] = (float)*ptr++; fimg->B[idx] = (float)*ptr++;
@ -170,9 +171,13 @@ unsigned char *bytes, *bptr;
double maximum, fk; double maximum, fk;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %-25s ( %p '%s' 0x%x )\n", __func__, src, outname, flags); fprintf(stderr, ">>> %s ( %p '%s' 0x%x )\n", __func__, src, outname, flags);
#endif #endif
if (flags) {
fprintf(stderr, "*** in %s, flags are %08x\n", __func__, flags);
}
/* convert ou floating datas to a byte/rgb array */ /* convert ou floating datas to a byte/rgb array */
/* first, alloc a buffer */ /* first, alloc a buffer */
sz = src->width * src->height; sz = src->width * src->height;

View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <tiffio.h> #include <tiffio.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -23,6 +23,9 @@ int x, y, idx, foo;
char ligne[100]; char ligne[100];
double maximum, fk; double maximum, fk;
if (flags) fprintf(stderr, "in %s, flags are 0x%04x, must be 0\n",
__func__, flags);
/* bon, tout cela semble bien tortueux ! */ /* bon, tout cela semble bien tortueux ! */
if (FIMG_TYPE_RGB != src->type) { if (FIMG_TYPE_RGB != src->type) {
@ -44,6 +47,8 @@ if (verbosity) {
tiff = TIFFOpen(fname, "w"); tiff = TIFFOpen(fname, "w");
if (NULL==tiff) { if (NULL==tiff) {
fprintf(stderr, "erreur TIFFOpen\n");
free(linebuff);
return -6; return -6;
} }

89
funcs/fmorpho.c Normal file
View File

@ -0,0 +1,89 @@
/*
* FLOATIMG
* --------
* F M O R P H O
*
* nouveau 30 septembre 2022 / integration 28 octobre 2022
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- !*/
static struct
{
int x, y;
} deltas[] =
{ { -1, -1, },
{ 0, -1, },
{ 1, -1, },
{ -1, 0, },
{ 0, 0, },
{ 1, 0, },
{ -1, 1, },
{ 0, 1, },
{ 1, 1 }
};
typedef struct
{
int x, y; // not used
float r, g, b;
float fgris;
int rang;
} fpixel;
static fpixel pixels[9];
/* --------------------------------------------------------------------- !*/
static int comparaison_fgris(const void *A, const void *B)
{
return ((fpixel *)A)->fgris > ((fpixel *)B)->fgris;
}
/* --------------------------------------------------------------------- !*/
/*
* this is a klugy approch, sorry.
*/
int fimg_filtre_morpho_0(FloatImg *sfimg, FloatImg *dfimg, int index)
{
int xs, ys, loop9;
int xp, yp;
float rgb[3];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, sfimg, dfimg, index);
#endif
if ( (index<0) || (index>8)) {
fprintf(stderr, " %s: bad index %d\n", __func__, index);
#if MUST_ABORT
fflush(stderr); abort();
#endif
return -1;
}
fimg_clear(dfimg);
for (ys=1; ys<sfimg->height-1; ys++) {
for (xs=1; xs<sfimg->width-1; xs++) {
for (loop9=0; loop9<9; loop9++) {
xp = xs + deltas[loop9].x;
yp = ys + deltas[loop9].y;
fimg_get_rgb(sfimg, xp, yp, rgb);
pixels[loop9].fgris = rgb[0] + rgb[1] + rgb[2];
pixels[loop9].rang = loop9;
}
qsort(&pixels, 9, sizeof(fpixel), comparaison_fgris);
rgb[0] = rgb[1] = rgb[2] = pixels[index].fgris;
fimg_put_rgb(dfimg, xs, ys, rgb);
}
}
return 0;
}
/* --------------------------------------------------------------------- !*/

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -26,6 +27,8 @@ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
src, dst, notused); src, dst, notused);
#endif #endif
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
/* no magic check here ? */ /* no magic check here ? */
if (dst->width || dst->height) { if (dst->width || dst->height) {
fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst); fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst);
@ -64,6 +67,8 @@ int wd, hd;
int foo, x, y, x2, y2; int foo, x, y, x2, y2;
float ac; float ac;
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
if (dst->width || dst->height) { if (dst->width || dst->height) {
fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst); fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst);
fimg_describe(dst, "destination halfsize 1"); fimg_describe(dst, "destination halfsize 1");
@ -105,19 +110,28 @@ for (y=0; y<hd; y++) {
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/*
* this function can be optimized with direct pixel copy
*/
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect) int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect)
{ {
int foo;
int xs, ys, xd, yd; int xs, ys, xd, yd;
int count; int count;
float rgb[3]; float rgb[3];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, in, out, rect);
#endif
if (verbosity > 1) { if (verbosity > 1) {
fimg_describe(in, "extractor: source"); fimg_describe(in, "extractor: source");
fimg_describe(out, "extractor: destination"); fimg_describe(out, "extractor: destination");
// print_rectangle(rect);
} }
/*
* some sanity controls, please ! XXX
*/
count = 0; count = 0;
for (yd=0; yd<rect->h; yd++) { for (yd=0; yd<rect->h; yd++) {
ys = yd + rect->y; ys = yd + rect->y;
@ -131,7 +145,7 @@ for (yd=0; yd<rect->h; yd++) {
} }
} }
// fprintf(stderr, "%s: %d pix moved\n", __func__, count); if (verbosity > 1) fprintf(stderr, "%s: %d pix moved\n", __func__, count);
return 0; return 0;
} }
@ -148,6 +162,8 @@ fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__,
src, dst, notused); src, dst, notused);
#endif #endif
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
if (fimg_images_not_compatible(src, dst)) { if (fimg_images_not_compatible(src, dst)) {
fprintf(stderr, "bad karma in %s\n", __func__); fprintf(stderr, "bad karma in %s\n", __func__);
return -9; return -9;

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -10,12 +10,19 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include "../floatimg.h" #include "../floatimg.h"
extern int verbosity; extern int verbosity;
/*
https://baillehachepascal.dev/2021/rgb_hsv.php
*/
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* helper functions */ /* helper functions */
static float maxi3f(float a, float b, float c) static float maxi3f(float a, float b, float c)
@ -28,7 +35,7 @@ return ((a < b)? (a < c ? a : c) : (b < c ? b : c));
} }
static int pseudoeq(float a, float b) static int pseudoeq(float a, float b)
{ {
return (fabsf(a-b)<0.00000000000001); // UGLY HACK ??? return (fabsf(a-b)<0.00000001); // UGLY HACK ???
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* /*
@ -78,7 +85,7 @@ float hh, ff, p, q, t;
long i; long i;
if(hsv[1] <= 0.0) { // < is bogus, just shuts up warnings if(hsv[1] <= 0.0) { // < is bogus, just shuts up warnings
rgb[0] = rgb[1] = rgb[2] = hsv[2]; rgb[0] = rgb[1] = rgb[2] = (hsv[2] * scale);
return 0; return 0;
} }
@ -124,7 +131,10 @@ int fimg_essai_hsv(char *fname)
float colors[3], values[3], newcols[3]; float colors[3], values[3], newcols[3];
int foo, r, g, b; int foo, r, g, b;
fprintf(stderr, "%s NOT writing to %s\n", __func__, fname);
#define INC 16 #define INC 16
for (r=0; r<255; r+=INC) { for (r=0; r<255; r+=INC) {
for (g=0; g<255; g+=INC) { for (g=0; g<255; g+=INC) {
for (b=0; b<255; b+=INC) { for (b=0; b<255; b+=INC) {

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -19,23 +20,26 @@ static int check_boundaries(FloatImg *from, FloatImg *to, FimgArea51 *a51)
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, from, to, a51); fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, from, to, a51);
fimg_printdims("from", from);
fimg_printdims("to ", to);
#endif #endif
if (verbosity > 1) {
fimg_printdims("from", from);
fimg_printdims("to ", to);
}
/* just a small molly-guard */ /* just a small molly-guard */
if ( (a51->w < 0) || (a51->h < 0) ) { if ( (a51->w < 0) || (a51->h < 0) ) {
fprintf(stderr, "%s: fubar on %p\n", __func__, a51); fprintf(stderr, "%s: fubar on %p\n", __func__, a51);
abort(); /* FY Bro ! */ abort(); /* FY Bro ! */
} }
return -1; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* XXX
static int move_pixels(FloatImg *from, FloatImg *to, static int move_pixels(FloatImg *from, FloatImg *to,
FimgArea51 *a51, int flags) FimgArea51 *a51, int flags)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p 0x%04x )\n", __func__, fprintf(stderr, ">>> %s ( %p %p %p 0x%04x )\n", __func__,
from, to, a51, flags); from, to, a51, flags);
@ -43,7 +47,11 @@ fprintf(stderr, ">>> %s ( %p %p %p 0x%04x )\n", __func__,
return -1; return -1;
} }
*/
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/*
* See also: fimg_extractor() in geometry.c
*/
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst, int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags) int xpos, int ypos, int flags)
{ {
@ -57,6 +65,8 @@ fprintf(stderr, ">>> %s ( %p %p %d %d 0x%04X\n", __func__, psrc, pdst,
xpos, ypos, flags); xpos, ypos, flags);
#endif #endif
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
if (verbosity > 1) { if (verbosity > 1) {
fimg_describe(psrc, "source"); fimg_describe(psrc, "source");
fimg_describe(pdst, "destination"); fimg_describe(pdst, "destination");
@ -66,10 +76,15 @@ if (verbosity > 1) {
area.x = xpos; area.y = ypos; area.x = xpos; area.y = ypos;
area.w = psrc->width; area.h = psrc->height; area.w = psrc->width; area.h = psrc->height;
foo = check_boundaries(psrc, pdst, &area); foo = check_boundaries(psrc, pdst, &area);
if (foo) {
fprintf(stderr, "Boudary error %d in %s:%d\n", foo, __func__, __LINE__);
return foo;
}
if ( (xpos < 0) || (xpos > pdst->width - psrc->width) || if ( (xpos < 0) || (xpos > pdst->width - psrc->width) ||
(ypos < 0) || (ypos > pdst->height - psrc->height) ) { (ypos < 0) || (ypos > pdst->height - psrc->height) ) {
fprintf(stderr, "%s: boudary error\n", __func__); fprintf(stderr, "%s: boudary error, x=%d y=%d\n", __func__,
xpos, ypos);
return -2; return -2;
} }

45
funcs/killrgb.c Normal file
View File

@ -0,0 +1,45 @@
/*
* KILL RGB !
*
* nouveau TerreBlanque 4 octobre 2021
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "../floatimg.h"
#include "tests.h"
/* --------------------------------------------------------------------- */
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k)
{
int line, col;
int ir;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, k);
#endif
if (k) { fprintf(stderr, "in %s k was %d\n", __func__, k); }
fimg_clear(dst);
ir = 0;
for (line=0; line<src->height; line++) {
// fprintf(stderr, "%s line %d\n", __func__, line);
for (col=0; col<(src->width-3); col+=3) {
dst->R[ir ] = src->R[ir]; ir++;
dst->G[ir+1] = src->G[ir]; ir++;
dst->B[ir+2] = src->B[ir]; ir++;
}
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -4,11 +4,17 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <math.h> #include <math.h>
#include "../floatimg.h" #include "../floatimg.h"
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/*
*********************************************
* SEGFAULT SI IMAGE TROP PETITE *
*********************************************
*/
int fimg_test_pattern(FloatImg *fimg, int type, double dval) int fimg_test_pattern(FloatImg *fimg, int type, double dval)
{ {
@ -25,6 +31,12 @@ if (fimg->type != FIMG_TYPE_RGB) {
return -6; return -6;
} }
fprintf(stderr, "ENTERING %s\n", __func__);
if (type) {
fprintf(stderr, "%s : %d %f\n", __func__, type, dval);
}
/* rampe de primaires dans le quart du haut */ /* rampe de primaires dans le quart du haut */
val = (float)dval; val = (float)dval;
for (x=0; x<fimg->width; x++) { for (x=0; x<fimg->width; x++) {
@ -45,7 +57,7 @@ for (x=0; x<fimg->width; x++) {
fimg_plot_rgb(fimg, x, y, fr, fg, fb); fimg_plot_rgb(fimg, x, y, fr, fg, fb);
} }
k = fimg->height / 4; k = (fimg->height / 4) + 20;
for (x=0; x<fimg->width; x++) { for (x=0; x<fimg->width; x++) {
val = ((double)x / (double)fimg->width) * dval; val = ((double)x / (double)fimg->width) * dval;
for (y=0; y<20; y++) { for (y=0; y<20; y++) {
@ -55,6 +67,27 @@ for (x=0; x<fimg->width; x++) {
// fprintf(stderr, " %6d %f\n", x, val); // fprintf(stderr, " %6d %f\n", x, val);
} }
k = (fimg->height / 4) + 90;
for (x=0; x<fimg->width; x++) {
val = ((x%8)<4) ? dval : 0.0;
for (y=0; y<20; y++) {
fimg_plot_rgb(fimg, x, k+y, val, val, val);
fimg_plot_rgb(fimg, x, k+y+20, dval-val, dval-val, dval-val);
}
}
k = (fimg->height / 4) + 140;
for (x=0; x<fimg->width; x++) {
for (y=0; y<20; y++) {
val = drand48() * dval;
fimg_plot_rgb(fimg, x, k+y, val, val, val);
fimg_plot_rgb(fimg, x, k+y+20, dval-val, dval-val, dval-val);
}
}
fprintf(stderr, "ALIVE %s\n", __func__);
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

101
funcs/pixelize.c Normal file
View File

@ -0,0 +1,101 @@
/*
* P I X E L I Z E
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau 10 octobre 2021 dans la roulotte de Terreblanque */
#define LARGEUR 16
int fimg_pixelize_h_0(FloatImg *psrc, FloatImg *pdst, int largeur)
{
int line, col, loop, idx;
float cr, cg, cb; /* cumuls */
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, largeur);
#endif
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: err compatibility\n", __func__);
return -8;
}
switch(largeur) {
case 8: case 16: case 32:
break;
default:
fprintf(stderr, "%s: bad width %d\n", __func__, largeur);
return -77;
}
for (line=0; line<psrc->height; line++) {
for (col=0; col<psrc->width; col+=largeur) {
cr = cg = cb = 0.0;
idx = line * psrc->width + col;
for (loop=0; loop<largeur; loop++) {
cr += psrc->R[idx+loop];
cg += psrc->G[idx+loop];
cb += psrc->B[idx+loop];
}
for (loop=0; loop<largeur; loop++) {
pdst->R[idx+loop] = cr / (float)largeur;
pdst->G[idx+loop] = cg / (float)largeur;
pdst->B[idx+loop] = cb / (float)largeur;
}
}
}
return 0;
}
/* -------------------------------------------------------------- */
/*
* un essai dans la roulotte :)
* 11 oct 2021 : premier jet, essai concluant, mais necessite
* du travail sur les rand() pour etre plus 'noisy'
*
*/
int fimg_pixelize_h_rnd(FloatImg *psrc, FloatImg *pdst, int largeur)
{
static int count = 0;
static int flag = 0;
int foo;
/* may be a mollyguard on 'largeur' parameter ? */
if (0==count) {
if (flag) {
count = irand2(5, 10);
flag = ! flag;
}
else {
count = irand2(20, 40);
flag = ! flag;
}
if (verbosity) {
fprintf(stderr, "%s c=%d f=%c\n", __func__,
count, flag?'T':'F');
}
}
if (verbosity) {
fprintf(stderr, "%s: count=%d flag=%d\n", __func__, count, flag);
}
foo = fimg_pixelize_h_0(psrc, pdst, flag ? largeur : 32);
if (foo) {
fprintf(stderr, "pixelize_h_0 give err %d in %s\n", foo, __func__);
}
count--; /* nice trick bro */
return 0;
}
/* -------------------------------------------------------------- */

View File

@ -8,6 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -30,13 +31,11 @@ for (y=0; y<img->height; y++) {
for (x=0; x<img->width; x++) { for (x=0; x<img->width; x++) {
dx = ((double)x/(double)img->width) - 0.5000; dx = ((double)x/(double)img->width) - 0.5000;
rgb[0] = sin(dx*10 + time) + 1.0; rgb[0] = sin(dx*10 + time + dy) + 1.0;
rgb[1] = sin(dx*12 + time) + 1.0; rgb[1] = sin(dx*12 + time + dy) + 1.0;
rgb[2] = sin(dx*14 + time) + 1.0; rgb[2] = sin(dx*14 + time + dy) + 1.0;
fimg_put_rgb(img, x, y, rgb); fimg_put_rgb(img, x, y, rgb);
} }
} }
return 0; return 0;

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -27,6 +28,8 @@ int foo, szimg;
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
#endif #endif
if (notused) { fprintf(stderr, "%s notused != 0, WTF ?\n", __func__); }
if (FIMG_TYPE_RGB != psrc->type) { if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7; return -7;
@ -77,6 +80,8 @@ float rgb[3];
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
#endif #endif
if (notused) { fprintf(stderr, "%s notused != 0, WTF ?\n", __func__); }
if (FIMG_TYPE_RGB != psrc->type) { if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7; return -7;

View File

@ -5,6 +5,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -22,8 +24,7 @@ if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__); fprintf(stderr, "%s bad type\n", __func__);
return -6; return -6;
} }
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
value = (float)x / (float)img->width; value = (float)x / (float)img->width;
value *= dcoef; value *= dcoef;
for (y=0; y<img->height; y++) { for (y=0; y<img->height; y++) {
@ -50,11 +51,10 @@ if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__); fprintf(stderr, "%s bad type\n", __func__);
return -6; return -6;
} }
for (y=0; y<img->height; y++) for (x=0; x<img->width; x++) {
{ value = (float)x / (float)img->width;
value = (float)y / (float)img->height;
value *= dcoef; value *= dcoef;
for (x=0; x<img->width; x++) { for (y=0; y<img->height; y++) {
fimg_plot_rgb(img, x, y, value, value, value); fimg_plot_rgb(img, x, y, value, value, value);
} }
} }
@ -62,3 +62,52 @@ for (y=0; y<img->height; y++)
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* nouveau 19 septembre 2022
*
* 6 octobre 2023 : rajout du parametre 'fmax'
*/
int fimg_do_stripes(FloatImg *img, float fmax, int mode)
{
int x, y, quad;
float *ligne;
float fr, fg, fb;
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__, img, fmax, mode);
/*
* allocate and fill a lookup table
*/
if (NULL==(ligne=malloc(img->width*sizeof(float)))) {
fprintf(stderr, "%s: malloc fail\n", __func__);
exit(1);
}
for (x=0; x<img->width; x++) {
ligne[x] = (float)x / (float)img->width;
ligne[x] *= fmax;
}
/*
* build the pixels
*/
for (y=0; y<img->height; y++)
{
quad = (y*4) / img->height ;
for (x=0; x<img->width; x++) {
fr = fg = fb = ligne[x];
switch(quad) {
case 0: fg = fb = 0; break;
case 1: fr = fb = 0; break;
case 2: fr = fg = 0; break;
case 3: break;
default: abort(); break;
}
fimg_plot_rgb(img, x, y, fr, fg, fb);
}
}
free(ligne);
return 0;
}
/* --------------------------------------------------------------------- */

38
funcs/rectangle.c Normal file
View File

@ -0,0 +1,38 @@
/*
* R E C T A N G L E
* This is an eternal WIP, sorry...
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- */
int fimg_clear_rectangle(FloatImg *pi, int coo[4])
{
int line, off;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, pi, coo);
#endif
/* please add boudary checks */
for (line=0; line<coo[3]; line++) {
off = (line+coo[1])*pi->width + coo[0];
// fprintf(stderr, "line %3d off %8d\n", line, off);
/* Kaboum ! */
memset(pi->R + off, 0, coo[2]*sizeof(float));
memset(pi->G + off, 0, coo[2]*sizeof(float));
memset(pi->B + off, 0, coo[2]*sizeof(float));
}
return -1;
}
/* --------------------------------------------------------------------- */

View File

@ -6,6 +6,8 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include <stdlib.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -21,8 +23,23 @@ int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused)
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused);
#endif #endif
if (notused) {
fprintf(stderr, "%s parameter notused is %d, must be 0\n",
__func__, notused);
return -2;
}
fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__); fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__);
if (fimg_images_not_compatible(src, dst)) {
fprintf(stderr, "%s: compatibility fatalerror\n", __func__);
exit(1);
}
/*
* bon, maintenant, il faut plonger dans du code du
* siecle dernier et l'adapter a ce nouveau contexte
*/
return -1; return -1;
} }
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -24,6 +25,8 @@ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
src, dst, notused); src, dst, notused);
#endif #endif
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
if (src->type != FIMG_TYPE_RGB) { if (src->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s: src type %d not valid\n", __func__, fprintf(stderr, "%s: src type %d not valid\n", __func__,
src->type); src->type);

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -25,7 +26,7 @@ if (FIMG_TYPE_RGB != fimg->type) {
nbpix = fimg->width * fimg->height; nbpix = fimg->width * fimg->height;
for (foo=0; foo<nbpix; foo++) { for (foo=0; foo<nbpix; foo++) {
if (fimg->R[foo] > fimg->G[foo]) if ((fimg->R[foo]+fval) > fimg->G[foo])
fimg->B[foo] = fimg->R[foo]; fimg->B[foo] = fimg->R[foo];
else else
fimg->B[foo] = fimg->G[foo]; fimg->B[foo] = fimg->G[foo];
@ -35,7 +36,7 @@ return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* /*
* parameter fval is not used, why ? * parameter fval is used for what ?
*/ */
int fimg_killcolors_b(FloatImg *fimg, float fval) int fimg_killcolors_b(FloatImg *fimg, float fval)
{ {
@ -49,7 +50,7 @@ if (FIMG_TYPE_RGB != fimg->type) {
nbpix = fimg->width * fimg->height; nbpix = fimg->width * fimg->height;
for (foo=0; foo<nbpix; foo++) { for (foo=0; foo<nbpix; foo++) {
if (fimg->R[foo] > fimg->B[foo]) if ((fimg->R[foo]+fval) > fimg->B[foo])
fimg->G[foo] = fimg->R[foo]; fimg->G[foo] = fimg->R[foo];
else else
fimg->G[foo] = fimg->B[foo]; fimg->G[foo] = fimg->B[foo];

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

Some files were not shown because too many files have changed in this diff Show More