Compare commits
866 Commits
38eae482ba
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8202df9a63 | ||
|
|
67ba638690 | ||
|
|
e8a7bf28e3 | ||
|
|
b19107d71b | ||
|
|
fabe94792b | ||
|
|
d1e67f7397 | ||
|
|
28453e862a | ||
|
|
2147d4b164 | ||
|
|
b0983ab18b | ||
|
|
08fcf513cc | ||
|
|
e6b72e5faa | ||
|
|
756766ca42 | ||
|
|
9ede78fa5d | ||
|
|
506bf39393 | ||
|
|
26e82619fb | ||
|
|
91440e7ea5 | ||
|
|
5fbff721d8 | ||
|
|
d510e56d44 | ||
|
|
2a8348f0f9 | ||
|
|
f473a58f75 | ||
|
|
556e1ad825 | ||
|
|
23842595fd | ||
|
|
6069c45b5a | ||
|
|
4e7debaae6 | ||
|
|
b7c32d24f3 | ||
|
|
4f27e491b1 | ||
|
|
11e87efd67 | ||
|
|
85dbf384bd | ||
|
|
8c4b9a6aa0 | ||
|
|
bb2b3b72de | ||
|
|
7586423d23 | ||
|
|
bdfb3e279d | ||
|
|
e00c6b8fb2 | ||
|
|
cce8e0b86c | ||
|
|
f5ce5a3699 | ||
|
|
0d092f89af | ||
|
|
79f4e011a5 | ||
|
|
a433176c54 | ||
|
|
02b4493659 | ||
|
|
fe3bc9d64c | ||
|
|
346ea08aba | ||
|
|
e0c5695ab8 | ||
|
|
3604f41a57 | ||
|
|
953462eb6e | ||
|
|
4ecce5bdc0 | ||
|
|
65c0212108 | ||
|
|
681899b06d | ||
|
|
fc9b6571f3 | ||
|
|
f1d42c74a6 | ||
|
|
36c9dc3e88 | ||
|
|
fa5e4d5acd | ||
|
|
5afb90bedf | ||
|
|
387c25401c | ||
|
|
9fb09f401f | ||
|
|
83e577b89a | ||
|
|
c598c4a2c0 | ||
|
|
b33a752af7 | ||
|
|
9c5849e299 | ||
|
|
9dd2064b7a | ||
|
|
a438ab9362 | ||
|
|
381f329810 | ||
|
|
3bd387f0a9 | ||
|
|
085e19942a | ||
|
|
152beddcb7 | ||
|
|
c1b6f9ae40 | ||
|
|
2c407e5dd9 | ||
|
|
c6b75d3bba | ||
|
|
12347e9066 | ||
|
|
9e9535221f | ||
|
|
1f1398f9f2 | ||
|
|
2699476135 | ||
|
|
cfe9f8cdae | ||
|
|
5d139312e2 | ||
|
|
2c14368cd5 | ||
|
|
658ef3ab08 | ||
|
|
8b8c1b466f | ||
|
|
817982c074 | ||
|
|
6a4b2f7c32 | ||
|
|
36fcc15b0a | ||
|
|
8c0f55b7cb | ||
|
|
ee5e081031 | ||
|
|
d23a35849a | ||
|
|
82ffe1c2cc | ||
|
|
0a482a7316 | ||
|
|
2c1687f82b | ||
|
|
0f245582d5 | ||
|
|
c8faa77904 | ||
|
|
03763a4dfb | ||
|
|
54d9a9939d | ||
|
|
488893f6a3 | ||
|
|
e9ca450584 | ||
|
|
3fd604b14a | ||
|
|
0169fbade7 | ||
|
|
0e00e00df5 | ||
|
|
6e9aa75694 | ||
|
|
603194451a | ||
|
|
3ef1fdf02e | ||
|
|
ad93b7935c | ||
|
|
cd6f045789 | ||
|
|
99bbd20b47 | ||
|
|
54b061232d | ||
|
|
b0fc5107c9 | ||
|
|
9e36c8b64c | ||
|
|
0a5f58867c | ||
|
|
5c59dc7ef7 | ||
|
|
7244b4c829 | ||
|
|
17a4cc4dd2 | ||
|
|
3949d147ef | ||
|
|
72cb5aa0f6 | ||
|
|
2ff17fc54b | ||
|
|
ed227d6563 | ||
|
|
90b9d4e37a | ||
|
|
253647c008 | ||
|
|
67cb70fa3b | ||
|
|
1d356a6f12 | ||
|
|
cc647b43b4 | ||
|
|
58e782de84 | ||
|
|
cb599a253c | ||
|
|
ff916c434c | ||
|
|
11a1e95146 | ||
|
|
6e92252778 | ||
|
|
a4b7f5c21c | ||
|
|
36d30b76d7 | ||
|
|
e00423ed9b | ||
|
|
3e66e822f2 | ||
|
|
a449c53592 | ||
|
|
154844c94d | ||
|
|
bf239a9004 | ||
|
|
7d66b09635 | ||
|
|
70694cf592 | ||
|
|
a72f544b4b | ||
|
|
b3ca197b89 | ||
|
|
c1ce8f7696 | ||
|
|
4ae4947fbe | ||
|
|
af103abdcf | ||
|
|
1ef877d947 | ||
|
|
1ad4b406d7 | ||
|
|
c004f22b16 | ||
|
|
d58decefcb | ||
|
|
63bc4ed7af | ||
|
|
b79f6851f5 | ||
|
|
70dc8a7638 | ||
|
|
63674c8eee | ||
|
|
be4b6a774e | ||
|
|
d750c027fa | ||
|
|
7f3912a133 | ||
|
|
1f4b424be7 | ||
|
|
d49b77a79f | ||
|
|
86a903360c | ||
|
|
5d18cb6c3f | ||
|
|
0e77fdeb7a | ||
|
|
0cb40ae2a0 | ||
|
|
a02b725ae0 | ||
|
|
56073c0c80 | ||
|
|
eedc9197db | ||
|
|
feafd2799d | ||
|
|
e6379f6338 | ||
|
|
1b598227c3 | ||
|
|
3eed90c3e7 | ||
|
|
c7a51ec7a0 | ||
|
|
aa2ced081a | ||
|
|
b12151444b | ||
|
|
af41acba4a | ||
|
|
f63f918530 | ||
|
|
e224ab83b6 | ||
|
|
3c551b6c7c | ||
|
|
fe9a14e2b5 | ||
|
|
11082c0d08 | ||
|
|
615321eca8 | ||
|
|
4dcc524fc4 | ||
|
|
263e254980 | ||
|
|
27e42a0ddd | ||
|
|
12c3218a93 | ||
|
|
8a663a95ee | ||
|
|
ddfadf9a67 | ||
|
|
455428f444 | ||
|
|
6810783426 | ||
|
|
5064126da8 | ||
|
|
2e6bff3f67 | ||
|
|
a5fac7effd | ||
|
|
4b64330884 | ||
|
|
f52e24b30c | ||
|
|
63e6dcd07b | ||
|
|
125383adf3 | ||
|
|
be48fc6e84 | ||
|
|
039d4cb77b | ||
|
|
7ea77cc882 | ||
|
|
60b4181f3c | ||
|
|
3eb2f549ee | ||
|
|
af92ce4e2e | ||
|
|
0cdb977a82 | ||
|
|
b98c398c3c | ||
|
|
c17132e969 | ||
|
|
6ffc08188d | ||
|
|
0da81df892 | ||
|
|
4597598b02 | ||
|
|
db7b740b2c | ||
|
|
6aa802fde2 | ||
|
|
879e25463b | ||
|
|
3f7abf4ea0 | ||
|
|
af7266eb30 | ||
|
|
0dee6e0e46 | ||
|
|
fcd8b09029 | ||
|
|
f938bbc7bd | ||
|
|
c61251ad53 | ||
|
|
e7e3713972 | ||
|
|
4c38ff032a | ||
|
|
a8d1e18650 | ||
|
|
ccd324749e | ||
|
|
ab9e4b0250 | ||
|
|
6e896ee463 | ||
|
|
99187104ce | ||
|
|
be4e6b0dc9 | ||
|
|
8c514ffe99 | ||
|
|
2a1d74a83f | ||
|
|
f09162d4ce | ||
|
|
8dbe6dd5c1 | ||
|
|
86df4ef602 | ||
|
|
5845ab7962 | ||
|
|
0e79b3e8fa | ||
|
|
1b5186f4b3 | ||
|
|
6c92cca12c | ||
|
|
bc864a6acb | ||
|
|
39f48a56b0 | ||
|
|
094b61ba39 | ||
|
|
9bde22f560 | ||
|
|
f3dc73782a | ||
|
|
b93ec2e603 | ||
|
|
9124ab6434 | ||
|
|
23908cb746 | ||
|
|
f08f860daa | ||
|
|
19c8f6aad5 | ||
|
|
30cb448642 | ||
|
|
40bf700a32 | ||
|
|
f24ad0d229 | ||
|
|
19094fee24 | ||
|
|
dbff8129b7 | ||
|
|
3b2be2e5dc | ||
|
|
e88ea153bd | ||
|
|
49d2703612 | ||
|
|
5a90dce59d | ||
|
|
17955bd303 | ||
|
|
865cc60ccf | ||
|
|
f77a63b08c | ||
|
|
389beea6cd | ||
|
|
b2d2c45be1 | ||
|
|
468b5feb74 | ||
|
|
fed3076b92 | ||
|
|
72e162e4cf | ||
|
|
802ec6e9c1 | ||
|
|
a87ad8dea2 | ||
|
|
41e77a5185 | ||
|
|
77e967cf38 | ||
|
|
20e2f1e71e | ||
|
|
92b7eb478c | ||
|
|
5b934abd0a | ||
|
|
07dde749ed | ||
|
|
4a52c16e40 | ||
|
|
cc79dd5152 | ||
|
|
daeb4c72a7 | ||
|
|
5dd2c66beb | ||
|
|
0ea39f2f9a | ||
|
|
73b8048dea | ||
|
|
198bd874f1 | ||
|
|
a27a165404 | ||
|
|
c30e073abd | ||
|
|
f67cd9be3e | ||
|
|
69cb36b84c | ||
|
|
a60d2afa4d | ||
|
|
936ea6ceab | ||
|
|
c0f3b86d0c | ||
|
|
ade40f2029 | ||
|
|
447d4dab7d | ||
|
|
f6b4a960b2 | ||
|
|
f19b526597 | ||
|
|
187c9488b2 | ||
|
|
c59eedd33c | ||
|
|
65eaca26cc | ||
|
|
87ab682879 | ||
|
|
08a30d9620 | ||
|
|
b63b590e1d | ||
|
|
98affe4b40 | ||
|
|
5199fa8005 | ||
|
|
bcc534a54d | ||
|
|
821377f666 | ||
|
|
9ddbef4e91 | ||
|
|
b3de3b96f7 | ||
|
|
004f24689b | ||
|
|
5ac050fa10 | ||
|
|
ce6d6e58bb | ||
|
|
6d4df793da | ||
|
|
0f2b0ec916 | ||
|
|
0632bc288d | ||
|
|
6b5412edcd | ||
|
|
487b091db3 | ||
|
|
ce73143d96 | ||
|
|
0478bae6a3 | ||
|
|
dcc1ff35cb | ||
|
|
2bd44fa853 | ||
|
|
4872ec698c | ||
|
|
1f03709b6c | ||
|
|
2b03f3f516 | ||
|
|
34ab825670 | ||
|
|
4095750024 | ||
|
|
dcc23cabc3 | ||
|
|
9cf60526d7 | ||
|
|
7718ca0f62 | ||
|
|
27af6d5282 | ||
|
|
b8a4514773 | ||
|
|
2e2448b9c9 | ||
|
|
6dc9aab6ba | ||
|
|
393112fb9b | ||
|
|
f0a4338741 | ||
|
|
96ad003df6 | ||
|
|
eaf49ad47d | ||
|
|
327cadd03a | ||
|
|
e81be7b0ca | ||
|
|
6e6433368c | ||
|
|
d7a3074561 | ||
|
|
0a92028c56 | ||
|
|
7c314c73ce | ||
|
|
81d04ec4d6 | ||
|
|
5cf9661713 | ||
|
|
f884220433 | ||
|
|
ad58bf521d | ||
|
|
97698bb66f | ||
|
|
d44591d0d9 | ||
|
|
5c9f76c749 | ||
|
|
154bf0e188 | ||
|
|
cb2e4e1359 | ||
|
|
dbee9eea6e | ||
|
|
3b0fc047ad | ||
|
|
7cf56ea70a | ||
|
|
f3c9d85c73 | ||
|
|
6e410e5f50 | ||
|
|
5d121dee87 | ||
|
|
2cf45fdbe5 | ||
|
|
635b722635 | ||
|
|
3f551e1473 | ||
|
|
c7e2ab12ca | ||
|
|
64c1383283 | ||
|
|
0aba64181c | ||
|
|
426ba67ddb | ||
|
|
3632dc1680 | ||
|
|
706e218ff0 | ||
|
|
e410b64514 | ||
|
|
13cb77496d | ||
|
|
7cb660c8c7 | ||
|
|
30de864c4d | ||
|
|
5f4e6e8fa8 | ||
|
|
cd1f278d45 | ||
|
|
b9d963dfa2 | ||
|
|
7ada60d113 | ||
| 10c92cc212 | |||
| b91c428370 | |||
|
|
0e579da7a0 | ||
|
|
149bd0b06c | ||
|
|
4556887358 | ||
|
|
583151302a | ||
|
|
268a73ceb5 | ||
|
|
69d94f59d3 | ||
|
|
0208ee3b2d | ||
|
|
8386c852a9 | ||
|
|
ea0945ab98 | ||
|
|
be7ea3e0ff | ||
|
|
4e32daa448 | ||
| fdcc0781eb | |||
| 0a1260eb6f | |||
| 6886fb4167 | |||
| 2a2bc51e70 | |||
| 8bbe639ad5 | |||
| 2116d62c63 | |||
| dc4f2f8089 | |||
| 9f78aa947d | |||
|
|
373f655107 | ||
|
|
6275449810 | ||
|
|
671f0fe0e4 | ||
|
|
a9e03371b8 | ||
|
|
d867b905a8 | ||
|
|
c6f10d642a | ||
|
|
74133a2cab | ||
|
|
3fce2b19c5 | ||
|
|
568811eb90 | ||
|
|
bdcbf8c067 | ||
|
|
8c2a66914a | ||
|
|
a38f4a8c72 | ||
|
|
b1cca46a8a | ||
|
|
57af8c2e93 | ||
|
|
75f36c0f6a | ||
|
|
1b24c65877 | ||
|
|
fe51a26674 | ||
|
|
445ecf3600 | ||
|
|
4a412b97fe | ||
| 3778e75399 | |||
| d3dfd6de0a | |||
| ffda756fde | |||
| 785b521d4f | |||
| 7da33bbd16 | |||
| 7f4ac3b39b | |||
| 6a53282cd9 | |||
| 8a1b164ea7 | |||
| 35e7354396 | |||
| 0d536187fd | |||
| b012e10b7e | |||
| 3f44abc18d | |||
|
|
170d0e7193 | ||
| 1f7ea9c394 | |||
| da4ae7c82f | |||
| ceefa63d1d | |||
| ccfe50e838 | |||
| 169ace3d25 | |||
| 47dbf6ea1a | |||
| 33338e7597 | |||
| 321b12dd9a | |||
| de3a50cc1d | |||
| 46fad56471 | |||
| 8425496f3f | |||
| 4946f5fbb2 | |||
| 1d6f0e8b4e | |||
| 87c681ac70 | |||
| 864c8d2d05 | |||
|
|
af1a48f149 | ||
| a31e51a234 | |||
| 1693ad9051 | |||
| f39f7ec830 | |||
|
|
10e5069efa | ||
| da44439be7 | |||
| 47e8db923b | |||
| ab8ad5a913 | |||
| b8e5bbf3cc | |||
| e7ad5188ca | |||
| 71205d4ab0 | |||
| 14ded65303 | |||
| ce96b51ca4 | |||
| db05907447 | |||
| 1a185d05c5 | |||
| bef5954b93 | |||
| 2460d622b1 | |||
| 8f6d80da12 | |||
| cdeeb9d92d | |||
| 6bd95089f9 | |||
| 22ef7c084e | |||
| 152bb72522 | |||
| cc897b7a94 | |||
| 77300f77ba | |||
| e3369b8bf6 | |||
| d369babbb3 | |||
| 0def451bf4 | |||
| 2187c1e062 | |||
| 729afe8296 | |||
| 79a09dd7bc | |||
|
|
9d874bf87b | ||
| 966ae9e465 | |||
| b03e674056 | |||
|
|
ae7fdd49bc | ||
|
|
8668e15d3e | ||
|
|
16c7d1ec4a | ||
|
|
1420deaf5e | ||
|
|
da8cfd1305 | ||
|
|
de1edceaf3 | ||
|
|
6ea654019c | ||
| 36421bab8f | |||
| 62aa91e434 | |||
| b1e613276d | |||
| d5ccf30dcc | |||
| 8009acc0d1 | |||
|
|
11b1d996e8 | ||
| 77a137a168 | |||
| 3fb8dfcdb7 | |||
| 3572966edb | |||
| 160a4afe7b | |||
| 8f29cb0db0 | |||
| a450ac4291 | |||
| a587a66af8 | |||
| 22999a4e40 | |||
| 4053baf7fd | |||
| 78c8b16fa6 | |||
| 11c457aa81 | |||
|
|
e17232f29c | ||
|
|
532bf5f0fc | ||
|
|
db7728bb10 | ||
|
|
54ee71119d | ||
|
|
f61f428066 | ||
|
|
ba945daa54 | ||
|
|
7c1ad9633a | ||
|
|
fdc2544ad1 | ||
|
|
1334d96822 | ||
|
|
8cb3d6e6a0 | ||
|
|
dcacb07738 | ||
|
|
70d811a7e5 | ||
|
|
d5af79e121 | ||
|
|
e1e32b1a99 | ||
|
|
bec63e97f5 | ||
|
|
f2e170c7d2 | ||
|
|
993b4ecd7d | ||
|
|
2790b3d22f | ||
|
|
954de623ab | ||
|
|
3706ad4d98 | ||
|
|
0fecf14eff | ||
|
|
e7c726320a | ||
|
|
905c61628f | ||
|
|
f5515b77a2 | ||
|
|
c3c5e0dc3f | ||
|
|
538a8ffa82 | ||
|
|
6b424ea72a | ||
|
|
b73c25f470 | ||
|
|
0481c39c5e | ||
|
|
e5236e0e3e | ||
|
|
7e7b878b30 | ||
| 44488e03a2 | |||
| 9febaea3ae | |||
| e0d154c37e | |||
| c9de7cdc80 | |||
| 014b1cc47a | |||
| cd8346362e | |||
| a940bba100 | |||
| 5b0670006a | |||
| 3cb969866f | |||
| 89c49282f1 | |||
| 3859777c47 | |||
| e404781d98 | |||
| 905022e782 | |||
| b4e68865b8 | |||
| f11db971fb | |||
| 3b088787fa | |||
| f9a09871bf | |||
| b43a62db68 | |||
| 423ab7f0ec | |||
| 8cc7695d70 | |||
| d50f2145ba | |||
| 364ce06130 | |||
| 922292adf8 | |||
| 1cc2f9caaf | |||
| 31ba65f01d | |||
| 6ff326d7d5 | |||
| 2d072bdfc9 | |||
| 76b7e9ad55 | |||
| a6658532de | |||
| ce02cf96bc | |||
| 3e820c8298 | |||
| f04f37ce43 | |||
| 8b8cf74128 | |||
| 29480bfdfd | |||
| 0b703e0633 | |||
| 453d08aa23 | |||
| 9fda48ab30 | |||
| 947152532d | |||
| 8206a1ac0a | |||
| 414bff491b | |||
| 6b95c2dba6 | |||
| aa42aa99fb | |||
| f6a1387bd0 | |||
| cc909c85d4 | |||
| 5599a2f7da | |||
| b1f8574f9d | |||
| 18399a40d2 | |||
| ceb806d19c | |||
| bbee507851 | |||
| 6a33b1d318 | |||
| a3e2cf55fc | |||
| f034c77401 | |||
| 91b5fe08a6 | |||
| 3e0b227520 | |||
| 95475b9c60 | |||
| 621759efb6 | |||
| 96409e56dd | |||
| b1bf9715e0 | |||
| cf42543659 | |||
| beedc2e190 | |||
| ac35780f47 | |||
| 607a37c901 | |||
| 8b4603fa21 | |||
| 44165c0a03 | |||
| 3cf887e103 | |||
| 6228533479 | |||
| 711e54fe43 | |||
| 951dc4450f | |||
| 4b2d2c264f | |||
| a5cd02a261 | |||
| fe22b0561e | |||
| 3279d0dde8 | |||
| 30347903ca | |||
| ed55a37bfe | |||
| c2bc5e1ba9 | |||
| ad9b009e05 | |||
| 3223caa03b | |||
| 301a0133e7 | |||
| 3063107b38 | |||
| e3cd73e7db | |||
| 5a34cda32e | |||
| abb7c92026 | |||
| 5aa9d5b88b | |||
| 1364698e63 | |||
| 47de778e60 | |||
| 36b42ea917 | |||
| d11ecd0e3f | |||
| 0651d8de7a | |||
| 0d93070774 | |||
| dbe8ee406a | |||
| 78ab2b4278 | |||
| 6ab57a4046 | |||
| 14062a9586 | |||
| 4fec59ec64 | |||
| fd10739cc7 | |||
| efc2807227 | |||
| c6dee909e8 | |||
| 421dd724a7 | |||
| b88d2c234a | |||
| d8bb6f4ec6 | |||
| 24976855d7 | |||
| 334cffce60 | |||
| be3338eb5f | |||
| 3849485c02 | |||
| 4e90a400e7 | |||
| 288c5a57df | |||
| 7eee0bd4d9 | |||
| d4d2dcc7f5 | |||
| b39660cc78 | |||
| 085387aba2 | |||
| ed864ea45a | |||
| a81d218fc8 | |||
| 9517c8a10f | |||
| 59cbb3c1e0 | |||
| 2b62730f47 | |||
| 81c1d98ffc | |||
| 79ab384136 | |||
| ba28fb9e80 | |||
| baddd6dedd | |||
| f7ff7e385a | |||
|
|
7ff4453fb1 | ||
|
|
83af701479 | ||
|
|
22e16d2ba6 | ||
|
|
dd9ac7c948 | ||
|
|
14256b1476 | ||
|
|
a600cbbf70 | ||
|
|
17415bd344 | ||
|
|
83ec42e140 | ||
|
|
e128add5a6 | ||
|
|
e9a61bb96a | ||
|
|
394b24bc92 | ||
|
|
d2727870a1 | ||
|
|
c3cca26ce9 | ||
| 7372ffdbb6 | |||
| 9b8a30f0b7 | |||
| 7e0f2f87dd | |||
| 20da2de7fb | |||
| 248061f46b | |||
| f9467dacee | |||
| e1938dfaeb | |||
| f451a8c8fe | |||
| 3b7b4f234c | |||
| 1840a5bddd | |||
| b35f72f9c2 | |||
| 7c378f1f7e | |||
| 8975639b73 | |||
| a75e018133 | |||
|
|
faf008265c | ||
|
|
2a3ecaf309 | ||
| 6f697ba107 | |||
| 884a9ab296 | |||
| 37ee68278b | |||
| 33daa84530 | |||
| f9c6b65ca8 | |||
| db715485a2 | |||
| 6d0e6d9b0c | |||
| a78d6c2a75 | |||
| b5fa68864a | |||
| 155674e74b | |||
| a0a563dfa1 | |||
| 5a66118f8b | |||
| 865c226051 | |||
|
|
80011c4182 | ||
|
|
8873521b90 | ||
|
|
951577dcb1 | ||
|
|
b1ae9f31ed | ||
|
|
d0b7ddfd91 | ||
|
|
6a2b37d4e3 | ||
|
|
219bd36cc2 | ||
|
|
e454404f97 | ||
| 23ce4cd337 | |||
| 2b26645b49 | |||
| 68a66dffaa | |||
| db5638c9bd | |||
| 94a90f2994 | |||
| ce476681e7 | |||
| 249a99854a | |||
| e761120787 | |||
| 622d011424 | |||
|
|
c48a3e4870 | ||
|
|
312f892576 | ||
|
|
379bd1b7de | ||
|
|
5da64b6145 | ||
|
|
0a814f1bc6 | ||
| bf5058b8d7 | |||
| e804534715 | |||
| cc9619fdbe | |||
| 87f3fb95bd | |||
| bbea24d65d | |||
|
|
a811beee8a | ||
|
|
57ef940536 | ||
|
|
1b2355f046 | ||
|
|
e46f54a8fc | ||
| 6ac0caa54a | |||
| d3c52d6127 | |||
| 692735a57f | |||
| d624a45fc4 | |||
| 4c5642881a | |||
| 2d75f70215 | |||
| 360c2e113a | |||
| 0104a736ea | |||
| e51888b206 | |||
| 3218e83688 | |||
| cef00ac04e | |||
| 6d13293ef2 | |||
| 6dbfa41890 | |||
| 28ac7c27e9 | |||
|
|
0224f6fd37 | ||
|
|
360459d938 | ||
|
|
46cd82f3b5 | ||
|
|
764b93e0b7 | ||
| c71e3b53b7 | |||
| fdf5cc9462 | |||
|
|
4273318063 | ||
| feb39d05fe | |||
| 746e8d12f6 | |||
| 03cfbf8217 | |||
| 29fff3c578 | |||
| 3712ef9efe | |||
| 44d2c9b744 | |||
| d0b64910f3 | |||
| 538023b586 | |||
| 452bc6cf29 | |||
| 8ce9251dec | |||
| c84a893380 | |||
| c4bf60e026 | |||
| bf40df4d1a | |||
| f43121f1db | |||
|
|
9e4b0e795c | ||
| b80839b076 | |||
| de3b31db94 | |||
|
|
3279d120bf | ||
| 116cb56e13 | |||
| 8a68cc24c6 | |||
| 9ae7e4d85f | |||
| 59bcdf30d4 | |||
| 33ae6c3ac7 | |||
| 8ebc82ae77 | |||
| b62b5a4805 | |||
| ca4bfcff05 | |||
| c7a428c5f0 | |||
| 210af322b0 | |||
| 3e60fed5ed | |||
|
|
447464f6c8 | ||
| 12197cc171 | |||
|
|
e81055756e | ||
|
|
24a8ff2dd7 | ||
| e96c940baa | |||
| 2ee1645a4a | |||
| efac70ab2d | |||
| a1657c8b18 | |||
| bfe9fd56ff | |||
| 85c6e943f3 | |||
| cf70ca6b81 | |||
| 6fe06f695a | |||
| 9246a88d2c | |||
| e2a5a5f5f8 | |||
| 21a6d792d5 | |||
| adc08ce777 | |||
| bacf6ecd94 | |||
| d672d02173 | |||
| 6c3b33dad1 | |||
| 4945bb1c53 | |||
| 252d5c62e0 | |||
| 98043bbe0c | |||
| f11bf3aa71 | |||
| 54269cc007 | |||
| d294102ca4 | |||
| 9f5d5e2763 | |||
| b0fe0091d4 | |||
| f3d2dd6034 | |||
| d4dbecc45d | |||
| c3bc39750d | |||
| b85b66caed | |||
| afac6aeff1 | |||
| c3f5419745 | |||
| 9b18958ee8 | |||
| 8b185f02e2 | |||
| 723319ea15 | |||
| 8f2c39ec02 | |||
| 5726161571 | |||
|
|
a301a492df | ||
| 681dfd69dc | |||
| 14dd4bd273 | |||
| 090a771971 | |||
| 2c758a4a61 | |||
| 8990d1f9a9 | |||
| 342fc4a721 | |||
| ee3c2c4cbc | |||
| 9f42b813e7 | |||
| 0eff0039eb | |||
| 7afe2b1b63 | |||
|
|
a5d4e5cc98 | ||
| 119ab151bb | |||
| dc641499cb | |||
| 3a141c5a17 | |||
| ffc99e6114 | |||
| 2aabc8b26b | |||
| a7392df682 | |||
| f109077b50 | |||
| 6176744de8 | |||
| ec56f998c2 | |||
| 2f3a8870c4 | |||
| f4001a1e13 | |||
| af9b912eb0 | |||
|
|
2cdb7dac81 | ||
|
|
1957acf93f | ||
| b276f87f4a | |||
| 48e0cb73ea | |||
| 31a20f5932 | |||
|
|
a9964cc39b | ||
| 2f01b6b9bf | |||
| 205816b618 | |||
| 0b644f7803 | |||
|
|
5758f1c932 | ||
| b67d023f0c | |||
| d3c1a1f0a2 | |||
|
|
19bcdd3cb5 | ||
| 5067b907cd | |||
| 3d23cbc3f4 | |||
|
|
4daa30816c | ||
| 262a7336ab | |||
| f0c704a818 | |||
| cc6dd330ed | |||
| 7157ce47a3 | |||
| d65b93fc66 | |||
| 7abdf7b43e | |||
| 144498d68e | |||
| 74496aa439 | |||
|
|
776c3e9dbd | ||
|
|
0e9fa47d76 | ||
| 4417575163 | |||
| 5c17358a37 | |||
| 0e279275df | |||
| 1c47b50954 | |||
| e10f26df53 | |||
| fe0f90af64 | |||
| 20d122890b | |||
| a07883c0c2 | |||
| d1e9999e1c | |||
| 8f65f414dc | |||
| 5c2b306051 | |||
| 03bfeacad5 | |||
| c3852b4dee | |||
|
|
4aaed6f322 | ||
| d11947bd7c | |||
| 4ea5294009 | |||
| 556522f647 | |||
| db037c5d12 | |||
| 411aad94d7 | |||
| 5d91e0b73b | |||
| 09cbe5b855 | |||
| 66cd54f3c6 | |||
| 016497c870 | |||
| 6258bd08ed | |||
| cdd6c30f6d | |||
|
|
282fe9f143 |
41
.gitignore
vendored
41
.gitignore
vendored
@@ -1,12 +1,19 @@
|
|||||||
|
|
||||||
lib/*.o
|
lib/*.o
|
||||||
lib/t
|
lib/t
|
||||||
funcs/*.o
|
lib/*.fimg
|
||||||
|
lib/*.png
|
||||||
|
lib/*.gif
|
||||||
|
|
||||||
|
|
||||||
*.a
|
*.a
|
||||||
gmon.out
|
gmon.out
|
||||||
|
cscope.out
|
||||||
|
|
||||||
|
*.swp
|
||||||
|
|
||||||
*.pnm
|
*.pnm
|
||||||
|
*.pgm
|
||||||
*.fimg
|
*.fimg
|
||||||
essai
|
essai
|
||||||
MANIFEST
|
MANIFEST
|
||||||
@@ -20,19 +27,35 @@ doc/*.pdf
|
|||||||
doc/*.idx
|
doc/*.idx
|
||||||
doc/*.ilg
|
doc/*.ilg
|
||||||
doc/*.ind
|
doc/*.ind
|
||||||
|
doc/co*.tex
|
||||||
|
doc/foo.html
|
||||||
|
|
||||||
|
scripts/*.fimg
|
||||||
|
scripts/*.pnm
|
||||||
|
scripts/*.gif
|
||||||
|
|
||||||
v4l2/t
|
v4l2/t
|
||||||
v4l2/capture
|
v4l2/capture
|
||||||
v4l2/grabvidseq
|
v4l2/grabvidseq
|
||||||
v4l2/*.o
|
v4l2/*.o
|
||||||
v4l2/*.ppm
|
v4l2/*.ppm
|
||||||
|
v4l2/*.png
|
||||||
|
v4l2/*.fits
|
||||||
|
v4l2/*.tiff
|
||||||
v4l2/video-infos
|
v4l2/video-infos
|
||||||
|
v4l2/nc-camcontrol
|
||||||
|
|
||||||
|
|
||||||
|
Fonderie/*.o
|
||||||
|
Fonderie/*.png
|
||||||
|
Fonderie/*.pnm
|
||||||
|
Fonderie/*.gif
|
||||||
|
Fonderie/*.fimg
|
||||||
|
Fonderie/fonderie
|
||||||
|
Fonderie/interpolator
|
||||||
|
Fonderie/t
|
||||||
|
Fonderie/singlepass
|
||||||
|
Fonderie/crapdef.h
|
||||||
|
Fonderie/crapstr.h
|
||||||
|
|
||||||
|
|
||||||
tools/fimg2png
|
|
||||||
tools/fimg2pnm
|
|
||||||
tools/fimgstats
|
|
||||||
tools/mkfimg
|
|
||||||
tools/png2fimg
|
|
||||||
tools/addtga2fimg
|
|
||||||
tools/addpnm2fimg
|
|
||||||
tools/cumulfimgs
|
|
||||||
|
|||||||
77
Fonderie/Makefile
Normal file
77
Fonderie/Makefile
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#
|
||||||
|
# compilation de la fonderie, du crapulator
|
||||||
|
# et de tout le crap...
|
||||||
|
#
|
||||||
|
|
||||||
|
COPT = -g -fpic -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses
|
||||||
|
LIBS = ../libfloatimg.a -ltiff -lpnglite -lm -lz -lcfitsio
|
||||||
|
|
||||||
|
OBJS = fifo.o sfx.o crapulator.o glitches.o metriques.o \
|
||||||
|
filterstack.o single.o utilfuncs.o
|
||||||
|
|
||||||
|
DEPS = ../floatimg.h \
|
||||||
|
../libfloatimg.a \
|
||||||
|
fifo.h crapulator.h metriques.h glitches.h sfx.h \
|
||||||
|
filterstack.h crapdef.h crapstr.h single.h utilfuncs.h
|
||||||
|
|
||||||
|
all: fonderie interpolator singlepass t
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
|
t: t.c Makefile ${OBJS}
|
||||||
|
gcc ${COPT} $< ${OBJS} ${LIBS} -o $@
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
#
|
||||||
|
# the three main programms
|
||||||
|
#
|
||||||
|
|
||||||
|
fonderie: fonderie.c ${DEPS} ${OBJS} Makefile
|
||||||
|
gcc ${COPT} $< ${OBJS} ${LIBS} -lz -o $@
|
||||||
|
|
||||||
|
# another way to brotch some pics...
|
||||||
|
interpolator: interpolator.c ${DEPS} ${OBJS} Makefile
|
||||||
|
gcc ${COPT} $< ${OBJS} ${LIBS} -lz -o $@
|
||||||
|
|
||||||
|
singlepass: singlepass.c ${DEPS} ${OBJS} Makefile
|
||||||
|
gcc ${COPT} $< ${OBJS} ${LIBS} -lz -o $@
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
#
|
||||||
|
# some files are magically generated, sorry.
|
||||||
|
#
|
||||||
|
crapdef.h: crapulors.liste Makefile craplist2h.awk
|
||||||
|
< $< ./craplist2h.awk > $@
|
||||||
|
|
||||||
|
crapstr.h: crapulors.liste Makefile craplist2str.awk
|
||||||
|
< $< ./craplist2str.awk > $@
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
#
|
||||||
|
# a lot of silly functions
|
||||||
|
#
|
||||||
|
crapulator.o: crapulator.c $(DEPS) Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
fifo.o: fifo.c fifo.h $(DEPS) Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
sfx.o: sfx.c ${DEPS} Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
single.o: single.c ${DEPS} Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
filterstack.o: filterstack.c ${DEPS} Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
metriques.o: metriques.c metriques.h Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
glitches.o: glitches.c glitches.h Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
utilfuncs.o: utilfuncs.c utilfuncs.h Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
147
Fonderie/README.md
Normal file
147
Fonderie/README.md
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
# Fonderie et Interpolator
|
||||||
|
|
||||||
|
Avec toutes ces fonctions disponibles et `grabvidseq`, nous
|
||||||
|
savons faire des images **floues**. L'étape suivante, les plus
|
||||||
|
pervers d'entre vous le savent déja, est celle de la création
|
||||||
|
de **films flous** dans le domaine spatio-temporel.
|
||||||
|
|
||||||
|
À l'heure actuelle, il y a plusieurs programmes distincts. Le premier
|
||||||
|
(fonderie) fait une moyenne mobile sur N images consécutives,
|
||||||
|
le second (interpolator) fait un fondu-enchainé de N pas
|
||||||
|
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
|
||||||
|
de filtres...
|
||||||
|
|
||||||
|
## Chaine de filtres
|
||||||
|
|
||||||
|
Ce système connait un certain nombre de filtres et d'effets spéciaux
|
||||||
|
destinés à augmenter la kitchitude du produit final. Ils peuvent être chainés
|
||||||
|
les uns après les autres, à l'entrée et à la sortie du process
|
||||||
|
de floutagement.
|
||||||
|
|
||||||
|
Ces filtres ont chacun un nom, utilisable dans une chaine de 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
|
||||||
|
de filtre, séparés par le caractère `:`, une façon de faire très
|
||||||
|
classique dans notre univers, en fait.
|
||||||
|
|
||||||
|
`mirsplit:ctr2x2:killlines`
|
||||||
|
|
||||||
|
Nous allons donc voir quelques exemples un peu plus loin.
|
||||||
|
|
||||||
|
## Fonderie
|
||||||
|
|
||||||
|
Le programme principal, utilisé à partir de la ligne de commande
|
||||||
|
avec une foule d'options aux mnémoniques abscons et à la syntaxe
|
||||||
|
perverse.
|
||||||
|
|
||||||
|
Rassurez-vous, en général il est wrappable dans des scripts
|
||||||
|
écrits en Bash. Il est même possible un jour qu'ils puissent lire des
|
||||||
|
paramètres dans `$(env)`.
|
||||||
|
|
||||||
|
```
|
||||||
|
./fonderie, compiled Dec 30 2020, 14:09:18, pid 5013
|
||||||
|
*** FloatImg library, alpha v116 (Dec 27 2020, 22:39:28)
|
||||||
|
FONDERIE
|
||||||
|
options:
|
||||||
|
-E input:filter:chain
|
||||||
|
-F output:filter:chain
|
||||||
|
-g convert to gray
|
||||||
|
-I input glob pattern
|
||||||
|
-L list available filters
|
||||||
|
-O output directory
|
||||||
|
-T fifo size
|
||||||
|
-v increase verbosity
|
||||||
|
```
|
||||||
|
|
||||||
|
## exemple d'utilisation
|
||||||
|
|
||||||
|
Voici comment appeler cette machinerie depuis la ligne de commande
|
||||||
|
tel qu'il m'arrive de le pratiquer :
|
||||||
|
|
||||||
|
```
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
GRABDIR="/spool/tth/fonderie"
|
||||||
|
FONDEUR="$HOME/Devel/FloatImg/Fonderie/fonderie"
|
||||||
|
GLOB=${GRABDIR}'/?????.fimg'
|
||||||
|
|
||||||
|
${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,
|
||||||
|
puis
|
||||||
|
ensuite il vous suffira d'encoder toutes les images générées dans
|
||||||
|
`p8/` (répertoire de sortie par défaut)
|
||||||
|
avec une incantation de ffmpeg :
|
||||||
|
|
||||||
|
```
|
||||||
|
ffmpeg -nostdin \
|
||||||
|
-loglevel error \
|
||||||
|
-y -r 30 -f image2 -i p8/%05d.png \
|
||||||
|
-c:v libx264 -pix_fmt yuv420p \
|
||||||
|
foo.mp4
|
||||||
|
```
|
||||||
|
|
||||||
|
## crapulator.c
|
||||||
|
|
||||||
|
C'est dans ce module qu'est codé le moteur de filtrage, utilisé
|
||||||
|
aussi bien en entrée qu'en sortie. Il est, à l'heure actuelle,
|
||||||
|
assez rudimentaire, avec un paramétrage simpliste, et un manque
|
||||||
|
criant de documentation...
|
||||||
|
|
||||||
|
Dans la même équipe, vous pouvez aussi aller contempler `glitches.c`
|
||||||
|
pour voir le genre de traitement que l'on fait subir à nos pixels
|
||||||
|
flottants.
|
||||||
|
|
||||||
|
## Interpolator
|
||||||
|
|
||||||
|
Un logiciel dont l'inspiration vient du passé et les améliorations
|
||||||
|
d'une résidence à Terre-Blanque, ça ne peut pas être complètement
|
||||||
|
malsain.
|
||||||
|
|
||||||
|
```
|
||||||
|
*** interpolator.c : compiled by tTh, Jan 12 2021 16:18:58
|
||||||
|
*** FloatImg library, alpha v116 (Dec 27 2020, 22:39:28)
|
||||||
|
INTERPOLATOR
|
||||||
|
usage:
|
||||||
|
interpolator [options] <inglob> <outdir> <nbsteep>
|
||||||
|
options:
|
||||||
|
-S nn mysterious sort
|
||||||
|
-E foo:bla:kr input filter chain
|
||||||
|
-F name:just output filter chain
|
||||||
|
-L list available filters
|
||||||
|
-v increase verbosity
|
||||||
|
```
|
||||||
|
## Singlepass
|
||||||
|
|
||||||
|
Le monde à l'envers : pas de traitement inter-frames, mais par contre,
|
||||||
|
on peut facilement tester une chaine de filtres sur une image unique.
|
||||||
|
|
||||||
|
```
|
||||||
|
*** singlepass.c : compiled Mar 17 2021 11:21:45
|
||||||
|
*** FloatImg library, alpha 122 (Mar 16 2021, 18:44:00)
|
||||||
|
------ Single pass serial filter ------
|
||||||
|
usage:
|
||||||
|
-F define:the:filter:chain
|
||||||
|
-g input glob pattern
|
||||||
|
-L list available filters
|
||||||
|
-r N repetiiing factor
|
||||||
|
-O /output/directory
|
||||||
|
-v spit more messages
|
||||||
|
```
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
Tout cela est bien rigolo :)
|
||||||
|
|
||||||
|
|
||||||
|
**Use the source, Luke**
|
||||||
|
|
||||||
24
Fonderie/craplist2h.awk
Executable file
24
Fonderie/craplist2h.awk
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/awk -f
|
||||||
|
|
||||||
|
#
|
||||||
|
# this utility script make a file who
|
||||||
|
# is includet by 'crapulator.h'
|
||||||
|
#
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
print "// -------------------------------------"
|
||||||
|
print "// generated file, do not edit by hand !"
|
||||||
|
print "// -------------------------------------"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1 is the badly brain-designed numeric id
|
||||||
|
# $2 is the user name of the filter
|
||||||
|
|
||||||
|
{
|
||||||
|
name = sprintf("CR_%s", $2)
|
||||||
|
printf "#define %-15s (%d)\n", name, $1
|
||||||
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
print "\n// generated file, do not edit by hand !"
|
||||||
|
}
|
||||||
28
Fonderie/craplist2str.awk
Executable file
28
Fonderie/craplist2str.awk
Executable 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 !"
|
||||||
|
}
|
||||||
619
Fonderie/crapulator.c
Normal file
619
Fonderie/crapulator.c
Normal file
@@ -0,0 +1,619 @@
|
|||||||
|
/*
|
||||||
|
* crapulator.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "glitches.h"
|
||||||
|
#include "sfx.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
static int trier_les_pixels(FloatImg *pimg)
|
||||||
|
{
|
||||||
|
FloatImg copy;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
fimg_clone(pimg, ©, 1);
|
||||||
|
|
||||||
|
foo = fimg_qsort_rgb_a(pimg, ©, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err qsort rgb = %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
incrustation_vignette(pimg, ©, 0);
|
||||||
|
|
||||||
|
fimg_copy_data(©, pimg);
|
||||||
|
|
||||||
|
fimg_destroy(©);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
static int effect_3(FloatImg *image)
|
||||||
|
{
|
||||||
|
float value;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
value = fimg_get_maxvalue(image);
|
||||||
|
fimg_mul_cste(image, -1.0);
|
||||||
|
fimg_add_cste(image, value);
|
||||||
|
foo = fimg_count_negativ(image);
|
||||||
|
if (foo) {
|
||||||
|
fimg_dump_to_file(image, "err.fimg", 0);
|
||||||
|
fprintf(stderr, "%s negativ %d\n",
|
||||||
|
__func__, foo);
|
||||||
|
return -78;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
static int insitu_ctr2x2(FloatImg *pimg)
|
||||||
|
{
|
||||||
|
FloatImg img;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
fimg_clone(pimg, &img, 0);
|
||||||
|
retval = fimg_contour_2x2(pimg, &img, 0);
|
||||||
|
if (retval) {
|
||||||
|
fprintf(stderr, "%s : err contour %d\n",
|
||||||
|
__func__, retval);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
fimg_copy_data(&img, pimg);
|
||||||
|
fimg_destroy(&img);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
static int insitu_filtre3x3(FloatImg *pimg, int typef)
|
||||||
|
{
|
||||||
|
FloatImg img;
|
||||||
|
int foo, retval;
|
||||||
|
FimgFilter3x3 *pfiltre;
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
static FimgFilter3x3 hipass = {
|
||||||
|
/* there was a bug with this filter */
|
||||||
|
{
|
||||||
|
-1.0, -1.0, -1.0,
|
||||||
|
-1.0, 9.0, -1.0,
|
||||||
|
-1.0, -1.0, -1.0,
|
||||||
|
},
|
||||||
|
1.0, 0.0
|
||||||
|
};
|
||||||
|
|
||||||
|
static FimgFilter3x3 diagonal = {
|
||||||
|
/* there was a bug with this filter */
|
||||||
|
{
|
||||||
|
4.0, 1.0, 0.0,
|
||||||
|
1.0, 0.0, -1.0,
|
||||||
|
0.0, -1.0, -4.0,
|
||||||
|
},
|
||||||
|
1.0, 0.0
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (typef) {
|
||||||
|
case 0: pfiltre = &lowpass; break;
|
||||||
|
case 1: pfiltre = &hipass; break;
|
||||||
|
case 2: pfiltre = &diagonal; break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s: bad filter number %d\n",
|
||||||
|
__func__, typef);
|
||||||
|
return -6;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_clone(pimg, &img, 0);
|
||||||
|
|
||||||
|
retval = fimg_filter_3x3(pimg, &img, pfiltre);
|
||||||
|
if (retval) {
|
||||||
|
fprintf(stderr, "%s error %d on filter\n", __func__, retval);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
(void)fimg_killborders(&img); /* nice try ? */
|
||||||
|
|
||||||
|
foo = fimg_auto_shift_to_zero(&img, &img);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d zero shift\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** may be, we can check for negative values ? */
|
||||||
|
/** or is this useless because whe have shifted to zero ? */
|
||||||
|
if (verbosity > 1) {
|
||||||
|
foo = fimg_count_negativ(&img);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s -> %d / %d negative pixels\n", __func__,
|
||||||
|
foo, img.width*img.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_killborders(&img);
|
||||||
|
fimg_copy_data(&img, pimg);
|
||||||
|
fimg_destroy(&img);
|
||||||
|
|
||||||
|
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
|
||||||
|
* output processing. It can be called by the filterstack
|
||||||
|
* processor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEBUG_THIS_CRAP 0
|
||||||
|
|
||||||
|
int crapulator(FloatImg *image, int idFx, float fval)
|
||||||
|
{
|
||||||
|
int retval;
|
||||||
|
// FloatImg imgtmp;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d %f )\n", __func__,
|
||||||
|
image, idFx, fval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEBUG_THIS_CRAP
|
||||||
|
static int count = 0;
|
||||||
|
int flag_debug = 0;
|
||||||
|
if (DEBUG_THIS_CRAP==count) {
|
||||||
|
flag_debug = 1;
|
||||||
|
fprintf(stderr, "DEBUG PT 1 in %s:%d\n", __func__, __LINE__);
|
||||||
|
fimg_save_as_png(image, "crap_before.png", 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
|
switch (idFx) {
|
||||||
|
case CR_none: /* DO NOTHING */
|
||||||
|
retval = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_cos01:
|
||||||
|
fimg_cos_01(image, image,
|
||||||
|
fimg_get_maxvalue(image));
|
||||||
|
break;
|
||||||
|
case CR_cos010:
|
||||||
|
fimg_cos_010(image, image,
|
||||||
|
fimg_get_maxvalue(image));
|
||||||
|
break;
|
||||||
|
case CR_fx3:
|
||||||
|
retval = effect_3(image);
|
||||||
|
break;
|
||||||
|
case CR_rnd48a:
|
||||||
|
brotche_rand48_a(image, 0.20,
|
||||||
|
fimg_get_maxvalue(image));
|
||||||
|
break;
|
||||||
|
case CR_rnd48b:
|
||||||
|
brotche_rand48_b(image, 0.10,
|
||||||
|
fimg_get_maxvalue(image)*0.8);
|
||||||
|
break;
|
||||||
|
case CR_killcola:
|
||||||
|
retval = fimg_killcolors_a(image, 0.0);
|
||||||
|
break;
|
||||||
|
case CR_colmixa:
|
||||||
|
retval = fimg_colors_mixer_a(image, 2.0);
|
||||||
|
break;
|
||||||
|
case CR_ctr2x2:
|
||||||
|
retval = insitu_ctr2x2(image);
|
||||||
|
break;
|
||||||
|
case CR_classtrial:
|
||||||
|
retval = fimg_classif_trial(image, image, 0.37, 0);
|
||||||
|
break;
|
||||||
|
case CR_binarize:
|
||||||
|
retval = fimg_binarize(image, 0);
|
||||||
|
break;
|
||||||
|
case CR_trinarize:
|
||||||
|
retval = fimg_trinarize(image, 0);
|
||||||
|
break;
|
||||||
|
case CR_liss2x2:
|
||||||
|
retval = fimg_lissage_2x2(image);
|
||||||
|
// (void)fimg_killborders(image);
|
||||||
|
break;
|
||||||
|
case CR_liss3x3:
|
||||||
|
/* smooth filter */
|
||||||
|
retval = insitu_filtre3x3(image, 0);
|
||||||
|
break;
|
||||||
|
case CR_desaturate:
|
||||||
|
retval = fimg_desaturate(image, image, 0);
|
||||||
|
break;
|
||||||
|
case CR_killlines:
|
||||||
|
retval = kill_a_few_lines(image, fval,
|
||||||
|
image->height/19);
|
||||||
|
break;
|
||||||
|
case CR_water:
|
||||||
|
retval = bouger_les_pixels(image, 12);
|
||||||
|
break;
|
||||||
|
case CR_mirsplit:
|
||||||
|
retval = mirror_split(image, 0);
|
||||||
|
break;
|
||||||
|
case CR_updown:
|
||||||
|
retval = upside_down(image);
|
||||||
|
break;
|
||||||
|
case CR_hipass:
|
||||||
|
/* hipass filter */
|
||||||
|
retval = insitu_filtre3x3(image, 1);
|
||||||
|
break;
|
||||||
|
case CR_diagonal:
|
||||||
|
retval = insitu_filtre3x3(image, 2);
|
||||||
|
break;
|
||||||
|
case CR_octotree:
|
||||||
|
retval = octotree_classif(image, 0.500, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_trinitron:
|
||||||
|
retval = trinitron(image, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_sqrt:
|
||||||
|
retval = fimg_square_root(image, image, 1000.0);
|
||||||
|
break;
|
||||||
|
case CR_pow2:
|
||||||
|
retval = fimg_power_2(image, image, 1000.0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_triplemul:
|
||||||
|
retval = fimg_sfx_triplemul(image, image, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* here are the glitches */
|
||||||
|
case CR_bsombra: /* experiment ! */
|
||||||
|
retval = des_bords_sombres_a(image, 160);
|
||||||
|
break;
|
||||||
|
case CR_bsombrb: /* experiment ! */
|
||||||
|
retval = des_bords_sombres_b(image, 120);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_vsglitch:
|
||||||
|
/* please make this function more tweakable */
|
||||||
|
retval = vertical_singlitch(image, 290+rand()%45,
|
||||||
|
fval, 0.19, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_crumphard: /* new june 1st 2021, in the bibcave */
|
||||||
|
retval = fimg_crump_hard(image, image, fval, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_rndblks:
|
||||||
|
retval = random_blocks(image, 70);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_shiftln0:
|
||||||
|
retval = multilines_shift_0(image, 11, 120);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_qsortrgb:
|
||||||
|
retval = trier_les_pixels(image);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_multidots:
|
||||||
|
retval = plot_multidots(image, 42);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_nothing:
|
||||||
|
retval = do_something(image, 3);
|
||||||
|
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:
|
||||||
|
retval = fimg_highlight_color(image, image, 'R', 1.717);
|
||||||
|
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 :
|
||||||
|
fprintf(stderr, "%s : effect #%d invalid\n",
|
||||||
|
__func__, idFx);
|
||||||
|
return -77;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_THIS_CRAP
|
||||||
|
if (flag_debug) {
|
||||||
|
fprintf(stderr, "DEBUG PT 2 in %s:%d\n", __func__, __LINE__);
|
||||||
|
fimg_save_as_png(image, "crap_after.png", 0);
|
||||||
|
flag_debug = 0;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
typedef struct {
|
||||||
|
int id;
|
||||||
|
char *name;
|
||||||
|
int ipar;
|
||||||
|
float fpar;
|
||||||
|
int flags;
|
||||||
|
} Crapulor;
|
||||||
|
|
||||||
|
/* Warning: overengeniring inside */
|
||||||
|
#include "crapstr.h" /* generated file ! */
|
||||||
|
#define NBCRAP (sizeof(CrapL)/sizeof(Crapulor))
|
||||||
|
|
||||||
|
void list_crapulors(char *texte)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
#define OUT stdout
|
||||||
|
|
||||||
|
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++) {
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n",
|
||||||
|
CrapL[idx].name,
|
||||||
|
CrapL[idx].id,
|
||||||
|
CrapL[idx].ipar,
|
||||||
|
CrapL[idx].fpar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(OUT, "%s\n", CrapL[idx].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#undef OUT
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
char * crap_name_from_number(int num)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %d )\n", __func__, num);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (idx=0; CrapL[idx].id!=-1; idx++) {
|
||||||
|
if (num == CrapL[idx].id) {
|
||||||
|
return CrapL[idx].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int crap_number_from_name(char *name)
|
||||||
|
{
|
||||||
|
int idx, retval;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
retval = -1; /* not found */
|
||||||
|
for (idx=0; CrapL[idx].id!=-1; idx++) {
|
||||||
|
if (0 == strcmp(CrapL[idx].name, name)) {
|
||||||
|
// fprintf(stderr, "found '%s' -> %d\n", name,
|
||||||
|
// CrapL[idx].id);
|
||||||
|
retval = CrapL[idx].id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval; /* not found */
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
21
Fonderie/crapulator.h
Normal file
21
Fonderie/crapulator.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* crapulator.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the main function */
|
||||||
|
|
||||||
|
int crapulator(FloatImg *image, int id_effect, float fparam);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* naming system */
|
||||||
|
void list_crapulors(char *texte);
|
||||||
|
char *crap_name_from_number(int num);
|
||||||
|
int crap_number_from_name(char *name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this generated file contains the #define
|
||||||
|
* for symbolic name of effect ids.
|
||||||
|
*/
|
||||||
|
#include "crapdef.h"
|
||||||
|
|
||||||
52
Fonderie/crapulors.liste
Normal file
52
Fonderie/crapulors.liste
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
0 none 1 1.0
|
||||||
|
1 cos01 1 1.0
|
||||||
|
2 cos010 1 1.0
|
||||||
|
3 fx3 1 1.0
|
||||||
|
4 rnd48a 1 1.0
|
||||||
|
5 rnd48b 1 1.0
|
||||||
|
6 killcola 1 1.0
|
||||||
|
7 colmixa 1 1.0
|
||||||
|
8 ctr2x2 1 1.0
|
||||||
|
9 classtrial 1 1.0
|
||||||
|
10 binarize 1 1.0
|
||||||
|
11 trinarize 1 1.0
|
||||||
|
12 liss2x2 1 1.0
|
||||||
|
13 liss3x3 1 1.0
|
||||||
|
14 desaturate 1 1.0
|
||||||
|
15 killlines 1 1.0
|
||||||
|
16 water 1 1.0
|
||||||
|
17 mirsplit 1 1.0
|
||||||
|
18 updown 1 1.0
|
||||||
|
19 hipass 1 1.0
|
||||||
|
20 octotree 1 1.0
|
||||||
|
21 trinitron 3 0.0
|
||||||
|
22 sqrt 1 0.0
|
||||||
|
23 pow2 1 0.0
|
||||||
|
24 bsombra 1 1.0
|
||||||
|
25 bsombrb 1 1.0
|
||||||
|
26 rndblks 1 1.0
|
||||||
|
27 shiftln0 1 1.0
|
||||||
|
28 qsortrgb 2 1.0
|
||||||
|
29 triplemul 3 1.0
|
||||||
|
30 multidots 100 1.333
|
||||||
|
31 diagonal 1 1.0
|
||||||
|
32 vsglitch 1 1.0
|
||||||
|
33 crumphard 1 1.0
|
||||||
|
42 nothing 42 3.1415926
|
||||||
|
43 killrgb0 1 9
|
||||||
|
45 hilightr 1 1.717
|
||||||
|
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
|
||||||
|
|
||||||
59
Fonderie/essai.sh
Executable file
59
Fonderie/essai.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
essai_filtres ()
|
||||||
|
{
|
||||||
|
FILTRES=$(./t -L | awk 'NR>1 { print $1 }' | sort)
|
||||||
|
|
||||||
|
rm /tmp/fstack*.png
|
||||||
|
|
||||||
|
SRC=$(ls -rt1 $HOME/Essais/FondageDePlomb/capture/* | tail -1)
|
||||||
|
# SRC=mire.fimg
|
||||||
|
|
||||||
|
for F in $FILTRES
|
||||||
|
do
|
||||||
|
I="/tmp/fstack-"$F".png"
|
||||||
|
echo ; echo ======== $I
|
||||||
|
./t -v -i $SRC -F $F -o foo.png
|
||||||
|
txt=$(printf "( %-10s )" $F)
|
||||||
|
convert foo.png -pointsize 48 -kerning 0 \
|
||||||
|
-fill Gray80 -undercolor Gray20 \
|
||||||
|
-font Courier-Bold \
|
||||||
|
-annotate +10+50 "$txt" \
|
||||||
|
$I
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ; echo "making gif89a..."
|
||||||
|
convert -delay 200 /tmp/fstack*.png foo.gif
|
||||||
|
}
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
essai_singlepass ()
|
||||||
|
{
|
||||||
|
MP4="/home/tth/Essais/FondageDePlomb/foo.mp4"
|
||||||
|
INPUT="/home/tth/Essais/FondageDePlomb/capture/02[0123]??.fimg"
|
||||||
|
FILTRE="multidots:liss3x3:nothing:liss3x3:liss3x3"
|
||||||
|
OUTDIR="/tmp/x8/"
|
||||||
|
|
||||||
|
echo '********* essai single *********'
|
||||||
|
|
||||||
|
rm $OUTDIR/*.png
|
||||||
|
|
||||||
|
time ./singlepass -v -g "$INPUT" -F $FILTRE -O $OUTDIR -s
|
||||||
|
|
||||||
|
echo ; echo "encoding picz to " $MP4
|
||||||
|
|
||||||
|
ffmpeg -nostdin \
|
||||||
|
-loglevel error \
|
||||||
|
-y -r 25 -f image2 -i /tmp/x8/%05d.png \
|
||||||
|
-c:v libx264 -pix_fmt yuv420p \
|
||||||
|
$MP4
|
||||||
|
|
||||||
|
}
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
|
||||||
|
essai_filtres
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
198
Fonderie/fifo.c
Normal file
198
Fonderie/fifo.c
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
/*
|
||||||
|
* Fonctions de la Fonderie du Cumul
|
||||||
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
* Du code bien cracra / tTh / Tetalab
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* global vars from main
|
||||||
|
*/
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* private vars of this module - it was very dirty,
|
||||||
|
* but simple and efficient.
|
||||||
|
*/
|
||||||
|
static A_Fifo g_fifo;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
static inline int big_adder(FloatImg *from, FloatImg *to)
|
||||||
|
{
|
||||||
|
int size, idx;
|
||||||
|
|
||||||
|
size = from->width * from->height;
|
||||||
|
|
||||||
|
for (idx=0; idx<size; idx++) to->R[idx] += from->R[idx];
|
||||||
|
for (idx=0; idx<size; idx++) to->G[idx] += from->G[idx];
|
||||||
|
for (idx=0; idx<size; idx++) to->B[idx] += from->B[idx];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* 97% of the total run time was in that function \o_
|
||||||
|
*/
|
||||||
|
int faire_la_somme(A_Fifo *pfifo, FloatImg *destination, int step)
|
||||||
|
{
|
||||||
|
int idx, foo;
|
||||||
|
FloatImg *pdest;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||||
|
pfifo, destination, step);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (step<1){
|
||||||
|
fprintf(stderr, "***** %s invalid step %d\n", __func__, step);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL==destination) {
|
||||||
|
pdest = &(pfifo->total); }
|
||||||
|
else {
|
||||||
|
pdest = destination; }
|
||||||
|
|
||||||
|
fimg_clear(pdest);
|
||||||
|
|
||||||
|
for (idx=0; idx<pfifo->nbslots; idx += step) {
|
||||||
|
|
||||||
|
foo = big_adder(&(pfifo->slots[idx]), pdest);
|
||||||
|
if (foo)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: err %d on add_2\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
fprintf(stderr, "*** %s:%s writing debugB file ***\n",
|
||||||
|
__FILE__, __func__);
|
||||||
|
fimg_dump_to_file(&g_fifo.total, "debugB.fimg", 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* called by 'fonderie.c'
|
||||||
|
*/
|
||||||
|
int export_fifo(char *fname, int notused)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = faire_la_somme(&g_fifo, NULL, 1);
|
||||||
|
|
||||||
|
foo = filterstack_run(1, &g_fifo.total, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: ERR post process picture -> %d\n",
|
||||||
|
__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
fimg_dump_to_file(&g_fifo.total, "outputXXX.fimg", 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&g_fifo.total, fname, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "ERR EXPORT '%s' is %d\n", fname, foo);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int insert_picture(FloatImg *src)
|
||||||
|
{
|
||||||
|
FloatImg *dst;
|
||||||
|
int nbre;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, src);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dst = &g_fifo.slots[g_fifo.next];
|
||||||
|
|
||||||
|
nbre = dst->width * dst->height * sizeof(float);
|
||||||
|
memcpy(dst->R, src->R, nbre);
|
||||||
|
memcpy(dst->G, src->G, nbre);
|
||||||
|
memcpy(dst->B, src->B, nbre);
|
||||||
|
|
||||||
|
/* XXX
|
||||||
|
fprintf(stderr, "*** %s:%s writing debugA file ***\n",
|
||||||
|
__FILE__, __func__);
|
||||||
|
foo = fimg_dump_to_file(dst, "debugA.fimg", 0);
|
||||||
|
fprintf(stderr, " ok file dumped %d\n", foo);
|
||||||
|
XXX */
|
||||||
|
|
||||||
|
g_fifo.next++; g_fifo.next %= g_fifo.nbslots;
|
||||||
|
|
||||||
|
if (verbosity > 2) fprintf(stderr, "%s : next slot %d\n",
|
||||||
|
__func__, g_fifo.next);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* this function must have a lot of new parameters,
|
||||||
|
* -- filetype of exported pictures...
|
||||||
|
*/
|
||||||
|
|
||||||
|
int create_fifo(int nbslot, int w, int h, int imgtype)
|
||||||
|
{
|
||||||
|
int foo, idx;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %d %dx%d %d )\n", __func__,
|
||||||
|
nbslot, w, h, imgtype);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset(&g_fifo, 0, sizeof(A_Fifo));
|
||||||
|
|
||||||
|
g_fifo.nbslots = nbslot;
|
||||||
|
|
||||||
|
g_fifo.slots = calloc(nbslot, sizeof(FloatImg));
|
||||||
|
if (NULL==g_fifo.slots) abort();
|
||||||
|
for (idx=0; idx<nbslot; idx++) {
|
||||||
|
foo = fimg_create(&g_fifo.slots[idx], w, h, imgtype);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s idx %d err%d\n", __func__, idx, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fimg_clear(&g_fifo.slots[idx]);
|
||||||
|
}
|
||||||
|
foo = fimg_create(&g_fifo.total, w, h, imgtype);
|
||||||
|
g_fifo.next = 0;
|
||||||
|
g_fifo.magic = MAGIC_FIFO;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* omfg ! I've write a setter !
|
||||||
|
*/
|
||||||
|
int set_fifo_output_format(int filetype)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %d )\n", __func__, filetype);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_fifo.export_type = filetype;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
49
Fonderie/fifo.h
Normal file
49
Fonderie/fifo.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Machine qui fait des fils flous par la
|
||||||
|
* méthode de la moyenne mobile.
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned long magic;
|
||||||
|
int nbslots; /* how many pics used ? */
|
||||||
|
|
||||||
|
FloatImg total; /* computing workspace */
|
||||||
|
FloatImg wspace; /* computing workspace */
|
||||||
|
|
||||||
|
FloatImg *slots; /* circular buffer */
|
||||||
|
|
||||||
|
int next; /* incremented with modulo */
|
||||||
|
|
||||||
|
int export_type; /* fimg/png/pnm/... */
|
||||||
|
} A_Fifo;
|
||||||
|
|
||||||
|
#define MAGIC_FIFO 0xabcd9876
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned long magic;
|
||||||
|
|
||||||
|
int blanks; /* ???? */
|
||||||
|
float fk;
|
||||||
|
int preproc, postproc;
|
||||||
|
|
||||||
|
int step; /* for fifo export */
|
||||||
|
|
||||||
|
} ControlBloc;
|
||||||
|
|
||||||
|
#define MAGIC_CTRLB 0xabcdfefe
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int create_fifo(int nbslot, int w, int h, int t);
|
||||||
|
int set_fifo_output_format(int filetype);
|
||||||
|
|
||||||
|
int export_fifo(char *fname, int notused);
|
||||||
|
|
||||||
|
int insert_picture(FloatImg *src);
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* funcs in 'sfx.c' ---> sfx.h
|
||||||
|
*/
|
||||||
243
Fonderie/filterstack.c
Normal file
243
Fonderie/filterstack.c
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
/*
|
||||||
|
* filterstack.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
|
||||||
|
// #undef DEBUG_LEVEL
|
||||||
|
// #define DEBUG_LEVEL 1
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
static FilterStack f_stacks[NUMBER_OF_STACK];
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int filterstack_init(int numid, int notused)
|
||||||
|
{
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %d %d )\n", __func__, numid, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
|
fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&f_stacks[numid], 0, sizeof(FilterSlot));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int filterstack_add(int numid, int code, int ival, float fval)
|
||||||
|
{
|
||||||
|
int idxsl;
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %d %d %f )\n", __func__, code, ival, fval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
|
fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f_stacks[numid].count == FILTER_BY_STACK) {
|
||||||
|
fprintf(stderr, "%s: stack is full\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
idxsl = f_stacks[numid].count; /* aliasing */
|
||||||
|
|
||||||
|
f_stacks[numid].slots[idxsl].numero = code;
|
||||||
|
f_stacks[numid].slots[idxsl].ival = ival;
|
||||||
|
f_stacks[numid].slots[idxsl].fval = fval;
|
||||||
|
|
||||||
|
f_stacks[numid].count++;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int filterstack_list(int numid, const char *txt)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
|
fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "---- %2d ---- %-20s -----------\n", numid, txt);
|
||||||
|
// fprintf(stderr, "stack at %p, size %d, current %d\n",
|
||||||
|
// f_slots, nbre_filters, idx_slot);
|
||||||
|
fprintf(stderr, "idx ___ fx# _ name ________ ival _ fval ___\n");
|
||||||
|
|
||||||
|
for (idx=0; idx<f_stacks[numid].count; idx++) {
|
||||||
|
|
||||||
|
fprintf(stderr, "%3d %3d %-10s %3d %f\n", idx,
|
||||||
|
f_stacks[numid].slots[idx].numero,
|
||||||
|
crap_name_from_number(f_stacks[numid].slots[idx].numero),
|
||||||
|
f_stacks[numid].slots[idx].ival,
|
||||||
|
f_stacks[numid].slots[idx].fval);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int filterstack_run(int numid, FloatImg *target, int notused)
|
||||||
|
{
|
||||||
|
int idx, foo, eff;
|
||||||
|
float fv;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, target, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
|
fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0==f_stacks[numid].count) {
|
||||||
|
fprintf(stderr, "%s: stack %d empty ?\n", __func__, numid);
|
||||||
|
return -11;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx=0; idx<f_stacks[numid].count; idx++) {
|
||||||
|
|
||||||
|
eff = f_stacks[numid].slots[idx].numero;
|
||||||
|
fv = f_stacks[numid].slots[idx].fval;
|
||||||
|
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf(stderr, "stack %d idx %d : effect %2d on %p\n",
|
||||||
|
numid, idx, eff, target);
|
||||||
|
|
||||||
|
foo = crapulator(target, eff, fv);
|
||||||
|
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"crapulator give me error %d on effect %d (%s)\n",
|
||||||
|
foo, eff,
|
||||||
|
crap_name_from_number(eff));
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int load_stack_from_file(int numid, char *fname, int notused)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
// int a, b;
|
||||||
|
// float f;
|
||||||
|
// char line[100];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
|
fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL==(fp=fopen(fname, "r"))) {
|
||||||
|
perror(fname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* here was dragons
|
||||||
|
*/
|
||||||
|
/* hadoc parser ? */
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int parse_filter_chain(int numid, char *argument)
|
||||||
|
{
|
||||||
|
char *cptr, *tmparg;
|
||||||
|
int value, foo;
|
||||||
|
|
||||||
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
|
fprintf(stderr, "%s: slot number %d is invalid\n", __func__, numid);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "\n%s: arg = '%s'\n", __func__, argument);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = filterstack_init(numid, 8);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: filterstack init --> %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* BUG ?
|
||||||
|
If the 'argument' string is coming from a default value (as defined
|
||||||
|
here in main), strtok make a nice segfault. so I make a copy of that
|
||||||
|
string...
|
||||||
|
*/
|
||||||
|
tmparg = alloca(strlen(argument) + 1);
|
||||||
|
if (NULL==tmparg) {
|
||||||
|
fprintf(stderr, "memory panic in %s:%s\n", __FILE__, __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
strcpy(tmparg, argument);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
cptr = strtok(tmparg, ":");
|
||||||
|
// fprintf(stderr, "cptr %p\n", cptr);
|
||||||
|
if (NULL==cptr) break;
|
||||||
|
tmparg = NULL; /* for the next pass of strtok */
|
||||||
|
// fprintf(stderr, " parsing '%s'\n", cptr);
|
||||||
|
|
||||||
|
if (isalpha(*cptr)) {
|
||||||
|
value = crap_number_from_name(cptr);
|
||||||
|
// fprintf(stderr, "%s: '%s' -> %d\n", __func__,
|
||||||
|
// cptr, value);
|
||||||
|
if (value < 0) {
|
||||||
|
fprintf(stderr, "%s: '%s' not found\n",
|
||||||
|
__func__, cptr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
foo = filterstack_add(numid, value, 1, 1.0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('@' == cptr[0]) {
|
||||||
|
fprintf(stderr, "%s: got indirect '%s'\n", __func__,
|
||||||
|
cptr+1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 == sscanf(cptr, "%d", &value)) {
|
||||||
|
foo = filterstack_add(numid, value, 1, 1.0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d add\n",
|
||||||
|
__func__, foo);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) filterstack_list(numid, __func__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
31
Fonderie/filterstack.h
Normal file
31
Fonderie/filterstack.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* filterstack.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int numero; /* id in crapulator */
|
||||||
|
char *name;
|
||||||
|
int ival;
|
||||||
|
float fval;
|
||||||
|
} FilterSlot;
|
||||||
|
|
||||||
|
#define NUMBER_OF_STACK 8
|
||||||
|
#define FILTER_BY_STACK 8
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int count;
|
||||||
|
FilterSlot slots[FILTER_BY_STACK];
|
||||||
|
} FilterStack;
|
||||||
|
|
||||||
|
int filterstack_init(int numid, int notused);
|
||||||
|
|
||||||
|
int filterstack_add(int numid, int code, int ival, float fval);
|
||||||
|
|
||||||
|
int filterstack_list(int numid, const char *txt); /* XXX */
|
||||||
|
|
||||||
|
int filterstack_run(int numid, FloatImg *target, int notused);
|
||||||
|
|
||||||
|
int load_stack_from_file(int numid, char *fname, int notused);
|
||||||
|
|
||||||
|
int parse_filter_chain(int numid, char *argument);
|
||||||
|
|
||||||
278
Fonderie/fonderie.c
Normal file
278
Fonderie/fonderie.c
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
/*
|
||||||
|
* FONDERIE
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <glob.h>
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "glitches.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* this is the real worker ? or just a wrapper ?
|
||||||
|
*/
|
||||||
|
int traite_une_image(FloatImg *image, char *outd)
|
||||||
|
{
|
||||||
|
static int numero;
|
||||||
|
int foo;
|
||||||
|
char ligne[200];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "\n>>> %s ( %p '%s' )\n", __func__, image, outd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* here, we put the picz in the fifo machinery */
|
||||||
|
foo = insert_picture(image);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d on insert\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* and now, we pull the result on the magic computation
|
||||||
|
*/
|
||||||
|
sprintf(ligne, "%s/%05d.png", outd, numero);
|
||||||
|
if (verbosity > 1) fprintf(stderr, " exporting to '%s'\n", ligne);
|
||||||
|
|
||||||
|
foo = export_fifo(ligne, 1);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d on export\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
numero++; /* VERY IMPORTANT :) */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int insert_blank(FloatImg *image, int nbre, char *outd)
|
||||||
|
{
|
||||||
|
int idx, foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d '%s' )\n", __func__,
|
||||||
|
image, nbre, outd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fimg_clear(image);
|
||||||
|
for (idx=0; idx<nbre; idx++) {
|
||||||
|
if ((foo=traite_une_image(image, outd))) {
|
||||||
|
fprintf(stderr, "%s : err %d from 'traite_une_image'\n",
|
||||||
|
__func__, foo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("\t%c\r", "ABCDEFGH"[idx%8]); fflush(stdout);
|
||||||
|
}
|
||||||
|
puts("");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int demarre_la_machine(char *pattern, char *outdir, int szfifo,
|
||||||
|
int outfmt, int blk)
|
||||||
|
{
|
||||||
|
int foo, idx, width, height;
|
||||||
|
glob_t globbuf;
|
||||||
|
char *cptr;
|
||||||
|
FloatImg input;
|
||||||
|
double fin;
|
||||||
|
float maxvalue;
|
||||||
|
int datas[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "\n>>> %s ( '%s' -> '%s' %d )\n", __func__,
|
||||||
|
pattern, outdir, szfifo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void)fimg_timer_set(0);
|
||||||
|
|
||||||
|
memset(&globbuf, 0, sizeof(glob_t));
|
||||||
|
foo = glob(pattern, 0, NULL, &globbuf);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "glob (%s) failure %d\n", pattern, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "glob '%s' -> %d, %d files found\n", pattern, foo,
|
||||||
|
(int)globbuf.gl_pathc);
|
||||||
|
|
||||||
|
/* get the size of the inputs images */
|
||||||
|
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
|
||||||
|
width = datas[0]; height = datas[1];
|
||||||
|
if (verbosity) fprintf(stderr, "first image size %dx%d\n", width, height);
|
||||||
|
|
||||||
|
fimg_create(&input, width, height, 3);
|
||||||
|
|
||||||
|
/* get the maximum value of the first pic */
|
||||||
|
foo = fimg_load_from_dump(globbuf.gl_pathv[0], &input);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d loading %s\n",
|
||||||
|
__func__, foo, globbuf.gl_pathv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
maxvalue = fimg_get_maxvalue(&input);
|
||||||
|
if (verbosity) fprintf(stderr, "first image maxvalue %f\n", maxvalue);
|
||||||
|
|
||||||
|
foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
|
||||||
|
if (verbosity) fprintf(stderr, "init fifo (%d slots) = %d\n", szfifo, foo);
|
||||||
|
|
||||||
|
/* XXX inject a few strange pics in the fifo */
|
||||||
|
insert_blank(&input, blk, outdir);
|
||||||
|
|
||||||
|
for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
||||||
|
|
||||||
|
cptr = globbuf.gl_pathv[idx];
|
||||||
|
/* first step : read the current grabed picz from disk,
|
||||||
|
and put it in our private buffer */
|
||||||
|
// fprintf(stderr, "\n######### loading '%s'\n", cptr);
|
||||||
|
foo = fimg_load_from_dump(cptr, &input);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fscking input filter here */
|
||||||
|
foo = filterstack_run(0, &input, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: input filter -> %d\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
if (idx==42) fimg_dump_to_file(&input, "inputXXX.fimg", 0);
|
||||||
|
#endif
|
||||||
|
foo = traite_une_image(&input, outdir);
|
||||||
|
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "traitement %s -> %d WTF?\n", cptr, foo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\t%5d / %5d\r", idx, (int)globbuf.gl_pathc);
|
||||||
|
}
|
||||||
|
|
||||||
|
fputs("\n", stderr);
|
||||||
|
|
||||||
|
insert_blank(&input, blk, outdir);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PLEASE, FLUSH THE FIFO !
|
||||||
|
*/
|
||||||
|
|
||||||
|
fin = fimg_timer_get(0);
|
||||||
|
if (idx) {
|
||||||
|
fprintf(stderr, "\nelapsed %.2f seconds, %.2f s/pic\n", fin, fin/idx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "\nelapsed %.2f seconds\n", fin);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 8; /* why 9 ? */
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
void help(void)
|
||||||
|
{
|
||||||
|
puts("\tFONDERIE\noptions:");
|
||||||
|
|
||||||
|
puts("\t-E\tinput:filter:chain");
|
||||||
|
puts("\t-F\toutput:filter:chain");
|
||||||
|
// puts("\t-g\tconvert to gray");
|
||||||
|
puts("\t-I\tinput glob pattern");
|
||||||
|
puts("\t-L\tlist available filters");
|
||||||
|
puts("\t-O\toutput directory (default p8/)");
|
||||||
|
puts("\t-T\tfifo size");
|
||||||
|
puts("\t-v\tincrease verbosity");
|
||||||
|
|
||||||
|
if (verbosity) { puts(""); fimg_print_version(2); puts(""); }
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo, opt;
|
||||||
|
int fifosize = 10;
|
||||||
|
char *in_pattern = "capture/?????.fimg";
|
||||||
|
char *out_dir = "p8";
|
||||||
|
int outfmt = FILE_TYPE_PNG;
|
||||||
|
int blanks = 10;
|
||||||
|
char *InFchain = "none";
|
||||||
|
char *OutFchain = "none";
|
||||||
|
|
||||||
|
fprintf(stderr, "*** %s\n\tcompiled %s, %s, pid %d\n",
|
||||||
|
argv[0], __DATE__, __TIME__, getpid());
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) {
|
||||||
|
switch(opt) {
|
||||||
|
case 'E': InFchain = optarg; break;
|
||||||
|
case 'F': OutFchain = optarg; break;
|
||||||
|
case 'B': blanks = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'g': // convert_to_gray = 1;
|
||||||
|
break;
|
||||||
|
case 'h': help();
|
||||||
|
break;
|
||||||
|
case 'I': in_pattern = optarg;
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
list_crapulors("available filters");
|
||||||
|
exit(0);
|
||||||
|
case 'O': out_dir = optarg;
|
||||||
|
break;
|
||||||
|
case 'T': fifosize = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'v': verbosity++;
|
||||||
|
break;
|
||||||
|
default: exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "\tinput glob '%s'\n", in_pattern);
|
||||||
|
fprintf(stderr, "\toutput dir '%s'\n", out_dir);
|
||||||
|
fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
|
||||||
|
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);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
foo = parse_filter_chain(1, OutFchain);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d parsing '%s'\n", foo, OutFchain);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
filterstack_list(0, "input");
|
||||||
|
filterstack_list(1, "ouput");
|
||||||
|
fprintf(stderr, ".\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = demarre_la_machine(in_pattern, out_dir, fifosize, outfmt, blanks);
|
||||||
|
|
||||||
|
fprintf(stderr, "retour du bigrun de la machine -> %d\n", foo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
316
Fonderie/glitches.c
Normal file
316
Fonderie/glitches.c
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
/*
|
||||||
|
* glitches.c
|
||||||
|
* ----------
|
||||||
|
*
|
||||||
|
* initially developped for the interpolator
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "glitches.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* 10 mai 2021 a Terre Blanque */
|
||||||
|
int microglitch(FloatImg *pimg, int notused)
|
||||||
|
{
|
||||||
|
int surface;
|
||||||
|
int offset, idx;
|
||||||
|
|
||||||
|
surface = pimg->width * pimg->height;
|
||||||
|
|
||||||
|
for (idx=0; idx<10000; idx++) {
|
||||||
|
offset = rand() % surface;
|
||||||
|
pimg->R[offset] *= 0.8;
|
||||||
|
pimg->G[offset] *= 0.8;
|
||||||
|
pimg->B[offset] *= 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau du 32 decembre 2020, endless september */
|
||||||
|
int do_something(FloatImg *pimg, int notused)
|
||||||
|
{
|
||||||
|
int ypos, idx, pos, sline;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ypos = rand() % pimg->width;
|
||||||
|
|
||||||
|
for (idx=0; idx < pimg->height; idx++) {
|
||||||
|
sline = idx * pimg->width;
|
||||||
|
pos = sline + ypos;
|
||||||
|
// fprintf(stderr, "%6d %6d\n", idx, sline);
|
||||||
|
pimg->R[pos] = pimg->G[pos];
|
||||||
|
pimg->B[pos] = pimg->G[pos];
|
||||||
|
pimg->G[pos] *= 1.717;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int kill_a_random_line(FloatImg *pvictime, float fval, int bits)
|
||||||
|
{
|
||||||
|
int line, xpos, offset;
|
||||||
|
float ftmp;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL > 1
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pvictime, bits);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "--> %s: hauteur image = %d fval = %f\n",
|
||||||
|
__func__, pvictime->height, fval);
|
||||||
|
}
|
||||||
|
|
||||||
|
line = rand() % pvictime->height;
|
||||||
|
|
||||||
|
if (verbosity > 2) {
|
||||||
|
fprintf(stderr, "%s: try to kill line %d\n", __func__, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = pvictime->width * line;
|
||||||
|
|
||||||
|
for (xpos=0; xpos<pvictime->width; xpos++) {
|
||||||
|
if (bits & 1) { ftmp = pvictime->R[offset+xpos] * fval;
|
||||||
|
pvictime->R[offset+xpos] = sqrt(ftmp); }
|
||||||
|
else pvictime->R[offset+xpos] = 0.0;
|
||||||
|
if (bits & 2) { ftmp = pvictime->G[offset+xpos] * fval;
|
||||||
|
pvictime->G[offset+xpos] = sqrt(ftmp); }
|
||||||
|
else pvictime->G[offset+xpos] = 0.0;
|
||||||
|
if (bits & 4) { ftmp = pvictime->B[offset+xpos] * fval;
|
||||||
|
pvictime->B[offset+xpos] = sqrt(ftmp); }
|
||||||
|
else pvictime->B[offset+xpos] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int kill_a_few_lines(FloatImg *who, float fval, int number)
|
||||||
|
{
|
||||||
|
int idx, foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__, who, fval, number);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Frag the pixels */
|
||||||
|
for (idx=0; idx<number; idx++) {
|
||||||
|
foo = kill_a_random_line(who, fval, rand() & 0x07);
|
||||||
|
if (foo) abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int un_petit_flou_8x8(FloatImg *picture, int xpos, int ypos)
|
||||||
|
{
|
||||||
|
float sr, sg, sb;
|
||||||
|
int x, y, off;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* please add boundary check ?
|
||||||
|
*/
|
||||||
|
sr = sg = sb = 0.0;
|
||||||
|
for (y=0; y<8; y++) {
|
||||||
|
off = xpos + (picture->width * (y+ypos));
|
||||||
|
for (x=0; x<8; x++) {
|
||||||
|
sr += picture->R[off];
|
||||||
|
sg += picture->G[off];
|
||||||
|
sb += picture->B[off];
|
||||||
|
off++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sr /= 64.0; sg /= 64.0; sb /= 64.0;
|
||||||
|
for (y=0; y<8; y++) {
|
||||||
|
off = xpos + (picture->width * (y+ypos));
|
||||||
|
for (x=0; x<8; x++) {
|
||||||
|
picture->R[off] = sr;
|
||||||
|
picture->G[off] = sg;
|
||||||
|
picture->B[off] = sb;
|
||||||
|
off++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int plot_multidots(FloatImg *picture, int notused)
|
||||||
|
{
|
||||||
|
int pass, szimg, osrc, odst;
|
||||||
|
|
||||||
|
szimg = picture->width * picture->height;
|
||||||
|
|
||||||
|
for (pass=0; pass<szimg/32; pass++) {
|
||||||
|
osrc = rand() % szimg;
|
||||||
|
odst = rand() % szimg;
|
||||||
|
picture->R[odst] = (picture->R[osrc] + picture->R[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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* FIXME XXX
|
||||||
|
*/
|
||||||
|
int random_blocks(FloatImg *picture, int percent)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
if ( (picture->width%16) || (picture->height%16) )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "WARNING %s: %dx%d bad dims\n", __func__,
|
||||||
|
picture->width, picture->height);
|
||||||
|
// return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y=16; y<picture->height-16; y+=16) {
|
||||||
|
for (x=16; x<picture->width-16; x+=16) {
|
||||||
|
if (percent < (rand()%100) ) {
|
||||||
|
un_petit_flou_8x8(picture, x, y);
|
||||||
|
un_petit_flou_8x8(picture, x+8, y);
|
||||||
|
un_petit_flou_8x8(picture, x, y+8);
|
||||||
|
un_petit_flou_8x8(picture, x+8, y+8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int un_moyen_flou_8x8(FloatImg *picture, int xpos, int ypos)
|
||||||
|
{
|
||||||
|
int i, j, x, y;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* please add boundary check ?
|
||||||
|
*/
|
||||||
|
for (i=y=0; i<8; i++, y+=8) {
|
||||||
|
for (j=x=0; j<8; j++, x+=8 ) {
|
||||||
|
un_petit_flou_8x8(picture, x+xpos, y+ypos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int poke_a_random_pixel(FloatImg *picz, float fval, int kaboo)
|
||||||
|
{
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* used by vertical_singlitch()
|
||||||
|
*/
|
||||||
|
static int x_delta(float dy, float phy)
|
||||||
|
{
|
||||||
|
float param, fv;
|
||||||
|
param = dy + phy;
|
||||||
|
fv = 12.11*sin(param+0.22) + 8.5*sin(param*3.02) + 0.42*sin(param*5.1);
|
||||||
|
return (int)fv;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* please explain arguments
|
||||||
|
*/
|
||||||
|
int vertical_singlitch(FloatImg *picz, int xpos, float fval,
|
||||||
|
float omega, float phi)
|
||||||
|
{
|
||||||
|
int y, x, w, h;
|
||||||
|
float dy;
|
||||||
|
float fv;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d %f %f )\n", __func__, picz,
|
||||||
|
xpos, omega, phi);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
h = picz->height; w = picz->width;
|
||||||
|
#define BB 2
|
||||||
|
for (y=BB; y<h-BB; y++) {
|
||||||
|
|
||||||
|
dy = (float)y * omega; /* normalize vertical position */
|
||||||
|
x = xpos + x_delta(dy, phi); /* add sinus deviation */
|
||||||
|
/* compute bounding box */
|
||||||
|
if ( (x>BB) && (x<w-BB) ) {
|
||||||
|
/* an make the glitch */
|
||||||
|
fimg_plot_rgb(picz, x, y, fval, fval, fval);
|
||||||
|
fv = fval / 3.0;
|
||||||
|
if (rand() & 8)
|
||||||
|
fimg_plot_rgb(picz, x-1, y, fv, fv, fv);
|
||||||
|
if (rand() & 8)
|
||||||
|
fimg_plot_rgb(picz, x+1, y, fv, fv, fv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
static void shifter(float *fs, float *fd, int stp, int largeur)
|
||||||
|
{
|
||||||
|
int xpos;
|
||||||
|
|
||||||
|
/* move the pixels */
|
||||||
|
for (xpos=0; xpos<largeur; xpos++) {
|
||||||
|
fd[xpos] = fs[(xpos+stp)%largeur];
|
||||||
|
}
|
||||||
|
/* take your sixpack, film at 11 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void smooth_line(float *fs, float *fd, int sz)
|
||||||
|
{
|
||||||
|
int xpos;
|
||||||
|
for (xpos=1; xpos<(sz-1); xpos++) {
|
||||||
|
fd[xpos] = (fs[xpos-1]+fs[xpos]+fs[xpos+1]) / 3.0;
|
||||||
|
}
|
||||||
|
fd[0] = fd[sz-1] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int multilines_shift_0(FloatImg *picz, int step, int nombre)
|
||||||
|
{
|
||||||
|
float *buffline, *sptr;
|
||||||
|
int idx, ypos;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, picz, step, nombre);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
buffline = alloca(picz->width * sizeof(float));
|
||||||
|
if (NULL==buffline) {
|
||||||
|
fprintf(stderr, "%s: memory panic\n", __func__);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx=0; idx<nombre; idx++) {
|
||||||
|
ypos = rand() % picz->height;
|
||||||
|
|
||||||
|
sptr = picz->R + (ypos * picz->width);
|
||||||
|
shifter(sptr, buffline, step, picz->width);
|
||||||
|
smooth_line(buffline, sptr, picz->width);
|
||||||
|
// XXX memcpy (sptr, buffline, picz->width*sizeof(float));
|
||||||
|
|
||||||
|
sptr = picz->G + (ypos * picz->width);
|
||||||
|
shifter(sptr, buffline, step, picz->width);
|
||||||
|
smooth_line(buffline, sptr, picz->width);
|
||||||
|
// XXX memcpy (sptr, buffline, picz->width*sizeof(float));
|
||||||
|
|
||||||
|
sptr = picz->B + (ypos * picz->width);
|
||||||
|
shifter(sptr, buffline, step, picz->width);
|
||||||
|
smooth_line(buffline, sptr, picz->width);
|
||||||
|
// XXX memcpy (sptr, buffline, picz->width*sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
22
Fonderie/glitches.h
Normal file
22
Fonderie/glitches.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* glitches.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
int microglitch(FloatImg *pimg, int notused);
|
||||||
|
|
||||||
|
int do_something(FloatImg *pimg, int notused);
|
||||||
|
int plot_multidots(FloatImg *picture, int notused);
|
||||||
|
|
||||||
|
int kill_a_random_line(FloatImg *pvictime, float level, int bits);
|
||||||
|
int kill_a_few_lines(FloatImg *who, float fval, int number);
|
||||||
|
int random_blocks(FloatImg *picture, int percent);
|
||||||
|
|
||||||
|
int un_petit_flou_8x8(FloatImg *picture, int x, int y);
|
||||||
|
int un_moyen_flou_8x8(FloatImg *picture, int x, int y);
|
||||||
|
int poke_a_random_pixel(FloatImg *picz, float fval, int kaboo);
|
||||||
|
|
||||||
|
int vertical_singlitch(FloatImg *picz, int xpos, float fv, float omega,
|
||||||
|
float phi);
|
||||||
|
int multilines_shift_0(FloatImg *picz, int step, int nombre);
|
||||||
|
|
||||||
|
/* this is a wtf file */
|
||||||
341
Fonderie/interpolator.c
Normal file
341
Fonderie/interpolator.c
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
/*
|
||||||
|
* INTERPOLATOR 2070
|
||||||
|
*
|
||||||
|
* +---------------------------------------+
|
||||||
|
* ! Do not use that software in real life !
|
||||||
|
* +---------------------------------------+
|
||||||
|
*
|
||||||
|
* imported in FloatImg Mon Nov 9 19:08:57 CET 2020
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "glitches.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "metriques.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* on va essayer de trier l'ordre d'apparition des images
|
||||||
|
* selon une metrique approximative
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int idx; /* in globbuf.gl_pathv[n] */
|
||||||
|
float value; /* from metric analyse */
|
||||||
|
} IdxValue;
|
||||||
|
|
||||||
|
static int negative = 0;
|
||||||
|
|
||||||
|
static int cmp_idxvalues(const void *pa, const void *pb)
|
||||||
|
{
|
||||||
|
if (negative)
|
||||||
|
return ( ((IdxValue *)pa)->value < ((IdxValue *)pb)->value);
|
||||||
|
else
|
||||||
|
return ( ((IdxValue *)pa)->value > ((IdxValue *)pb)->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int tentative_triage(glob_t *ptr_glob, IdxValue **ptr_idxval,
|
||||||
|
int method, double *p_average)
|
||||||
|
{
|
||||||
|
int idx, foo, nombre;
|
||||||
|
float metrique;
|
||||||
|
double average;
|
||||||
|
char *filename;
|
||||||
|
IdxValue *idxvalues;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d %p)\n", __func__, ptr_glob,
|
||||||
|
ptr_idxval, method, p_average);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (0==method && verbosity) {
|
||||||
|
fprintf(stderr, "\tWTF? in %s, sort method was ZERO?\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
nombre = ptr_glob->gl_pathc;
|
||||||
|
|
||||||
|
/* allocate the array for the sorting action */
|
||||||
|
idxvalues = calloc(nombre, sizeof(IdxValue));
|
||||||
|
if (NULL==idxvalues) {
|
||||||
|
fprintf(stderr, "MEMORY ERROR in %s\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// fprintf(stderr, "IdxValues array at %p\n", idxvalues);
|
||||||
|
|
||||||
|
*ptr_idxval = idxvalues;
|
||||||
|
average = 0.0;
|
||||||
|
|
||||||
|
/* compute all the needed values */
|
||||||
|
for (idx=0; idx<nombre; idx++) {
|
||||||
|
filename = ptr_glob->gl_pathv[idx];
|
||||||
|
foo = get_float_metric_from_file(filename, &metrique, method);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d get metric of '%s'\n",
|
||||||
|
__func__, foo, filename);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (verbosity)
|
||||||
|
fprintf(stderr, "%5d %s %10.3f\r",
|
||||||
|
idx, filename, metrique);
|
||||||
|
idxvalues[idx].idx = idx;
|
||||||
|
idxvalues[idx].value = metrique;
|
||||||
|
average += (double)metrique;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method) {
|
||||||
|
/* and now, we can massage all our datas */
|
||||||
|
fprintf(stderr, "sorting method = %d ...\n", method);
|
||||||
|
qsort(idxvalues, nombre, sizeof(IdxValue), cmp_idxvalues);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
for (idx=0; idx<nombre; idx++) {
|
||||||
|
printf("%5d %9.3f %5d\n", idx,
|
||||||
|
idxvalues[idx].value, idxvalues[idx].idx);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
average /= (double)nombre;
|
||||||
|
*p_average = average;
|
||||||
|
|
||||||
|
fprintf(stderr, "\naverage of ??? is %f\n", average);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* This is the mega working loop
|
||||||
|
*/
|
||||||
|
int interpolator(char *pattern, char *outdir, int Nsteps,
|
||||||
|
int infx, int outfx, int sort)
|
||||||
|
{
|
||||||
|
FloatImg A, B, Out, *pFirst, *pSecond;
|
||||||
|
glob_t globbuf;
|
||||||
|
int foo, idx, ipng, w, h, step;
|
||||||
|
int curpix;
|
||||||
|
int iarray[3];
|
||||||
|
char *cptr, line[200];
|
||||||
|
float coef;
|
||||||
|
double meanmetric;
|
||||||
|
IdxValue *idx_values; /* gni? */
|
||||||
|
|
||||||
|
fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n",
|
||||||
|
pattern, outdir, Nsteps);
|
||||||
|
|
||||||
|
if (negative) fprintf(stderr, "%s: negative ON\n", __func__);
|
||||||
|
|
||||||
|
memset(&globbuf, 0, sizeof(glob_t));
|
||||||
|
foo = glob(pattern, 0, NULL, &globbuf);
|
||||||
|
fprintf(stderr, " globbing '%s' -> %d, %d files found\n",
|
||||||
|
pattern, foo, (int)globbuf.gl_pathc);
|
||||||
|
if (0 == globbuf.gl_pathc) {
|
||||||
|
fprintf(stderr, "%s : no file found, ABEND\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
idx_values = NULL;
|
||||||
|
foo = tentative_triage(&globbuf, &idx_values, sort, &meanmetric);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "sort of %p -> %d\n\n", idx_values, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_fileinfos(globbuf.gl_pathv[0], iarray);
|
||||||
|
if (FIMG_TYPE_RGB != iarray[2]) {
|
||||||
|
fprintf(stderr, "can work only on RGB fimg picture, was %d\n",
|
||||||
|
iarray[2]);
|
||||||
|
exit(1); /* BLAM! */
|
||||||
|
}
|
||||||
|
|
||||||
|
w = iarray[0], h = iarray[1];
|
||||||
|
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(&B, w, h, 3); pSecond = &B; fimg_clear(&B);
|
||||||
|
fimg_create(&Out, w, h, 3);
|
||||||
|
|
||||||
|
ipng = 0;
|
||||||
|
for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
||||||
|
|
||||||
|
curpix = idx_values[idx].idx;
|
||||||
|
cptr = globbuf.gl_pathv[curpix]; /* aliasing filename */
|
||||||
|
|
||||||
|
/* read the next file in B */
|
||||||
|
fprintf(stderr, "%5d / %5d %s\r", idx,
|
||||||
|
(int)globbuf.gl_pathc, cptr);
|
||||||
|
foo = fimg_load_from_dump(cptr, &B);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "\n%s: load %s from dump -> %d\n", __func__,
|
||||||
|
cptr, foo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* here was the input filter */
|
||||||
|
foo = filterstack_run(0, &B, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: input fx fail %d\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (step=0; step<Nsteps; step++) {
|
||||||
|
coef = (float)step / (float)Nsteps;
|
||||||
|
fimg_interpolate(pSecond, pFirst, &Out, coef);
|
||||||
|
|
||||||
|
foo = filterstack_run(1, &Out, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "run filt stack--> %d\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(line, "%s/%05d.png", outdir, ipng);
|
||||||
|
foo = fimg_save_as_png(&Out, line, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err saving %s\n", line);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
ipng++;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
/* temporary hack : move datas */
|
||||||
|
fimg_copy_data(&B, &A);
|
||||||
|
#else
|
||||||
|
/* swap pointers to the two picz */
|
||||||
|
pTmp = pSecond;
|
||||||
|
pSecond = pFirst;
|
||||||
|
pFirst = pTmp;
|
||||||
|
/* XXX THIS CODE DON'T WORK !!! */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "\ngenerated %d png files\n", ipng);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
void help(void)
|
||||||
|
{
|
||||||
|
puts("\tINTERPOLATOR");
|
||||||
|
puts("usage:\n\tinterpolator [options] <inglob> <outdir> <nbsteep>");
|
||||||
|
|
||||||
|
/* may be we can make options incoherent, like
|
||||||
|
* the options of 'fonderie' software ?
|
||||||
|
*/
|
||||||
|
puts("options:");
|
||||||
|
puts("\t-E i:bla:k\tinput filter chain");
|
||||||
|
puts("\t-F name:j\toutput filter chain");
|
||||||
|
puts("\t-n\t\tmake negative");
|
||||||
|
puts("\t-S nn\t\tmysterious sort");
|
||||||
|
puts("\t-L\t\tlist available filters");
|
||||||
|
puts("\t-v\t\tincrease verbosity");
|
||||||
|
|
||||||
|
if (verbosity) { puts(""); fimg_print_version(2); puts(""); }
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
int nbrsteps = 9;
|
||||||
|
int opt;
|
||||||
|
// int inFx = 0;
|
||||||
|
// int outFx = 0;
|
||||||
|
int sort = 0;
|
||||||
|
char *InFchain = "0";
|
||||||
|
char *OutFchain = "0";
|
||||||
|
char *out_dir = "p8/";
|
||||||
|
|
||||||
|
fprintf(stderr, "*** %s\n\tcompiled on %s %s\n", argv[0],
|
||||||
|
__DATE__, __TIME__);
|
||||||
|
if (verbosity) fimg_print_version(2);
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
/* this is for the debug off calling shellscript */
|
||||||
|
for (foo=0; foo<argc; foo++)
|
||||||
|
fprintf(stderr, "%5d %s\n", foo, argv[foo]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "E:F:hLnS:v")) != -1) {
|
||||||
|
switch(opt) {
|
||||||
|
case 'E': InFchain = optarg; break;
|
||||||
|
case 'F': OutFchain = optarg; break;
|
||||||
|
case 'h': help(); break;
|
||||||
|
case 'L':
|
||||||
|
list_crapulors("available filters");
|
||||||
|
exit(0);
|
||||||
|
case 'S': sort = atoi(optarg); break;
|
||||||
|
case 'v': verbosity++; break;
|
||||||
|
case 'n': negative = 1; break;
|
||||||
|
default: exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "%s: argc = %d, optind = %d\n", argv[0], argc, optind);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (3 != (argc-optind)) {
|
||||||
|
fprintf(stderr, "args: [options] <inglob> <outdir> <nbsteep>\n");
|
||||||
|
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);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
foo = parse_filter_chain(1, OutFchain);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d parsing '%s'\n", foo, OutFchain);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "\tinput glob '%s'\n", argv[optind]);
|
||||||
|
fprintf(stderr, "\toutput dir '%s'\n", argv[optind+1]);
|
||||||
|
fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
|
||||||
|
fprintf(stderr, "\tout filter '%s'\n", OutFchain);
|
||||||
|
fprintf(stderr, "\tsort %d\n", sort);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fputs("=========================\n", stderr);
|
||||||
|
filterstack_list(0, __FILE__);
|
||||||
|
filterstack_list(1, __FILE__);
|
||||||
|
fputs("=========================\n", stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbrsteps = atoi(argv[optind+2]);
|
||||||
|
foo = interpolator(argv[optind], argv[optind+1], nbrsteps,
|
||||||
|
0, 0, sort);
|
||||||
|
|
||||||
|
fprintf(stderr, "interpolator give us a %d score\n", foo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
161
Fonderie/metriques.c
Normal file
161
Fonderie/metriques.c
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
* metriques.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
#include "metriques.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* usage --> sfx.c:trinitron */
|
||||||
|
int stat_zone(FloatImg *pimg, int geom[4], float v3[3])
|
||||||
|
{
|
||||||
|
int x, y, xe, ye;
|
||||||
|
int off;
|
||||||
|
double accus[3], divisor;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stdout, "geom: %5d %5d %5d %5d\n",
|
||||||
|
geom[0], geom[1], geom[2], geom[3]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
xe = geom[0] + geom[2];
|
||||||
|
ye = geom[1] + geom[3];
|
||||||
|
|
||||||
|
accus[0] = accus[1] = accus[2] = 0.0;
|
||||||
|
for (y=geom[1]; y<ye; y++) {
|
||||||
|
for (x=geom[0]; x<xe; x++) {
|
||||||
|
off = (y*pimg->width) + x;
|
||||||
|
accus[0] += (double) pimg->R[off];
|
||||||
|
accus[1] += (double) pimg->G[off];
|
||||||
|
accus[2] += (double) pimg->B[off];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
divisor = (double)(geom[2] * geom[3]); /* array of zone */
|
||||||
|
v3[0] = (float)(accus[0] / divisor);
|
||||||
|
v3[1] = (float)(accus[1] / divisor);
|
||||||
|
v3[2] = (float)(accus[2] / divisor);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* premier essai : moyenne de toutes les composantes
|
||||||
|
* de tous les pixels.
|
||||||
|
*
|
||||||
|
* Question: pourquoi pas le retour en double precision ?
|
||||||
|
*/
|
||||||
|
int get_float_metric_avg(FloatImg *pimg, float *where)
|
||||||
|
{
|
||||||
|
float means[4]; /* four values : R G B A */
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, pimg, where);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = fimg_meanvalues(pimg, means);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "fatal error in %s\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
*where = means[0] + means[1] + means[2];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* echantillonage des pixels rouges */
|
||||||
|
int get_float_metric_iRed(FloatImg *pimg, float *where)
|
||||||
|
{
|
||||||
|
int idx, size, nbre;
|
||||||
|
double adder;
|
||||||
|
|
||||||
|
adder = 0.0;
|
||||||
|
nbre = 0;
|
||||||
|
size = pimg->width * pimg->height;
|
||||||
|
for (idx=20; idx < size; idx+=42) {
|
||||||
|
adder += (double)pimg->R[idx];
|
||||||
|
nbre++;
|
||||||
|
}
|
||||||
|
*where = (float)(adder/(nbre+1));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* LR mean left/right
|
||||||
|
*/
|
||||||
|
int get_float_metric_LR(FloatImg *pimg, float *where)
|
||||||
|
{
|
||||||
|
int coords[4], foo;
|
||||||
|
float valL[3], valR[3];
|
||||||
|
|
||||||
|
coords[0] = 0; // X
|
||||||
|
coords[1] = 0; // Y
|
||||||
|
coords[2] = pimg->width / 2; // W
|
||||||
|
coords[3] = pimg->height; // H
|
||||||
|
|
||||||
|
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;
|
||||||
|
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];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* et voici le grand dispactheur
|
||||||
|
*/
|
||||||
|
int get_float_metric_from_file(char *fname, float *where, int mode)
|
||||||
|
{
|
||||||
|
FloatImg image;
|
||||||
|
int foo;
|
||||||
|
float fval;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, fname, where, mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(fname, &image);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fname);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fval = -1.0; /* sensible default value */
|
||||||
|
switch (mode) {
|
||||||
|
case 0: case 1:
|
||||||
|
foo = get_float_metric_avg(&image, &fval);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
foo = get_float_metric_iRed(&image, &fval);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
foo = get_float_metric_LR(&image, &fval);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s: method %d invalid\n",
|
||||||
|
__func__, mode);
|
||||||
|
exit(1);
|
||||||
|
break; /* not reached */
|
||||||
|
}
|
||||||
|
|
||||||
|
*where = fval;
|
||||||
|
|
||||||
|
fimg_destroy(&image);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
15
Fonderie/metriques.h
Normal file
15
Fonderie/metriques.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* metriques.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int stat_zone(FloatImg *pimg, int geom[4], float v3[3]);
|
||||||
|
|
||||||
|
|
||||||
|
/* first experiments */
|
||||||
|
|
||||||
|
int get_float_metric_a(FloatImg *pimg, float *where);
|
||||||
|
int get_float_metric_from_file(char *imgname, float *where, int mode);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
4
Fonderie/notes.md
Normal file
4
Fonderie/notes.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
'help system' pour l'explication des divers filtres.
|
||||||
|
|
||||||
|
pipeliner le graber et le fondeur par la SHM ?
|
||||||
|
|
||||||
531
Fonderie/sfx.c
Normal file
531
Fonderie/sfx.c
Normal file
@@ -0,0 +1,531 @@
|
|||||||
|
/*
|
||||||
|
* SPECIAL EFFECTS
|
||||||
|
*
|
||||||
|
* Du code bien cracra / tTh / Tetalab
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "metriques.h"
|
||||||
|
#include "sfx.h"
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* here are global vars exported by the main module
|
||||||
|
*/
|
||||||
|
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 !
|
||||||
|
*/
|
||||||
|
int incrustation_vignette(FloatImg *src, FloatImg *dst, int k)
|
||||||
|
{
|
||||||
|
int x, y, x4, y4;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, k);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
x4 = dst->width / 4, y4 = dst->height / 4;
|
||||||
|
|
||||||
|
for (y=0; y<y4; y++) {
|
||||||
|
for (x=0; x<x4; x++) {
|
||||||
|
fimg_get_rgb(src, x*4, y*4, rgb);
|
||||||
|
fimg_put_rgb(dst, x+39, y+39, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* 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)
|
||||||
|
{
|
||||||
|
int x, y, pline, off;
|
||||||
|
int ym;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
for (x=0; x<5; x++) {
|
||||||
|
off = pline + (x+pos[0]);
|
||||||
|
|
||||||
|
/* wtf i'm doing here ? */
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* need more explanation, need more work
|
||||||
|
*/
|
||||||
|
int trinitron(FloatImg *pimg, int notused)
|
||||||
|
{
|
||||||
|
int x, y, coo[4], foo;
|
||||||
|
float vals[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
for (y=0; y < pimg->height-STP; y+=STP) {
|
||||||
|
coo[1] = y;
|
||||||
|
for (x=0; x < pimg->width-STP; x+=STP) {
|
||||||
|
coo[0] = x;
|
||||||
|
foo = stat_zone(pimg, coo, vals);
|
||||||
|
if (foo) abort();
|
||||||
|
pixel_trinitron(pimg, coo, vals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#undef STP
|
||||||
|
|
||||||
|
// fprintf(stderr, " end trinitron\n"); // XXX
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau du 27 decembre 2020, un soir de grand froid... */
|
||||||
|
int octotree_classif(FloatImg *pimg, float kdist, int notused)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
float mm[6], delta[3];
|
||||||
|
float r, g, b, kr, kg, kb, dp, trig;
|
||||||
|
int idx, sz, n8, count;
|
||||||
|
typedef struct {
|
||||||
|
float x, y, z;
|
||||||
|
} ptc_t;
|
||||||
|
ptc_t ptc[8];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__,
|
||||||
|
pimg, kdist, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(pimg, mm);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "oups %d in get minmax\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
if (verbosity>1) fimg_print_minmax(mm, " input pic ");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* compute the 8 center points
|
||||||
|
*/
|
||||||
|
delta[0] = mm[1] - mm[0]; /* R */
|
||||||
|
delta[1] = mm[3] - mm[2]; /* G */
|
||||||
|
delta[2] = mm[5] - mm[4]; /* B */
|
||||||
|
// fprintf(stderr, "delta: %11.3f %11.3f %11.3f\n",
|
||||||
|
// delta[0], delta[1], delta[2]);
|
||||||
|
for (idx=0; idx<8; idx++) {
|
||||||
|
kr = 0.25 * ((idx & 0x4) ? 1 : 3);
|
||||||
|
kg = 0.25 * ((idx & 0x2) ? 1 : 3);
|
||||||
|
kb = 0.25 * ((idx & 0x1) ? 1 : 3);
|
||||||
|
// fprintf(stderr, "%6d %.2f %.2f %.2f\n", idx, kr, kg, kb);
|
||||||
|
ptc[idx].x = (delta[0] * kr) + mm[0];
|
||||||
|
ptc[idx].y = (delta[1] * kg) + mm[2];
|
||||||
|
ptc[idx].z = (delta[2] * kb) + mm[4];
|
||||||
|
// fprintf(stderr, "%6d %.3f %.3f %.3f\n", idx,
|
||||||
|
// ptc[idx].x, ptc[idx].y, ptc[idx].z);
|
||||||
|
}
|
||||||
|
|
||||||
|
sz = pimg->width * pimg->height;
|
||||||
|
trig = kdist * ((mm[1] + mm[3] + mm[5])/6.0);
|
||||||
|
// fprintf(stderr, "trig value %f\n", trig);
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
#define X(a,b) ( ((a)-(b)) * ((a)-(b)) )
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
|
||||||
|
r = pimg->R[idx]; g = pimg->G[idx]; b = pimg->B[idx];
|
||||||
|
for (n8=0; n8<8; n8++) {
|
||||||
|
dp = sqrt(X(r,ptc[n8].x)+X(g,ptc[n8].y)+X(b,ptc[n8].z));
|
||||||
|
if (dp < trig) {
|
||||||
|
pimg->R[idx] = ptc[n8].x;
|
||||||
|
pimg->G[idx] = ptc[n8].y;
|
||||||
|
pimg->B[idx] = ptc[n8].z;
|
||||||
|
count++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pimg->R[idx]=pimg->G[idx]=pimg->B[idx]=0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "%s: %d/%d pixels, ratio %f\n", __func__, count, sz,
|
||||||
|
(float)count/(float)sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau du 19 decembre 2020, pour le grand ecran de da Scritch */
|
||||||
|
|
||||||
|
int upside_down(FloatImg *pimg)
|
||||||
|
{
|
||||||
|
float *rowpix;
|
||||||
|
float *Ps, *Pd;
|
||||||
|
int Os, Od; /* offset of lines */
|
||||||
|
int wsz;
|
||||||
|
int ya, y2;
|
||||||
|
|
||||||
|
if (verbosity>1) fprintf(stderr, "%s: image width is %d\n",
|
||||||
|
__func__, pimg->width);
|
||||||
|
|
||||||
|
rowpix = calloc(pimg->width, sizeof(float));
|
||||||
|
if (NULL==rowpix) {
|
||||||
|
fprintf(stderr, "%s : memory full\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
wsz = pimg->width * sizeof(float);
|
||||||
|
if (verbosity>1) fprintf(stderr, "%s: wsx = %d\n", __func__, wsz);
|
||||||
|
|
||||||
|
for (ya=0; ya<pimg->height/2; ya++) {
|
||||||
|
|
||||||
|
y2 = pimg->height - (ya+1);
|
||||||
|
Os = (pimg->width * ya);
|
||||||
|
Od = (pimg->width * y2);
|
||||||
|
|
||||||
|
/* let's go, crash coredumping... */
|
||||||
|
Ps = pimg->R + Os;
|
||||||
|
Pd = pimg->R + Od;
|
||||||
|
memcpy(rowpix, Ps, wsz);
|
||||||
|
memcpy(Ps, Pd, wsz);
|
||||||
|
memcpy(Pd, rowpix, wsz);
|
||||||
|
|
||||||
|
Ps = pimg->G + Os;
|
||||||
|
Pd = pimg->G + Od;
|
||||||
|
memcpy(rowpix, Ps, wsz);
|
||||||
|
memcpy(Ps, Pd, wsz);
|
||||||
|
memcpy(Pd, rowpix, wsz);
|
||||||
|
|
||||||
|
Ps = pimg->B + Os;
|
||||||
|
Pd = pimg->B + Od;
|
||||||
|
memcpy(rowpix, Ps, wsz);
|
||||||
|
memcpy(Ps, Pd, wsz);
|
||||||
|
memcpy(Pd, rowpix, wsz);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(rowpix);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau du 9 decembre 2020, en ecoutant le Fermion raconter du
|
||||||
|
superbe portnawak */
|
||||||
|
int bouger_les_pixels(FloatImg *pimg, int intensite)
|
||||||
|
{
|
||||||
|
int x, y, nx, ny;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, intensite);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (intensite < 1) {
|
||||||
|
fprintf(stderr, "%s: %d bad intensity\n", __func__, intensite);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (x=0; x<pimg->width; x++) {
|
||||||
|
for (y=0; y<pimg->height; y++) {
|
||||||
|
|
||||||
|
nx = x+(rand()%intensite)-(intensite/2);
|
||||||
|
ny = y+(rand()%intensite)-(intensite/2);
|
||||||
|
|
||||||
|
if ( nx<0 || ny<0 || nx>=pimg->width
|
||||||
|
|| ny>=pimg->height )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* XXX optimize here ? */
|
||||||
|
fimg_get_rgb(pimg, nx, ny, rgb);
|
||||||
|
fimg_put_rgb(pimg, x, y, rgb);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau du 9 decembre 2020, en ecoutant les Cernettes */
|
||||||
|
int mirror_split(FloatImg *pimg, int kaboo)
|
||||||
|
{
|
||||||
|
int line, x, xs, xd;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, kaboo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (line=0; line<pimg->height; line++) {
|
||||||
|
for (x=0; x<pimg->width/2; x++) {
|
||||||
|
xs = (pimg->width * line) + x;
|
||||||
|
xd = (pimg->width * line) + (pimg->width -x);
|
||||||
|
pimg->R[xd] = pimg->R[xs];
|
||||||
|
pimg->G[xd] = pimg->G[xs];
|
||||||
|
pimg->B[xd] = pimg->B[xs];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau du 20 novembre 2020, pour encoder une vidz du vernissage
|
||||||
|
* du festival Sauvageonnes de Mixart-Myrys */
|
||||||
|
int des_bords_sombres_a(FloatImg *pimg, int offset)
|
||||||
|
{
|
||||||
|
float coef;
|
||||||
|
int xpos, xp2, lidx, y;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (offset<0 || offset>=pimg->width) {
|
||||||
|
fprintf(stderr, "%s: offset %d is bad\n", __func__, offset);
|
||||||
|
return -66;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y=0; y<pimg->height; y++) {
|
||||||
|
lidx = y * pimg->width; /* start of the
|
||||||
|
'y' line */
|
||||||
|
for (xpos=0; xpos<offset; xpos++) {
|
||||||
|
coef = (float)xpos / (float)offset;
|
||||||
|
pimg->R[xpos+lidx] *= coef;
|
||||||
|
pimg->G[xpos+lidx] *= coef;
|
||||||
|
pimg->B[xpos+lidx] *= coef;
|
||||||
|
xp2 = pimg->width-xpos;
|
||||||
|
pimg->R[xp2+lidx] *= coef;
|
||||||
|
pimg->G[xp2+lidx] *= coef;
|
||||||
|
pimg->B[xp2+lidx] *= coef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* nouveau Mon 10 May 2021 08:46:02 PM CEST
|
||||||
|
* chez Eric 1KA */
|
||||||
|
int des_bords_sombres_b(FloatImg *pimg, int nbre)
|
||||||
|
{
|
||||||
|
int idx, x, foo;
|
||||||
|
float coef, *fptr;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, nbre);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (idx=0; idx<nbre; idx++) {
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// fprintf(stderr, "WARNING: %s badly implemented\n", __func__);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* int binarize(FloatImg *pimg, int notused) was now in
|
||||||
|
* funcs/sfx2.c
|
||||||
|
* same move for trinarize.
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval)
|
||||||
|
{
|
||||||
|
int nbpix, todo, foo;
|
||||||
|
int x, y;
|
||||||
|
float fval;
|
||||||
|
|
||||||
|
nbpix = fimg->width * fimg->height;
|
||||||
|
todo = (int)((float)nbpix * ratio);
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__,
|
||||||
|
ratio, nbpix, todo);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (foo=0; foo<todo; foo++)
|
||||||
|
{
|
||||||
|
fval = (float)drand48() * mval;
|
||||||
|
x = rand() % fimg->width;
|
||||||
|
y = rand() % fimg->height;
|
||||||
|
fimg_plot_rgb(fimg, x, y, fval, fval, fval);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int brotche_rand48_b(FloatImg *fimg, float ratio, float mval)
|
||||||
|
{
|
||||||
|
int nbpix, todo, foo;
|
||||||
|
int x, y;
|
||||||
|
float fval;
|
||||||
|
|
||||||
|
nbpix = fimg->width * fimg->height;
|
||||||
|
todo = (int)((float)nbpix * ratio);
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__,
|
||||||
|
ratio, nbpix, todo);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (foo=0; foo<todo; foo++)
|
||||||
|
{
|
||||||
|
fval = (float)drand48() * mval;
|
||||||
|
x = 1 + (rand() % (fimg->width-2));
|
||||||
|
y = rand() % fimg->height;
|
||||||
|
fimg_plot_rgb(fimg, x-1, y, fval, 0.0, 0.0);
|
||||||
|
fimg_plot_rgb(fimg, x , y, 0.0, 0.0, fval);
|
||||||
|
fimg_plot_rgb(fimg, x+1, y, 0.0, fval, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
29
Fonderie/sfx.h
Normal file
29
Fonderie/sfx.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* sfx.h - special effects for fonderie & interpolator
|
||||||
|
* ---------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
int graylevel2popcolors(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 bouger_les_pixels(FloatImg *pimg, int kaboo);
|
||||||
|
int octotree_classif(FloatImg *pimg, float fk, int notused);
|
||||||
|
|
||||||
|
int mirror_split(FloatImg *pimg, int kaboo);
|
||||||
|
int upside_down(FloatImg *pimg);
|
||||||
|
|
||||||
|
int des_bords_sombres_a(FloatImg *pimg, int offset);
|
||||||
|
int des_bords_sombres_b(FloatImg *pimg, int offset);
|
||||||
|
|
||||||
|
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval);
|
||||||
|
int brotche_rand48_b(FloatImg *fimg, float ratio, float mval);
|
||||||
|
int colors_brotcher(FloatImg *fimg, float fval);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* see also "crapulator.h" for some #define's
|
||||||
|
*/
|
||||||
112
Fonderie/single.c
Normal file
112
Fonderie/single.c
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
SINGLE PICZ PROCESSOR
|
||||||
|
|
||||||
|
experimental and/or testing code, do not use in
|
||||||
|
production.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "sfx.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "single.h"
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* singleton/private variables
|
||||||
|
*/
|
||||||
|
static int nextpng, counter;
|
||||||
|
static char *destination;
|
||||||
|
static int chainfilter;
|
||||||
|
// static int outtype;
|
||||||
|
|
||||||
|
/* and the classic global var */
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int single_init(int next, char *dest, int fxchain, int outfmt)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
struct stat stbuf;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %d '%s' %d %d )\n", __func__,
|
||||||
|
next, dest, fxchain, outfmt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nextpng = next;
|
||||||
|
chainfilter = fxchain;
|
||||||
|
|
||||||
|
foo = stat(dest, &stbuf);
|
||||||
|
if (foo) {
|
||||||
|
perror("stat dest dir");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (S_IFDIR != (stbuf.st_mode & S_IFMT)) {
|
||||||
|
fprintf(stderr, "%s: %s must be a directory\n", __func__, dest);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
destination = strdup(dest); /* have a static copy */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int single_push_picture(FloatImg *pimg)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
char line[1000], buff[100];
|
||||||
|
char *extension = "png";
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, pimg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
strncpy(line, destination, 100);
|
||||||
|
if ('/' != line[strlen(line)-1]) {
|
||||||
|
// fprintf(stderr, "adding '/'\n");
|
||||||
|
strcat(line, "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buff, "%05d.%s", nextpng, extension);
|
||||||
|
strcat(line, buff);
|
||||||
|
|
||||||
|
// fprintf(stderr, "writing %p to '%s'\n", pimg, line);
|
||||||
|
foo = fimg_export_picture(pimg, line, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d on export\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
nextpng++; counter++;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int single_print_state(char *title, int k)
|
||||||
|
{
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, title, k);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fprintf(stderr, "%s : %s\n", __FILE__, title);
|
||||||
|
fprintf(stderr, " nextpng %d\n", nextpng);
|
||||||
|
fprintf(stderr, " counter %d\n", counter);
|
||||||
|
fprintf(stderr, " chainfilter %d\n", chainfilter);
|
||||||
|
fprintf(stderr, " destination %s\n", destination);
|
||||||
|
|
||||||
|
if (k) {
|
||||||
|
/* XXX */
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
21
Fonderie/single.h
Normal file
21
Fonderie/single.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
SINGLE
|
||||||
|
experimental and/or testing code, do not use in
|
||||||
|
serious production.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* next:
|
||||||
|
* dest:
|
||||||
|
* fxchain:
|
||||||
|
* outfmt: see floatimg.h for FILE_TYPE_XXX constants
|
||||||
|
*/
|
||||||
|
int single_init(int next, char *dest, int fxchain, int outfmt);
|
||||||
|
|
||||||
|
int single_push_picture(FloatImg *pimg);
|
||||||
|
|
||||||
|
int single_print_state(char *title, int k);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
235
Fonderie/singlepass.c
Normal file
235
Fonderie/singlepass.c
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* +-------------------------+
|
||||||
|
* | S I N G L E P A S S |
|
||||||
|
* +-------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
#include "single.h"
|
||||||
|
#include "glitches.h"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
#define FILTERS 0
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* parameter 'duplic' is the repetition factor
|
||||||
|
*/
|
||||||
|
int run_the_singlepass(char *globber, char *destdir, int duplic,
|
||||||
|
int fchain, int outfmt)
|
||||||
|
{
|
||||||
|
FloatImg image = { 0 };
|
||||||
|
int idx, foo, loop;
|
||||||
|
glob_t globbuf;
|
||||||
|
char *fname;
|
||||||
|
double elapsed;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d %d %d )\n", __func__,
|
||||||
|
globber, destdir, duplic, fchain, outfmt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (verbosity) filterstack_list(fchain, "Run the single pass");
|
||||||
|
|
||||||
|
(void)fimg_timer_set(0);
|
||||||
|
|
||||||
|
foo = single_init(0, destdir, fchain, outfmt);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "erreur %d single_init\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
// single_print_state("just after init", 0);
|
||||||
|
|
||||||
|
memset(&globbuf, 0, sizeof(glob_t));
|
||||||
|
foo = glob(globber, 0, NULL, &globbuf);
|
||||||
|
// fprintf(stderr, "globbing '%s' -> %d, %d files found\n",
|
||||||
|
// globber, foo, (int)globbuf.gl_pathc);
|
||||||
|
switch (foo) {
|
||||||
|
case GLOB_NOSPACE:
|
||||||
|
fprintf(stderr, "%s: glob run out of memory\n", __func__);
|
||||||
|
break;
|
||||||
|
case GLOB_ABORTED:
|
||||||
|
fprintf(stderr, "%s: glob read error\n", __func__);
|
||||||
|
break;
|
||||||
|
case GLOB_NOMATCH:
|
||||||
|
fprintf(stderr, "%s: glob found no matches\n", __func__);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == globbuf.gl_pathc) {
|
||||||
|
fprintf(stderr, "%s: no file found, aborting\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
||||||
|
|
||||||
|
fname = globbuf.gl_pathv[idx]; /* alias of filename */
|
||||||
|
|
||||||
|
if (0==image.width && 0==image.height) {
|
||||||
|
foo = fimg_create_from_dump(fname, &image);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foo = fimg_load_from_dump(fname, &image);
|
||||||
|
}
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "%s: image '%s' loaded in %p\n",
|
||||||
|
__func__, fname, &image);
|
||||||
|
}
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "get image -> %d\n", foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0==idx && verbosity) {
|
||||||
|
fprintf(stderr, "\tfirst image size %dx%d\n",
|
||||||
|
image.width, image.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname);
|
||||||
|
|
||||||
|
foo = filterstack_run(fchain, &image, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: filterstack run --> %d\n",
|
||||||
|
__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HERE WE CAN REPEAT THE INSERT OF THE PICZ */
|
||||||
|
for (loop=0; loop<duplic; loop++) {
|
||||||
|
foo = single_push_picture(&image);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "error %d on push_picture\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
globfree(&globbuf);
|
||||||
|
|
||||||
|
fimg_destroy(&image);
|
||||||
|
// single_print_state("end of run", 0);
|
||||||
|
|
||||||
|
elapsed = fimg_timer_get(0);
|
||||||
|
fprintf(stderr, "%s: %ld frames, elapsed %.3f s, %.3f fps\n",
|
||||||
|
__func__,
|
||||||
|
(long)globbuf.gl_pathc, elapsed,
|
||||||
|
(double)globbuf.gl_pathc/elapsed);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
static void help(void)
|
||||||
|
{
|
||||||
|
puts("------ Single pass serial filter ------\nusage:");
|
||||||
|
|
||||||
|
puts("\t-F\tdefine:the:filter:chain");
|
||||||
|
puts("\t-g\tinput glob pattern");
|
||||||
|
puts("\t-L\tlist available filters");
|
||||||
|
puts("\t-O\t/output/directory (default ./p8)");
|
||||||
|
puts("\t-r N\trepetiiing factor");
|
||||||
|
// puts("\t-s\tdo single test");
|
||||||
|
puts("\t-v\tspit more messages");
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo, opt;
|
||||||
|
char *filterchain = "none";
|
||||||
|
char *globbing = "./capture/?????.fimg";
|
||||||
|
char *outdir = "./p8";
|
||||||
|
// char *outtype = ".png";
|
||||||
|
int do_xper = 0;
|
||||||
|
int repeat = 1;
|
||||||
|
|
||||||
|
fprintf(stderr, "*** %s\n\tcompiled %s %s\n", argv[0],
|
||||||
|
__DATE__, __TIME__);
|
||||||
|
if (verbosity) fimg_print_version(2);
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "\t/!\\ %s is option driven\n", argv[0]);
|
||||||
|
help();
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "hF:g:LO:r:svx")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'h': help(); break;
|
||||||
|
|
||||||
|
case 'F': filterchain = optarg; break;
|
||||||
|
case 'g': globbing = optarg; break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
list_crapulors("available filters");
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
case 'O': outdir = optarg; break;
|
||||||
|
|
||||||
|
case 'r': repeat = atoi(optarg); break;
|
||||||
|
|
||||||
|
case 'v': verbosity++; break;
|
||||||
|
|
||||||
|
case 'x': do_xper = 1; break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s ABEND\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (repeat < 1) {
|
||||||
|
fprintf(stderr, "%s: loop %d invalid\n", argv[0], repeat);
|
||||||
|
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);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "\tpid %d\n", getpid());
|
||||||
|
fprintf(stderr, "\tinput glob %s\n", globbing);
|
||||||
|
fprintf(stderr, "\tfilter chain %s\n", filterchain);
|
||||||
|
fprintf(stderr, "\toutput dir %s\n", outdir);
|
||||||
|
fprintf(stderr, "\trepeat %d\n", repeat);
|
||||||
|
// fprintf(stderr, "\toutput type %s\n", outtype);
|
||||||
|
fprintf(stderr, "\tdo xper %d\n", do_xper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REAL action here
|
||||||
|
*/
|
||||||
|
foo = run_the_singlepass(globbing, outdir, repeat,
|
||||||
|
FILTERS, FILE_TYPE_PNG);
|
||||||
|
fprintf(stderr, "\tRun the single pass --> %d\n", foo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
288
Fonderie/t.c
Normal file
288
Fonderie/t.c
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
/*
|
||||||
|
* test des trucs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
#include "glitches.h"
|
||||||
|
#include "sfx.h"
|
||||||
|
#include "filterstack.h"
|
||||||
|
#include "crapulator.h"
|
||||||
|
#include "single.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
#define PNG "out.png"
|
||||||
|
#define W 800
|
||||||
|
#define H 600
|
||||||
|
#define LMAX 255.0
|
||||||
|
#define TIMER 1
|
||||||
|
|
||||||
|
#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 foo;
|
||||||
|
FloatImg image;
|
||||||
|
double debut, fin;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, fIname, fOname);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// filterstack_list(STK, __func__);
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(fIname, &image);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d create from dump\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
srand(getpid()); srand48(getpid());
|
||||||
|
|
||||||
|
debut = fimg_timer_set(TIMER);
|
||||||
|
|
||||||
|
foo = filterstack_run(STK, &image, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "filterstack run --> %d\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
fin = fimg_timer_set(TIMER);
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&image, fOname, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "erreur export %d\n", foo);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "elapsed %f\n", fin-debut);
|
||||||
|
|
||||||
|
fimg_destroy(&image);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* test-only function !
|
||||||
|
|
||||||
|
foo = essayer_single("capture/???42.fimg", "/tmp/x8/", STK);
|
||||||
|
fprintf(stderr, "essayer single -> %d\n", foo);
|
||||||
|
*/
|
||||||
|
int essayer_single(char *globpattern, char *destdir, int chain)
|
||||||
|
{
|
||||||
|
FloatImg image = { 0 };
|
||||||
|
int idx, foo;
|
||||||
|
glob_t globbuf;
|
||||||
|
char *fname;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
|
||||||
|
globpattern, destdir, chain);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
filterstack_list(chain, "essai du single");
|
||||||
|
|
||||||
|
foo = single_init(0, destdir, chain, -1);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "erreur %d single_init\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
single_print_state("just after init", 0);
|
||||||
|
|
||||||
|
memset(&globbuf, 0, sizeof(glob_t));
|
||||||
|
foo = glob(globpattern, 0, NULL, &globbuf);
|
||||||
|
fprintf(stderr, "globbing '%s' -> %d, %d files found\n",
|
||||||
|
globpattern, foo, (int)globbuf.gl_pathc);
|
||||||
|
if (0 == globbuf.gl_pathc) {
|
||||||
|
fprintf(stderr, "%s : no file found, aborting\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
||||||
|
|
||||||
|
fname = globbuf.gl_pathv[idx]; /* alias of filename */
|
||||||
|
fprintf(stderr, "%s %6d %s\r", __func__, idx, fname);
|
||||||
|
|
||||||
|
if (0==image.width && 0==image.height) {
|
||||||
|
foo = fimg_create_from_dump(fname, &image);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foo = fimg_load_from_dump(fname, &image);
|
||||||
|
}
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "get image -> %d\n", foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = filterstack_run(chain, &image, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: filterstack run --> %d\n",
|
||||||
|
__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = single_push_picture(&image);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "erreur %d push picture\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
single_print_state("end of run :)", 0);
|
||||||
|
|
||||||
|
fimg_destroy(&image);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
int help(void)
|
||||||
|
{
|
||||||
|
puts("Yolo!");
|
||||||
|
|
||||||
|
puts("\t-F\tdefine:the:filter:chain");
|
||||||
|
puts("\t-g\tinput glob pattern");
|
||||||
|
puts("\t-i\tinfile.fimg");
|
||||||
|
puts("\t-L\tlist available filters");
|
||||||
|
puts("\t-o\toutfile.xxx");
|
||||||
|
puts("\t-O\t/output/directory");
|
||||||
|
puts("\t-s\tdo single test");
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
int experiment(char *fname)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
FloatImg image, dest;
|
||||||
|
|
||||||
|
fprintf(stderr, "----- EXPERIMENT on '%s' -----\n", fname);
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(fname, &image);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d on create_from_dump\n",
|
||||||
|
__func__, foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_clone(&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);
|
||||||
|
|
||||||
|
exit(0); /* back to real world */
|
||||||
|
}
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo, opt;
|
||||||
|
int do_xper = 0;
|
||||||
|
int do_single = 0;
|
||||||
|
char *filterchain = "0";
|
||||||
|
char *infile = "mire.fimg";
|
||||||
|
char *outfile = PNG;
|
||||||
|
char *outdir = "/tmp/x8/";
|
||||||
|
char *globstr = "capture/????7.fimg";
|
||||||
|
|
||||||
|
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
|
||||||
|
__DATE__, __TIME__);
|
||||||
|
fimg_print_version(2);
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "hF:g:i:Lo:O:svx")) != -1) {
|
||||||
|
switch(opt) {
|
||||||
|
case 'h': help(); break;
|
||||||
|
case 'F': filterchain = optarg; break;
|
||||||
|
case 'g': globstr = optarg; break;
|
||||||
|
case 'i': infile = optarg; break;
|
||||||
|
case 'L':
|
||||||
|
list_crapulors("available filters");
|
||||||
|
exit(0);
|
||||||
|
case 'o': outfile = optarg; break;
|
||||||
|
case 'O': outdir = optarg; break;
|
||||||
|
case 's': do_single = 1; break;
|
||||||
|
case 'v': verbosity++; break;
|
||||||
|
case 'x': do_xper = 1; break;
|
||||||
|
default: exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s : argc=%d, optind=%d\n", argv[0], argc, optind);
|
||||||
|
#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);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (do_xper) {
|
||||||
|
experiment(infile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (do_single) {
|
||||||
|
fprintf(stderr, "Globbing '%s'\n", globstr);
|
||||||
|
essayer_single(globstr, outdir, STK);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = essai_filterstack(infile, outfile);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d in essai_filterstack\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
53
Fonderie/utilfuncs.c
Normal file
53
Fonderie/utilfuncs.c
Normal 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
11
Fonderie/utilfuncs.h
Normal 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
6
Global.makefile
Normal 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
14
LICENSE
Normal 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.
|
||||||
|
|
||||||
18
Makefile
18
Makefile
@@ -3,25 +3,27 @@
|
|||||||
# a look to the 'build.sh' script ! #
|
# a look to the 'build.sh' script ! #
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
COPT = -Wall -fpic -g -pg -DDEBUG_LEVEL=0
|
COPT = -Wall -Wextra -fpic -g -no-pie -DDEBUG_LEVEL=0
|
||||||
LDOPT = libfloatimg.a -pg -lm
|
LDOPT = libfloatimg.a -g -lm
|
||||||
|
|
||||||
all: essai
|
all: essai
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
exemple: exemple.c libfloatimg.a floatimg.h Makefile
|
|
||||||
gcc $(COPT) $< $(LDOPT) -o $@
|
|
||||||
|
|
||||||
essai: essai.c libfloatimg.a floatimg.h Makefile
|
essai: essai.c libfloatimg.a floatimg.h Makefile
|
||||||
gcc $(COPT) $< $(LDOPT) -lpnglite -o $@
|
gcc $(COPT) $< $(LDOPT) -lpnglite -lz -o $@
|
||||||
|
|
||||||
|
install:
|
||||||
|
@echo "=== Use the 'install.sh' script ==="
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
TOTAR = *.[ch] Makefile *.sh *.txt doc/*.tex \
|
TOTAR = *.[ch] Makefile *.sh *.md \
|
||||||
|
doc/the*.tex doc/mk*.sh doc/*.txt \
|
||||||
funcs/*.[ch] funcs/Makefile \
|
funcs/*.[ch] funcs/Makefile \
|
||||||
tools/*.[ch] tools/Makefile \
|
tools/*.[ch] tools/*.sh tools/README.md tools/Makefile \
|
||||||
v4l2/*.[ch] v4l2/Makefile \
|
v4l2/*.[ch] v4l2/Makefile \
|
||||||
|
scripts/*.sh scripts/README.md \
|
||||||
lib/*.[ch] lib/Makefile
|
lib/*.[ch] lib/Makefile
|
||||||
|
|
||||||
lines: $(TOTAR)
|
lines: $(TOTAR)
|
||||||
|
|||||||
93
README.md
Normal file
93
README.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Traitement des images en virgule flottante.
|
||||||
|
|
||||||
|
C'est d"abord un ensemble de fonctions pour traiter des images avec une énorme dynamique
|
||||||
|
sur les niveaux de pixels. C'est aussi quelques outils pour traiter ces images.
|
||||||
|
Et c'est enfin plusieurs embryons de logiciel destiné à faire des photos floues,
|
||||||
|
voire même des [films flous](Fonderie/).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Il y a une [description](http://la.buvette.org/photos/cumul/) bien plus
|
||||||
|
pas trop longue pour les curieux, et un début de
|
||||||
|
[documentation](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
|
||||||
|
pour les codeurs.
|
||||||
|
Le service après-vente est (plus ou moins bien) assuré sur
|
||||||
|
la [mailing list](https://lists.tetalab.org/mailman/listinfo/tetalab) et/ou
|
||||||
|
le canal IRC #tetalab sur le réseau de
|
||||||
|
[Libera.Chat](https://libera.chat/)...
|
||||||
|
|
||||||
|
Par ailleurs, d'autres expérimentations sont
|
||||||
|
[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
|
||||||
|
des films flous.
|
||||||
|
|
||||||
|
## *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
|
||||||
|
|
||||||
|
Bien entendu, avant tout, il faut installer quelques outils et
|
||||||
|
dépendances. Je vais tenter de les lister dans le plus grand
|
||||||
|
désordre (à la sauce Debian) :
|
||||||
|
|
||||||
|
```
|
||||||
|
apt install libtiff-dev
|
||||||
|
apt install libpnglite-dev
|
||||||
|
apt install liblo-dev
|
||||||
|
apt install libv4l2-dev
|
||||||
|
apt install libcfitsio-dev
|
||||||
|
apt install libnetpbm-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 :
|
||||||
|
|
||||||
|
- gnuplot, pour analyser des données,
|
||||||
|
- ImageMagick, parce que Brunus aime ça,
|
||||||
|
- LaTeX, pour la (trop maigre) documentation.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Encore trop légère, mais déja [présente](doc/).
|
||||||
|
C'est à vous de compiler le
|
||||||
|
[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...*
|
||||||
11
build.sh
11
build.sh
@@ -1,10 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e ; set -u
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
function build
|
function build
|
||||||
{
|
{
|
||||||
echo ============= $1 ==============
|
echo "============= $1 =============="
|
||||||
curdir=${PWD}
|
curdir=${PWD}
|
||||||
cd $1
|
cd $1
|
||||||
make
|
make
|
||||||
@@ -13,8 +15,8 @@ cd ${curdir}
|
|||||||
|
|
||||||
if [ ${error} -ne 0 ]
|
if [ ${error} -ne 0 ]
|
||||||
then
|
then
|
||||||
echo === error on $1 = ${error}
|
echo "=== error on $1 = ${error}"
|
||||||
exit
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,10 +26,11 @@ build lib
|
|||||||
build funcs
|
build funcs
|
||||||
build tools
|
build tools
|
||||||
build v4l2
|
build v4l2
|
||||||
|
build Fonderie
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
echo "========== Project root ==============="
|
||||||
make
|
make
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
14
contrib/.gitignore
vendored
Normal file
14
contrib/.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
fimg2povhf
|
||||||
|
demo_fmorph
|
||||||
|
|
||||||
|
toto
|
||||||
|
core
|
||||||
|
|
||||||
|
*.tga
|
||||||
|
*.png
|
||||||
|
*.pnm
|
||||||
|
*.gif
|
||||||
|
*.fimg
|
||||||
|
*.mp4
|
||||||
|
|
||||||
18
contrib/Makefile
Normal file
18
contrib/Makefile
Normal 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
14
contrib/README.md
Normal 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
116
contrib/demo_fmorph.c
Normal 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
163
contrib/do_eff_spass.sh
Executable 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
116
contrib/fimg2povhf.c
Normal 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
31
contrib/raytrace.sh
Executable 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
41
contrib/scene.pov
Normal 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 }
|
||||||
|
|
||||||
11
doc/README.md
Normal file
11
doc/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# The FloatImg Hack
|
||||||
|
|
||||||
|
Et voilà la documentation...
|
||||||
|
|
||||||
|
|
||||||
|
Pour la générer :
|
||||||
|
|
||||||
|
`bash mkdoc.sh`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash -v
|
||||||
|
|
||||||
DOC=the_floatimg_hack
|
DOC=the_floatimg_hack
|
||||||
|
|
||||||
|
bash ./mkgraf.sh
|
||||||
|
|
||||||
pdflatex $DOC.tex
|
pdflatex $DOC.tex
|
||||||
|
|
||||||
makeindex $DOC
|
makeindex $DOC
|
||||||
|
|||||||
58
doc/mkgraf.sh
Normal file
58
doc/mkgraf.sh
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# this script generate some picz for the PDF documentation
|
||||||
|
# and was called by mkdoc.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
PI=" 3.141592654 "
|
||||||
|
|
||||||
|
# ---------------------------------------------------
|
||||||
|
|
||||||
|
OUT="cos01.tex"
|
||||||
|
|
||||||
|
gnuplot << __EOF__
|
||||||
|
|
||||||
|
set term latex
|
||||||
|
set output "$OUT"
|
||||||
|
set title "COS01"
|
||||||
|
set xlabel "input value"
|
||||||
|
|
||||||
|
set ylabel '\rotatebox{90}{corrected value}'
|
||||||
|
|
||||||
|
set grid
|
||||||
|
|
||||||
|
plot \
|
||||||
|
[0:1] [0:1] \
|
||||||
|
(0.5 - 0.5 * cos(x*$PI)) \
|
||||||
|
with line
|
||||||
|
|
||||||
|
__EOF__
|
||||||
|
|
||||||
|
wc $OUT
|
||||||
|
|
||||||
|
# ---------------------------------------------------
|
||||||
|
|
||||||
|
OUT="cos010.tex"
|
||||||
|
|
||||||
|
gnuplot << __EOF__
|
||||||
|
|
||||||
|
set term latex
|
||||||
|
set output "$OUT"
|
||||||
|
set title "COS010"
|
||||||
|
set xlabel "input value"
|
||||||
|
|
||||||
|
set ylabel '\rotatebox{90}{corrected value}'
|
||||||
|
|
||||||
|
set grid
|
||||||
|
|
||||||
|
plot \
|
||||||
|
[0:1] [0:1] \
|
||||||
|
(0.5 - 0.5 * cos(x*$PI*2)) \
|
||||||
|
with line
|
||||||
|
|
||||||
|
__EOF__
|
||||||
|
|
||||||
|
wc $OUT
|
||||||
|
|
||||||
|
# ---------------------------------------------------
|
||||||
19
doc/notes.txt
Normal file
19
doc/notes.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
Caméra astronomique de Blaise
|
||||||
|
|
||||||
|
[794365.688044] usb 4-5: new high-speed USB device number 17 using ehci-pci
|
||||||
|
[794365.892442] usb 4-5: config 1 interface 0 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 1024
|
||||||
|
[794365.892923] usb 4-5: New USB device found, idVendor=03c3, idProduct=120b
|
||||||
|
[794365.892927] usb 4-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
|
||||||
|
[794365.892930] usb 4-5: Product: ASI120MC
|
||||||
|
[794365.892934] usb 4-5: Manufacturer: ZWOptical company
|
||||||
|
[794365.892937] usb 4-5: SerialNumber: 00000
|
||||||
|
|
||||||
|
|
||||||
|
Comment imprimer ce code trop gruik ?
|
||||||
|
|
||||||
|
enscript -o - -Ec -f Courier9 -F Times-Roman14 --word-wrap \
|
||||||
|
-i 6 --swap-even-page-margins v4l2_pr_structs.c |
|
||||||
|
ps2pdf - /media/tth/BLIRBOU/v4l2_pr_structs.pdf
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
88
essai.c
88
essai.c
@@ -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>
|
||||||
@@ -14,71 +15,20 @@
|
|||||||
int verbosity;
|
int verbosity;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int add(FloatImg *a, FloatImg *b)
|
void fait_un_dessin(FloatImg *dessin)
|
||||||
{
|
{
|
||||||
int x, y;
|
|
||||||
int offset;
|
|
||||||
double tb;
|
|
||||||
|
|
||||||
fimg_timer_set(0);
|
// fprintf(stderr, "je dessine dans %p\n", dessin);
|
||||||
|
|
||||||
for (x=0; x<a->width; x++) {
|
fimg_draw_something(dessin);
|
||||||
for (y=0; y<a->height; y++) {
|
|
||||||
offset = x + (y * a->width);
|
|
||||||
a->R[offset] += b->R[offset];
|
|
||||||
a->G[offset] += b->G[offset];
|
|
||||||
a->B[offset] += b->B[offset];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tb = fimg_timer_get(0);
|
|
||||||
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
void fait_un_dessin(char *fname)
|
void help(void)
|
||||||
{
|
|
||||||
FloatImg dessin;
|
|
||||||
double tb;
|
|
||||||
|
|
||||||
puts("");
|
|
||||||
fimg_timer_set(0);
|
|
||||||
fimg_create(&dessin, 3200, 2400, 3);
|
|
||||||
fimg_draw_something(&dessin);
|
|
||||||
fimg_dump_to_file(&dessin, "dessin.fimg", 0);
|
|
||||||
fimg_destroy(&dessin);
|
|
||||||
tb = fimg_timer_get(0);
|
|
||||||
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
|
||||||
|
|
||||||
puts("");
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
int parse_WxH(char *str, int *pw, int *ph)
|
|
||||||
{
|
|
||||||
// char *ptr;
|
|
||||||
int foo, w, h;
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
|
||||||
fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__,
|
|
||||||
str, pw, ph);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
foo = sscanf(str, "%dx%d", &w, &h);
|
|
||||||
if (2 != foo) {
|
|
||||||
fprintf(stderr, "%s : arg '%s' is invalid\n", __func__, str);
|
|
||||||
return foo;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pw = w; *ph = h;
|
|
||||||
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
void help(int k)
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@@ -87,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,13 +54,25 @@ if (verbosity) fimg_print_version(0);
|
|||||||
fimg_create(&fimgA, W, H, 3);
|
fimg_create(&fimgA, W, H, 3);
|
||||||
fimg_create(&fimgB, W, H, 3);
|
fimg_create(&fimgB, W, H, 3);
|
||||||
|
|
||||||
fimg_timer_set(0);
|
fimg_clear(&fimgA);
|
||||||
|
|
||||||
fimg_drand48(&fimgB, 100.0);
|
fimg_drand48(&fimgB, 100.0);
|
||||||
fimg_drand48(&fimgA, 100.0);
|
foo = fimg_dump_to_file(&fimgB, "B.fimg", 0);
|
||||||
add(&fimgA, &fimgB);
|
|
||||||
|
fimg_timer_set(0);
|
||||||
|
#define NBP 5
|
||||||
|
for (foo=0; foo<NBP; foo++) {
|
||||||
|
if (verbosity) {
|
||||||
|
printf("%5d / %5d\n", foo, NBP);
|
||||||
|
}
|
||||||
|
fait_un_dessin(&fimgB);
|
||||||
|
fimg_add_3(&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, "out.fimg", 0);
|
||||||
|
|
||||||
fimg_destroy(&fimgA);
|
fimg_destroy(&fimgA);
|
||||||
fimg_destroy(&fimgB);
|
fimg_destroy(&fimgB);
|
||||||
|
|||||||
14
experiment/.gitignore
vendored
Normal file
14
experiment/.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
*.fimg
|
||||||
|
*.o
|
||||||
|
*.pnm
|
||||||
|
*.data
|
||||||
|
|
||||||
|
assemblage
|
||||||
|
extracteur
|
||||||
|
fimg2obj
|
||||||
|
mnt
|
||||||
|
movepixels
|
||||||
|
muxplanes
|
||||||
|
tcache
|
||||||
40
experiment/Makefile
Normal file
40
experiment/Makefile
Normal 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
29
experiment/README.md
Normal 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).
|
||||||
85
experiment/assemblage.c
Normal file
85
experiment/assemblage.c
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* assemblage experimental
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
// #include "incrustator.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
|
/*
|
||||||
|
* le prototype de base avec trop peu de parametres, mais
|
||||||
|
* c'est assez dur de formaliser la structure des informations
|
||||||
|
* a transmettre de fonction en fonction, et commant on peut
|
||||||
|
* integrer cette mecanique dans singlepass.c ?!#@
|
||||||
|
*/
|
||||||
|
int premier_essai(int largeur, int hauteur, char *outname)
|
||||||
|
{
|
||||||
|
FloatImg grande, incrust;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
foo = fimg_create(&grande, largeur, hauteur, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: Kkrkr %d pour create grande\n", __func__, foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fimg_vdeg_a(&grande, 2345);
|
||||||
|
|
||||||
|
foo = fimg_create(&incrust, 640, 480, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: Kkrkr %d pour create incrust\n", __func__, foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// fimg_drand48(&incrust, 13.37);
|
||||||
|
foo = fimg_load_from_dump("foo.fimg", &incrust);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d loading image\n", __func__, foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FLAGS 0
|
||||||
|
foo = fimg_incrustator_0(&incrust, &grande, 111, 111, FLAGS);
|
||||||
|
#undef FLAGS
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d sur incrustator_0\n", __func__, foo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&grande, outname, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: error %d export '%s'\n", __func__,
|
||||||
|
foo, outname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_destroy(&incrust); fimg_destroy(&grande);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
verbosity = 2;
|
||||||
|
|
||||||
|
fimg_print_version(1);
|
||||||
|
|
||||||
|
foo = premier_essai(1280, 1024, "out.png");
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "EPIC FAIL %s\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
145
experiment/cachengn.c
Normal file
145
experiment/cachengn.c
Normal 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
29
experiment/cachengn.h
Normal 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);
|
||||||
26
experiment/essai.sh
Executable file
26
experiment/essai.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make extracteur
|
||||||
|
|
||||||
|
IMGS="foo.fimg"
|
||||||
|
|
||||||
|
for idx in $(seq 0 69)
|
||||||
|
do
|
||||||
|
outf=$(printf "%s/X%04d.png" "/tmp" $idx)
|
||||||
|
echo "work on "$outf
|
||||||
|
|
||||||
|
x=$(( idx * 4 ))
|
||||||
|
y=$(( idx + 80 ))
|
||||||
|
|
||||||
|
./extracteur $IMGS 256,128,${x},${y} $outf
|
||||||
|
error=$?
|
||||||
|
if [ 0 -ne $error ] ; then
|
||||||
|
echo error $error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
convert -delay 10 /tmp/X????.png foo.gif
|
||||||
|
|
||||||
67
experiment/fimg2obj.c
Normal file
67
experiment/fimg2obj.c
Normal 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
239
experiment/mnt.c
Normal 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
156
experiment/movepixels.c
Normal 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
113
experiment/muxplanes.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------- */
|
||||||
49
experiment/tcache.c
Normal file
49
experiment/tcache.c
Normal 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
24
experiment/tripla.sh
Executable 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
|
||||||
|
|
||||||
292
floatimg.h
292
floatimg.h
@@ -1,77 +1,341 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
|
* http://la.buvette.org/photos/cumul/
|
||||||
|
* https://git.tetalab.org/tTh/FloatImg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIMG_VERSION 64
|
#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 {
|
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
|
||||||
|
typedef struct {
|
||||||
|
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 ! */
|
||||||
int w, h, t;
|
int32_t w, h, t;
|
||||||
|
/*
|
||||||
|
* what about the packing ?
|
||||||
|
*/
|
||||||
} FimgFileHead;
|
} FimgFileHead;
|
||||||
|
|
||||||
|
|
||||||
|
#define MAGIC_AREA51 0xA5EA0051
|
||||||
|
typedef struct {
|
||||||
|
uint32_t magic;
|
||||||
|
int w, h;
|
||||||
|
int x, y;
|
||||||
|
int flags;
|
||||||
|
} FimgArea51;
|
||||||
|
|
||||||
#define FIMG_TYPE_GRAY 1
|
#define FIMG_TYPE_GRAY 1
|
||||||
#define FIMG_TYPE_RGB 3
|
#define FIMG_TYPE_RGB 3
|
||||||
#define FIMG_TYPE_RGBA 4
|
#define FIMG_TYPE_RGBA 4
|
||||||
|
#define FIMG_TYPE_RGBZ 99
|
||||||
|
|
||||||
|
#define FILE_TYPE_FIMG 1
|
||||||
|
#define FILE_TYPE_PNM 2
|
||||||
|
#define FILE_TYPE_PNG 3
|
||||||
|
#define FILE_TYPE_TGA 4
|
||||||
|
#define FILE_TYPE_TIFF 5
|
||||||
|
#define FILE_TYPE_FITS 6
|
||||||
|
#define FILE_TYPE_BMP 7
|
||||||
|
#define FILE_TYPE_EXR 8
|
||||||
|
#define FILE_TYPE_DICOM 9
|
||||||
|
#define FILE_TYPE_PGM 10
|
||||||
|
|
||||||
|
/* lib/contrast.c */
|
||||||
|
#define CONTRAST_NONE 0
|
||||||
|
#define CONTRAST_SQRT 1
|
||||||
|
#define CONTRAST_POW2 2
|
||||||
|
#define CONTRAST_COS01 3
|
||||||
|
#define CONTRAST_COS010 4
|
||||||
|
#define CONTRAST_XPER 5 /* use with caution */
|
||||||
/*
|
/*
|
||||||
* core module
|
* core module
|
||||||
*/
|
*/
|
||||||
int fimg_create(FloatImg *fimg, int w, int h, int t);
|
int fimg_create(FloatImg *fimg, int w, int h, int t);
|
||||||
int fimg_destroy(FloatImg *fimg);
|
int fimg_destroy(FloatImg *fimg);
|
||||||
|
int fimg_clone(FloatImg *fimg, FloatImg *newpic, int flags);
|
||||||
|
int fimg_copy_data(FloatImg *from, FloatImg *to);
|
||||||
|
int fimg_type_is_valid(int type);
|
||||||
|
|
||||||
|
|
||||||
int fimg_print_version(int k);
|
int fimg_print_version(int k);
|
||||||
|
void fimg_print_sizeof(void);
|
||||||
void fimg_printhead(FloatImg *h);
|
void fimg_printhead(FloatImg *h);
|
||||||
|
void fimg_printdims(char *txt, FloatImg *pi);
|
||||||
int fimg_describe(FloatImg *head, char *txt);
|
int fimg_describe(FloatImg *head, char *txt);
|
||||||
int fimg_fileinfo(char *fname, int *datas);
|
char *fimg_str_type(int type);
|
||||||
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b);
|
int fimg_plot_rgb (FloatImg *head, int x, int y,
|
||||||
|
float r, float g, float b);
|
||||||
|
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
|
||||||
|
int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
|
||||||
int fimg_clear(FloatImg *fimg);
|
int fimg_clear(FloatImg *fimg);
|
||||||
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
|
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
|
||||||
|
int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
|
||||||
|
|
||||||
|
/* --> lib/fimg-compare.c */
|
||||||
|
int fimg_images_not_compatible(FloatImg *a, FloatImg *b);
|
||||||
|
|
||||||
|
int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef);
|
||||||
|
|
||||||
|
/* 'operats' module */
|
||||||
|
int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||||
|
int fimg_add_2(FloatImg *a, FloatImg *b); /* B+=A */
|
||||||
|
int fimg_sub_3(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||||
|
int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||||
|
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||||
|
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------- */
|
||||||
|
/* funcs/filtrage.c */
|
||||||
|
typedef struct {
|
||||||
|
float matrix[9];
|
||||||
|
float mult;
|
||||||
|
float offset;
|
||||||
|
} FimgFilter3x3;
|
||||||
|
/*
|
||||||
|
* this module contains bugs...
|
||||||
|
*/
|
||||||
|
int fimg_killborders(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_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse);
|
||||||
|
|
||||||
|
/* ---------------------------------------------------- */
|
||||||
|
|
||||||
|
/* module sfx0.c */
|
||||||
|
int fimg_killcolors_a(FloatImg *fimg, float fval);
|
||||||
|
int fimg_killcolors_b(FloatImg *fimg, float fval);
|
||||||
|
int fimg_colors_mixer_a(FloatImg *fimg, float fval);
|
||||||
|
|
||||||
|
/* module sfx1.c */
|
||||||
|
int fimg_highlight_color(FloatImg *src, FloatImg *dst,
|
||||||
|
char color, float fval);
|
||||||
|
|
||||||
|
/* module sfx2.c */
|
||||||
|
int fimg_binarize(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 */
|
||||||
|
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 */
|
||||||
|
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 */
|
||||||
|
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 notused);
|
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);
|
||||||
|
|
||||||
|
/* --> lib/contrast.c */
|
||||||
|
int fimg_id_contraste(char *name);
|
||||||
|
int fimg_square_root(FloatImg *s, FloatImg *d, double maxval);
|
||||||
|
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
|
||||||
|
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
|
||||||
|
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
|
||||||
|
int fimg_mix_rgb_gray(FloatImg *img, float mix);
|
||||||
|
|
||||||
/* FIMG files module */
|
/* funcs/saturation.c */
|
||||||
|
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
|
||||||
|
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 */
|
||||||
|
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 ! */
|
||||||
|
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_b(FloatImg *psrc, FloatImg *pdst, int notused);
|
||||||
|
|
||||||
|
/* module funcs/equalize.c */
|
||||||
|
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_desaturate(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
|
||||||
|
/* module funcs/geometry.c */
|
||||||
|
/* warning, this module is a mess */
|
||||||
|
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
|
||||||
|
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
|
||||||
|
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
||||||
|
int xpos, int ypos, int flags);
|
||||||
|
|
||||||
|
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
|
||||||
|
|
||||||
|
/* module funcs/rampes.c */
|
||||||
|
int fimg_hdeg_a(FloatImg *img, double dcoef);
|
||||||
|
int fimg_vdeg_a(FloatImg *img, double dcoef);
|
||||||
|
int fimg_do_stripes(FloatImg *img, float fmax, int mode);
|
||||||
|
|
||||||
|
/* 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_create_from_dump(char *fname, FloatImg *head);
|
int fimg_create_from_dump(char *fname, FloatImg *head);
|
||||||
|
|
||||||
/* mathematics oprations */
|
/* 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_G_as_fits(FloatImg *src, char *outname, int flags);
|
||||||
|
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
|
||||||
|
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_save_as_exr(FloatImg *src, char *outname, int flags);
|
||||||
|
|
||||||
|
/* 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_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);
|
||||||
void 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_div_cste(FloatImg *fi, float value);
|
||||||
|
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_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);
|
||||||
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
|
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
|
||||||
|
|
||||||
|
int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
|
||||||
|
|
||||||
|
int fimg_test_pattern(FloatImg *fimg, int type, double dval);
|
||||||
int fimg_draw_something(FloatImg *fimg);
|
int fimg_draw_something(FloatImg *fimg);
|
||||||
|
int fimg_mircol_1(FloatImg *dst, float mval);
|
||||||
|
int fimg_multirandom(FloatImg *fimg, long nbpass);
|
||||||
|
|
||||||
|
/* file is 'funcs/utils.c' */
|
||||||
|
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_double(char *str, double *dptr);
|
||||||
|
int irand2(int offset, int modulo);
|
||||||
|
int print_rectangle(char *str, FimgArea51 *rect);
|
||||||
|
int parse_rectangle(char *str, FimgArea51 *r, int notused);
|
||||||
|
int format_from_extension(char *fname);
|
||||||
|
char * extension_from_format(int fmt);
|
||||||
|
|
||||||
|
int fimg_clear_rectangle(FloatImg *pimg, int rect[4]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
funcs/.gitignore
vendored
Normal file
10
funcs/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
tpnm
|
||||||
|
t
|
||||||
|
*.o
|
||||||
|
*.png
|
||||||
|
*.gif
|
||||||
|
*.fits
|
||||||
|
*.tiff
|
||||||
|
|
||||||
|
|
||||||
142
funcs/Makefile
142
funcs/Makefile
@@ -1,22 +1,160 @@
|
|||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
COPT = -Wall -fpic -g -no-pie -pg -DDEBUG_LEVEL=0
|
# Please, use the 'Gloabl.makefile' system !
|
||||||
|
|
||||||
|
|
||||||
|
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
|
|
||||||
|
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.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 \
|
||||||
|
equalize.o fimg-fits.o saturation.o histogram.o \
|
||||||
|
fimg-dicom.o \
|
||||||
|
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
|
||||||
|
displacement.o dithering.o plasmas.o incrustator.o \
|
||||||
|
killrgb.o recurse.o pixelize.o decomprgb.o
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
|
all: t
|
||||||
|
|
||||||
|
tests.o: tests.c tests.h $(DEPS)
|
||||||
|
gcc $(COPT) -I/usr/include/netpbm -c $<
|
||||||
|
|
||||||
|
t: t.c $(DEPS) ../libfloatimg.a tests.o
|
||||||
|
gcc $(COPT) $< \
|
||||||
|
tests.o \
|
||||||
|
-I/usr/include/netpbm/ \
|
||||||
|
-I/usr/include/cfitsio/ \
|
||||||
|
../libfloatimg.a -lnetpbm -lpnglite -lcfitsio \
|
||||||
|
-ltiff \
|
||||||
|
-lz -lm -o $@
|
||||||
|
|
||||||
|
tpnm: tpnm.c Makefile fimg-libpnm.o
|
||||||
|
gcc $(COPT) -I/usr/include/netpbm \
|
||||||
|
fimg-libpnm.o -lnetpbm $< -o $@
|
||||||
|
|
||||||
|
#---------------------------------------------------------------
|
||||||
|
# upper-level functions
|
||||||
|
|
||||||
../libfloatimg.a: $(OBJS)
|
../libfloatimg.a: $(OBJS)
|
||||||
$(AR) r $@ $?
|
$(AR) r $@ $?
|
||||||
|
|
||||||
|
# ###
|
||||||
|
|
||||||
|
rectangle.o: rectangle.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
decomprgb.o: decomprgb.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
pixelize.o: pixelize.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
killrgb.o: killrgb.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
recurse.o: recurse.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
incrustator.o: incrustator.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
displacement.o: displacement.c $(DEPS)
|
||||||
|
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 $<
|
||||||
|
|
||||||
|
fimg-bmp.o: fimg-bmp.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
fimg-tiff.o: fimg-tiff.c $(DEPS)
|
fimg-tiff.o: fimg-tiff.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
fimg-openexr.o: fimg-openexr.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
fimg-dicom.o: fimg-dicom.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
fimg-fits.o: fimg-fits.c $(DEPS)
|
||||||
|
gcc $(COPT) -I/usr/include/cfitsio/ -c $<
|
||||||
|
|
||||||
|
fimg-libpnm.o: fimg-libpnm.c $(DEPS)
|
||||||
|
gcc $(COPT) -I/usr/include/netpbm -c $<
|
||||||
|
|
||||||
misc-plots.o: misc-plots.c $(DEPS)
|
misc-plots.o: misc-plots.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
filtrage.o: filtrage.c $(DEPS)
|
filtrage.o: filtrage.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
geometry.o: geometry.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
rotate.o: rotate.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
saturation.o: saturation.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
histogram.o: histogram.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
equalize.o: equalize.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
dithering.o: dithering.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
plasmas.o: plasmas.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
sfx0.o: sfx0.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
sfx1.o: sfx1.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
sfx2.o: sfx2.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
sfx3.o: sfx3.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
sfx4.o: sfx4.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
contour2x2.o: contour2x2.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
rampes.o: rampes.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
classif.o: classif.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
qsortrgb.o: qsortrgb.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
exporter.o: exporter.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
falsecolors.o: falsecolors.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
thermocolor.o: thermocolor.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
hsv.o: hsv.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
utils.o: utils.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|||||||
53
funcs/README.md
Normal file
53
funcs/README.md
Normal 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.
|
||||||
33
funcs/alltests.sh
Executable file
33
funcs/alltests.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# trying to run a maximum of ugly code
|
||||||
|
#
|
||||||
|
|
||||||
|
for trial in $(./t -l)
|
||||||
|
do
|
||||||
|
|
||||||
|
printf "============ %-10s ============\n" $trial
|
||||||
|
|
||||||
|
make t
|
||||||
|
error=$?
|
||||||
|
if [ 0 -ne $error ]
|
||||||
|
then
|
||||||
|
echo "make error is " $error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
./t -v $trial
|
||||||
|
error=$?
|
||||||
|
if [ 0 -ne $error ]
|
||||||
|
then
|
||||||
|
echo "run error is " $error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\t=== return code %d\n" $error
|
||||||
|
echo
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
done
|
||||||
106
funcs/classif.c
Normal file
106
funcs/classif.c
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* classif.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau 2 octobre 2020, juste avant sonoptic de la pluie craignos */
|
||||||
|
|
||||||
|
int fimg_classif_trial(FloatImg *psrc, FloatImg *pdst, float fval, int flags)
|
||||||
|
{
|
||||||
|
float minmax[6], delta[3], baryc[3];
|
||||||
|
float range, dist, rgb[3], dr, dg, db;
|
||||||
|
int x, y, on, off;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__,
|
||||||
|
psrc, pdst, fval, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
|
||||||
|
|
||||||
|
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, pdst)) {
|
||||||
|
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculer les amplitudes RGB de l'image source */
|
||||||
|
fimg_get_minmax_rgb(psrc, minmax);
|
||||||
|
delta[0] = minmax[1] - minmax[0];
|
||||||
|
delta[1] = minmax[3] - minmax[2];
|
||||||
|
delta[2] = minmax[5] - minmax[4];
|
||||||
|
|
||||||
|
/* chercher le plus petit des deltas */
|
||||||
|
range = delta[0]; if (delta[1]<range) range=delta[1];
|
||||||
|
if (delta[2]<range) range=delta[2];
|
||||||
|
|
||||||
|
/* convertir le diametre en rayon (magic inside) */
|
||||||
|
range *= fval;
|
||||||
|
|
||||||
|
if (verbosity > 1) fprintf(stderr, "deltas : %f %f %f / %f\n",
|
||||||
|
delta[0], delta[1], delta[2], range);
|
||||||
|
|
||||||
|
|
||||||
|
/* calcul du "barycentre" chromatique */
|
||||||
|
baryc[0] = (minmax[1] + minmax[0]) / 2;
|
||||||
|
baryc[1] = (minmax[3] + minmax[2]) / 2;
|
||||||
|
baryc[2] = (minmax[5] + minmax[4]) / 2;
|
||||||
|
if (verbosity > 1) fprintf(stderr, "barycs : %f %f %f\n",
|
||||||
|
baryc[0], baryc[1], baryc[2]);
|
||||||
|
|
||||||
|
on = off = 0;
|
||||||
|
|
||||||
|
for (y=0; y<psrc->height; y++) {
|
||||||
|
for (x=0; x<psrc->width; x++) {
|
||||||
|
|
||||||
|
fimg_get_rgb(psrc, x, y, rgb);
|
||||||
|
|
||||||
|
/* calcul de la distance chromatique */
|
||||||
|
dr = rgb[0] - baryc[0];
|
||||||
|
dg = rgb[1] - baryc[1];
|
||||||
|
db = rgb[2] - baryc[2];
|
||||||
|
dist = sqrtf( (dr*dr) + (dg*dg) + (db*db) );
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
if (x==y) fprintf(stderr, "%4d %4d %f\n", x, y, dist);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* action !!! */
|
||||||
|
if (dist > range) {
|
||||||
|
/* make our pixel gray-level */
|
||||||
|
rgb[0] = rgb[1] = rgb[2] = 0.0;
|
||||||
|
// (rgb[0] + rgb[1] + rgb[2]) / 3.0;
|
||||||
|
on++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* the easy part : do nothing */
|
||||||
|
off++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_put_rgb(pdst, x, y, rgb);
|
||||||
|
|
||||||
|
/* MUST BE MORE CREATIVE HERE !!! */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) fprintf(stderr, "on %d off %d\n", on, off);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
96
funcs/contour2x2.c
Normal file
96
funcs/contour2x2.c
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Detection de contours
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau 4 octobre 2020, juste avant sonoptic de la pluie craignos */
|
||||||
|
|
||||||
|
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse)
|
||||||
|
{
|
||||||
|
float avg[4];
|
||||||
|
int foo, x, y, q;
|
||||||
|
float v1, v2;
|
||||||
|
|
||||||
|
int tbl[] = /* deep magic inside */
|
||||||
|
{
|
||||||
|
0, 1, 1, 1,
|
||||||
|
1, 1, 0, 1,
|
||||||
|
1, 0, 1, 1,
|
||||||
|
1, 1, 1, 0
|
||||||
|
}; /* please explain */
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, reverse);
|
||||||
|
#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, pdst)) {
|
||||||
|
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reverse) {
|
||||||
|
v1 = 0.0; v2 = 1.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
v1 = 1.0; v2 = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_meanvalues(psrc, avg);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d on fimg_meanvalues\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "%s: %f %f %f\n", __func__, avg[0], avg[1], avg[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RP(ix, iy) ( psrc->R[((iy)*psrc->width)+(ix)] < avg[0] )
|
||||||
|
#define GP(ix, iy) ( psrc->G[((iy)*psrc->width)+(ix)] < avg[1] )
|
||||||
|
#define BP(ix, iy) ( psrc->B[((iy)*psrc->width)+(ix)] < avg[2] )
|
||||||
|
|
||||||
|
for (y=0; y<psrc->height-1; y++) {
|
||||||
|
|
||||||
|
for (x=0; x<psrc->width-1; x++) {
|
||||||
|
|
||||||
|
q = ( ( RP(x, y) << 3 ) |
|
||||||
|
( RP(x+1, y) << 2 ) |
|
||||||
|
( RP(x, y+1) << 1 ) |
|
||||||
|
( RP(x+1, y+1) ) );
|
||||||
|
pdst->R[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
|
||||||
|
|
||||||
|
q = ( ( GP(x, y) << 3 ) |
|
||||||
|
( GP(x+1, y) << 2 ) |
|
||||||
|
( GP(x, y+1) << 1 ) |
|
||||||
|
( GP(x+1, y+1) ) );
|
||||||
|
pdst->G[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
|
||||||
|
|
||||||
|
q = ( ( BP(x, y) << 3 ) |
|
||||||
|
( BP(x+1, y) << 2 ) |
|
||||||
|
( BP(x, y+1) << 1 ) |
|
||||||
|
( BP(x+1, y+1) ) );
|
||||||
|
pdst->B[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* kill potential NaN values in last row or last column */
|
||||||
|
fimg_killborders(pdst);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
157
funcs/decomprgb.c
Normal file
157
funcs/decomprgb.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* == ---------------------------------------------------- == */
|
||||||
94
funcs/displacement.c
Normal file
94
funcs/displacement.c
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* displacement.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
|
||||||
|
|
||||||
|
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags)
|
||||||
|
{
|
||||||
|
int x, y, foo;
|
||||||
|
float minmax[6];
|
||||||
|
float rgb[3];
|
||||||
|
float dltr, dltg, dltb; /* delta des minmax */
|
||||||
|
float dispx, dispy;
|
||||||
|
int dstx, dsty;
|
||||||
|
int in, out;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, psrc, pdst, flags);
|
||||||
|
#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, pdst)) {
|
||||||
|
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(psrc, minmax);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s : err %d on get minmax\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
if (verbosity) {
|
||||||
|
fimg_print_minmax(minmax, (char *)__func__);
|
||||||
|
}
|
||||||
|
// dltr = minmax[1] - minmax[0];
|
||||||
|
dltg = minmax[3] - minmax[2];
|
||||||
|
dltb = minmax[5] - minmax[4];
|
||||||
|
|
||||||
|
in = out = 0;
|
||||||
|
/*
|
||||||
|
* BE WARNED !
|
||||||
|
* This code doesn't work as expected, so I have to
|
||||||
|
* rewrite it, maybe when the pandemic is closed...
|
||||||
|
*/
|
||||||
|
for (y=0; y<psrc->height; y++) {
|
||||||
|
|
||||||
|
for (x=0; x<psrc->width; x++) {
|
||||||
|
|
||||||
|
fimg_get_rgb(psrc, x, y, rgb);
|
||||||
|
|
||||||
|
dispx = (float)x + (rgb[1]/dltg * 20.0);
|
||||||
|
dispy = (float)y + (rgb[2]/dltb * 20.0);
|
||||||
|
dstx = (int)roundf(dispx - 10.0);
|
||||||
|
dsty = (int)roundf(dispy - 10.0);
|
||||||
|
|
||||||
|
if ( (dstx < 0) || (dsty < 0) ||
|
||||||
|
(dstx >= psrc->width) ||
|
||||||
|
(dsty >= psrc->height) )
|
||||||
|
{
|
||||||
|
/* OUT OF DESTINATION PICTURE */
|
||||||
|
out++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (flags & 1) {
|
||||||
|
/* going monochrome */
|
||||||
|
rgb[1] = rgb[2] = rgb[0];
|
||||||
|
}
|
||||||
|
fimg_put_rgb(pdst, dstx, dsty, rgb);
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
44
funcs/dithering.c
Normal file
44
funcs/dithering.c
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* FloatImg : some dithering experiments
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_dither_0(FloatImg *psrc, FloatImg *pdst, int flags)
|
||||||
|
{
|
||||||
|
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 (x=0; x<psrc->width; x++)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* PLEASE DO SOMETHING HERE */
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
98
funcs/equalize.c
Normal file
98
funcs/equalize.c
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* egalisation dynamique approximative
|
||||||
|
* #coronamaison Thu 09 Apr 2020 03:37:10 PM CEST
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
float minmax[6];
|
||||||
|
int foo;
|
||||||
|
float dr, dg, db;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %f )\n", __func__, src, vptr, vmax);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset(minmax, 0, 6*sizeof(float));
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(src, minmax);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d get minmax in %s\n", foo, __func__);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "vptr is %p vmax is %f\n", vptr, vmax);
|
||||||
|
|
||||||
|
dr = minmax[1] - minmax[0];
|
||||||
|
dg = minmax[3] - minmax[2];
|
||||||
|
db = minmax[5] - minmax[4];
|
||||||
|
|
||||||
|
printf("Rmin %12.4g max %12.4g delta %12.4g\n", minmax[0], minmax[1], dr);
|
||||||
|
printf("Gmin %12.4g max %12.4g delta %12.4g\n", minmax[2], minmax[3], dg);
|
||||||
|
printf("Bmin %12.4g max %12.4g delta %12.4g\n", minmax[4], minmax[5], db);
|
||||||
|
|
||||||
|
if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) {
|
||||||
|
fprintf(stderr, "%s: negative value ?\n", __func__);
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "deltas %12.4g %12.4g %12.4g\n", dr, dg, db);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
82
funcs/exporter.c
Normal file
82
funcs/exporter.c
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* exporter.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* multi-magic 'save file' function.
|
||||||
|
*/
|
||||||
|
int fimg_export_picture(FloatImg *pic, char *fname, int flags)
|
||||||
|
{
|
||||||
|
int filetype;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__,
|
||||||
|
pic, fname, flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
|
||||||
|
|
||||||
|
filetype = format_from_extension(fname);
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "file %s have type %d\n", fname, filetype);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(filetype) {
|
||||||
|
case FILE_TYPE_FIMG:
|
||||||
|
foo = fimg_dump_to_file(pic, fname, 0);
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_PNM:
|
||||||
|
foo = fimg_save_as_pnm(pic, fname, 0);
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_PNG:
|
||||||
|
foo = fimg_save_as_png(pic, fname, 0);
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_TGA:
|
||||||
|
fprintf(stderr, "%s: FILE_TYPE_TGA not implemented\n",
|
||||||
|
__func__);
|
||||||
|
foo = -666;
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_TIFF:
|
||||||
|
foo = fimg_write_as_tiff(pic, fname, 0);
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_FITS:
|
||||||
|
foo = fimg_save_R_as_fits(pic, fname, 0);
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_BMP:
|
||||||
|
fprintf(stderr, "%s: file type BMP not implemented\n", __func__);
|
||||||
|
foo = -666;
|
||||||
|
break;
|
||||||
|
case FILE_TYPE_EXR:
|
||||||
|
fprintf(stderr, "%s: file type EXR experimental\n", __func__);
|
||||||
|
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:
|
||||||
|
foo = -1789;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: exporting '%s' -> %d\n", __func__,
|
||||||
|
fname, foo);
|
||||||
|
/* que faire maintenant ? */
|
||||||
|
}
|
||||||
|
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
83
funcs/falsecolors.c
Normal file
83
funcs/falsecolors.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
270
funcs/filtrage.c
270
funcs/filtrage.c
@@ -1,32 +1,284 @@
|
|||||||
|
/*
|
||||||
|
* 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_lissage_2x2(FloatImg *img)
|
int fimg_show_filter(char *title, FimgFilter3x3 *filtr)
|
||||||
{
|
{
|
||||||
int x, y, offset;
|
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 x, y, w, h, of;
|
||||||
|
float *pr, *pg, *pb; /* alias for src pix filds */
|
||||||
|
float *M; /* alias of filter matrix */
|
||||||
|
double dval;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, src, dst, filtr);
|
||||||
fprintf(stderr," type %s size %dx%d\n", img->type,
|
|
||||||
img->width, img->height);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (y=1; y<img->height; y++) {
|
if (src->type != FIMG_TYPE_RGB) {
|
||||||
|
fprintf(stderr, "%s: src type %d invalid\n", __func__, src->type);
|
||||||
|
return -99;
|
||||||
|
}
|
||||||
|
if (dst->type != FIMG_TYPE_RGB) {
|
||||||
|
fprintf(stderr, "%s: dst type %d invalid\n", __func__, dst->type);
|
||||||
|
return -99;
|
||||||
|
}
|
||||||
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
|
fprintf(stderr, "%s: src & dst not compatibles\n", __func__);
|
||||||
|
return -98;
|
||||||
|
}
|
||||||
|
|
||||||
for (x=1; x<img->width; x++) {
|
if (verbosity > 1) {
|
||||||
|
fimg_show_filter((char *)__func__, filtr);
|
||||||
|
}
|
||||||
|
|
||||||
offset = x + (y * img->width);
|
/* aliasing some vars for cleaner code */
|
||||||
|
pr = src->R; pg = src->G; pb = src->B;
|
||||||
|
w = src->width; h = src->height;
|
||||||
|
M = filtr->matrix;
|
||||||
|
|
||||||
|
for (y=1; y < h-1; y++) {
|
||||||
|
for (x=1; x < w-1; x++) {
|
||||||
|
of = x + (y * w);
|
||||||
|
|
||||||
|
dval = M[0] * pr[of-(w+1)] +
|
||||||
|
M[1] * pr[of-w] +
|
||||||
|
M[2] * pr[of-(w-1)] +
|
||||||
|
M[3] * pr[of-1] +
|
||||||
|
M[4] * pr[of] +
|
||||||
|
M[5] * pr[of+1] +
|
||||||
|
M[6] * pr[of+(w+1)] +
|
||||||
|
M[7] * pr[of+w] +
|
||||||
|
M[8] * pr[of+(w-1)] ;
|
||||||
|
|
||||||
|
dst->R[of] = dval + filtr->offset;
|
||||||
|
|
||||||
|
dval = M[0] * pg[of-(w+1)] +
|
||||||
|
M[1] * pg[of-w] +
|
||||||
|
M[2] * pg[of-(w-1)] +
|
||||||
|
M[3] * pg[of-1] +
|
||||||
|
M[4] * pg[of] +
|
||||||
|
M[5] * pg[of+1] +
|
||||||
|
M[6] * pg[of+(w+1)] +
|
||||||
|
M[7] * pg[of+w] +
|
||||||
|
M[8] * pg[of+(w-1)] ;
|
||||||
|
|
||||||
|
dst->G[of] = dval + filtr->offset;
|
||||||
|
|
||||||
|
dval = M[0] * pb[of-(w+1)] +
|
||||||
|
M[1] * pb[of-w] +
|
||||||
|
M[2] * pb[of-(w-1)] +
|
||||||
|
M[3] * pb[of-1] +
|
||||||
|
M[4] * pb[of] +
|
||||||
|
M[5] * pb[of+1] +
|
||||||
|
M[6] * pb[of+(w+1)] +
|
||||||
|
M[7] * pb[of+w] +
|
||||||
|
M[8] * pb[of+(w-1)] ;
|
||||||
|
|
||||||
|
dst->B[of] = dval + filtr->offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* this is the more shifting hack on the block.
|
||||||
|
*/
|
||||||
|
static int fimg_lissage_2x2_a(FloatImg *img)
|
||||||
|
{
|
||||||
|
int x, y, offset;
|
||||||
|
float cr, cg, cb;
|
||||||
|
float *pr, *pg, *pb;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
fprintf(stderr," type %d size %dx%d\n", img->type,
|
||||||
|
img->width, img->height);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (img->type != FIMG_TYPE_RGB) {
|
||||||
|
fprintf(stderr, "%s : type %d invalide\n", __func__, img->type);
|
||||||
|
return -99;
|
||||||
|
}
|
||||||
|
|
||||||
|
pr = img->R; pg = img->G; pb = img->B;
|
||||||
|
|
||||||
|
for (y=1; y < img->height-1; y++) {
|
||||||
|
for (x=1; x < img->width-1; x++) {
|
||||||
|
offset = x + (y * img->width);
|
||||||
|
|
||||||
|
cr = pr[offset] + pr[offset+1] +
|
||||||
|
pr[offset+img->width] + pr[offset+img->width+1];
|
||||||
|
|
||||||
|
cg = pg[offset] + pg[offset+1] +
|
||||||
|
pg[offset+img->width] + pg[offset+img->width+1];
|
||||||
|
|
||||||
|
cb = pb[offset] + pb[offset+1] +
|
||||||
|
pb[offset+img->width] + pb[offset+img->width+1];
|
||||||
|
|
||||||
|
pr[offset] = cr / 4.0;
|
||||||
|
pg[offset] = cg / 4.0;
|
||||||
|
pb[offset] = cb / 4.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
int fimg_killborders(FloatImg *img)
|
||||||
|
{
|
||||||
|
int idx, h, w, o;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
fprintf(stderr," type %d size %dx%d\n", img->type,
|
||||||
|
img->width, img->height);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (img->type != FIMG_TYPE_RGB) {
|
||||||
|
fprintf(stderr, "%s : type %d invalide\n", __func__, img->type);
|
||||||
|
return -99;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = img->height; w = img->width;
|
||||||
|
|
||||||
|
for (idx=0; idx<h; idx++) {
|
||||||
|
|
||||||
|
#define FAST 1
|
||||||
|
#if FAST
|
||||||
|
img->R[idx*w] = 0.0;
|
||||||
|
img->G[idx*w] = 0.0;
|
||||||
|
img->B[idx*w] = 0.0;
|
||||||
|
img->R[(idx*w)+w-1] = 0.0;
|
||||||
|
img->G[(idx*w)+w-1] = 0.0;
|
||||||
|
img->B[(idx*w)+w-1] = 0.0;
|
||||||
|
#else
|
||||||
|
fimg_plot_rgb(img, 0, idx, 0.0, 0.0, 0.0);
|
||||||
|
fimg_plot_rgb(img, w-1, idx, 0.0, 0.0, 0.0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
o = w * (h - 1);
|
||||||
|
for (idx=0; idx<w; idx++) {
|
||||||
|
#if FAST
|
||||||
|
img->R[idx] = 0.0;
|
||||||
|
img->G[idx] = 0.0;
|
||||||
|
img->B[idx] = 0.0;
|
||||||
|
img->R[idx+o] = 0.0;
|
||||||
|
img->G[idx+o] = 0.0;
|
||||||
|
img->B[idx+o] = 0.0;
|
||||||
|
#else
|
||||||
|
fimg_plot_rgb(img, idx, 0, 0.0, 0.0, 0.0);
|
||||||
|
fimg_plot_rgb(img, idx, h-1, 0.0, 0.0, 0.0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
int fimg_lissage_2x2(FloatImg *img)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = fimg_lissage_2x2_a(img);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: fail %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_killborders(img);
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
21
funcs/fimg-bmp.c
Normal file
21
funcs/fimg-bmp.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Lecture/ecriture des images BMP
|
||||||
|
* -------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_save_as_bmp(FloatImg *src, char *outname, int flags)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
33
funcs/fimg-dicom.c
Normal file
33
funcs/fimg-dicom.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
118
funcs/fimg-fits.c
Normal file
118
funcs/fimg-fits.c
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* import/export to/from FITS files
|
||||||
|
|
||||||
|
https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node1.html
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <fitsio.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_save_plane_as_fits(FloatImg *src, char *outname,
|
||||||
|
char plane, int flags)
|
||||||
|
{
|
||||||
|
fitsfile *fptr; /* pointer to the FITS file */
|
||||||
|
int status, sz;
|
||||||
|
int bitpix = FLOAT_IMG;
|
||||||
|
float *pplane;
|
||||||
|
long naxis = 2;
|
||||||
|
long naxes[2];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outname, flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
|
||||||
|
switch (plane) {
|
||||||
|
case 'r': case 'R':
|
||||||
|
pplane = src->R; break;
|
||||||
|
case 'g': case 'G':
|
||||||
|
pplane = src->G; break;
|
||||||
|
case 'b': case 'B':
|
||||||
|
pplane = src->B; break;
|
||||||
|
default:
|
||||||
|
return -66;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(outname); /* Delete old file if it already exists */
|
||||||
|
if (fits_create_file(&fptr, outname, &status)) {
|
||||||
|
fits_report_error(stderr, status);
|
||||||
|
return -9;
|
||||||
|
}
|
||||||
|
|
||||||
|
naxes[0] = src->width; naxes[1] = src->height;
|
||||||
|
if (verbosity > 1) fimg_describe(src, "to be saved as FITS");
|
||||||
|
|
||||||
|
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
|
||||||
|
fits_report_error(stderr, status);
|
||||||
|
return -10;
|
||||||
|
}
|
||||||
|
|
||||||
|
sz = naxes[0]*naxes[1];
|
||||||
|
if ( fits_write_img(fptr, TFLOAT, 1, sz, pplane, &status) ) {
|
||||||
|
fits_report_error(stderr, status);
|
||||||
|
return -10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( fits_close_file(fptr, &status) ) {
|
||||||
|
fits_report_error(stderr, status);
|
||||||
|
return -9;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags)
|
||||||
|
{
|
||||||
|
int retv;
|
||||||
|
retv = fimg_save_plane_as_fits(src, outname, 'r', flags);
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags)
|
||||||
|
{
|
||||||
|
int retv;
|
||||||
|
retv = fimg_save_plane_as_fits(src, outname, 'g', flags);
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags)
|
||||||
|
{
|
||||||
|
int retv;
|
||||||
|
retv = fimg_save_plane_as_fits(src, outname, 'b', flags);
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
***** MAGIC CODE FROM OUTERSPACE ?
|
||||||
|
|
||||||
|
function 'writeimage' from :
|
||||||
|
https://heasarc.gsfc.nasa.gov/docs/software/fitsio/cexamples/cookbook.c
|
||||||
|
|
||||||
|
float **array;
|
||||||
|
array = calloc(src->height, sizeof(float *));
|
||||||
|
array[0] = src->R;
|
||||||
|
#define REVERSE 1
|
||||||
|
for( idx=0; idx<naxes[1]; idx++ ) {
|
||||||
|
#if REVERSE
|
||||||
|
k = naxes[1] - idx - 1;
|
||||||
|
#else
|
||||||
|
k = idx;
|
||||||
|
#endif
|
||||||
|
array[idx] = src->R + (k*naxes[0]);
|
||||||
|
fprintf(stderr, " %6d %6d %p\n", idx, k, array[idx]);
|
||||||
|
}
|
||||||
|
**************************************************************/
|
||||||
53
funcs/fimg-libpnm.c
Normal file
53
funcs/fimg-libpnm.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* interface FloatImg <-> libpnm(3)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <pam.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
static void print_struct_pam(struct pam *ppam, char *text)
|
||||||
|
{
|
||||||
|
printf("\ttext %s\n", text);
|
||||||
|
printf("\tsize %d\n", ppam->size);
|
||||||
|
|
||||||
|
printf("\tformat %d 0x%04x\n", ppam->format, ppam->format);
|
||||||
|
printf("\tplainformat %d\n", ppam->plainformat);
|
||||||
|
printf("\twidth & height %d %d\n", ppam->width, ppam->height);
|
||||||
|
printf("\tdepth %d\n", ppam->depth);
|
||||||
|
printf("\tmaxval %lu\n", ppam->maxval);
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int fimg_pnm_infos(char *fname)
|
||||||
|
{
|
||||||
|
struct pam inpam;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf(" --- infos for '%s' ------------\n", fname);
|
||||||
|
|
||||||
|
if (NULL==(fp=fopen(fname, "r"))) {
|
||||||
|
perror(fname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pnm_readpaminit(fp, &inpam, sizeof(inpam));
|
||||||
|
print_struct_pam(&inpam, fname);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
31
funcs/fimg-openexr.c
Normal file
31
funcs/fimg-openexr.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Lecture/ecriture des images EXR
|
||||||
|
* -------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_save_as_exr(FloatImg *src, char *outname, int flags)
|
||||||
|
{
|
||||||
|
// #if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__, src, outname, flags);
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != src->type) {
|
||||||
|
fprintf(stderr, "%s: src bad type %d\n", __func__, src->type);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
105
funcs/fimg-png.c
105
funcs/fimg-png.c
@@ -1,19 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Lecture des images PNG
|
* Lecture des images PNG
|
||||||
|
* ----------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#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>
|
||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
* warning : this func has been tested only with
|
* warning : this func has been tested only with
|
||||||
* RGB (3x8bits) PNG files
|
* RGB (3x8bits) PNG files
|
||||||
|
*
|
||||||
|
* Attention : certains fichiers, tels que ceux
|
||||||
|
* produits par ImageMagick ne sont pas lisibles
|
||||||
|
* par cette fonction :(
|
||||||
*/
|
*/
|
||||||
int fimg_create_from_png(char *filename, FloatImg *fimg)
|
int fimg_create_from_png(char *filename, FloatImg *fimg)
|
||||||
{
|
{
|
||||||
@@ -26,35 +34,36 @@ int datasize;
|
|||||||
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, filename, fimg);
|
fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, filename, fimg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* We MUST clear the fimg destination header first */
|
||||||
|
memset(fimg, 0, sizeof(FloatImg));
|
||||||
|
|
||||||
memset(&png, 0, sizeof(png_t));
|
memset(&png, 0, sizeof(png_t));
|
||||||
png_init(NULL, NULL); /* this is VITAL ! */
|
png_init(NULL, NULL); /* this is VITAL ! */
|
||||||
|
|
||||||
foo = png_open_file_read(&png, filename);
|
foo = png_open_file_read(&png, filename);
|
||||||
if (PNG_NO_ERROR != foo) {
|
if (PNG_NO_ERROR != foo) {
|
||||||
fprintf(stderr, "%s open_file '%s' -> %d\n", __func__, filename, foo);
|
fprintf(stderr, "%s :\n\topen_file '%s' = %d %s\n", __func__,
|
||||||
|
filename, foo, png_error_string(foo));
|
||||||
|
png_close_file(&png);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
#if DEBUG_LEVEL > 1
|
#if DEBUG_LEVEL > 1
|
||||||
fprintf(stderr, "%s opened\n", filename);
|
fprintf(stderr, "%s opened\n", filename);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
datasize = png.width * png.height * png.bpp;
|
if (verbosity) {
|
||||||
|
printf("----------- %s ---------\n", filename);
|
||||||
|
png_print_info(&png); puts("");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
if ( 3 != png.bpp ) {
|
if ( 3 != png.bpp ) {
|
||||||
fprintf(stderr, "format %d of '%s' not supported\n",
|
fprintf(stderr, "bpp format %d of '%s' not supported\n",
|
||||||
png.color_type, filename);
|
png.color_type, filename);
|
||||||
return -21;
|
return -21;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
datasize = png.width * png.height * png.bpp;
|
||||||
printf("\t%s is %d x %d\n", filename, png.width, png.height);
|
|
||||||
printf("\tdatalen %d\n", png.png_datalen);
|
|
||||||
printf("\tcolor type %d\n", png.color_type);
|
|
||||||
printf("\tbyte/pixel %d\n", png.bpp);
|
|
||||||
printf("\tdatasize %d\n", datasize);
|
|
||||||
puts(""); png_print_info(&png); puts("");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
datas = malloc(datasize);
|
datas = malloc(datasize);
|
||||||
if (NULL==datas) {
|
if (NULL==datas) {
|
||||||
fprintf(stderr, "%s : fatal memory failure\n", __func__);
|
fprintf(stderr, "%s : fatal memory failure\n", __func__);
|
||||||
@@ -68,15 +77,17 @@ if (foo) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* I GET AN 'Unknown file error' HERE, WHY ???*/
|
||||||
foo = png_get_data(&png, datas);
|
foo = png_get_data(&png, datas);
|
||||||
if (PNG_NO_ERROR != foo) {
|
if (PNG_NO_ERROR != foo) {
|
||||||
fprintf(stderr, "error in '%s' : read png -> %d\n",
|
fprintf(stderr, "err in '%s:%s' :\n\tpng_get_data -> %d = %s\n\n",
|
||||||
__func__, foo);
|
__FILE__, __func__, foo, png_error_string(foo));
|
||||||
|
png_close_file(&png);
|
||||||
return foo;
|
return 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++;
|
||||||
@@ -121,12 +132,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
datasize = png.width * png.height * png.bpp;
|
datasize = png.width * png.height * png.bpp;
|
||||||
datas = malloc(datasize);
|
datas = malloc(datasize);
|
||||||
if (NULL==datas) {
|
if (NULL==datas) {
|
||||||
fprintf(stderr, "%s : fatal memory failure\n", __func__);
|
fprintf(stderr, "%s : fatal memory failure\n", __func__);
|
||||||
@@ -138,8 +149,9 @@ if (PNG_NO_ERROR != foo) {
|
|||||||
__func__, foo);
|
__func__, foo);
|
||||||
return foo;
|
return 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++;
|
||||||
@@ -150,13 +162,64 @@ png_close_file(&png);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau 13 decembre 2019 */
|
||||||
int fimg_save_as_png(FloatImg *src, char *outname, int flags)
|
int fimg_save_as_png(FloatImg *src, char *outname, int flags)
|
||||||
{
|
{
|
||||||
png_t png;
|
png_t png;
|
||||||
|
int foo, sz, idx;
|
||||||
|
unsigned char *bytes, *bptr;
|
||||||
|
double maximum, fk;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' 0x%x )\n", __func__, src, outname, flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (flags) {
|
||||||
|
fprintf(stderr, "*** in %s, flags are %08x\n", __func__, flags);
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
/* convert ou floating datas to a byte/rgb array */
|
||||||
|
/* first, alloc a buffer */
|
||||||
|
sz = src->width * src->height;
|
||||||
|
bytes = calloc(sz, 3);
|
||||||
|
if (NULL==bytes) {
|
||||||
|
fprintf(stderr, "%s : no mem ?\n", __func__);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
/* compute max value */
|
||||||
|
maximum = (double)fimg_get_maxvalue(src);
|
||||||
|
fk = maximum / 255.0;
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf(stderr, "%s: max val %g fk %g\n", __func__, maximum, fk);
|
||||||
|
/* massage des pixels */
|
||||||
|
bptr = bytes;
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
*bptr++ = (unsigned char) (src->R[idx] / fk);
|
||||||
|
*bptr++ = (unsigned char) (src->G[idx] / fk);
|
||||||
|
*bptr++ = (unsigned char) (src->B[idx] / fk);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&png, 0, sizeof(png_t));
|
||||||
|
png_init(NULL, NULL); /* this is VITAL ! */
|
||||||
|
|
||||||
|
foo = png_open_file_write(&png, outname);
|
||||||
|
if (PNG_NO_ERROR != foo) {
|
||||||
|
fprintf(stderr, "error in '%s' : open_file_write -> %d\n",
|
||||||
|
__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = png_set_data(&png, src->width, src->height, 8, PNG_TRUECOLOR, bytes);
|
||||||
|
if (PNG_NO_ERROR != foo) {
|
||||||
|
fprintf(stderr, "error in '%s' : set_data -> %d\n",
|
||||||
|
__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_close_file(&png);
|
||||||
|
|
||||||
|
free(bytes); /* yolo ? */
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -4,9 +4,91 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <tiffio.h>
|
||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags)
|
||||||
|
{
|
||||||
|
TIFF *tiff;
|
||||||
|
unsigned short *linebuff, *ptr;
|
||||||
|
int x, y, idx, foo;
|
||||||
|
char ligne[100];
|
||||||
|
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 ! */
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != src->type) {
|
||||||
|
fprintf(stderr, "%s: src bad type %d\n", __func__, src->type);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
linebuff = calloc(src->width, 3*sizeof(unsigned short));
|
||||||
|
if (NULL==linebuff) {
|
||||||
|
fprintf(stderr, "%s: fatal memory error\n", __func__);
|
||||||
|
return -7;
|
||||||
|
}
|
||||||
|
|
||||||
|
maximum = (double)fimg_get_maxvalue(src);
|
||||||
|
fk = maximum / 65535.0;
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "%s : maxv %f fk %f\n", __func__, maximum, fk);
|
||||||
|
}
|
||||||
|
|
||||||
|
tiff = TIFFOpen(fname, "w");
|
||||||
|
if (NULL==tiff) {
|
||||||
|
fprintf(stderr, "erreur TIFFOpen\n");
|
||||||
|
free(linebuff);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, src->width);
|
||||||
|
TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, src->height);
|
||||||
|
|
||||||
|
TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3); // RGB
|
||||||
|
TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 16); // 0->65535
|
||||||
|
|
||||||
|
TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||||
|
TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||||
|
|
||||||
|
sprintf(ligne, "lib FloatImg v %d by tTh", FIMG_VERSION);
|
||||||
|
TIFFSetField(tiff, TIFFTAG_SOFTWARE, ligne);
|
||||||
|
|
||||||
|
foo = src->width * 3;
|
||||||
|
foo = TIFFDefaultStripSize(tiff, foo);
|
||||||
|
if (verbosity) fprintf(stderr, "default strip size %d\n", foo);
|
||||||
|
|
||||||
|
TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, foo);
|
||||||
|
|
||||||
|
for (y=0; y<src->height; y++) {
|
||||||
|
ptr = linebuff;
|
||||||
|
idx = y * src->width;
|
||||||
|
|
||||||
|
for (x=0; x<src->width; x++) {
|
||||||
|
*ptr++ = (unsigned short) (src->R[idx] / fk);
|
||||||
|
*ptr++ = (unsigned short) (src->G[idx] / fk);
|
||||||
|
*ptr++ = (unsigned short) (src->B[idx] / fk);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
TIFFWriteScanline(tiff, linebuff, y, 0);
|
||||||
|
idx += src->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
TIFFClose(tiff);
|
||||||
|
|
||||||
|
free(linebuff);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|||||||
89
funcs/fmorpho.c
Normal file
89
funcs/fmorpho.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- !*/
|
||||||
196
funcs/geometry.c
Normal file
196
funcs/geometry.c
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* distorsions géométriques - coredumping ?
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* really crude function, need more work...
|
||||||
|
*/
|
||||||
|
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused)
|
||||||
|
{
|
||||||
|
int wd, hd;
|
||||||
|
int foo, x, y;
|
||||||
|
float pixel[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||||
|
src, dst, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
|
||||||
|
|
||||||
|
/* no magic check here ? */
|
||||||
|
if (dst->width || dst->height) {
|
||||||
|
fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst);
|
||||||
|
fimg_describe(dst, "destination halfsize 0");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
wd = src->width / 2; hd = src->height / 2;
|
||||||
|
foo = fimg_create(dst, wd, hd, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err create %d\n", __func__, foo);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y=0; y<hd; y++) {
|
||||||
|
for (x=0; x<wd; x++) {
|
||||||
|
foo = fimg_get_rgb(src, x*2, y*2, pixel);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err get %d\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
foo = fimg_plot_rgb(dst, x, y, pixel[0], pixel[1], pixel[2]);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err plot %d\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused)
|
||||||
|
{
|
||||||
|
int wd, hd;
|
||||||
|
int foo, x, y, x2, y2;
|
||||||
|
float ac;
|
||||||
|
|
||||||
|
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
|
||||||
|
|
||||||
|
if (dst->width || dst->height) {
|
||||||
|
fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst);
|
||||||
|
fimg_describe(dst, "destination halfsize 1");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
wd = src->width / 2; hd = src->height / 2;
|
||||||
|
if ( (foo = fimg_create(dst, wd, hd, FIMG_TYPE_RGB)) ) {
|
||||||
|
fprintf(stderr, "%s: err create %d\n", __func__, foo);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define WS (src->width)
|
||||||
|
#define WD (dst->width)
|
||||||
|
|
||||||
|
for (y=0; y<hd; y++) {
|
||||||
|
y2 = y * 2;
|
||||||
|
for (x=0; x<wd; x++) {
|
||||||
|
x2 = x * 2;
|
||||||
|
|
||||||
|
ac = src->R[(y2*WS)+x2] + src->R[(y2*WS)+x2+1] +
|
||||||
|
src->R[((1+y2)*WS)+x2] + src->R[((1+y2)*WS)+x2+1];
|
||||||
|
dst->R[y*WD +x] = ac / 4.0;
|
||||||
|
|
||||||
|
ac = src->G[(y2*WS)+x2] + src->G[(y2*WS)+x2+1] +
|
||||||
|
src->G[((1+y2)*WS)+x2] + src->G[((1+y2)*WS)+x2+1];
|
||||||
|
dst->G[y*WD +x] = ac / 4.0;
|
||||||
|
|
||||||
|
ac = src->B[(y2*WS)+x2] + src->B[(y2*WS)+x2+1] +
|
||||||
|
src->B[((1+y2)*WS)+x2] + src->B[((1+y2)*WS)+x2+1];
|
||||||
|
dst->B[y*WD +x] = ac / 4.0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef WS
|
||||||
|
#undef WD
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* this function can be optimized with direct pixel copy
|
||||||
|
*/
|
||||||
|
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect)
|
||||||
|
{
|
||||||
|
int xs, ys, xd, yd;
|
||||||
|
int count;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, in, out, rect);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fimg_describe(in, "extractor: source");
|
||||||
|
fimg_describe(out, "extractor: destination");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* some sanity controls, please ! XXX
|
||||||
|
*/
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity > 1) fprintf(stderr, "%s: %d pix moved\n", __func__, count);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* ho, btw, you can have a locck at 'incrustator.c' :) */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused)
|
||||||
|
{
|
||||||
|
float *fptr;
|
||||||
|
int line, col, offl;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__,
|
||||||
|
src, dst, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
|
||||||
|
|
||||||
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
|
fprintf(stderr, "bad karma in %s\n", __func__);
|
||||||
|
return -9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == (fptr=alloca(src->width*sizeof(float)))) {
|
||||||
|
fprintf(stderr, "%s: no mem available\n", __func__);
|
||||||
|
#if MUST_ABORT
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
return -11;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (line=0; line<src->height; line++) {
|
||||||
|
offl = line * src->width;
|
||||||
|
for (col=0; col<src->width; col++)
|
||||||
|
fptr[(src->width-1) - col] = src->R[offl+col];
|
||||||
|
memcpy(dst->R+offl, fptr, src->width*sizeof(float));
|
||||||
|
for (col=0; col<src->width; col++)
|
||||||
|
fptr[(src->width-1) - col] = src->G[offl+col];
|
||||||
|
memcpy(dst->G+offl, fptr, src->width*sizeof(float));
|
||||||
|
for (col=0; col<src->width; col++)
|
||||||
|
fptr[(src->width-1) - col] = src->B[offl+col];
|
||||||
|
memcpy(dst->B+offl, fptr, src->width*sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
96
funcs/histogram.c
Normal file
96
funcs/histogram.c
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* calculer un histogramme et l'afficher
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_calcul_histo(FloatImg *src, long *ghist, int sz)
|
||||||
|
{
|
||||||
|
float maxval;
|
||||||
|
int x, y, idx;
|
||||||
|
float rgb[3], moy;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, ghist, sz);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != src->type) {
|
||||||
|
fprintf(stderr, "%s: bad type %d of image\n", __func__, src->type);
|
||||||
|
return -97;
|
||||||
|
}
|
||||||
|
|
||||||
|
maxval = fimg_get_maxvalue(src);
|
||||||
|
|
||||||
|
fprintf(stderr, "maximum is %f\n", maxval);
|
||||||
|
|
||||||
|
for (y=0; y<src->height; y++) {
|
||||||
|
for(x=0; x<src->width; x++) {
|
||||||
|
fimg_get_rgb(src, x, y, rgb);
|
||||||
|
moy = (rgb[0]+rgb[1]+rgb[2]) / 3.0;
|
||||||
|
|
||||||
|
/* ok, here the had math part ... */
|
||||||
|
idx = (int)( (moy*sz) / maxval);
|
||||||
|
|
||||||
|
/* sanity check */
|
||||||
|
if (idx<0 || idx>=sz) {
|
||||||
|
fprintf(stderr, "idx = %d, error\n", idx);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
ghist[idx]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -66;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int fimg_essai_histo(FloatImg *src, char *outpic, int nbslices)
|
||||||
|
{
|
||||||
|
long *histo;
|
||||||
|
int foo;
|
||||||
|
FILE *pipe;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outpic, nbslices);
|
||||||
|
|
||||||
|
if (NULL==(histo=calloc(nbslices, sizeof(long)))) {
|
||||||
|
fprintf(stderr, "OUT OF MEMORY\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_calcul_histo(src, histo, nbslices);
|
||||||
|
|
||||||
|
// for (foo=0; foo<NSLICES; foo++) {
|
||||||
|
// printf("%7d %ld\n", foo, histo[foo]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
pipe = popen("gnuplot", "w");
|
||||||
|
if (NULL==pipe) {
|
||||||
|
fprintf(stderr, "%s: error running gnuplot\n", __func__);
|
||||||
|
return -17;
|
||||||
|
}
|
||||||
|
fprintf(pipe, "set term png size 1024,512\n");
|
||||||
|
fprintf(pipe, "set grid\n");
|
||||||
|
fprintf(pipe, "set output \"%s\"\n", outpic);
|
||||||
|
fprintf(pipe, "plot '/dev/stdin' with lines\n");
|
||||||
|
|
||||||
|
for (foo=0; foo<nbslices; foo++) {
|
||||||
|
fprintf(pipe, "%d %ld\n", foo, histo[foo]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pclose(pipe); // and not fclose (see man page)
|
||||||
|
|
||||||
|
free(histo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
171
funcs/hsv.c
Normal file
171
funcs/hsv.c
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* FloatImg library
|
||||||
|
* HUE - SATURATION - VALUE
|
||||||
|
|
||||||
|
+---------------------------------------------+
|
||||||
|
| ce code ne fonctionne vraiment PAS ! |
|
||||||
|
+---------------------------------------------+
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/*
|
||||||
|
https://baillehachepascal.dev/2021/rgb_hsv.php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* helper functions */
|
||||||
|
static float maxi3f(float a, float b, float c)
|
||||||
|
{
|
||||||
|
return ((a > b)? (a > c ? a : c) : (b > c ? b : c));
|
||||||
|
}
|
||||||
|
static float mini3f(float a, float b, float c)
|
||||||
|
{
|
||||||
|
return ((a < b)? (a < c ? a : c) : (b < c ? b : c));
|
||||||
|
}
|
||||||
|
static int pseudoeq(float a, float b)
|
||||||
|
{
|
||||||
|
return (fabsf(a-b)<0.00000001); // UGLY HACK ???
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* WARNING : ALL THIS CODE IS STRANGE
|
||||||
|
*
|
||||||
|
|
||||||
|
www.tutorialspoint.com/c-program-to-change-rgb-color-model-to-hsv-color-model
|
||||||
|
|
||||||
|
*/
|
||||||
|
int fimg_rgb2hsv(float rgb[3], float hsv[3], float scale)
|
||||||
|
{
|
||||||
|
// float h, s, v;
|
||||||
|
float cmin, cmax, diff;
|
||||||
|
|
||||||
|
// scale input value to [0..1]
|
||||||
|
rgb[0] /= scale; rgb[1] /= scale; rgb[2] /= scale;
|
||||||
|
|
||||||
|
hsv[0] = hsv[1] = hsv[2] = -12345.6789;
|
||||||
|
|
||||||
|
cmin = mini3f(rgb[0], rgb[1], rgb[2]);
|
||||||
|
cmax = maxi3f(rgb[0], rgb[1], rgb[2]);
|
||||||
|
diff = cmax - cmin;
|
||||||
|
|
||||||
|
if (pseudoeq(cmax, cmin)) hsv[0] = 0.0;
|
||||||
|
else if (pseudoeq(cmax, rgb[0]))
|
||||||
|
hsv[0] = fmod((60 * ((rgb[1] - rgb[2]) / diff) + 360), 360.0);
|
||||||
|
else if (pseudoeq(cmax, rgb[1]))
|
||||||
|
hsv[0] = fmod((60 * ((rgb[2] - rgb[0]) / diff) + 120), 360.0);
|
||||||
|
else if (pseudoeq(cmax, rgb[2]))
|
||||||
|
hsv[0] = fmod((60 * ((rgb[0] - rgb[1]) / diff) + 240), 360.0);
|
||||||
|
|
||||||
|
if (pseudoeq(cmax, 0.0)) hsv[1] = 0.0;
|
||||||
|
else hsv[1] = (diff / cmax) / 100.0;
|
||||||
|
|
||||||
|
hsv[2] = cmax * 100.0; /* WHAT THE FUCK ? */
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "cmin/cmax %f %f\n", cmin, cmax);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_hsv2rgb(float hsv[3], float rgb[3], float scale)
|
||||||
|
{
|
||||||
|
float hh, ff, p, q, t;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
if(hsv[1] <= 0.0) { // < is bogus, just shuts up warnings
|
||||||
|
rgb[0] = rgb[1] = rgb[2] = (hsv[2] * scale);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hh = hsv[0];
|
||||||
|
if(hh >= 360.0) hh = 0.0;
|
||||||
|
hh /= 60.0;
|
||||||
|
i = (long)hh;
|
||||||
|
ff = hh - i;
|
||||||
|
p = hsv[2] * (1.0 - hsv[1]);
|
||||||
|
q = hsv[2] * (1.0 - (hsv[1] * ff));
|
||||||
|
t = hsv[2] * (1.0 - (hsv[1] * (1.0 - ff)));
|
||||||
|
|
||||||
|
switch(i) {
|
||||||
|
case 0:
|
||||||
|
rgb[0] = hsv[2]; rgb[1] = t; rgb[2] = p;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
rgb[0] = q; rgb[1] = hsv[2]; rgb[2] = p;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
rgb[0] = p; rgb[1] = hsv[2]; rgb[2] = t;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
rgb[0] = p; rgb[1] = q; rgb[2] = hsv[2];
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
rgb[0] = t; rgb[1] = p; rgb[2] = hsv[2];
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
default:
|
||||||
|
rgb[0] = hsv[2]; rgb[1] = p; rgb[2] = q;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* expect garbage !
|
||||||
|
*/
|
||||||
|
int fimg_essai_hsv(char *fname)
|
||||||
|
{
|
||||||
|
float colors[3], values[3], newcols[3];
|
||||||
|
int foo, r, g, b;
|
||||||
|
|
||||||
|
fprintf(stderr, "%s NOT writing to %s\n", __func__, fname);
|
||||||
|
|
||||||
|
#define INC 16
|
||||||
|
|
||||||
|
for (r=0; r<255; r+=INC) {
|
||||||
|
for (g=0; g<255; g+=INC) {
|
||||||
|
for (b=0; b<255; b+=INC) {
|
||||||
|
|
||||||
|
printf("%4d %4d %4d ", r, g, b);
|
||||||
|
|
||||||
|
colors[0] = (float)r;
|
||||||
|
colors[1] = (float)g;
|
||||||
|
colors[2] = (float)b;
|
||||||
|
foo = fimg_rgb2hsv(colors, values, 255.0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d in rgv->hsv\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" %8.4f %8.4f %8.4f ",
|
||||||
|
values[0], values[1], values[2]);
|
||||||
|
|
||||||
|
foo = fimg_hsv2rgb(values, newcols, 255.0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d in hsv->rgb\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" %8.4f %8.4f %8.4f\n",
|
||||||
|
newcols[0], newcols[1], newcols[2]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
108
funcs/incrustator.c
Normal file
108
funcs/incrustator.c
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* incrustator VERY experimental
|
||||||
|
* KRKRK
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
// XXX #include "incrustator.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
static int check_boundaries(FloatImg *from, FloatImg *to, FimgArea51 *a51)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, from, to, a51);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fimg_printdims("from", from);
|
||||||
|
fimg_printdims("to ", to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* just a small molly-guard */
|
||||||
|
if ( (a51->w < 0) || (a51->h < 0) ) {
|
||||||
|
fprintf(stderr, "%s: fubar on %p\n", __func__, a51);
|
||||||
|
abort(); /* FY Bro ! */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/* XXX
|
||||||
|
static int move_pixels(FloatImg *from, FloatImg *to,
|
||||||
|
FimgArea51 *a51, int flags)
|
||||||
|
{
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %p 0x%04x )\n", __func__,
|
||||||
|
from, to, a51, flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* See also: fimg_extractor() in geometry.c
|
||||||
|
*/
|
||||||
|
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
||||||
|
int xpos, int ypos, int flags)
|
||||||
|
{
|
||||||
|
int y, srcpos, dstpos, szl;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
FimgArea51 area;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d %d 0x%04X\n", __func__, psrc, pdst,
|
||||||
|
xpos, ypos, flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
|
||||||
|
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fimg_describe(psrc, "source");
|
||||||
|
fimg_describe(pdst, "destination");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check boudaries */
|
||||||
|
area.x = xpos; area.y = ypos;
|
||||||
|
area.w = psrc->width; area.h = psrc->height;
|
||||||
|
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) ||
|
||||||
|
(ypos < 0) || (ypos > pdst->height - psrc->height) ) {
|
||||||
|
fprintf(stderr, "%s: boudary error, x=%d y=%d\n", __func__,
|
||||||
|
xpos, ypos);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* move all the data by looping over lines */
|
||||||
|
srcpos = 0;
|
||||||
|
dstpos = (ypos * pdst->width) + xpos;
|
||||||
|
szl = psrc->width * sizeof(float);
|
||||||
|
for (y=0; y<psrc->height; y++) {
|
||||||
|
// fprintf(stderr, " %7d %7d %7d\n", y, srcpos, dstpos);
|
||||||
|
|
||||||
|
memcpy(pdst->R + dstpos, psrc->R + srcpos, szl);
|
||||||
|
memcpy(pdst->G + dstpos, psrc->G + srcpos, szl);
|
||||||
|
memcpy(pdst->B + dstpos, psrc->B + srcpos, szl);
|
||||||
|
|
||||||
|
srcpos += psrc->width;
|
||||||
|
dstpos += pdst->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
45
funcs/killrgb.c
Normal file
45
funcs/killrgb.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
@@ -1,16 +1,96 @@
|
|||||||
/*
|
/*
|
||||||
testing some random funcs.
|
* This is an eternal WIP, sorry...
|
||||||
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#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 nio;
|
||||||
|
int x, y, k;
|
||||||
|
float fr, fg, fb, val;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d %g )\n", __func__, fimg, type, dval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fimg->type != FIMG_TYPE_RGB) {
|
||||||
|
fprintf(stderr, "%s need an rgb pic\n", __func__);
|
||||||
|
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 */
|
||||||
|
val = (float)dval;
|
||||||
|
for (x=0; x<fimg->width; x++) {
|
||||||
|
nio = x / (fimg->width / 8);
|
||||||
|
switch(nio) {
|
||||||
|
case 0: fr = 0.0, fg = 0.0, fb = 0.0; break;
|
||||||
|
case 1: fr = val, fg = 0.0, fb = 0.0; break;
|
||||||
|
case 2: fr = 0.0, fg = val, fb = 0.0; break;
|
||||||
|
case 3: fr = val, fg = val, fb = 0.0; break;
|
||||||
|
case 4: fr = 0.0, fg = 0.0, fb = val; break;
|
||||||
|
case 5: fr = val, fg = 0.0, fb = val; break;
|
||||||
|
case 6: fr = 0.0, fg = val, fb = val; break;
|
||||||
|
case 7: fr = val, fg = val, fb = val; break;
|
||||||
|
default:
|
||||||
|
abort(); break;
|
||||||
|
}
|
||||||
|
for (y=0; y<fimg->height/4; y++)
|
||||||
|
fimg_plot_rgb(fimg, x, y, fr, fg, fb);
|
||||||
|
}
|
||||||
|
|
||||||
|
k = (fimg->height / 4) + 20;
|
||||||
|
for (x=0; x<fimg->width; x++) {
|
||||||
|
val = ((double)x / (double)fimg->width) * dval;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
int fimg_draw_something(FloatImg *fimg)
|
int fimg_draw_something(FloatImg *fimg)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
@@ -32,21 +112,39 @@ for (y=1; y<fimg->height; y++) {
|
|||||||
fx = (float)x / (float)fimg->width;
|
fx = (float)x / (float)fimg->width;
|
||||||
fimg_plot_rgb(fimg, x, y,
|
fimg_plot_rgb(fimg, x, y,
|
||||||
M*(cos(fx*K)+1.2),
|
M*(cos(fx*K)+1.2),
|
||||||
M*(cos(fy*K)+1.2),
|
M*(sin(fy*K)+1.4),
|
||||||
M*(cos(fx*fy)+1.2));
|
M*(cos(fx*fy)+1.6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int fimg_multirandom(FloatImg *fimg)
|
int fimg_mircol_1(FloatImg *dst, float mval)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
float fx, fy, rgb[3];
|
||||||
|
|
||||||
|
for (y=0; y<dst->height; y++) {
|
||||||
|
fy = (float)y / (float)dst->height;
|
||||||
|
for (x=0; x<dst->width; x++) {
|
||||||
|
fx = (float)x / (float)dst->width;
|
||||||
|
rgb[0] = mval * fx;
|
||||||
|
rgb[1] = mval * ((fx+fy)/2.0);
|
||||||
|
rgb[2] = mval * fy;
|
||||||
|
fimg_put_rgb(dst, x, y, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_multirandom(FloatImg *fimg, long nbpass)
|
||||||
{
|
{
|
||||||
int foo, x, y;
|
int foo, x, y;
|
||||||
|
|
||||||
#define RI ( (rand()/7) + (rand()/9) )
|
#define RI ( (rand()/7) + (rand()/9) )
|
||||||
#define RD ( (drand48()/7) + (drand48()/7) )
|
#define RD ( (drand48()/7) + (drand48()/7) )
|
||||||
|
|
||||||
for (foo=0; foo<100000000; foo++)
|
for (foo=0; foo<nbpass; foo++)
|
||||||
{
|
{
|
||||||
x = RI % fimg->width;
|
x = RI % fimg->width;
|
||||||
y = RI % fimg->height;
|
y = RI % fimg->height;
|
||||||
|
|||||||
101
funcs/pixelize.c
Normal file
101
funcs/pixelize.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
43
funcs/plasmas.c
Normal file
43
funcs/plasmas.c
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
PLASMAS
|
||||||
|
|
||||||
|
Inspiration Reep : https://blog.314r.net/2021/01/10/plasma/
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_prototype_plasma(FloatImg *img, double time, int type)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
float rgb[3];
|
||||||
|
double dx, dy;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p %.3f %d )\n", __func__,
|
||||||
|
img, time, type);
|
||||||
|
|
||||||
|
for (y=0; y<img->height; y++) {
|
||||||
|
dy = ((double)y/(double)img->height) - 0.5000;
|
||||||
|
|
||||||
|
for (x=0; x<img->width; x++) {
|
||||||
|
dx = ((double)x/(double)img->width) - 0.5000;
|
||||||
|
|
||||||
|
rgb[0] = sin(dx*10 + time + dy) + 1.0;
|
||||||
|
rgb[1] = sin(dx*12 + time + dy) + 1.0;
|
||||||
|
rgb[2] = sin(dx*14 + time + dy) + 1.0;
|
||||||
|
fimg_put_rgb(img, x, y, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
133
funcs/qsortrgb.c
Normal file
133
funcs/qsortrgb.c
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* qsort_rgb.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau 7 octobre 2020, juste avant sonoptic de la pluie craignos */
|
||||||
|
|
||||||
|
static int compare_a(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
return ( *(float *)p1 < *(float *)p2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused)
|
||||||
|
{
|
||||||
|
int foo, szimg;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (notused) { fprintf(stderr, "%s notused != 0, WTF ?\n", __func__); }
|
||||||
|
|
||||||
|
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, pdst)) {
|
||||||
|
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (psrc != pdst) { /* optimize or futurbug ? */
|
||||||
|
foo = fimg_copy_data(psrc, pdst);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d on copy data\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
szimg = pdst->width * pdst->height;
|
||||||
|
// fprintf(stderr, "%s : %d pixels\n", __func__, szimg);
|
||||||
|
|
||||||
|
qsort(pdst->R, szimg, sizeof(float), compare_a);
|
||||||
|
qsort(pdst->G, szimg, sizeof(float), compare_a);
|
||||||
|
qsort(pdst->B, szimg, sizeof(float), compare_a);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
typedef struct {
|
||||||
|
float sum;
|
||||||
|
float r, g, b;
|
||||||
|
} pix;
|
||||||
|
|
||||||
|
static int compare_b(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
pix *s1, *s2;
|
||||||
|
s1 = (pix *)p1;
|
||||||
|
s2 = (pix *)p2;
|
||||||
|
return ( s1->sum < s2->sum );
|
||||||
|
}
|
||||||
|
|
||||||
|
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused)
|
||||||
|
{
|
||||||
|
int x, y, szimg;
|
||||||
|
pix *ppix, *ptr;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (notused) { fprintf(stderr, "%s notused != 0, WTF ?\n", __func__); }
|
||||||
|
|
||||||
|
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, pdst)) {
|
||||||
|
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
szimg = pdst->width * pdst->height;
|
||||||
|
// fprintf(stderr, "%s : %d pixels\n", __func__, szimg);
|
||||||
|
|
||||||
|
ppix = calloc(szimg, sizeof(pix));
|
||||||
|
|
||||||
|
ptr = ppix; /* mobile pointer */
|
||||||
|
for (y=0; y<psrc->height; y++) {
|
||||||
|
for (x=0; x<psrc->width; x++) {
|
||||||
|
|
||||||
|
fimg_get_rgb(psrc, x, y, rgb);
|
||||||
|
|
||||||
|
ptr->sum = rgb[0] + rgb[1] + rgb[2];
|
||||||
|
ptr->r = rgb[0];
|
||||||
|
ptr->g = rgb[1];
|
||||||
|
ptr->b = rgb[2];
|
||||||
|
|
||||||
|
ptr++; /* next pixel */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort(ppix, szimg, sizeof(pix), compare_b);
|
||||||
|
|
||||||
|
ptr = ppix; /* mobile pointer */
|
||||||
|
for (y=0; y<psrc->height; y++) {
|
||||||
|
for (x=0; x<psrc->width; x++) {
|
||||||
|
|
||||||
|
rgb[0] = ptr->r;
|
||||||
|
rgb[1] = ptr->g;
|
||||||
|
rgb[2] = ptr->b;
|
||||||
|
fimg_put_rgb(pdst, x, y, rgb);
|
||||||
|
|
||||||
|
ptr++; /* next pixel */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(ppix);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
113
funcs/rampes.c
Normal file
113
funcs/rampes.c
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* rampes diverses, trucs etranges
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_hdeg_a(FloatImg *img, double dcoef)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
float value;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %f )\n", __func__, img, dcoef);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != img->type) {
|
||||||
|
fprintf(stderr, "%s bad type\n", __func__);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
for (x=0; x<img->width; x++) {
|
||||||
|
value = (float)x / (float)img->width;
|
||||||
|
value *= dcoef;
|
||||||
|
for (y=0; y<img->height; y++) {
|
||||||
|
fimg_plot_rgb(img, x, y, value, value, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* To have the black at the bottom, use a negative dcoef
|
||||||
|
*/
|
||||||
|
int fimg_vdeg_a(FloatImg *img, double dcoef)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
float value;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %f )\n", __func__, img, dcoef);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != img->type) {
|
||||||
|
fprintf(stderr, "%s bad type\n", __func__);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
for (x=0; x<img->width; x++) {
|
||||||
|
value = (float)x / (float)img->width;
|
||||||
|
value *= dcoef;
|
||||||
|
for (y=0; y<img->height; y++) {
|
||||||
|
fimg_plot_rgb(img, x, y, value, value, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
38
funcs/rectangle.c
Normal 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;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
46
funcs/recurse.c
Normal file
46
funcs/recurse.c
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
RECURSION 'QUADTREE' SUR LES IMAGES
|
||||||
|
-----------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* may be we need some private variables ? */
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* nouveau 29 avril 2021, pendant un autre masque-flamme coronavidique */
|
||||||
|
|
||||||
|
int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused);
|
||||||
|
#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__);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
76
funcs/rotate.c
Normal file
76
funcs/rotate.c
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* rotation matricielle des images
|
||||||
|
* #coronamaison Mon 23 Mar 2020 11:45:59 AM CET
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
int x, y, k;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||||
|
src, dst, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
|
||||||
|
|
||||||
|
if (src->type != FIMG_TYPE_RGB) {
|
||||||
|
fprintf(stderr, "%s: src type %d not valid\n", __func__,
|
||||||
|
src->type);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if dst pic is not allocated */
|
||||||
|
if ( 0 == (dst->type | dst->width | dst->height) ) {
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "in %s, %p is empty\n", __func__, dst);
|
||||||
|
#endif
|
||||||
|
/* OK allocate a new fpic */
|
||||||
|
foo = fimg_create(dst, src->height, src->width, src->type);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d create new pic\n", __func__, foo);
|
||||||
|
return -887;
|
||||||
|
}
|
||||||
|
// if (verbosity>1) fimg_describe(dst, "new pic");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if dst and src are conpatibles */
|
||||||
|
if ( (src->type != dst->type) ||
|
||||||
|
(src->width != dst->height) || (src->height != dst->width) ) {
|
||||||
|
fprintf(stderr, "%s: src & dst not compatibles\n", __func__);
|
||||||
|
return -888;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* THIS IS A CRUDE IMPLEMENTATION
|
||||||
|
*/
|
||||||
|
for (y=0; y<src->height; y++) {
|
||||||
|
for (x=0; x<src->width; x++) {
|
||||||
|
fimg_get_rgb(src, x, y, rgb);
|
||||||
|
// XXX ??? j = (dst->height - x) - 1;
|
||||||
|
k = (dst->width - y) - 1;
|
||||||
|
#if DEBUG_LEVEL > 1
|
||||||
|
fprintf(stderr, "%6d %6d\n", k, j);
|
||||||
|
#endif
|
||||||
|
fimg_put_rgb(dst, k, x, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we don't have any cleanup to make */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
111
funcs/saturation.c
Normal file
111
funcs/saturation.c
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* FloatImg library from tTh - really ugly code inside
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* global vars exported from main
|
||||||
|
*/
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* parameter mix is between 0.0 and 1.0 but other
|
||||||
|
* values give sometime good vibrations.
|
||||||
|
*/
|
||||||
|
int fimg_mix_rgb_gray(FloatImg *img, float mix)
|
||||||
|
{
|
||||||
|
int x, y, p;
|
||||||
|
float gr;
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != img->type) {
|
||||||
|
fprintf(stderr, "%s bad type\n", __func__);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y=0; y<img->height; y++) {
|
||||||
|
p = y * img->width; /* first pixel of the row */
|
||||||
|
for (x=0; x<img->width; x++) {
|
||||||
|
|
||||||
|
gr = (img->R[p] + img->G[p] + img->R[p]) / 3.0;
|
||||||
|
|
||||||
|
img->R[p] = ((gr * mix) + (img->R[p] * (1.0-mix))) / 2.0;
|
||||||
|
img->G[p] = ((gr * mix) + (img->G[p] * (1.0-mix))) / 2.0;
|
||||||
|
img->B[p] = ((gr * mix) + (img->B[p] * (1.0-mix))) / 2.0;
|
||||||
|
p++; /* next pixel in the row */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* The third parameter was a six value array with min and max
|
||||||
|
* values maybe computed by the 'fimg_get_minmax_rgb' function.
|
||||||
|
*/
|
||||||
|
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6])
|
||||||
|
{
|
||||||
|
int sz, idx;
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != s->type) {
|
||||||
|
fprintf(stderr, "%s bad type\n", __func__);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
sz = s->width * s->height;
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
d->R[idx] = s->R[idx] - coefs[0];
|
||||||
|
d->G[idx] = s->G[idx] - coefs[2];
|
||||||
|
d->B[idx] = s->B[idx] - coefs[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* I think that this function is fully buggy, and need
|
||||||
|
* more explanations.
|
||||||
|
*/
|
||||||
|
int fimg_auto_shift_to_zero(FloatImg *src, FloatImg *dst)
|
||||||
|
{
|
||||||
|
float coefs[6];
|
||||||
|
int foo;
|
||||||
|
float minima = 1e7; /* magic value ? */
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != src->type) {
|
||||||
|
fprintf(stderr, "%s: bad image type %d\n", __func__, src->type);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(src, coefs);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d get minmax\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* crude hack for now */
|
||||||
|
if (coefs[0] < minima) minima = coefs[0];
|
||||||
|
if (coefs[2] < minima) minima = coefs[2];
|
||||||
|
if (coefs[4] < minima) minima = coefs[4];
|
||||||
|
|
||||||
|
coefs[0] = coefs[2] = coefs[4] = minima;
|
||||||
|
|
||||||
|
foo = fimg_shift_to_zero(src, dst, coefs);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s WTF? %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
91
funcs/sfx0.c
Normal file
91
funcs/sfx0.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* effets spéciaux àlc sur les couleurs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* OMG ! a Color Graphic Adaptor emulator :)
|
||||||
|
*/
|
||||||
|
int fimg_killcolors_a(FloatImg *fimg, float fval)
|
||||||
|
{
|
||||||
|
int nbpix, foo;
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != fimg->type) {
|
||||||
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
||||||
|
fimg->type, fimg);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbpix = fimg->width * fimg->height;
|
||||||
|
for (foo=0; foo<nbpix; foo++) {
|
||||||
|
if ((fimg->R[foo]+fval) > fimg->G[foo])
|
||||||
|
fimg->B[foo] = fimg->R[foo];
|
||||||
|
else
|
||||||
|
fimg->B[foo] = fimg->G[foo];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* parameter fval is used for what ?
|
||||||
|
*/
|
||||||
|
int fimg_killcolors_b(FloatImg *fimg, float fval)
|
||||||
|
{
|
||||||
|
int nbpix, foo;
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != fimg->type) {
|
||||||
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
||||||
|
fimg->type, fimg);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbpix = fimg->width * fimg->height;
|
||||||
|
for (foo=0; foo<nbpix; foo++) {
|
||||||
|
if ((fimg->R[foo]+fval) > fimg->B[foo])
|
||||||
|
fimg->G[foo] = fimg->R[foo];
|
||||||
|
else
|
||||||
|
fimg->G[foo] = fimg->B[foo];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_colors_mixer_a(FloatImg *fimg, float fval)
|
||||||
|
{
|
||||||
|
int nbpix, foo;
|
||||||
|
float R, G, B;
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != fimg->type) {
|
||||||
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
||||||
|
fimg->type, fimg);
|
||||||
|
#if MUST_ABORT
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbpix = fimg->width * fimg->height;
|
||||||
|
|
||||||
|
for (foo=0; foo<nbpix; foo++) {
|
||||||
|
|
||||||
|
R = (fimg->G[foo] + fimg->B[foo]) / fval;
|
||||||
|
G = (fimg->R[foo] + fimg->B[foo]) / fval;
|
||||||
|
B = (fimg->R[foo] + fimg->G[foo]) / fval;
|
||||||
|
|
||||||
|
fimg->R[foo] = R;
|
||||||
|
fimg->G[foo] = G;
|
||||||
|
fimg->B[foo] = B;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
108
funcs/sfx1.c
Normal file
108
funcs/sfx1.c
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG - a kluge from tTh
|
||||||
|
* effets spéciaux bizarres sur les couleurs.
|
||||||
|
* nouveau pour un truc chelou avec Maëva
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
/* WARNING
|
||||||
|
some crapy code cuted & pasted here */
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
static void highlight_red(FloatImg *src, FloatImg *dst, float fval)
|
||||||
|
{
|
||||||
|
int sz, idx;
|
||||||
|
|
||||||
|
sz = src->width * src->height;
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
dst->G[idx] = src->G[idx];
|
||||||
|
dst->B[idx] = src->B[idx];
|
||||||
|
if ( (src->G[idx] < src->R[idx]) &&
|
||||||
|
(src->B[idx] < src->R[idx]) ) {
|
||||||
|
dst->R[idx] = src->R[idx] * fval;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dst->R[idx] = src->R[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
static void highlight_green(FloatImg *src, FloatImg *dst, float fval)
|
||||||
|
{
|
||||||
|
int sz, idx;
|
||||||
|
|
||||||
|
sz = src->width * src->height;
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
dst->R[idx] = src->R[idx];
|
||||||
|
dst->B[idx] = src->B[idx];
|
||||||
|
if ( (src->R[idx] < src->R[idx]) &&
|
||||||
|
(src->B[idx] < src->R[idx]) ) {
|
||||||
|
dst->G[idx] = src->G[idx] * fval;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dst->G[idx] = src->G[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
static void highlight_blue(FloatImg *src, FloatImg *dst, float fval)
|
||||||
|
{
|
||||||
|
int sz, idx;
|
||||||
|
|
||||||
|
sz = src->width * src->height;
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
dst->G[idx] = src->G[idx];
|
||||||
|
dst->R[idx] = src->R[idx];
|
||||||
|
if ( (src->G[idx] < src->B[idx]) &&
|
||||||
|
(src->R[idx] < src->B[idx]) ) {
|
||||||
|
dst->B[idx] = src->B[idx] * fval;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dst->B[idx] = src->B[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int fimg_highlight_color(FloatImg *src, FloatImg *dst, char color, float fval)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p [%c] %f )\n", __func__,
|
||||||
|
src, dst, color, fval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_RGB != src->type) {
|
||||||
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
||||||
|
src->type, src);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
|
fprintf(stderr, "oh fuck in %s\n", __func__);
|
||||||
|
return -9;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (color) {
|
||||||
|
|
||||||
|
case 'r': case 'R':
|
||||||
|
highlight_red(src, dst, fval); break;
|
||||||
|
case 'g': case 'G':
|
||||||
|
highlight_green(src, dst, fval); break;
|
||||||
|
case 'b': case 'B':
|
||||||
|
highlight_blue(src, dst, fval); break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s: '%c' is invalid\n", __func__, color);
|
||||||
|
return -11;
|
||||||
|
break; /* nottreached */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
109
funcs/sfx2.c
Normal file
109
funcs/sfx2.c
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG - a kluge from tTh
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* a place for moving here Fonderie effects
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int fimg_binarize(FloatImg *pimg, int notused)
|
||||||
|
{
|
||||||
|
float mm[6], mR, mG, mB;
|
||||||
|
int foo, size;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (notused) {
|
||||||
|
fprintf(stderr, "notused was %d, must be 0 in %s\n",
|
||||||
|
notused, __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(pimg, mm);
|
||||||
|
mR = (mm[1] - mm[0]) / 2.0;
|
||||||
|
mG = (mm[3] - mm[2]) / 2.0;
|
||||||
|
mB = (mm[5] - mm[4]) / 2.0;
|
||||||
|
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf(stderr, "%s: %f %f %f\n", __func__, mR, mG, mB);
|
||||||
|
|
||||||
|
size = pimg->width * pimg->height;
|
||||||
|
|
||||||
|
for (foo=0; foo<size; foo++) {
|
||||||
|
if (pimg->R[foo] < mR) pimg->R[foo] = mm[0];
|
||||||
|
else pimg->R[foo] = mm[1];
|
||||||
|
if (pimg->G[foo] < mG) pimg->G[foo] = mm[2];
|
||||||
|
else pimg->G[foo] = mm[3];
|
||||||
|
if (pimg->B[foo] < mB) pimg->B[foo] = mm[4];
|
||||||
|
else pimg->B[foo] = mm[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int fimg_trinarize(FloatImg *pimg, int notused)
|
||||||
|
{
|
||||||
|
float mm[6], mRa, mGa, mBa, mRb, mGb, mBb;
|
||||||
|
float *fptr;
|
||||||
|
int foo, size;
|
||||||
|
|
||||||
|
if (notused) {
|
||||||
|
fprintf(stderr, "notused was %d, must be 0 in %s\n",
|
||||||
|
notused, __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(pimg, mm);
|
||||||
|
mRa = (mm[1] - mm[0]) * 0.33333;
|
||||||
|
mGa = (mm[3] - mm[2]) * 0.33333;
|
||||||
|
mBa = (mm[5] - mm[4]) * 0.33333;
|
||||||
|
mRb = (mm[1] - mm[0]) * 0.66666;
|
||||||
|
mGb = (mm[3] - mm[2]) * 0.66666;
|
||||||
|
mBb = (mm[5] - mm[4]) * 0.66666;
|
||||||
|
|
||||||
|
size = pimg->width * pimg->height;
|
||||||
|
|
||||||
|
for (foo=0; foo<size; foo++) {
|
||||||
|
|
||||||
|
fptr = pimg->R;
|
||||||
|
if (fptr[foo] < mRa || fptr[foo] > mRb)
|
||||||
|
fptr[foo] = mm[0];
|
||||||
|
else
|
||||||
|
fptr[foo] = mm[1];
|
||||||
|
|
||||||
|
fptr = pimg->G;
|
||||||
|
if (fptr[foo] < mGa || fptr[foo] > mGb)
|
||||||
|
fptr[foo] = mm[2];
|
||||||
|
else
|
||||||
|
fptr[foo] = mm[3];
|
||||||
|
|
||||||
|
fptr = pimg->B;
|
||||||
|
if (fptr[foo] < mBa || fptr[foo] > mBb)
|
||||||
|
fptr[foo] = mm[4];
|
||||||
|
else
|
||||||
|
fptr[foo] = mm[5];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* ici, il manque le quaternize :)
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user