From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- SD-VBS/benchmarks/mser/.mser.mex.c.swp | Bin 0 -> 16384 bytes SD-VBS/benchmarks/mser/Makefile | 3 + SD-VBS/benchmarks/mser/data/Makefile | 3 + SD-VBS/benchmarks/mser/data/cif/1.bmp | Bin 0 -> 278838 bytes SD-VBS/benchmarks/mser/data/cif/Makefile | 6 + SD-VBS/benchmarks/mser/data/cif/VBS_Ver1 | Bin 0 -> 79632 bytes SD-VBS/benchmarks/mser/data/cif/expected.m | 162 ++++ SD-VBS/benchmarks/mser/data/cif/mser | Bin 0 -> 48200 bytes SD-VBS/benchmarks/mser/data/fullhd/1.bmp | Bin 0 -> 6220854 bytes SD-VBS/benchmarks/mser/data/fullhd/Makefile | 6 + SD-VBS/benchmarks/mser/data/fullhd/mser | Bin 0 -> 48200 bytes SD-VBS/benchmarks/mser/data/qcif/1.bmp | Bin 0 -> 69750 bytes SD-VBS/benchmarks/mser/data/qcif/Makefile | 6 + SD-VBS/benchmarks/mser/data/qcif/VBS_Ver1 | Bin 0 -> 79672 bytes SD-VBS/benchmarks/mser/data/qcif/expected.m | 68 ++ SD-VBS/benchmarks/mser/data/qcif/mser | Bin 0 -> 42656 bytes SD-VBS/benchmarks/mser/data/sim/1.bmp | Bin 0 -> 17478 bytes SD-VBS/benchmarks/mser/data/sim/Makefile | 6 + SD-VBS/benchmarks/mser/data/sim/expected.m | 16 + SD-VBS/benchmarks/mser/data/sim/mser | Bin 0 -> 42656 bytes SD-VBS/benchmarks/mser/data/sim_fast/1.bmp | Bin 0 -> 5238 bytes SD-VBS/benchmarks/mser/data/sim_fast/Makefile | 8 + SD-VBS/benchmarks/mser/data/sim_fast/expected.m | 7 + SD-VBS/benchmarks/mser/data/sim_fast/mser | Bin 0 -> 42656 bytes SD-VBS/benchmarks/mser/data/sqcif/1.bmp | Bin 0 -> 17478 bytes SD-VBS/benchmarks/mser/data/sqcif/Makefile | 6 + SD-VBS/benchmarks/mser/data/sqcif/expected.m | 27 + SD-VBS/benchmarks/mser/data/sqcif/mser | Bin 0 -> 42656 bytes SD-VBS/benchmarks/mser/data/test/1.bmp | Bin 0 -> 630 bytes SD-VBS/benchmarks/mser/data/test/Makefile | 7 + SD-VBS/benchmarks/mser/data/test/expected.m | 1 + SD-VBS/benchmarks/mser/data/test/mser | Bin 0 -> 42656 bytes SD-VBS/benchmarks/mser/data/vga/1.bmp | Bin 0 -> 921654 bytes SD-VBS/benchmarks/mser/data/vga/Makefile | 6 + SD-VBS/benchmarks/mser/data/vga/expected.m | 297 ++++++++ SD-VBS/benchmarks/mser/data/vga/mser | Bin 0 -> 42656 bytes SD-VBS/benchmarks/mser/src/c/mser.c | 714 ++++++++++++++++++ SD-VBS/benchmarks/mser/src/c/mser.h | 83 +++ SD-VBS/benchmarks/mser/src/c/script_mser.c | 120 +++ SD-VBS/benchmarks/mser/src/matlab/Makefile | 123 ++++ SD-VBS/benchmarks/mser/src/matlab/TIMESTAMP | 2 + SD-VBS/benchmarks/mser/src/matlab/erfill.m | 13 + SD-VBS/benchmarks/mser/src/matlab/erfill.mex.c | 223 ++++++ SD-VBS/benchmarks/mser/src/matlab/erfill.mexa64 | Bin 0 -> 10930 bytes SD-VBS/benchmarks/mser/src/matlab/erfill.mexglx | Bin 0 -> 8744 bytes SD-VBS/benchmarks/mser/src/matlab/mexutils.c | 111 +++ SD-VBS/benchmarks/mser/src/matlab/mser.mex.c | 815 +++++++++++++++++++++ SD-VBS/benchmarks/mser/src/matlab/mser.mexa64 | Bin 0 -> 14107 bytes SD-VBS/benchmarks/mser/src/matlab/mser.mexglx | Bin 0 -> 12459 bytes SD-VBS/benchmarks/mser/src/matlab/mser_compile.m | 7 + SD-VBS/benchmarks/mser/src/matlab/mser_demo2.m | 62 ++ SD-VBS/benchmarks/mser/src/matlab/mser_demo3.m | 117 +++ SD-VBS/benchmarks/mser/src/matlab/old/Makefile | 123 ++++ SD-VBS/benchmarks/mser/src/matlab/old/TIMESTAMP | 2 + SD-VBS/benchmarks/mser/src/matlab/old/erfill.m | 13 + SD-VBS/benchmarks/mser/src/matlab/old/erfill.mex.c | 223 ++++++ .../benchmarks/mser/src/matlab/old/erfill.mexa64 | Bin 0 -> 18714 bytes SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c | 111 +++ SD-VBS/benchmarks/mser/src/matlab/old/mser.mex.c | 809 ++++++++++++++++++++ SD-VBS/benchmarks/mser/src/matlab/old/mser.mexa64 | Bin 0 -> 28582 bytes .../benchmarks/mser/src/matlab/old/mser_compile.m | 7 + SD-VBS/benchmarks/mser/src/matlab/old/mser_demo2.m | 62 ++ SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m | 117 +++ .../benchmarks/mser/src/matlab/old/overview_mser.m | 8 + .../mser/src/matlab/old/script_run_profile.m | 137 ++++ SD-VBS/benchmarks/mser/src/matlab/overview_mser.m | 8 + .../mser/src/matlab/script_run_profile.m | 126 ++++ 67 files changed, 4771 insertions(+) create mode 100755 SD-VBS/benchmarks/mser/.mser.mex.c.swp create mode 100644 SD-VBS/benchmarks/mser/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/cif/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/cif/Makefile create mode 100755 SD-VBS/benchmarks/mser/data/cif/VBS_Ver1 create mode 100644 SD-VBS/benchmarks/mser/data/cif/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/cif/mser create mode 100644 SD-VBS/benchmarks/mser/data/fullhd/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/fullhd/Makefile create mode 100755 SD-VBS/benchmarks/mser/data/fullhd/mser create mode 100644 SD-VBS/benchmarks/mser/data/qcif/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/qcif/Makefile create mode 100755 SD-VBS/benchmarks/mser/data/qcif/VBS_Ver1 create mode 100644 SD-VBS/benchmarks/mser/data/qcif/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/qcif/mser create mode 100644 SD-VBS/benchmarks/mser/data/sim/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/sim/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/sim/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/sim/mser create mode 100644 SD-VBS/benchmarks/mser/data/sim_fast/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/sim_fast/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/sim_fast/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/sim_fast/mser create mode 100644 SD-VBS/benchmarks/mser/data/sqcif/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/sqcif/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/sqcif/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/sqcif/mser create mode 100644 SD-VBS/benchmarks/mser/data/test/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/test/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/test/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/test/mser create mode 100644 SD-VBS/benchmarks/mser/data/vga/1.bmp create mode 100644 SD-VBS/benchmarks/mser/data/vga/Makefile create mode 100644 SD-VBS/benchmarks/mser/data/vga/expected.m create mode 100755 SD-VBS/benchmarks/mser/data/vga/mser create mode 100644 SD-VBS/benchmarks/mser/src/c/mser.c create mode 100644 SD-VBS/benchmarks/mser/src/c/mser.h create mode 100644 SD-VBS/benchmarks/mser/src/c/script_mser.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/Makefile create mode 100755 SD-VBS/benchmarks/mser/src/matlab/TIMESTAMP create mode 100755 SD-VBS/benchmarks/mser/src/matlab/erfill.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/erfill.mex.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/erfill.mexa64 create mode 100755 SD-VBS/benchmarks/mser/src/matlab/erfill.mexglx create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mexutils.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mser.mex.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mser.mexa64 create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mser.mexglx create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mser_compile.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mser_demo2.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/mser_demo3.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/Makefile create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/TIMESTAMP create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/erfill.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/erfill.mex.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/erfill.mexa64 create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/mser.mex.c create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/mser.mexa64 create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/mser_compile.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/mser_demo2.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/overview_mser.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/old/script_run_profile.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/overview_mser.m create mode 100755 SD-VBS/benchmarks/mser/src/matlab/script_run_profile.m (limited to 'SD-VBS/benchmarks/mser') diff --git a/SD-VBS/benchmarks/mser/.mser.mex.c.swp b/SD-VBS/benchmarks/mser/.mser.mex.c.swp new file mode 100755 index 0000000..4f3a21c Binary files /dev/null and b/SD-VBS/benchmarks/mser/.mser.mex.c.swp differ diff --git a/SD-VBS/benchmarks/mser/Makefile b/SD-VBS/benchmarks/mser/Makefile new file mode 100644 index 0000000..60cc0ec --- /dev/null +++ b/SD-VBS/benchmarks/mser/Makefile @@ -0,0 +1,3 @@ +include ../../common/makefiles/Makefile.include +include $(MAKEFILE_COMMON_DIR)/Makefile.recurse + diff --git a/SD-VBS/benchmarks/mser/data/Makefile b/SD-VBS/benchmarks/mser/data/Makefile new file mode 100644 index 0000000..ba33d35 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/Makefile @@ -0,0 +1,3 @@ +include ../../../common/makefiles/Makefile.include +include $(MAKEFILE_COMMON_DIR)/Makefile.recurse + diff --git a/SD-VBS/benchmarks/mser/data/cif/1.bmp b/SD-VBS/benchmarks/mser/data/cif/1.bmp new file mode 100644 index 0000000..df56ca3 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/cif/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/cif/Makefile b/SD-VBS/benchmarks/mser/data/cif/Makefile new file mode 100644 index 0000000..41c7f38 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/cif/Makefile @@ -0,0 +1,6 @@ +INPUT=cif +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +include $(MAKEFILE_COMMON_DIR)/Makefile.common + diff --git a/SD-VBS/benchmarks/mser/data/cif/VBS_Ver1 b/SD-VBS/benchmarks/mser/data/cif/VBS_Ver1 new file mode 100755 index 0000000..bafb9c7 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/cif/VBS_Ver1 differ diff --git a/SD-VBS/benchmarks/mser/data/cif/expected.m b/SD-VBS/benchmarks/mser/data/cif/expected.m new file mode 100644 index 0000000..b4123c3 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/cif/expected.m @@ -0,0 +1,162 @@ +91080 +40916 +90318 +48277 +57285 +66702 +66453 +15757 +56228 +9401 +72213 +62502 +50676 +8016 +76446 +4080 +26989 +2894 +15233 +25177 +46411 +77708 +79330 +79286 +7639 +39100 +20919 +24125 +69034 +87683 +33330 +9587 +14591 +37790 +57107 +2905 +72581 +30138 +66349 +69782 +53208 +63252 +8011 +20400 +47661 +59179 +71075 +3544 +75352 +5143 +42527 +49924 +9933 +13880 +38559 +45184 +48697 +51275 +57095 +27545 +41718 +46519 +25666 +31481 +56792 +59176 +29879 +42197 +62643 +58210 +20334 +5623 +43569 +46210 +50474 +62104 +65808 +46945 +52682 +63195 +77194 +50534 +60544 +41770 +48717 +53246 +57723 +3829 +20457 +28461 +32341 +6413 +30286 +41193 +50243 +55458 +56851 +60038 +35141 +59004 +63503 +34763 +48953 +55092 +4534 +70791 +20249 +28134 +33971 +53439 +55882 +30562 +33993 +34523 +67709 +60469 +8591 +20489 +72123 +20237 +62971 +26046 +27337 +27638 +29497 +46390 +18004 +41108 +47659 +72386 +31584 +52173 +58091 +46624 +68233 +25267 +29768 +52802 +63228 +39529 +37092 +48469 +41074 +44231 +18653 +40524 +26529 +32423 +27131 +37373 +39650 +65233 +72920 +12277 +33656 +33151 +40026 +48408 +33352 +91265 +32307 +33875 diff --git a/SD-VBS/benchmarks/mser/data/cif/mser b/SD-VBS/benchmarks/mser/data/cif/mser new file mode 100755 index 0000000..e2e5016 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/cif/mser differ diff --git a/SD-VBS/benchmarks/mser/data/fullhd/1.bmp b/SD-VBS/benchmarks/mser/data/fullhd/1.bmp new file mode 100644 index 0000000..c09aaf0 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/fullhd/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/fullhd/Makefile b/SD-VBS/benchmarks/mser/data/fullhd/Makefile new file mode 100644 index 0000000..5cce221 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/fullhd/Makefile @@ -0,0 +1,6 @@ +INPUT=fullhd +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +include $(MAKEFILE_COMMON_DIR)/Makefile.common + diff --git a/SD-VBS/benchmarks/mser/data/fullhd/mser b/SD-VBS/benchmarks/mser/data/fullhd/mser new file mode 100755 index 0000000..ab94dc8 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/fullhd/mser differ diff --git a/SD-VBS/benchmarks/mser/data/qcif/1.bmp b/SD-VBS/benchmarks/mser/data/qcif/1.bmp new file mode 100644 index 0000000..f5a4408 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/qcif/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/qcif/Makefile b/SD-VBS/benchmarks/mser/data/qcif/Makefile new file mode 100644 index 0000000..0c1d924 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/qcif/Makefile @@ -0,0 +1,6 @@ +INPUT=qcif +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +include $(MAKEFILE_COMMON_DIR)/Makefile.common + diff --git a/SD-VBS/benchmarks/mser/data/qcif/VBS_Ver1 b/SD-VBS/benchmarks/mser/data/qcif/VBS_Ver1 new file mode 100755 index 0000000..a973e58 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/qcif/VBS_Ver1 differ diff --git a/SD-VBS/benchmarks/mser/data/qcif/expected.m b/SD-VBS/benchmarks/mser/data/qcif/expected.m new file mode 100644 index 0000000..41fc7d7 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/qcif/expected.m @@ -0,0 +1,68 @@ +22308 +10162 +14251 +9500 +18683 +5669 +1501 +2813 +5180 +6119 +3731 +3939 +22065 +2417 +5048 +17994 +14159 +15203 +17195 +18926 +13616 +2192 +2 +6900 +9794 +11366 +14679 +5344 +17471 +11778 +16661 +10323 +12856 +13141 +7022 +12740 +11984 +14560 +12982 +19042 +13916 +1250 +7680 +159 +5477 +13909 +15632 +7620 +6936 +14660 +2021 +12466 +16436 +6556 +12499 +9457 +6559 +13998 +17616 +9992 +12224 +14654 +9572 +6970 +8661 +18900 +3364 +8379 diff --git a/SD-VBS/benchmarks/mser/data/qcif/mser b/SD-VBS/benchmarks/mser/data/qcif/mser new file mode 100755 index 0000000..3a8d82b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/qcif/mser differ diff --git a/SD-VBS/benchmarks/mser/data/sim/1.bmp b/SD-VBS/benchmarks/mser/data/sim/1.bmp new file mode 100644 index 0000000..953fe98 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/sim/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/sim/Makefile b/SD-VBS/benchmarks/mser/data/sim/Makefile new file mode 100644 index 0000000..fc94f6e --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/sim/Makefile @@ -0,0 +1,6 @@ +INPUT=sim +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +include $(MAKEFILE_COMMON_DIR)/Makefile.common + diff --git a/SD-VBS/benchmarks/mser/data/sim/expected.m b/SD-VBS/benchmarks/mser/data/sim/expected.m new file mode 100644 index 0000000..c52e720 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/sim/expected.m @@ -0,0 +1,16 @@ +3611 +5615 +3876 +2441 +5556 +127 +1109 +71 +8 +16 +3567 +817 +3169 +2121 +4036 +3985 diff --git a/SD-VBS/benchmarks/mser/data/sim/mser b/SD-VBS/benchmarks/mser/data/sim/mser new file mode 100755 index 0000000..3a8d82b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/sim/mser differ diff --git a/SD-VBS/benchmarks/mser/data/sim_fast/1.bmp b/SD-VBS/benchmarks/mser/data/sim_fast/1.bmp new file mode 100644 index 0000000..5ec0de1 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/sim_fast/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/sim_fast/Makefile b/SD-VBS/benchmarks/mser/data/sim_fast/Makefile new file mode 100644 index 0000000..f5845eb --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/sim_fast/Makefile @@ -0,0 +1,8 @@ + +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +INPUT=sim_fast +include $(MAKEFILE_COMMON_DIR)/Makefile.common + + diff --git a/SD-VBS/benchmarks/mser/data/sim_fast/expected.m b/SD-VBS/benchmarks/mser/data/sim_fast/expected.m new file mode 100644 index 0000000..5ba3c55 --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/sim_fast/expected.m @@ -0,0 +1,7 @@ +1214 +353 +1146 +29 +187 +829 +976 diff --git a/SD-VBS/benchmarks/mser/data/sim_fast/mser b/SD-VBS/benchmarks/mser/data/sim_fast/mser new file mode 100755 index 0000000..3a8d82b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/sim_fast/mser differ diff --git a/SD-VBS/benchmarks/mser/data/sqcif/1.bmp b/SD-VBS/benchmarks/mser/data/sqcif/1.bmp new file mode 100644 index 0000000..9122269 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/sqcif/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/sqcif/Makefile b/SD-VBS/benchmarks/mser/data/sqcif/Makefile new file mode 100644 index 0000000..42808ce --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/sqcif/Makefile @@ -0,0 +1,6 @@ +INPUT=sqcif +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +include $(MAKEFILE_COMMON_DIR)/Makefile.common + diff --git a/SD-VBS/benchmarks/mser/data/sqcif/expected.m b/SD-VBS/benchmarks/mser/data/sqcif/expected.m new file mode 100644 index 0000000..a3ccbad --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/sqcif/expected.m @@ -0,0 +1,27 @@ +3549 +5615 +3941 +5626 +5113 +1079 +3840 +4838 +4050 +7 +1741 +2778 +2060 +3911 +13 +1923 +3918 +3463 +480 +1488 +344 +33 +2158 +3398 +1694 +2420 +4026 diff --git a/SD-VBS/benchmarks/mser/data/sqcif/mser b/SD-VBS/benchmarks/mser/data/sqcif/mser new file mode 100755 index 0000000..3a8d82b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/sqcif/mser differ diff --git a/SD-VBS/benchmarks/mser/data/test/1.bmp b/SD-VBS/benchmarks/mser/data/test/1.bmp new file mode 100644 index 0000000..ba8fb8b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/test/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/test/Makefile b/SD-VBS/benchmarks/mser/data/test/Makefile new file mode 100644 index 0000000..8a1c79b --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/test/Makefile @@ -0,0 +1,7 @@ +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +INPUT=test +include $(MAKEFILE_COMMON_DIR)/Makefile.common + + diff --git a/SD-VBS/benchmarks/mser/data/test/expected.m b/SD-VBS/benchmarks/mser/data/test/expected.m new file mode 100644 index 0000000..30d764c --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/test/expected.m @@ -0,0 +1 @@ +171 diff --git a/SD-VBS/benchmarks/mser/data/test/mser b/SD-VBS/benchmarks/mser/data/test/mser new file mode 100755 index 0000000..3a8d82b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/test/mser differ diff --git a/SD-VBS/benchmarks/mser/data/vga/1.bmp b/SD-VBS/benchmarks/mser/data/vga/1.bmp new file mode 100644 index 0000000..bbb3e60 Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/vga/1.bmp differ diff --git a/SD-VBS/benchmarks/mser/data/vga/Makefile b/SD-VBS/benchmarks/mser/data/vga/Makefile new file mode 100644 index 0000000..1b0032a --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/vga/Makefile @@ -0,0 +1,6 @@ +INPUT=vga +include ../../../../common/makefiles/Makefile.include + +BMARK=mser +include $(MAKEFILE_COMMON_DIR)/Makefile.common + diff --git a/SD-VBS/benchmarks/mser/data/vga/expected.m b/SD-VBS/benchmarks/mser/data/vga/expected.m new file mode 100644 index 0000000..23ca6be --- /dev/null +++ b/SD-VBS/benchmarks/mser/data/vga/expected.m @@ -0,0 +1,297 @@ +150188 +139161 +226889 +295683 +188158 +218738 +24760 +122860 +234561 +71415 +184318 +25237 +84868 +27054 +73340 +252342 +178044 +251786 +38543 +166539 +265202 +13175 +230154 +241697 +268924 +106165 +87963 +140157 +178621 +3821 +49293 +51544 +87463 +138676 +146393 +153034 +178140 +263663 +35512 +81293 +128231 +24929 +38545 +157836 +201762 +260875 +53461 +58270 +68286 +78904 +123882 +143979 +155623 +289494 +17912 +166189 +172421 +188794 +258462 +80809 +110040 +125346 +193605 +215682 +492 +242242 +98477 +204773 +271899 +305023 +20339 +47220 +48233 +48129 +78890 +78902 +121066 +157838 +157696 +222421 +195436 +202237 +222353 +247870 +263209 +60698 +67419 +141637 +168504 +225211 +246839 +16955 +45396 +75542 +167666 +175462 +185528 +186845 +11725 +12720 +17432 +90532 +153694 +157695 +163260 +166188 +228166 +242515 +264159 +24279 +90873 +137217 +178145 +85543 +103800 +121961 +126261 +142142 +149331 +166705 +138344 +192225 +61171 +137772 +159873 +183201 +191826 +12731 +21743 +41559 +116677 +177659 +157702 +163404 +187318 +199366 +216135 +174026 +209457 +218175 +256531 +109213 +205085 +50229 +137858 +155858 +176013 +190780 +10764 +169116 +56443 +99749 +100683 +184963 +34340 +84582 +152527 +225832 +60575 +115240 +226637 +161966 +183392 +197327 +213856 +241059 +240186 +100504 +74754 +81674 +93395 +132483 +183200 +197487 +71281 +78323 +108050 +115058 +156455 +179831 +104 +178270 +200686 +205651 +54048 +67055 +157242 +226147 +264274 +97314 +112166 +99664 +112206 +116049 +182192 +21848 +66537 +130426 +152940 +156285 +197779 +209053 +238177 +259864 +61533 +97798 +104222 +176915 +180751 +210478 +63199 +69447 +224698 +238313 +67034 +85757 +85258 +105388 +153466 +180480 +88659 +123185 +176914 +26649 +101110 +109718 +112129 +153412 +169722 +173098 +97319 +122228 +126071 +150970 +186255 +91527 +149140 +222949 +117832 +128889 +129467 +151042 +125202 +126520 +173763 +196324 +207128 +103415 +137589 +149105 +82420 +118796 +137047 +146660 +151972 +118828 +127476 +124086 +68492 +91587 +90605 +113982 +117387 +150991 +152035 +122974 +84235 +212209 +114957 +42000 +242485 +103945 +143398 +116457 +198008 +134212 +257564 +255173 +252776 +107194 +289726 +294096 +161443 +292606 +277399 +105290 +159533 +294098 +276919 +279700 +304797 +90329 +57239 +104324 +58669 +114859 +185568 diff --git a/SD-VBS/benchmarks/mser/data/vga/mser b/SD-VBS/benchmarks/mser/data/vga/mser new file mode 100755 index 0000000..3a8d82b Binary files /dev/null and b/SD-VBS/benchmarks/mser/data/vga/mser differ diff --git a/SD-VBS/benchmarks/mser/src/c/mser.c b/SD-VBS/benchmarks/mser/src/c/mser.c new file mode 100644 index 0000000..d886d7a --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/c/mser.c @@ -0,0 +1,714 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +/*** +% MSER Maximally Stable Extremal Regions +% R=MSER(I,DELTA) computes the Maximally Stable Extremal Regions +% (MSER) of image I with stability threshold DELTA. I is any +% array of class UINT8, while DELTA is a scalar of the same class. +% R is an index set (of class UINT32) which enumerates the +% representative pixels of the detected regions. +% +% A region R can be recovered from a representative pixel X as the +% connected component of the level set {Y:I(Y) <= I(X)} which +% contains X. +***/ + + +#include "mser.h" +#include + +/* advance N-dimensional subscript */ +void +adv(iArray *dims, int ndims, iArray *subs_pt) +{ + int d = 0 ; + while(d < ndims) + { + sref(subs_pt,d) = sref(subs_pt,d) + 1; + if( sref(subs_pt,d) < sref(dims,d) ) + return ; + sref(subs_pt,d++) = 0 ; + } +} + +/** driver **/ +I2D* mser(I2D* I, int in_delta, + iArray* subs_pt, iArray* nsubs_pt, iArray* strides_pt, iArray* visited_pt, iArray* dims, + uiArray* joins_pt, + region_t* regions_pt, + pair_t* pairs_pt, + node_t* forest_pt, + ulliArray* acc_pt, ulliArray* ell_pt, + I2D* out) +{ + idx_t i, rindex=0; + int k; + int nout = 1; + + int OUT_REGIONS=0; + int OUT_ELL = 1; + int OUT_PARENTS = 2; + int OUT_AREA = 3; + int BUCKETS = 256; + + //I2D* out; + + int IN_I = 0; + int IN_DELTA = 1; + + /* configuration */ + int verbose = 1 ; /* be verbose */ + int small_cleanup= 1 ; /* remove very small regions */ + int big_cleanup = 1 ; /* remove very big regions */ + int bad_cleanup = 0 ; /* remove very bad regions */ + int dup_cleanup = 1 ; /* remove duplicates */ + val_t delta ; /* stability delta */ + + /* node value denoting a void node */ + idx_t const node_is_void = 0xffffffff ; + + //iArray* subs_pt ; /* N-dimensional subscript + //iArray* nsubs_pt ; /* diff-subscript to point to neigh. +// uiArray* strides_pt ; /* strides to move in image array +// uiArray* visited_pt ; /* flag + + int nel ; /* number of image elements (pixels) */ + int ner = 0 ; /* number of extremal regions */ + int nmer = 0 ; /* number of maximally stable */ + int ndims ; /* number of dimensions */ +// iArray* dims ; /* dimensions + int njoins = 0 ; /* number of join ops */ + + I2D* I_pt ; /* source image */ + //pair_t* pairs_pt ; /* scratch buffer to sort pixels +// node_t* forest_pt ; /* the extremal regions forest +// region_t* regions_pt ; /* list of extremal regions found + int regions_pt_size; + int pairs_pt_size; + int forest_pt_size; + + /* ellipses fitting */ + //ulliArray* acc_pt ; /* accumulator to integrate region moments + //ulliArray* ell_pt ; /* ellipses parameters + int gdl ; /* number of parameters of an ellipse */ + //uiArray* joins_pt ; /* sequence of joins + + delta = 0; + delta = in_delta; + + /* get dimensions */ + + nel = I->height*I->width; /* number of elements of src image */ + ndims = 2; + //dims = malloc(sizeof(iArray) + sizeof(int)*ndims); + I_pt = I; + + sref(dims,0) = I->height; + sref(dims,1) = I->width; + + /* allocate stuff */ + //subs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); + //nsubs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); + + //strides_pt = malloc(sizeof(uiArray)+sizeof(unsigned int)*ndims); + //visited_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); + //joins_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); + + //regions_pt = (region_t*)malloc(sizeof(region_t)*nel); + regions_pt_size = nel; + + //pairs_pt = (pair_t*)malloc(sizeof(pair_t)*nel); + pairs_pt_size = nel; + + //forest_pt = (node_t*)malloc(sizeof(node_t)*nel); + forest_pt_size = nel; + + /* compute strides to move into the N-dimensional image array */ + sref(strides_pt,0) = 1; + for(k = 1 ; k < ndims ; ++k) + { + sref(strides_pt,k) = sref(strides_pt,k-1) * sref(dims,k-1) ; + } + + /* sort pixels in increasing order of intensity: using Bucket Sort */ + { + int unsigned buckets [BUCKETS] ; + memset(buckets, 0, sizeof(int unsigned)*BUCKETS) ; + + for(i = 0 ; i < nel ; ++i) + { + val_t v = asubsref(I_pt,i) ; + ++buckets[v] ; + } + + for(i = 1 ; i < BUCKETS ; ++i) + { + arrayref(buckets,i) += arrayref(buckets,i-1) ; + } + + for(i = nel ; i >= 1 ; ) + { + val_t v = asubsref(I_pt,--i) ; + idx_t j = --buckets[v] ; + pairs_pt[j].value = v ; + pairs_pt[j].index = i ; + } + } + + /* initialize the forest with all void nodes */ + for(i = 0 ; i < nel ; ++i) + { + forest_pt[i].parent = node_is_void ; + } + + /* number of ellipse free parameters */ + gdl = ndims*(ndims+1)/2 + ndims ; + + /* ----------------------------------------------------------------- + * Compute extremal regions tree + * -------------------------------------------------------------- */ + + for(i = 0 ; i < nel ; ++i) + { + /* pop next node xi */ + idx_t index = pairs_pt [i].index ; + val_t value = pairs_pt [i].value ; + + /* this will be needed later */ + rindex = index ; + + /* push it into the tree */ + forest_pt [index] .parent = index ; + forest_pt [index] .shortcut = index ; + forest_pt [index] .area = 1 ; +#ifdef USE_RANK_UNION + forest_pt [index] .height = 1 ; +#endif + + /* convert index into a subscript sub; also initialize nsubs + to (-1,-1,...,-1) */ + { + idx_t temp = index ; + for(k = ndims-1 ; k >=0 ; --k) + { + sref(nsubs_pt,k) = -1 ; + sref(subs_pt,k) = temp / sref(strides_pt,k) ; + temp = temp % sref(strides_pt,k) ; + } + } + + /* process neighbors of xi */ + while(1) + { + int good = 1 ; + idx_t nindex = 0 ; + + /* compute NSUBS+SUB, the correspoinding neighbor index NINDEX + and check that the pixel is within image boundaries. */ + for(k = 0 ; k < ndims && good ; ++k) + { + int temp = sref(nsubs_pt,k) + sref(subs_pt,k) ; + good &= 0 <= temp && temp < sref(dims,k) ; + nindex += temp * sref(strides_pt,k) ; + } + + + /* keep going only if + 1 - the neighbor is within image boundaries; + 2 - the neighbor is indeed different from the current node + (this happens when nsub=(0,0,...,0)); + 3 - the nieghbor is already in the tree, meaning that + is a pixel older than xi. + */ + if(good && nindex != index && forest_pt[nindex].parent != node_is_void ) + { + idx_t nrindex = 0, nvisited ; + val_t nrvalue = 0 ; + + +#ifdef USE_RANK_UNION + int height = forest_pt [ rindex] .height ; + int nheight = forest_pt [nrindex] .height ; +#endif + + /* RINDEX = ROOT(INDEX) might change as we merge trees, so we + need to update it after each merge */ + + /* find the root of the current node */ + /* also update the shortcuts */ + nvisited = 0 ; + while( forest_pt[rindex].shortcut != rindex ) + { + sref(visited_pt,nvisited++) = rindex ; + rindex = forest_pt[rindex].shortcut ; + } + while( nvisited-- ) + { + forest_pt [ sref(visited_pt,nvisited) ] .shortcut = rindex ; + } + + /* find the root of the neighbor */ + nrindex = nindex ; + nvisited = 0 ; + while( forest_pt[nrindex].shortcut != nrindex ) + { + sref(visited_pt, nvisited++) = nrindex ; + nrindex = forest_pt[nrindex].shortcut ; + } + while( nvisited-- ) + { + forest_pt [ sref(visited_pt,nvisited) ] .shortcut = nrindex ; + } + + /* + Now we join the two subtrees rooted at + + RINDEX = ROOT(INDEX) and NRINDEX = ROOT(NINDEX). + + Only three things can happen: + + a - ROOT(INDEX) == ROOT(NRINDEX). In this case the two trees + have already been joined and we do not do anything. + + b - I(ROOT(INDEX)) == I(ROOT(NRINDEX)). In this case index + is extending an extremal region with the same + value. Since ROOT(NRINDEX) will NOT be an extremal + region of the full image, ROOT(INDEX) can be safely + addedd as children of ROOT(NRINDEX) if this reduces + the height according to union rank. + + c - I(ROOT(INDEX)) > I(ROOT(NRINDEX)) as index is extending + an extremal region, but increasing its level. In this + case ROOT(NRINDEX) WILL be an extremal region of the + final image and the only possibility is to add + ROOT(NRINDEX) as children of ROOT(INDEX). + */ + + if( rindex != nrindex ) + { + /* this is a genuine join */ + + nrvalue = asubsref(I_pt,nrindex) ; + if( nrvalue == value +#ifdef USE_RANK_UNION + && height < nheight +#endif + ) + { + /* ROOT(INDEX) becomes the child */ + forest_pt[rindex] .parent = nrindex ; + forest_pt[rindex] .shortcut = nrindex ; + forest_pt[nrindex].area += forest_pt[rindex].area ; + +#ifdef USE_RANK_UNION + forest_pt[nrindex].height = MAX(nheight, height+1) ; +#endif + + sref(joins_pt,njoins++) = rindex ; + + } + else + { + /* ROOT(index) becomes parent */ + forest_pt[nrindex] .parent = rindex ; + forest_pt[nrindex] .shortcut = rindex ; + forest_pt[rindex] .area += forest_pt[nrindex].area ; + +#ifdef USE_RANK_UNION + forest_pt[rindex].height = MAX(height, nheight+1) ; +#endif + if( nrvalue != value ) + { + /* nrindex is extremal region: save for later */ + forest_pt[nrindex].region = ner ; + regions_pt [ner] .index = nrindex ; + regions_pt [ner] .parent = ner ; + regions_pt [ner] .value = nrvalue ; + regions_pt [ner] .area = forest_pt [nrindex].area ; + regions_pt [ner] .area_top = nel ; + regions_pt [ner] .area_bot = 0 ; + ++ner ; + } + + /* annote join operation for post-processing */ + sref(joins_pt,njoins++) = nrindex ; + } + } + + } /* neighbor done */ + + /* move to next neighbor */ + k = 0 ; + sref(nsubs_pt,k) = sref(nsubs_pt,k) + 1; + while( sref(nsubs_pt, k) > 1) + { + sref(nsubs_pt,k++) = -1 ; + if(k == ndims) goto done_all_neighbors ; + sref(nsubs_pt,k) = sref(nsubs_pt,k) + 1; + } + } /* next neighbor */ + done_all_neighbors : ; + } /* next pixel */ + + + /* the root of the last processed pixel must be a region */ + forest_pt [rindex].region = ner ; + regions_pt [ner] .index = rindex ; + regions_pt [ner] .parent = ner ; + regions_pt [ner] .value = asubsref(I_pt,rindex) ; + regions_pt [ner] .area = forest_pt [rindex] .area ; + regions_pt [ner] .area_top = nel ; + regions_pt [ner] .area_bot = 0 ; + ++ner ; + + /* ----------------------------------------------------------------- + * Compute region parents + * -------------------------------------------------------------- */ + for( i = 0 ; i < ner ; ++i) + { + idx_t index = regions_pt [i].index ; + val_t value = regions_pt [i].value ; + idx_t j = i ; + + while(j == i) + { + idx_t pindex = forest_pt [index].parent ; + val_t pvalue = asubsref(I_pt,pindex) ; + + /* top of the tree */ + if(index == pindex) + { + j = forest_pt[index].region ; + break ; + } + + /* if index is the root of a region, either this is still + i, or it is the parent region we are looking for. */ + if(value < pvalue) + { + j = forest_pt[index].region ; + } + + index = pindex ; + value = pvalue ; + } + regions_pt[i]. parent = j ; + } + + /* ----------------------------------------------------------------- + * Compute areas of tops and bottoms + * -------------------------------------------------------------- */ + + /* We scan the list of regions from the bottom. Let x0 be the current + region and be x1 = PARENT(x0), x2 = PARENT(x1) and so on. + + Here we do two things: + + 1) Look for regions x for which x0 is the BOTTOM. This requires + VAL(x0) <= VAL(x) - DELTA < VAL(x1). + We update AREA_BOT(x) for each of such x found. + + 2) Look for the region y which is the TOP of x0. This requires + VAL(y) <= VAL(x0) + DELTA < VAL(y+1) + We update AREA_TOP(x0) as soon as we find such y. + + */ + + for( i = 0 ; i < ner ; ++i) + { + /* fix xi as the region, then xj are the parents */ + idx_t parent = regions_pt [i].parent ; + int val0 = regions_pt [i].value ; + int val1 = regions_pt [parent].value ; + int val = val0 ; + idx_t j = i ; + + while(1) + { + int valp = regions_pt [parent].value ; + + /* i is the bottom of j */ + if(val0 <= val - delta && val - delta < val1) + { + regions_pt [j].area_bot = + MAX(regions_pt [j].area_bot, regions_pt [i].area) ; + } + + /* j is the top of i */ + if(val <= val0 + delta && val0 + delta < valp) + { + regions_pt [i].area_top = regions_pt [j].area ; + } + + /* stop if going on is useless */ + if(val1 <= val - delta && val0 + delta < val) + break ; + + /* stop also if j is the root */ + if(j == parent) + break ; + + /* next region upward */ + j = parent ; + parent = regions_pt [j].parent ; + val = valp ; + } + } + + /* ----------------------------------------------------------------- + * Compute variation + * -------------------------------------------------------------- */ + for(i = 0 ; i < ner ; ++i) + { + int area = regions_pt [i].area ; + int area_top = regions_pt [i].area_top ; + int area_bot = regions_pt [i].area_bot ; + regions_pt [i].variation = (area_top - area_bot) / (area*1.0) ; + + /* initialize .mastable to 1 for all nodes */ + regions_pt [i].maxstable = 1 ; + } + + /* ----------------------------------------------------------------- + * Remove regions which are NOT maximally stable + * -------------------------------------------------------------- */ + nmer = ner ; + for(i = 0 ; i < ner ; ++i) + { + idx_t parent = regions_pt [i] .parent ; + float var = regions_pt [i] .variation ; + float pvar = regions_pt [parent] .variation ; + idx_t loser ; + + /* decide which one to keep and put that in loser */ + if(var < pvar) loser = parent ; else loser = i ; + + /* make loser NON maximally stable */ + if(regions_pt [loser].maxstable) --nmer ; + regions_pt [loser].maxstable = 0 ; + } + + + /* ----------------------------------------------------------------- + * Remove more regions + * -------------------------------------------------------------- */ + + /* it is critical for correct duplicate detection to remove regions + from the bottom (smallest one first) */ + + if( big_cleanup || small_cleanup || bad_cleanup || dup_cleanup ) + { + int nbig = 0 ; + int nsmall = 0 ; + int nbad = 0 ; + int ndup = 0 ; + + /* scann all extremal regions */ + for(i = 0 ; i < ner ; ++i) + { + + /* process only maximally stable extremal regions */ + if(! regions_pt [i].maxstable) continue ; + + if( bad_cleanup && regions_pt[i].variation >= 1.0f ) + { + ++nbad ; + goto remove_this_region ; + } + + if( big_cleanup && regions_pt[i].area > nel/2 ) + { + ++nbig ; + goto remove_this_region ; + } + + if( small_cleanup && regions_pt[i].area < 25 ) + { + ++nsmall ; + goto remove_this_region ; + } + + /** Remove duplicates */ + + if( dup_cleanup ) + { + idx_t parent = regions_pt [i].parent ; + int area, parea ; + float change ; + + /* the search does not apply to root regions */ + if(parent != i) + { + + /* search for the maximally stable parent region */ + while(! regions_pt[parent].maxstable) + { + idx_t next = regions_pt[parent].parent ; + if(next == parent) break ; + parent = next ; + } + + /* compare with the parent region; if the current and parent + regions are too similar, keep only the parent */ + + area = regions_pt [i].area ; + parea = regions_pt [parent].area ; + change = (parea - area)/(area*1.0) ; + + if(change < 0.5) + { + ++ndup ; + goto remove_this_region ; + } + + } /* drop duplicates */ + } + + continue ; + remove_this_region : + regions_pt[i].maxstable = 0 ; + --nmer ; + + } /* next region to cleanup */ + + if(0) + { + printf(" Bad regions: %d\n", nbad ) ; + printf(" Small regions: %d\n", nsmall ) ; + printf(" Big regions: %d\n", nbig ) ; + printf(" Duplicated regions: %d\n", ndup ) ; + } + } + +/* printf("Cleaned-up regions: %d (%.1f%%)\n", + nmer, 100.0 * (double) nmer / ner) ; +*/ + /* ----------------------------------------------------------------- + * Fit ellipses + * -------------------------------------------------------------- */ + //ell_pt = 0 ; + //memset(ell_pt, sizeof(ulliArray) + sizeof(acc_t)*gdl*nmer, 0) ; + if (nout >= 1) + { + int midx = 1 ; + int d, index, j ; + + /* enumerate maxstable regions */ + for(i = 0 ; i < ner ; ++i) + { + if(! regions_pt [i].maxstable) continue ; + regions_pt [i].maxstable = midx++ ; + } + + /* allocate space */ + //acc_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*nel) ; + //printf("nmer = %d\n", nmer); + //ell_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*gdl*nmer) ; + + /* clear accumulators */ + for(d=0; d<(gdl*nmer); d++) + sref(ell_pt,d) = 0; + + /* for each gdl */ + for(d = 0 ; d < gdl ; ++d) + { + /* initalize parameter */ + int counter_i; + for(counter_i=0; counter_i j) + { + i -= j + 1 ; + j ++ ; + } + + /* add x_i * x_j */ + for(index = 0 ; index < nel ; ++ index) + { + sref(acc_pt,index) = sref(subs_pt,i) * sref(subs_pt,j) ; + adv(dims, ndims, subs_pt) ; + } + } + + /* integrate parameter */ + for(i = 0 ; i < njoins ; ++i) + { + idx_t index = sref(joins_pt,i); + idx_t parent = forest_pt [ index ].parent ; + sref(acc_pt,parent) += sref(acc_pt,index) ; + } + + /* save back to ellpises */ + for(i = 0 ; i < ner ; ++i) + { + idx_t region = regions_pt [i].maxstable ; + + /* skip if not extremal region */ + if(region-- == 0) continue ; + sref(ell_pt,d + gdl*region) = sref(acc_pt, regions_pt[i].index) ; + } + + /* next gdl */ + } + //free(acc_pt) ; + //free(ell_pt) ; + } + + /* ----------------------------------------------------------------- + * Save back and exit + * -------------------------------------------------------------- */ + + /* + * Save extremal regions + */ + { + int dims[2], j=0; + I2D* pt ; + dims[0] = nmer ; + //out = iMallocHandle(1, nmer); + out->height = 1; + out->width = nmer; + pt = out; + for (i = 0 ; i < ner ; ++i) + { + if( regions_pt[i].maxstable ) + { + /* adjust for MATLAB index compatibility */ +// *pt++ = regions_pt[i].index + 1 ; + asubsref(pt,j++) = regions_pt[i].index + 1 ; + } + } + } + + /* free stuff */ + //free(dims); + //free( forest_pt ) ; + //free( pairs_pt ) ; + //free( regions_pt ) ; + //free( visited_pt ) ; + //free( strides_pt ) ; + //free( nsubs_pt ) ; + //free( subs_pt ) ; + //free( joins_pt ) ; + + return out; +} + + + diff --git a/SD-VBS/benchmarks/mser/src/c/mser.h b/SD-VBS/benchmarks/mser/src/c/mser.h new file mode 100644 index 0000000..8876311 --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/c/mser.h @@ -0,0 +1,83 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#ifndef _MSER_ +#define _MSER_ + +#define sref(a,i) a->data[i] + +#include "sdvbs_common.h" +#define NMER_MAX 756 + +typedef int val_t; + +typedef struct +{ + int width; + int data[]; +}iArray; + +typedef struct +{ + int width; + unsigned int data[]; +}uiArray; + +typedef struct +{ + int width; + long long int unsigned data[]; +}ulliArray; + +#define MIN(a,b) (ab)?a:b + +typedef int unsigned idx_t ; +typedef long long int unsigned acc_t ; + +/* pairs are used to sort the pixels */ +typedef struct +{ + val_t value ; + idx_t index ; +} pair_t ; + +/* forest node */ +typedef struct +{ + idx_t parent ; /**< parent pixel */ + idx_t shortcut ; /**< shortcut to the root */ + idx_t region ; /**< index of the region */ + int area ; /**< area of the region */ +#ifdef USE_RANK_UNION + int height ; /**< node height */ +#endif +} node_t ; + +/* extremal regions */ +typedef struct +{ + idx_t parent ; /**< parent region */ + idx_t index ; /**< index of root pixel */ + val_t value ; /**< value of root pixel */ + int area ; /**< area of the region */ + int area_top ; /**< area of the region DELTA levels above */ + int area_bot ; /**< area of the region DELTA levels below */ + float variation ; /**< variation */ + int maxstable ; /**< max stable number (=0 if not maxstable) */ +} region_t ; + +int script_mser(); +I2D* mser(I2D* I, int in_delta, + iArray* subs_pt, iArray* nsubs_pt, iArray* strides_pt, iArray* visited_pt, iArray* dims, + uiArray* joins_pt, + region_t* regions_pt, + pair_t* pairs_pt, + node_t* forest_pt, + ulliArray* acc_pt, ulliArray* ell_pt, + I2D* out); + +#endif + + diff --git a/SD-VBS/benchmarks/mser/src/c/script_mser.c b/SD-VBS/benchmarks/mser/src/c/script_mser.c new file mode 100644 index 0000000..d4a98cd --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/c/script_mser.c @@ -0,0 +1,120 @@ +/******************************** +Author: Sravanthi Kota Venkata +********************************/ + +#include "mser.h" +#include +#include "extra.h" +#define min(a,b) (ab)?a:b + +int main(int argc, char* argv[]) +{ + SET_UP + int which_image; + int i, j, k; + I2D *idx; + I2D *I; + I2D *It; + I2D *out; + int rows=196, cols=98; + int minVal = 1000; + int maxVal = -1000; + int lev = 10; + + char im1[100], im2[100]; + + iArray *subs_pt, *nsubs_pt, *strides_pt, *visited_pt, *dims; + uiArray* joins_pt; + ulliArray *acc_pt, *ell_pt; + region_t* regions_pt; + pair_t* pairs_pt; + node_t* forest_pt; + + int ndims, nel, gdl, nmer; + + printf("Input Image: "); + scanf("%s", im1); + + I = readImage(im1); + + rows = I->height; + cols = I->width; + + It = readImage(im1); + + k = 0; + for(i=0; iheight * It->width; + gdl = ndims * (ndims+1)/2 + ndims; + nmer = NMER_MAX; + + dims = malloc(sizeof(iArray) + sizeof(int)*ndims); + /* allocate stuff */ + subs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); + nsubs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims); + strides_pt = malloc(sizeof(uiArray)+sizeof(unsigned int)*ndims); + visited_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); + joins_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel); + + regions_pt = (region_t*)malloc(sizeof(region_t)*nel); + pairs_pt = (pair_t*)malloc(sizeof(pair_t)*nel); + forest_pt = (node_t*)malloc(sizeof(node_t)*nel); + + acc_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*nel) ; + ell_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*gdl*nmer) ; + + + out = iMallocHandle(1, nmer); + printf("start\n"); + for_each_job{ + idx = mser(It, 2, subs_pt, nsubs_pt, strides_pt, visited_pt, dims, + joins_pt, + regions_pt, + pairs_pt, + forest_pt, + acc_pt, ell_pt, + out); + } + printf("end..\n"); + +#ifdef CHECK + /** Self checking - use expected.txt from data directory **/ + { + int tol, ret=0; + tol = 1; +#ifdef GENERATE_OUTPUT + writeMatrix(idx, argv[1]); +#endif + ret = selfCheck(idx, "expected_C.txt", tol); + if (ret == -1) + printf("Error in MSER\n"); + } + /** Self checking done **/ +#endif + free(dims); + free( forest_pt ) ; + free( pairs_pt ) ; + free( regions_pt ) ; + free( visited_pt ) ; + free( strides_pt ) ; + free( nsubs_pt ) ; + free( subs_pt ) ; + free( joins_pt ) ; + free( acc_pt ) ; + free( ell_pt ) ; + iFreeHandle(idx); + iFreeHandle(I); + iFreeHandle(It); + WRITE_TO_FILE + return 0; +} + diff --git a/SD-VBS/benchmarks/mser/src/matlab/Makefile b/SD-VBS/benchmarks/mser/src/matlab/Makefile new file mode 100755 index 0000000..29c0982 --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/matlab/Makefile @@ -0,0 +1,123 @@ +# file: Makefile +# author: Andrea Vedaldi +# description: Build mex files + +# -------------------------------------------------------------------- +# +# -------------------------------------------------------------------- + +# Determine on the flight the system we are running on +Darwin_ARCH := mac +Linux_ARCH := glx +ARCH := $($(shell uname)_ARCH) + +mac_CFLAGS := -I. -pedantic -Wall -Wno-long-long +mac_MEX_CFLAGS := -g -O CFLAGS='$$CFLAGS $(mac_CFLAGS)' +mac_MEX_SUFFIX := mexmac + +glx_CFLAGS := -I. -pedantic -Wall -Wno-long-long +glx_MEX_CFLAGS := -g -O CFLAGS='$$CFLAGS $(glx_CFLAGS)' +glx_MEX_SUFFIX := mexglx + +MEX_SUFFIX := $($(ARCH)_MEX_SUFFIX) +MEX_CFLAGS := $($(ARCH)_MEX_CFLAGS) + +VER := 0.4 +DIST := mser-$(VER) +BINDIST := $(DIST)-$(ARCH) + +# -------------------------------------------------------------------- +# +# -------------------------------------------------------------------- + +vpath %.mex.c . + +src := $(wildcard *.mex.c) +msrc := $(wildcard *.m) +stem := $(notdir $(basename $(basename $(src)))) +tgt := $(addprefix ./, $(addsuffix .$(MEX_SUFFIX),$(stem))) + +%.$(MEX_SUFFIX) : %.mex.c + mex -I. $(MEX_CFLAGS) $< -output $* + +.PHONY: all +all: $(tgt) + +.PHONY: info +info : + @echo src = $(src) + @echo stem = $(stem) + @echo tgt = $(tgt) + +# PDF documentation +.PHONY: doc +doc: mser.html doc/mser.pdf + +mser.html : $(msrc) + mdoc --output=mser.html . \ + --exclude='.*(_demo|_compile).*.m' + +.PHONY: clean +clean: + rm -f $(tgt) + find . -name '.DS_Store' -exec rm -f \{\} \; + find . -name '.gdb_history' -exec rm -f \{\} \; + find . -name '*~' -exec rm -f \{\} \; + find . -name '*.bak' -exec rm -f \{\} \; + make -C doc/figures clean + +.PHONY: distclean +distclean: clean + rm -f *.mexmac *.mexglx + rm -f mser.html + rm -f mser-*.tar.gz + rm -f doc/*.log + rm -f doc/*.aux + rm -f doc/*.toc + rm -f doc/*.bbl + rm -f doc/*.blg + rm -f doc/*.out + rm -f $(DIST).tar.gz + rm -f $(BINDIST).tar.gz + rm -rf $(BINDIST) + +.PHONY: dist +dist: distclean + echo Version $(VER) >TIMESTAMP + echo Archive created on `date` >>TIMESTAMP + d=$(notdir $(CURDIR)) ; \ + tar chzvf $(DIST).tar.gz \ + --exclude mser_demo4.m \ + --exclude data/seq.avi \ + --exclude results \ + ../$${d} + +.PHONY: bindist +bindist: all + test -e $(BINDIST) || mkdir $(BINDIST) + cp *.$(MEX_SUFFIX) $(BINDIST) + cd $(BINDIST) ; strip -S *.$(MEX_SUFFIX) + tar chzvf $(BINDIST).tar.gz $(BINDIST) + +.PHONY: autorights +autorights: + autorights . \ + --verbose \ + --recursive \ + --template cal \ + --years 2006 \ + --authors "Andrea Vedaldi (UCLA VisionLab)" \ + --program "Video Extremal Regions" + +doc/mser.pdf : doc/*.tex doc/*.bib doc/figures/*.fig + make -C doc/figures all + cd doc ; \ + for k in 1 2 3 ; \ + do \ + pdflatex -file-line-error-style -interaction batchmode \ + mser.tex ; \ + if test "$$k" = '1' ; \ + then \ + bibtex mser.aux ; \ + fi ; \ + done diff --git a/SD-VBS/benchmarks/mser/src/matlab/TIMESTAMP b/SD-VBS/benchmarks/mser/src/matlab/TIMESTAMP new file mode 100755 index 0000000..1de1720 --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/matlab/TIMESTAMP @@ -0,0 +1,2 @@ +Version 0.4 +Archive created on Wed Feb 7 11:08:47 PST 2007 diff --git a/SD-VBS/benchmarks/mser/src/matlab/erfill.m b/SD-VBS/benchmarks/mser/src/matlab/erfill.m new file mode 100755 index 0000000..6e11fc6 --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/matlab/erfill.m @@ -0,0 +1,13 @@ +% ERFILL Fill extremal region +% MEMBERS=ERFILL(I,ER) returns the list MEMBERS of the pixels which +% belongs to the extremal region represented by the pixel ER. +% +% The selected region is the one that contains pixel ER and of +% inensity I(ER). +% +% I must be of class UINT8 and ER must be a (scalar) index of the +% region representative point. +% +% See also MSER(). + + diff --git a/SD-VBS/benchmarks/mser/src/matlab/erfill.mex.c b/SD-VBS/benchmarks/mser/src/matlab/erfill.mex.c new file mode 100755 index 0000000..893d346 --- /dev/null +++ b/SD-VBS/benchmarks/mser/src/matlab/erfill.mex.c @@ -0,0 +1,223 @@ +/* file: erfill.mex.c +** description: Extremal Regions filling +** author: Andrea Vedaldi +**/ + +/* AUTORIGHTS +Copyright (C) 2006 Regents of the University of California +All rights reserved + +Written by Andrea Vedaldi (UCLA VisionLab). + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the University of California, Berkeley nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** @file + ** @brief Maximally Stable Extremal Regions - MEX implementation + **/ + +#include +#include +#include +#include +#include +#include + +#define MIN(x,y) (((x)<(y))?(x):(y)) +#define MAX(x,y) (((x)>(y))?(x):(y)) + +typedef char unsigned val_t ; +typedef int unsigned idx_t ; +typedef long long int unsigned acc_t ; + +/* advance N-dimensional subscript */ +void +adv(int const* dims, int ndims, int* subs_pt) +{ + int d = 0 ; + while(d < ndims) { + if( ++subs_pt[d] < dims[d] ) return ; + subs_pt[d++] = 0 ; + } +} + +/* driver */ +void +mexFunction(int nout, mxArray *out[], + int nin, const mxArray *in[]) +{ + + enum {IN_I=0, IN_ER} ; + enum {OUT_MEMBERS} ; + + idx_t i ; + int k, nel, ndims ; + int const * dims ; + val_t const * I_pt ; + int last = 0 ; + int last_expanded = 0 ; + val_t value = 0 ; + + double const * er_pt ; + + int* subs_pt ; /* N-dimensional subscript */ + int* nsubs_pt ; /* diff-subscript to point to neigh. */ + idx_t* strides_pt ; /* strides to move in image array */ + val_t* visited_pt ; /* flag */ + idx_t* members_pt ; /* region members */ + + /** ----------------------------------------------------------------- + ** Check the arguments + ** -------------------------------------------------------------- */ + if (nin != 2) { + mexErrMsgTxt("Two arguments required.") ; + } else if (nout > 4) { + mexErrMsgTxt("Too many output arguments."); + } + + if(mxGetClassID(in[IN_I]) != mxUINT8_CLASS) { + mexErrMsgTxt("I must be of class UINT8.") ; + } + + if(!uIsRealScalar(in[IN_ER])) { + mexErrMsgTxt("ER must be a DOUBLE scalar.") ; + } + + /* get dimensions */ + nel = mxGetNumberOfElements(in[IN_I]) ; + ndims = mxGetNumberOfDimensions(in[IN_I]) ; + dims = mxGetDimensions(in[IN_I]) ; + I_pt = mxGetData(in[IN_I]) ; + + /* allocate stuff */ + subs_pt = mxMalloc( sizeof(int) * ndims ) ; + nsubs_pt = mxMalloc( sizeof(int) * ndims ) ; + strides_pt = mxMalloc( sizeof(idx_t) * ndims ) ; + visited_pt = mxMalloc( sizeof(val_t) * nel ) ; + members_pt = mxMalloc( sizeof(idx_t) * nel ) ; + + er_pt = mxGetPr(in[IN_ER]) ; + + /* compute strides to move into the N-dimensional image array */ + strides_pt [0] = 1 ; + for(k = 1 ; k < ndims ; ++k) { + strides_pt [k] = strides_pt [k-1] * dims [k-1] ; + } + + /* load first pixel */ + memset(visited_pt, 0, sizeof(val_t) * nel) ; + { + idx_t idx = (idx_t) *er_pt ; + if( idx < 1 || idx > nel ) { + char buff[80] ; + snprintf(buff,80,"ER=%d out of range [1,%d]",idx,nel) ; + mexErrMsgTxt(buff) ; + } + members_pt [last++] = idx - 1 ; + } + value = I_pt[ members_pt[0] ] ; + + /* ----------------------------------------------------------------- + * Fill region + * -------------------------------------------------------------- */ + while(last_expanded < last) { + + /* pop next node xi */ + idx_t index = members_pt[last_expanded++] ; + + /* convert index into a subscript sub; also initialize nsubs + to (-1,-1,...,-1) */ + { + idx_t temp = index ; + for(k = ndims-1 ; k >=0 ; --k) { + nsubs_pt [k] = -1 ; + subs_pt [k] = temp / strides_pt [k] ; + temp = temp % strides_pt [k] ; + } + } + + /* process neighbors of xi */ + while( true ) { + int good = true ; + idx_t nindex = 0 ; + + /* compute NSUBS+SUB, the correspoinding neighbor index NINDEX + and check that the pixel is within image boundaries. */ + for(k = 0 ; k < ndims && good ; ++k) { + int temp = nsubs_pt [k] + subs_pt [k] ; + good &= 0 <= temp && temp < dims[k] ; + nindex += temp * strides_pt [k] ; + } + + /* process neighbor + 1 - the pixel is within image boundaries; + 2 - the pixel is indeed different from the current node + (this happens when nsub=(0,0,...,0)); + 3 - the pixel has value not greather than val + is a pixel older than xi + 4 - the pixel has not been visited yet + */ + if(good + && nindex != index + && I_pt [nindex] <= value + && ! visited_pt [nindex] ) { + + /* mark as visited */ + visited_pt [nindex] = 1 ; + + /* add to list */ + members_pt [last++] = nindex ; + } + + /* move to next neighbor */ + k = 0 ; + while(++ nsubs_pt [k] > 1) { + nsubs_pt [k++] = -1 ; + if(k == ndims) goto done_all_neighbors ; + } + } /* next neighbor */ + done_all_neighbors : ; + } /* goto pop next member */ + + /* + * Save results + */ + { + int dims[2] ; + int unsigned * pt ; + dims[0] = last ; + out[OUT_MEMBERS] = mxCreateNumericArray(1,dims,mxUINT32_CLASS,mxREAL); + pt = mxGetData(out[OUT_MEMBERS]) ; + for (i = 0 ; i < last ; ++i) { + *pt++ = members_pt[i] + 1 ; + } + } + + /* free stuff */ + mxFree( members_pt ) ; + mxFree( visited_pt ) ; + mxFree( strides_pt ) ; + mxFree( nsubs_pt ) ; + mxFree( subs_pt ) ; +} diff --git a/SD-VBS/benchmarks/mser/src/matlab/erfill.mexa64 b/SD-VBS/benchmarks/mser/src/matlab/erfill.mexa64 new file mode 100755 index 0000000..bc54d65 Binary files /dev/null and b/SD-VBS/benchmarks/mser/src/matlab/erfill.mexa64 differ diff --git a/SD-VBS/benchmarks/mser/src/matlab/erfill.mexglx b/SD-VBS/benchmarks/mser/src/matlab/erfill.mexglx new file mode 100755 index 0000000..8eec110 Binary files /dev/null and