diff --git a/.gitignore b/.gitignore index b9feb24da4ec2e083f56dcdf04f68aca45397170..08d9c28304209a902e8afdd224cf640913be1fd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -/java_gui/dist/ -/java_gui/build/ \ No newline at end of file +java_gui/dist/ +java_gui/build/ +qt_gui/ +vs2013/ \ No newline at end of file diff --git a/fet/FG/1.png b/fet/FG/1.png new file mode 100644 index 0000000000000000000000000000000000000000..7499d7a739fa6a517b3f8f549743ecb39a6ad676 Binary files /dev/null and b/fet/FG/1.png differ diff --git a/fet/FG/10.png b/fet/FG/10.png new file mode 100644 index 0000000000000000000000000000000000000000..317b59aefc59b56711225e7911df4f4d8d97cc10 Binary files /dev/null and b/fet/FG/10.png differ diff --git a/fet/FG/11.png b/fet/FG/11.png new file mode 100644 index 0000000000000000000000000000000000000000..5e9516fc8b77f8a527240ad4cdd6e133d81f0845 Binary files /dev/null and b/fet/FG/11.png differ diff --git a/fet/FG/12.png b/fet/FG/12.png new file mode 100644 index 0000000000000000000000000000000000000000..ac37d7651e0357625a5886d1b5c13e914dcdd196 Binary files /dev/null and b/fet/FG/12.png differ diff --git a/fet/FG/13.png b/fet/FG/13.png new file mode 100644 index 0000000000000000000000000000000000000000..3341fa96267fe5acd232f06082b6a26d3efa2a97 Binary files /dev/null and b/fet/FG/13.png differ diff --git a/fet/FG/14.png b/fet/FG/14.png new file mode 100644 index 0000000000000000000000000000000000000000..b17ecc97430f40896e4e50b32d517d33f3eff479 Binary files /dev/null and b/fet/FG/14.png differ diff --git a/fet/FG/15.png b/fet/FG/15.png new file mode 100644 index 0000000000000000000000000000000000000000..6506cc3dd81982fbf7a038e50a7a25c8efe98e45 Binary files /dev/null and b/fet/FG/15.png differ diff --git a/fet/FG/16.png b/fet/FG/16.png new file mode 100644 index 0000000000000000000000000000000000000000..a843b346b6a94766cc759e6a0e0cf4ad1b4608de Binary files /dev/null and b/fet/FG/16.png differ diff --git a/fet/FG/17.png b/fet/FG/17.png new file mode 100644 index 0000000000000000000000000000000000000000..cd5d623f74b83ba9486700c1d932031263964480 Binary files /dev/null and b/fet/FG/17.png differ diff --git a/fet/FG/18.png b/fet/FG/18.png new file mode 100644 index 0000000000000000000000000000000000000000..14b1eb4b0368f6619d3abb5588a6f24a65123bb0 Binary files /dev/null and b/fet/FG/18.png differ diff --git a/fet/FG/19.png b/fet/FG/19.png new file mode 100644 index 0000000000000000000000000000000000000000..d7346727c029b8a6a778744860b55de3f639734e Binary files /dev/null and b/fet/FG/19.png differ diff --git a/fet/FG/2.png b/fet/FG/2.png new file mode 100644 index 0000000000000000000000000000000000000000..7c65d44657cdcb6d1cd3aec5867f36c828f9fec7 Binary files /dev/null and b/fet/FG/2.png differ diff --git a/fet/FG/20.png b/fet/FG/20.png new file mode 100644 index 0000000000000000000000000000000000000000..6696869a95b6a939eb8a2b91bf59d95f56db07a5 Binary files /dev/null and b/fet/FG/20.png differ diff --git a/fet/FG/21.png b/fet/FG/21.png new file mode 100644 index 0000000000000000000000000000000000000000..db96c493eb1866508e987d76abc221d867b40707 Binary files /dev/null and b/fet/FG/21.png differ diff --git a/fet/FG/22.png b/fet/FG/22.png new file mode 100644 index 0000000000000000000000000000000000000000..11d73c9a04a375ab209a760570025e0730ec1ae3 Binary files /dev/null and b/fet/FG/22.png differ diff --git a/fet/FG/23.png b/fet/FG/23.png new file mode 100644 index 0000000000000000000000000000000000000000..04b88253979f5a2687ba1c988a21bea1f90960b0 Binary files /dev/null and b/fet/FG/23.png differ diff --git a/fet/FG/24.png b/fet/FG/24.png new file mode 100644 index 0000000000000000000000000000000000000000..e7c22057bc7c53710fb159868064806e69c76bad Binary files /dev/null and b/fet/FG/24.png differ diff --git a/fet/FG/25.png b/fet/FG/25.png new file mode 100644 index 0000000000000000000000000000000000000000..4e172d9d04c589b58eebcdcf97bb12eed1b1f5db Binary files /dev/null and b/fet/FG/25.png differ diff --git a/fet/FG/26.png b/fet/FG/26.png new file mode 100644 index 0000000000000000000000000000000000000000..d9b7aeff0fa463b403c7b5168f775ba92b03a0f5 Binary files /dev/null and b/fet/FG/26.png differ diff --git a/fet/FG/27.png b/fet/FG/27.png new file mode 100644 index 0000000000000000000000000000000000000000..840771a14963203544dc46addb40aa9dbd28f730 Binary files /dev/null and b/fet/FG/27.png differ diff --git a/fet/FG/28.png b/fet/FG/28.png new file mode 100644 index 0000000000000000000000000000000000000000..dbe2e162bdf2d57627034bc0b77dfba497f5b345 Binary files /dev/null and b/fet/FG/28.png differ diff --git a/fet/FG/29.png b/fet/FG/29.png new file mode 100644 index 0000000000000000000000000000000000000000..54051fdbe7bf3462500535556060aafb60630c21 Binary files /dev/null and b/fet/FG/29.png differ diff --git a/fet/FG/3.png b/fet/FG/3.png new file mode 100644 index 0000000000000000000000000000000000000000..55b81b77322ace9ffd4e187b67bc8887c6298380 Binary files /dev/null and b/fet/FG/3.png differ diff --git a/fet/FG/30.png b/fet/FG/30.png new file mode 100644 index 0000000000000000000000000000000000000000..b7f758183638004960117baea94af4c95008a3f7 Binary files /dev/null and b/fet/FG/30.png differ diff --git a/fet/FG/31.png b/fet/FG/31.png new file mode 100644 index 0000000000000000000000000000000000000000..241a06e7e5be56e59ffb0edc0bde6f2980195fa7 Binary files /dev/null and b/fet/FG/31.png differ diff --git a/fet/FG/4.png b/fet/FG/4.png new file mode 100644 index 0000000000000000000000000000000000000000..749d99b730130cb6fdd135743ad24d43659ed73b Binary files /dev/null and b/fet/FG/4.png differ diff --git a/fet/FG/5.png b/fet/FG/5.png new file mode 100644 index 0000000000000000000000000000000000000000..f30bbdb9614fbad16f3fa5a46c509a4df0332fac Binary files /dev/null and b/fet/FG/5.png differ diff --git a/fet/FG/6.png b/fet/FG/6.png new file mode 100644 index 0000000000000000000000000000000000000000..743c6eae5efcd8c52808be5feee2fab5182caced Binary files /dev/null and b/fet/FG/6.png differ diff --git a/fet/FG/7.png b/fet/FG/7.png new file mode 100644 index 0000000000000000000000000000000000000000..431868a4ea0f0eabf1fd8e9677772a803e8536ad Binary files /dev/null and b/fet/FG/7.png differ diff --git a/fet/FG/8.png b/fet/FG/8.png new file mode 100644 index 0000000000000000000000000000000000000000..519e7c4861c87530f658f5e016d35931df04fa5f Binary files /dev/null and b/fet/FG/8.png differ diff --git a/fet/FG/9.png b/fet/FG/9.png new file mode 100644 index 0000000000000000000000000000000000000000..ce0f8b4675dfea0dea02941d4ed68a63916ae6a0 Binary files /dev/null and b/fet/FG/9.png differ diff --git a/fet/GT/1.png b/fet/GT/1.png new file mode 100644 index 0000000000000000000000000000000000000000..a83eed15797767b9ee132de9af5688eee1a6ac84 Binary files /dev/null and b/fet/GT/1.png differ diff --git a/fet/GT/10.png b/fet/GT/10.png new file mode 100644 index 0000000000000000000000000000000000000000..5c25f22009e6a8c9725ad61e6f13b635f5d734c7 Binary files /dev/null and b/fet/GT/10.png differ diff --git a/fet/GT/11.png b/fet/GT/11.png new file mode 100644 index 0000000000000000000000000000000000000000..d210aebc5fe56b1a03b55afa4d61fed7ae953996 Binary files /dev/null and b/fet/GT/11.png differ diff --git a/fet/GT/12.png b/fet/GT/12.png new file mode 100644 index 0000000000000000000000000000000000000000..502aaef6bc9b8785554e0d3a562db5c6960c8ba5 Binary files /dev/null and b/fet/GT/12.png differ diff --git a/fet/GT/13.png b/fet/GT/13.png new file mode 100644 index 0000000000000000000000000000000000000000..7c1f5b260833c32413460888a8fed8de0d7af06d Binary files /dev/null and b/fet/GT/13.png differ diff --git a/fet/GT/14.png b/fet/GT/14.png new file mode 100644 index 0000000000000000000000000000000000000000..0c5dc2985a71419db3fdd9193a9c2d73079812bf Binary files /dev/null and b/fet/GT/14.png differ diff --git a/fet/GT/15.png b/fet/GT/15.png new file mode 100644 index 0000000000000000000000000000000000000000..fee645236682e15c02a4d2b6866821adb8629421 Binary files /dev/null and b/fet/GT/15.png differ diff --git a/fet/GT/16.png b/fet/GT/16.png new file mode 100644 index 0000000000000000000000000000000000000000..5ea76253c9955537425b6bfd7d5824ecbce107d6 Binary files /dev/null and b/fet/GT/16.png differ diff --git a/fet/GT/17.png b/fet/GT/17.png new file mode 100644 index 0000000000000000000000000000000000000000..3c22afd786425862703f3424ceae1d7d77508eb6 Binary files /dev/null and b/fet/GT/17.png differ diff --git a/fet/GT/18.png b/fet/GT/18.png new file mode 100644 index 0000000000000000000000000000000000000000..bde26d9de58ed9749d97e83a5b0a1076f33b3225 Binary files /dev/null and b/fet/GT/18.png differ diff --git a/fet/GT/19.png b/fet/GT/19.png new file mode 100644 index 0000000000000000000000000000000000000000..8e9e67d0dff4c2c4fde9dbb89b9f73d1f37a0b3b Binary files /dev/null and b/fet/GT/19.png differ diff --git a/fet/GT/2.png b/fet/GT/2.png new file mode 100644 index 0000000000000000000000000000000000000000..1ee7984a68d412f6c8c5fa21cbe61d7f341c7fd3 Binary files /dev/null and b/fet/GT/2.png differ diff --git a/fet/GT/20.png b/fet/GT/20.png new file mode 100644 index 0000000000000000000000000000000000000000..755fe247e339f94e806aeba88099a189128f53a7 Binary files /dev/null and b/fet/GT/20.png differ diff --git a/fet/GT/21.png b/fet/GT/21.png new file mode 100644 index 0000000000000000000000000000000000000000..120c8dc76daebfb9ed74a84643b6cdaf78836fec Binary files /dev/null and b/fet/GT/21.png differ diff --git a/fet/GT/22.png b/fet/GT/22.png new file mode 100644 index 0000000000000000000000000000000000000000..712f86e56c4a664dc0d5813bc36924a94dd5000f Binary files /dev/null and b/fet/GT/22.png differ diff --git a/fet/GT/23.png b/fet/GT/23.png new file mode 100644 index 0000000000000000000000000000000000000000..ebebd5a7a9bc1e12fecdd82c14a7ba03e267d657 Binary files /dev/null and b/fet/GT/23.png differ diff --git a/fet/GT/24.png b/fet/GT/24.png new file mode 100644 index 0000000000000000000000000000000000000000..26524250a594a74d9405dbfa34e343939db9cd98 Binary files /dev/null and b/fet/GT/24.png differ diff --git a/fet/GT/25.png b/fet/GT/25.png new file mode 100644 index 0000000000000000000000000000000000000000..ed8b02f3c51cb6cdcc55ce3bd2c61914f697b313 Binary files /dev/null and b/fet/GT/25.png differ diff --git a/fet/GT/26.png b/fet/GT/26.png new file mode 100644 index 0000000000000000000000000000000000000000..e13e9cf59f0a3a03dc4b6d6c5b9f583feed9f1d8 Binary files /dev/null and b/fet/GT/26.png differ diff --git a/fet/GT/27.png b/fet/GT/27.png new file mode 100644 index 0000000000000000000000000000000000000000..197781212150908e9f19f9470be88a3e2bd34d5f Binary files /dev/null and b/fet/GT/27.png differ diff --git a/fet/GT/28.png b/fet/GT/28.png new file mode 100644 index 0000000000000000000000000000000000000000..635880bc8aa25b0034c0017762bd2bb50f5ed41d Binary files /dev/null and b/fet/GT/28.png differ diff --git a/fet/GT/29.png b/fet/GT/29.png new file mode 100644 index 0000000000000000000000000000000000000000..a87158cbbc8433e59d44fb7923dbed9743b2f2a1 Binary files /dev/null and b/fet/GT/29.png differ diff --git a/fet/GT/3.png b/fet/GT/3.png new file mode 100644 index 0000000000000000000000000000000000000000..1fe595d42efff60be54d5406429ab6bfb884361d Binary files /dev/null and b/fet/GT/3.png differ diff --git a/fet/GT/30.png b/fet/GT/30.png new file mode 100644 index 0000000000000000000000000000000000000000..e6f0275ad9a2126c398bf439a0665112b6b690af Binary files /dev/null and b/fet/GT/30.png differ diff --git a/fet/GT/31.png b/fet/GT/31.png new file mode 100644 index 0000000000000000000000000000000000000000..a072d7dfff52d5be0d1b4469b096412ccf7a93ad Binary files /dev/null and b/fet/GT/31.png differ diff --git a/fet/GT/4.png b/fet/GT/4.png new file mode 100644 index 0000000000000000000000000000000000000000..19a6e319a686dfdfac045b5fc7408fa306888656 Binary files /dev/null and b/fet/GT/4.png differ diff --git a/fet/GT/5.png b/fet/GT/5.png new file mode 100644 index 0000000000000000000000000000000000000000..365f8320811628b4d662515453b2e3d9661d06a6 Binary files /dev/null and b/fet/GT/5.png differ diff --git a/fet/GT/6.png b/fet/GT/6.png new file mode 100644 index 0000000000000000000000000000000000000000..6814ce19758e2ca538b8f0b73c8619c66c4251dc Binary files /dev/null and b/fet/GT/6.png differ diff --git a/fet/GT/7.png b/fet/GT/7.png new file mode 100644 index 0000000000000000000000000000000000000000..1746dca0e8bc810e49620e456e28de813bdf1b98 Binary files /dev/null and b/fet/GT/7.png differ diff --git a/fet/GT/8.png b/fet/GT/8.png new file mode 100644 index 0000000000000000000000000000000000000000..f96928492d1bccd80b35966b6850fed01aeb0211 Binary files /dev/null and b/fet/GT/8.png differ diff --git a/fet/GT/9.png b/fet/GT/9.png new file mode 100644 index 0000000000000000000000000000000000000000..3a818061e1795b8ad6a56443399865d342a439cc Binary files /dev/null and b/fet/GT/9.png differ diff --git a/fet/README.txt b/fet/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..157650e1bf5dcf68576408176abecb014d971c7f --- /dev/null +++ b/fet/README.txt @@ -0,0 +1,22 @@ +FET - FOREGROUND EVALUATION TOOL + +Implemented in Python 2.7 + +Available measurements +---------------------- + +TP - True positive: Total number of true positive pixels. +FP - False positive: Total number of false positive pixels. +TN - True negative: Total number of true negative pixels. +FN - False negative: Total number of false negative pixels. + +Precision: Number of true positive pixels / (number of true positive pixels + number of false positive pixels). +Recall: Number of true positive pixels / (number of true positive pixels + number of false negative pixels). +F-factor: 2 × (precision × recall)/(precision + recall). *** Also known as F1 score, F-score or F-measure. + +Description +----------- +# TP - # of foreground pixels classified as foreground pixels. +# FP - # of background pixels classified as foreground pixels. +# TN - # of background pixels classified as background pixels. +# FN - # of foreground pixels classified as background pixels. diff --git a/fet/SC/1.png b/fet/SC/1.png new file mode 100644 index 0000000000000000000000000000000000000000..cea30406d290611ecfa6746701149bdefaf9cd4f Binary files /dev/null and b/fet/SC/1.png differ diff --git a/fet/SC/10.png b/fet/SC/10.png new file mode 100644 index 0000000000000000000000000000000000000000..22d7c72c378097a88305a4eeab23714b9f1d937e Binary files /dev/null and b/fet/SC/10.png differ diff --git a/fet/SC/11.png b/fet/SC/11.png new file mode 100644 index 0000000000000000000000000000000000000000..5104848ac262eab52b6df7d603137a78c9be06de Binary files /dev/null and b/fet/SC/11.png differ diff --git a/fet/SC/12.png b/fet/SC/12.png new file mode 100644 index 0000000000000000000000000000000000000000..ece4867d6ae9233521914648edfb65be7bb75e82 Binary files /dev/null and b/fet/SC/12.png differ diff --git a/fet/SC/13.png b/fet/SC/13.png new file mode 100644 index 0000000000000000000000000000000000000000..4dd201a87f0fb417fae95a19c9e6ad5882c5f63b Binary files /dev/null and b/fet/SC/13.png differ diff --git a/fet/SC/14.png b/fet/SC/14.png new file mode 100644 index 0000000000000000000000000000000000000000..bdb4cb2e163bff222609898b6263a19d86386b30 Binary files /dev/null and b/fet/SC/14.png differ diff --git a/fet/SC/15.png b/fet/SC/15.png new file mode 100644 index 0000000000000000000000000000000000000000..cefdb6519e9d4a3adb662d954eadc584e30d709d Binary files /dev/null and b/fet/SC/15.png differ diff --git a/fet/SC/16.png b/fet/SC/16.png new file mode 100644 index 0000000000000000000000000000000000000000..7cf71a420fcb16a69f648d089c2b944615302895 Binary files /dev/null and b/fet/SC/16.png differ diff --git a/fet/SC/17.png b/fet/SC/17.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd022637506370e869f6820fcc62079a64caaf3 Binary files /dev/null and b/fet/SC/17.png differ diff --git a/fet/SC/18.png b/fet/SC/18.png new file mode 100644 index 0000000000000000000000000000000000000000..2dbebfd56438117f637461e67a0f7549dfb5ddd6 Binary files /dev/null and b/fet/SC/18.png differ diff --git a/fet/SC/19.png b/fet/SC/19.png new file mode 100644 index 0000000000000000000000000000000000000000..83610f680f067cdde1127e0ec393294e1ecc124a Binary files /dev/null and b/fet/SC/19.png differ diff --git a/fet/SC/2.png b/fet/SC/2.png new file mode 100644 index 0000000000000000000000000000000000000000..c4d1f65d8c7e60e273e7573b36d18d7b7866798e Binary files /dev/null and b/fet/SC/2.png differ diff --git a/fet/SC/20.png b/fet/SC/20.png new file mode 100644 index 0000000000000000000000000000000000000000..2d447e528c5a3b0f4df5546a4ab16c7782fd8e8b Binary files /dev/null and b/fet/SC/20.png differ diff --git a/fet/SC/21.png b/fet/SC/21.png new file mode 100644 index 0000000000000000000000000000000000000000..2104c0be9833b10e698a1db835c1373e24c1757f Binary files /dev/null and b/fet/SC/21.png differ diff --git a/fet/SC/22.png b/fet/SC/22.png new file mode 100644 index 0000000000000000000000000000000000000000..0e3245aaaf1ebf5e149a134a91e5321824c3ab4c Binary files /dev/null and b/fet/SC/22.png differ diff --git a/fet/SC/23.png b/fet/SC/23.png new file mode 100644 index 0000000000000000000000000000000000000000..5b7fd1d937cf761b97482ec13fe2738830afba46 Binary files /dev/null and b/fet/SC/23.png differ diff --git a/fet/SC/24.png b/fet/SC/24.png new file mode 100644 index 0000000000000000000000000000000000000000..e2f2bc7bf9360a6f9a64925c0e03f530786db9d5 Binary files /dev/null and b/fet/SC/24.png differ diff --git a/fet/SC/25.png b/fet/SC/25.png new file mode 100644 index 0000000000000000000000000000000000000000..baf5197938a10a4420ee989446654bf38a6a45fe Binary files /dev/null and b/fet/SC/25.png differ diff --git a/fet/SC/26.png b/fet/SC/26.png new file mode 100644 index 0000000000000000000000000000000000000000..70d79c77bd468a394c55127496798b03522244f8 Binary files /dev/null and b/fet/SC/26.png differ diff --git a/fet/SC/27.png b/fet/SC/27.png new file mode 100644 index 0000000000000000000000000000000000000000..6ef5a223b627fa4e4afa32918c5ecdc60cf9b76e Binary files /dev/null and b/fet/SC/27.png differ diff --git a/fet/SC/28.png b/fet/SC/28.png new file mode 100644 index 0000000000000000000000000000000000000000..cf9668d98dc6e4e02f0b3336f2b0a6f0fb01a2ca Binary files /dev/null and b/fet/SC/28.png differ diff --git a/fet/SC/29.png b/fet/SC/29.png new file mode 100644 index 0000000000000000000000000000000000000000..1e3a429eb7a3d379cddae2b46531c6a47c37798e Binary files /dev/null and b/fet/SC/29.png differ diff --git a/fet/SC/3.png b/fet/SC/3.png new file mode 100644 index 0000000000000000000000000000000000000000..150b10337fdfb2c521e694795505b7f295698d9a Binary files /dev/null and b/fet/SC/3.png differ diff --git a/fet/SC/30.png b/fet/SC/30.png new file mode 100644 index 0000000000000000000000000000000000000000..d500c5878e449dca671264abe02ad43d174e18df Binary files /dev/null and b/fet/SC/30.png differ diff --git a/fet/SC/31.png b/fet/SC/31.png new file mode 100644 index 0000000000000000000000000000000000000000..c1baa7c9eb00b3af276b6b3f020c025eef3dd121 Binary files /dev/null and b/fet/SC/31.png differ diff --git a/fet/SC/4.png b/fet/SC/4.png new file mode 100644 index 0000000000000000000000000000000000000000..e535e41b5440ca405cf366ad0e0b10b754bdb05c Binary files /dev/null and b/fet/SC/4.png differ diff --git a/fet/SC/5.png b/fet/SC/5.png new file mode 100644 index 0000000000000000000000000000000000000000..e91a1e1406d6b9d61df553aa34f1182c52eadf00 Binary files /dev/null and b/fet/SC/5.png differ diff --git a/fet/SC/6.png b/fet/SC/6.png new file mode 100644 index 0000000000000000000000000000000000000000..46ea268d9a0bd643e1fab91dee15e42c3f8cf27a Binary files /dev/null and b/fet/SC/6.png differ diff --git a/fet/SC/7.png b/fet/SC/7.png new file mode 100644 index 0000000000000000000000000000000000000000..f1adff9be3c586b74d3d1cd00d5d1b82ff36cd73 Binary files /dev/null and b/fet/SC/7.png differ diff --git a/fet/SC/8.png b/fet/SC/8.png new file mode 100644 index 0000000000000000000000000000000000000000..94a0eb3e23868f53d9c7b4cab444d3cf9403e533 Binary files /dev/null and b/fet/SC/8.png differ diff --git a/fet/SC/9.png b/fet/SC/9.png new file mode 100644 index 0000000000000000000000000000000000000000..2196ff9331b75c163b906348d7fc54da07f3b200 Binary files /dev/null and b/fet/SC/9.png differ diff --git a/fet/fet.py b/fet/fet.py new file mode 100644 index 0000000000000000000000000000000000000000..021abeaa7d9b8512abe632a521b708709f588818 --- /dev/null +++ b/fet/fet.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +""" +FET - FOREGROUND EVALUATION TOOL + +@author: Andrews Sobral +""" + +import numpy as np +import cv2 +from os import listdir +from os.path import isfile, join + +path_gt = 'GT/' +path_fg = 'FG/' +path_sc = 'SC/' + +files_gt = [ f for f in listdir(path_gt) if isfile(join(path_gt,f)) ] +files_fg = [ f for f in listdir(path_gt) if isfile(join(path_gt,f)) ] + +TP = .0 # True positive pixels +FP = .0 # False positive pixels +TN = .0 # True negative pixels +FN = .0 # False negative pixels +Recall = .0 # TP / (TP + FN) +Precision = .0 # TP / (TP + FP) +Fscore = .0 # 2*(Precision*Recall)/(Precision+Recall) + +# TP - # of foreground pixels classified as foreground pixels. +# FP - # of background pixels classified as foreground pixels. +# TN - # of background pixels classified as background pixels. +# FN - # of foreground pixels classified as background pixels. + +green = [0,255,0] # for FN +blue = [255,0,0] +red = [0,0,255] # for FP +white = [255,255,255] # for TP +black = [0,0,0] # for TN + +print 'Processing' +k = 1 +for file_gt, file_fg in zip(files_gt, files_fg): + print(k, file_gt, file_fg) + img_gt = cv2.imread(path_gt + file_gt,cv2.IMREAD_GRAYSCALE) + img_fg = cv2.imread(path_fg + file_fg,cv2.IMREAD_GRAYSCALE) + #print(img_gt.shape,img_fg.shape) + rows,cols = img_gt.shape + img_res = np.zeros((rows,cols,3),np.uint8) + for i in xrange(rows): + for j in xrange(cols): + pixel_gt = img_gt[i,j] + pixel_fg = img_fg[i,j] + if(pixel_gt == 255 and pixel_fg == 255): + TP = TP + 1 + img_res[i,j] = white + if(pixel_gt == 0 and pixel_fg == 255): + FP = FP + 1 + img_res[i,j] = red + if(pixel_gt == 0 and pixel_fg == 0): + TN = TN + 1 + img_res[i,j] = black + if(pixel_gt == 255 and pixel_fg == 0): + FN = FN + 1 + img_res[i,j] = green + cv2.imshow('GT',img_gt) + cv2.imshow('FG',img_fg) + cv2.imshow('SC',img_res) + cv2.imwrite(path_sc + file_gt, img_res) + cv2.waitKey(1) # 33 + k = k + 1 + #break +cv2.destroyAllWindows() + +Recall = TP / (TP + FN) +Precision = TP / (TP + FP) +Fscore = 2*Precision*Recall/(Precision+Recall) + +print 'Score:' +print 'TP: ', TP +print 'FP: ', FP +print 'TN: ', TN +print 'FN: ', FN +print 'Recall: ', Recall +print 'Precision: ', Precision +print 'Fscore: ', Fscore +print '' + +##################################################################### +