├── sceneparsing ├── evaluationCode │ ├── __init__.py │ ├── pixelAccuracy.m │ ├── intersectionAndUnion.m │ └── utils_eval.py ├── objectName150.mat ├── visualizationCode │ ├── color150.mat │ ├── color150 │ │ ├── bag.jpg │ │ ├── ball.jpg │ │ ├── bar.jpg │ │ ├── base.jpg │ │ ├── bed.jpg │ │ ├── boat.jpg │ │ ├── book.jpg │ │ ├── box.jpg │ │ ├── bus.jpg │ │ ├── car.jpg │ │ ├── case.jpg │ │ ├── desk.jpg │ │ ├── door.jpg │ │ ├── fan.jpg │ │ ├── flag.jpg │ │ ├── food.jpg │ │ ├── hill.jpg │ │ ├── hood.jpg │ │ ├── lake.jpg │ │ ├── lamp.jpg │ │ ├── land.jpg │ │ ├── oven.jpg │ │ ├── palm.jpg │ │ ├── path.jpg │ │ ├── pier.jpg │ │ ├── pole.jpg │ │ ├── pot.jpg │ │ ├── road.jpg │ │ ├── rock.jpg │ │ ├── rug.jpg │ │ ├── sand.jpg │ │ ├── sea.jpg │ │ ├── seat.jpg │ │ ├── ship.jpg │ │ ├── sink.jpg │ │ ├── sky.jpg │ │ ├── sofa.jpg │ │ ├── step.jpg │ │ ├── tank.jpg │ │ ├── tent.jpg │ │ ├── tray.jpg │ │ ├── tree.jpg │ │ ├── van.jpg │ │ ├── vase.jpg │ │ ├── wall.jpg │ │ ├── animal.jpg │ │ ├── ashcan.jpg │ │ ├── awning.jpg │ │ ├── barrel.jpg │ │ ├── basket.jpg │ │ ├── bench.jpg │ │ ├── blind.jpg │ │ ├── booth.jpg │ │ ├── bottle.jpg │ │ ├── bridge.jpg │ │ ├── buffet.jpg │ │ ├── canopy.jpg │ │ ├── chair.jpg │ │ ├── clock.jpg │ │ ├── column.jpg │ │ ├── cradle.jpg │ │ ├── earth.jpg │ │ ├── fence.jpg │ │ ├── field.jpg │ │ ├── floor.jpg │ │ ├── flower.jpg │ │ ├── glass.jpg │ │ ├── grass.jpg │ │ ├── house.jpg │ │ ├── hovel.jpg │ │ ├── light.jpg │ │ ├── mirror.jpg │ │ ├── person.jpg │ │ ├── pillow.jpg │ │ ├── plant.jpg │ │ ├── plate.jpg │ │ ├── poster.jpg │ │ ├── river.jpg │ │ ├── runway.jpg │ │ ├── sconce.jpg │ │ ├── screen.jpg │ │ ├── shelf.jpg │ │ ├── shower.jpg │ │ ├── stage.jpg │ │ ├── stairs.jpg │ │ ├── stool.jpg │ │ ├── stove.jpg │ │ ├── table.jpg │ │ ├── toilet.jpg │ │ ├── towel.jpg │ │ ├── tower.jpg │ │ ├── truck.jpg │ │ ├── washer.jpg │ │ ├── water.jpg │ │ ├── airplane.jpg │ │ ├── apparel.jpg │ │ ├── armchair.jpg │ │ ├── bannister.jpg │ │ ├── bathtub.jpg │ │ ├── bicycle.jpg │ │ ├── blanket.jpg │ │ ├── bookcase.jpg │ │ ├── building.jpg │ │ ├── cabinet.jpg │ │ ├── ceiling.jpg │ │ ├── computer.jpg │ │ ├── counter.jpg │ │ ├── curtain.jpg │ │ ├── cushion.jpg │ │ ├── escalator.jpg │ │ ├── fireplace.jpg │ │ ├── fountain.jpg │ │ ├── microwave.jpg │ │ ├── minibike.jpg │ │ ├── monitor.jpg │ │ ├── mountain.jpg │ │ ├── ottoman.jpg │ │ ├── painting.jpg │ │ ├── plaything.jpg │ │ ├── radiator.jpg │ │ ├── railing.jpg │ │ ├── sculpture.jpg │ │ ├── sidewalk.jpg │ │ ├── signboard.jpg │ │ ├── stairway.jpg │ │ ├── wardrobe.jpg │ │ ├── waterfall.jpg │ │ ├── chandelier.jpg │ │ ├── countertop.jpg │ │ ├── crt screen.jpg │ │ ├── dirt track.jpg │ │ ├── dishwasher.jpg │ │ ├── grandstand.jpg │ │ ├── pool table.jpg │ │ ├── screen door.jpg │ │ ├── skyscraper.jpg │ │ ├── streetlight.jpg │ │ ├── trade name.jpg │ │ ├── windowpane.jpg │ │ ├── arcade machine.jpg │ │ ├── bulletin board.jpg │ │ ├── coffee table.jpg │ │ ├── conveyer belt.jpg │ │ ├── kitchen island.jpg │ │ ├── refrigerator.jpg │ │ ├── swimming pool.jpg │ │ ├── swivel chair.jpg │ │ ├── traffic light.jpg │ │ ├── chest of drawers.jpg │ │ └── television receiver.jpg │ ├── colorEncode.m │ ├── colorMap.m │ └── plotResult.m ├── demoVisualization.m ├── demoEvaluation.m ├── README.md └── objectInfo150.txt ├── boundarydetection ├── evaluationCode │ ├── cp_src │ │ ├── build.sh │ │ ├── correspondPixels.mexa64 │ │ ├── kofn.hh │ │ ├── build.m │ │ ├── README │ │ ├── match.hh │ │ ├── csa.cc │ │ ├── Exception.cc │ │ ├── Point.hh │ │ ├── Exception.hh │ │ ├── kofn.cc │ │ ├── Random.cc │ │ ├── correspondPixels.cc │ │ ├── Timer.cc │ │ ├── Timer.hh │ │ ├── Random.hh │ │ ├── String.cc │ │ ├── String.hh │ │ ├── csa_types.h │ │ ├── csa_defs.h │ │ ├── Sort.hh │ │ ├── Array.hh │ │ └── match.cc │ ├── isoF.fig │ ├── config.m │ ├── plot_pr.m │ ├── plot_eval_multiple.m │ ├── evaluate_imgs.m │ ├── parfor_progress.m │ ├── evaluate_bdry.m │ ├── benchmark_category.m │ └── collect_eval_bdry.m ├── objectName150.mat ├── visualizationCode │ ├── color150.mat │ ├── colorEncode.m │ └── subaxis │ │ ├── subaxis.m │ │ └── parseArgs.m ├── .gitignore ├── demoEvaluation.m ├── demoVisualization.m ├── README.md └── objectInfo150.txt ├── instancesegmentation ├── images │ ├── sample1.png │ ├── sample2.png │ └── sample3.png ├── visualization │ ├── instanceNames100.mat │ └── overlayAnno.m ├── evaluation │ ├── eval_main.py │ ├── convert_anns_to_json_dataset.py │ └── evaluator.py ├── demoVisualization.m ├── categoryMapping.txt ├── instanceInfo100_val.txt ├── instanceInfo100_train.txt └── README.md ├── README.md └── LICENSE /sceneparsing/evaluationCode/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sceneparsing/objectName150.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/objectName150.mat -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/build.sh: -------------------------------------------------------------------------------- 1 | matlab -nodisplay -nojvm -r "build; exit" 2 | cp -f correspondPixels.mex* ../ 3 | -------------------------------------------------------------------------------- /boundarydetection/objectName150.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/boundarydetection/objectName150.mat -------------------------------------------------------------------------------- /instancesegmentation/images/sample1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/instancesegmentation/images/sample1.png -------------------------------------------------------------------------------- /instancesegmentation/images/sample2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/instancesegmentation/images/sample2.png -------------------------------------------------------------------------------- /instancesegmentation/images/sample3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/instancesegmentation/images/sample3.png -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/isoF.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/boundarydetection/evaluationCode/isoF.fig -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150.mat -------------------------------------------------------------------------------- /boundarydetection/visualizationCode/color150.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/boundarydetection/visualizationCode/color150.mat -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bag.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bag.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/ball.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/ball.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bar.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/base.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/base.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bed.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/boat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/boat.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/book.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/book.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/box.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bus.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/car.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/case.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/case.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/desk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/desk.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/door.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/door.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/fan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/fan.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/flag.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/flag.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/food.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/food.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/hill.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/hill.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/hood.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/hood.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/lake.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/lake.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/lamp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/lamp.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/land.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/land.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/oven.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/oven.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/palm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/palm.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/path.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/path.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/pier.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/pier.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/pole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/pole.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/pot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/pot.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/road.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/road.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/rock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/rock.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/rug.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/rug.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sand.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sea.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sea.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/seat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/seat.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/ship.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/ship.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sink.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sink.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sky.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sofa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sofa.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/step.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/step.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/tank.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/tank.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/tent.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/tent.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/tray.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/tray.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/tree.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/van.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/van.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/vase.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/vase.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/wall.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/wall.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/animal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/animal.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/ashcan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/ashcan.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/awning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/awning.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/barrel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/barrel.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/basket.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/basket.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bench.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bench.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/blind.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/blind.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/booth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/booth.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bottle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bottle.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bridge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bridge.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/buffet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/buffet.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/canopy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/canopy.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/chair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/chair.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/clock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/clock.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/column.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/column.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/cradle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/cradle.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/earth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/earth.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/fence.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/fence.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/field.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/field.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/floor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/floor.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/flower.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/flower.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/glass.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/glass.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/grass.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/grass.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/house.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/house.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/hovel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/hovel.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/light.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/light.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/mirror.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/mirror.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/person.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/person.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/pillow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/pillow.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/plant.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/plant.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/plate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/plate.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/poster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/poster.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/river.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/river.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/runway.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/runway.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sconce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sconce.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/screen.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/shelf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/shelf.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/shower.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/shower.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/stage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/stage.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/stairs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/stairs.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/stool.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/stool.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/stove.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/stove.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/table.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/toilet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/toilet.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/towel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/towel.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/tower.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/tower.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/truck.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/truck.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/washer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/washer.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/water.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/airplane.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/airplane.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/apparel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/apparel.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/armchair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/armchair.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bannister.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bannister.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bathtub.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bathtub.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bicycle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bicycle.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/blanket.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/blanket.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bookcase.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bookcase.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/building.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/building.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/cabinet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/cabinet.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/ceiling.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/ceiling.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/computer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/computer.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/counter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/counter.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/curtain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/curtain.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/cushion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/cushion.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/escalator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/escalator.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/fireplace.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/fireplace.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/fountain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/fountain.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/microwave.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/microwave.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/minibike.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/minibike.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/monitor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/monitor.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/mountain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/mountain.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/ottoman.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/ottoman.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/painting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/painting.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/plaything.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/plaything.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/radiator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/radiator.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/railing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/railing.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sculpture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sculpture.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/sidewalk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/sidewalk.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/signboard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/signboard.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/stairway.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/stairway.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/wardrobe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/wardrobe.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/waterfall.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/waterfall.jpg -------------------------------------------------------------------------------- /instancesegmentation/visualization/instanceNames100.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/instancesegmentation/visualization/instanceNames100.mat -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/chandelier.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/chandelier.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/countertop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/countertop.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/crt screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/crt screen.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/dirt track.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/dirt track.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/dishwasher.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/dishwasher.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/grandstand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/grandstand.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/pool table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/pool table.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/screen door.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/screen door.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/skyscraper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/skyscraper.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/streetlight.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/streetlight.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/trade name.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/trade name.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/windowpane.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/windowpane.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/arcade machine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/arcade machine.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/bulletin board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/bulletin board.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/coffee table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/coffee table.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/conveyer belt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/conveyer belt.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/kitchen island.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/kitchen island.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/refrigerator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/refrigerator.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/swimming pool.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/swimming pool.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/swivel chair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/swivel chair.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/traffic light.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/traffic light.jpg -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/chest of drawers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/chest of drawers.jpg -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/correspondPixels.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/boundarydetection/evaluationCode/cp_src/correspondPixels.mexa64 -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/kofn.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __kofn_hh__ 3 | #define __kofn_hh__ 4 | 5 | void kOfN (int k, int n, int* values); 6 | 7 | #endif // __kofn_hh__ 8 | -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/color150/television receiver.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanx169/placeschallenge/master/sceneparsing/visualizationCode/color150/television receiver.jpg -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/build.m: -------------------------------------------------------------------------------- 1 | mex -v CXXFLAGS="\$CXXFLAGS -O3 -DNOBLAS" correspondPixels.cc csa.cc kofn.cc match.cc Exception.cc Matrix.cc Random.cc String.cc Timer.cc 2 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/README: -------------------------------------------------------------------------------- 1 | To compile the benchmarking software from source code, run: 2 | 3 | source build.sh 4 | 5 | This script should compile the correspondPixels mex file and copy it into the 6 | ../benchmarks/ directory. 7 | -------------------------------------------------------------------------------- /boundarydetection/.gitignore: -------------------------------------------------------------------------------- 1 | # Data files 2 | *.png 3 | *.jpg 4 | *.log 5 | 6 | # MATLAB 7 | *.mex* 8 | *.mat 9 | *.m~ 10 | 11 | # Others 12 | *.bin 13 | 14 | # Exceptions 15 | !objectName150.mat 16 | !visualizationCode/color150.mat 17 | !evaluationCode/cp_src/*.mex* 18 | evaluationCode/parfor_progress.txt 19 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/config.m: -------------------------------------------------------------------------------- 1 | SBDopts.datasetpath='~/semantic_contours/benchmark/new_dataset/'; 2 | SBDopts.path=fullfile(SBDopts.datasetpath,'cls/%s.mat'); 3 | %SBDopts.val_path=fullfile(SBDopts.datasetpath,'%d/val/%s.mat'); 4 | SBDopts.train_list=fullfile(SBDopts.datasetpath,'train.txt'); 5 | SBDopts.val_list=fullfile(SBDopts.datasetpath,'val.txt'); 6 | 7 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/match.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __match_hh__ 3 | #define __match_hh__ 4 | 5 | class Matrix; 6 | 7 | // returns the cost of the assignment 8 | double matchEdgeMaps ( 9 | const Matrix& bmap1, const Matrix& bmap2, 10 | double maxDist, double outlierCost, 11 | Matrix& match1, Matrix& match2); 12 | 13 | #endif // __match_hh__ 14 | -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/colorEncode.m: -------------------------------------------------------------------------------- 1 | function rgbLab = colorEncode(grayLab, colorcode) 2 | %% This function encodes label maps into rgb images for better visualization 3 | % grayLab: [h, w] 4 | % colorcode: [n, 3] where n is the number of classes 5 | % rgbLab: [h, w, 3] 6 | 7 | [h, w] = size(grayLab); 8 | rgbLab = zeros(h, w, 3, 'uint8'); 9 | 10 | idx_unique = unique(grayLab)'; 11 | for idx = idx_unique 12 | if idx==0 continue; end 13 | rgbLab = rgbLab + bsxfun(@times, uint8(grayLab==idx), reshape(colorcode(idx,:), [1,1,3])); 14 | end -------------------------------------------------------------------------------- /boundarydetection/visualizationCode/colorEncode.m: -------------------------------------------------------------------------------- 1 | function rgbLab = colorEncode(grayLab, colorcode) 2 | %% This function encodes label maps into rgb images for better visualization 3 | % grayLab: [h, w] 4 | % colorcode: [n, 3] where n is the number of classes 5 | % rgbLab: [h, w, 3] 6 | 7 | [h, w] = size(grayLab); 8 | rgbLab = zeros(h, w, 3, 'uint8'); 9 | 10 | idx_unique = unique(grayLab)'; 11 | for idx = idx_unique 12 | if idx==0 continue; end 13 | rgbLab = rgbLab + bsxfun(@times, uint8(grayLab==idx), reshape(colorcode(idx,:), [1,1,3])); 14 | end -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/colorMap.m: -------------------------------------------------------------------------------- 1 | function colormap = colorMap(imPred, imAnno, objectnames) 2 | %% This function generates colormaps with text annotations for visualization 3 | % imPred, imAnno: [h, w] 4 | % colormap: [h, w, 3] 5 | 6 | colormap = cell(2,8); 7 | 8 | idxUnique = unique([imPred, imAnno])'; 9 | cnt = 0; 10 | for idx = idxUnique 11 | if idx==0 12 | continue; 13 | else 14 | cnt = cnt + 1; 15 | colormap{cnt} = imread([objectnames{idx} '.jpg']); 16 | end 17 | 18 | if cnt>= numel(colormap) 19 | break; 20 | end 21 | end 22 | 23 | for i = cnt+1 : numel(colormap) 24 | colormap{i} = 255 * ones(30, 150, 3, 'uint8'); 25 | end 26 | 27 | colormap = cell2mat(colormap'); -------------------------------------------------------------------------------- /sceneparsing/evaluationCode/pixelAccuracy.m: -------------------------------------------------------------------------------- 1 | function [pixel_accuracy, pixel_correct, pixel_labeled]= pixelAccuracy(imPred, imLab) 2 | %% This function takes the prediction and label of a single image, returns pixel-wise accuracy 3 | % To compute over many images do: 4 | % for i = 1:Nimages 5 | % [pixel_accuracy(i), pixel_correct(i), pixel_labeled(i)] = pixelAccuracy(imPred{i}, imLab{i}); 6 | % end 7 | % mean_pixel_accuracy = sum(pixel_correct)/(eps + sum(pixel_labeled)); 8 | 9 | imPred = uint16(imPred(:)); 10 | imLab = uint16(imLab(:)); 11 | 12 | % Remove classes from unlabeled pixels in gt image. 13 | % We should not penalize detections in unlabeled portions of the image. 14 | pixel_labeled = sum(imLab>0); 15 | pixel_correct = sum((imPred==imLab).*(imLab>0)); 16 | pixel_accuracy = pixel_correct / pixel_labeled; 17 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/csa.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "csa.hh" 3 | 4 | char* CSA::err_messages[] = 5 | { 6 | "Can't read from the input file.", 7 | "Not a correct assignment problem line.", 8 | "Error reading a node descriptor from the input.", 9 | "Error reading an arc descriptor from the input.", 10 | "Unknown line type in the input", 11 | "Inconsistent number of arcs in the input.", 12 | "Parsing noncontiguous node ID numbers not implemented.", 13 | "Can't obtain enough memory to solve this problem.", 14 | }; 15 | 16 | char* CSA::nomem_msg = "Insufficient memory.\n"; 17 | 18 | CSA::CSA (int n, int m, const int* graph) 19 | { 20 | assert(n>0); 21 | assert(m>0); 22 | assert(graph!=NULL); 23 | assert((n%2)==0); 24 | _init(n,m); 25 | main(graph); 26 | } 27 | 28 | CSA::~CSA () 29 | { 30 | _delete(); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /sceneparsing/visualizationCode/plotResult.m: -------------------------------------------------------------------------------- 1 | function plotResult(im, imPred, imAnno, objectNames, colors, filename) 2 | %% This function plots single image results 3 | if nargin<5 4 | % use random color instead 5 | colors = im2uint8(hsv(255)); 6 | rng(1); 7 | colors = colors(randperm(255), :); 8 | end 9 | if nargin<6 10 | filename = ''; 11 | end 12 | 13 | % color encoding 14 | rgbPred = colorEncode(imPred, colors); 15 | rgbLab = colorEncode(imAnno, colors); 16 | 17 | % colormaps 18 | colormap = colorMap(imPred, imAnno, objectNames); 19 | 20 | % plot 21 | set(gcf, 'Name', [filename ' [Press any key to the next image...]'], 'NumberTitle','off'); 22 | 23 | subplot(221); 24 | imshow(im); title('Image'); 25 | subplot(222); 26 | imshow(rgbPred); title('Prediction'); 27 | subplot(223); 28 | imshow(colormap); title('Colormap'); 29 | subplot(224); 30 | imshow(rgbLab); title('Annotation (GT)'); 31 | drawnow; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![teaser](http://placeschallenge.csail.mit.edu/assets/images/montage_word.jpg) 3 | 4 | # The Toolkit for Places Challenge 2017 5 | 6 | ## Overview 7 | This is the toolkit and instruction page for the [Places Challenge 2017](http://placeschallenge.csail.mit.edu/). There are three tasks in Places Challenge 2017: Scene Parsing, Scene Instance Segmentation, and Semantic Boundary Detection. The data for all the three tasks are from the fully annotated image dataset ADE20K, there are 20K images for training, 2K images for validation, and 3K images for testing. Teams could particpate in one or two or three of the tasks. Click the instruction below 8 | for the detail of each task. 9 | 10 | ## Instructions for Each Task 11 | 12 | - Instruction for Scene Parsing Task is [here](sceneparsing) 13 | - Instruction for Instance Segmentation Task is [here](instancesegmentation) 14 | - Instruction for Semantic Boundary Segmentation Task is [here](boundarydetection) 15 | 16 | -------------------------------------------------------------------------------- /instancesegmentation/evaluation/eval_main.py: -------------------------------------------------------------------------------- 1 | # Evaluation demo for places instance segmentation challenge 2 | # Our evaluation follow the COCO instance segmentation criterion 3 | # Before running this script: 4 | # 1. encode annotations(*.png) into RLE format (.json) 5 | # by running convert_anns_to_json_dataset.py; 6 | # 2. detection results should also be saved as RLE format (.json) 7 | 8 | import os 9 | import argparse 10 | import sys 11 | from evaluator import InstanceEvaluator 12 | 13 | 14 | def parse_args(): 15 | parser = argparse.ArgumentParser(description='Evaluation demo') 16 | parser.add_argument('--dataset_json', default='./instance_validation_gts.json') 17 | parser.add_argument('--preds_json', default='./instance_validation_preds.json') 18 | 19 | args = parser.parse_args() 20 | return args 21 | 22 | 23 | def eval(args): 24 | evaluator = InstanceEvaluator(args.dataset_json, args.preds_json) 25 | evaluator.evaluate() 26 | evaluator.summarize() 27 | 28 | 29 | if __name__ == '__main__': 30 | args = parse_args() 31 | eval(args) -------------------------------------------------------------------------------- /instancesegmentation/demoVisualization.m: -------------------------------------------------------------------------------- 1 | % This script demos how to visualize instance annotations 2 | close all; clc; clear; 3 | rng(123); 4 | 5 | % change to your dataset root 6 | rootDataset = '.'; 7 | 8 | % Paths and options 9 | addpath(genpath('visualization')); 10 | 11 | % path to image(.jpg) and annotation(.png) 12 | pathImg = fullfile(rootDataset, 'images', 'validation'); 13 | pathLab = fullfile(rootDataset, 'annotations_instance', 'validation'); 14 | 15 | % loop over the dataset 16 | filesLab = dir(fullfile(pathLab, '*.png')); 17 | for i = 1: numel(filesLab) 18 | % read image 19 | fileImg = fullfile(pathImg, strrep(filesLab(i).name, '.png', '.jpg')); 20 | fileLab = fullfile(pathLab, filesLab(i).name); 21 | im = imread(fileImg); 22 | anno = imread(fileLab); 23 | 24 | % color encoding 25 | imVis = overlayAnno(im, anno); 26 | 27 | % plot 28 | set(gcf, 'Name', [fileImg ' [Press any key to the next image...]'], 'NumberTitle','off'); 29 | imshow(imVis); title('Image with instance annotations'); 30 | waitforbuttonpress; 31 | 32 | end -------------------------------------------------------------------------------- /sceneparsing/evaluationCode/intersectionAndUnion.m: -------------------------------------------------------------------------------- 1 | function [area_intersection, area_union] = intersectionAndUnion(imPred, imLab, numClass) 2 | %% This function takes the prediction and label of a single image, returns intersection and union areas for each class 3 | % To compute over many images do: 4 | % for i = 1:Nimages 5 | % [area_intersection(:,i), area_union(:,i)]=intersectionAndUnion(imPred{i}, imLab{i}); 6 | % end 7 | % IoU = sum(area_intersection,2)./sum(eps+area_union,2); 8 | 9 | imPred = uint16(imPred(:)); 10 | imLab = uint16(imLab(:)); 11 | 12 | % Remove classes from unlabeled pixels in label image. 13 | % We should not penalize detections in unlabeled portions of the image. 14 | imPred = imPred.*uint16(imLab>0); 15 | 16 | % Compute area intersection 17 | intersection = imPred.*uint16(imPred==imLab); 18 | area_intersection = hist(intersection, 0:numClass); 19 | 20 | % Compute area union 21 | area_pred = hist(imPred, 0:numClass); 22 | area_lab = hist(imLab, 0:numClass); 23 | area_union = area_pred + area_lab - area_intersection; 24 | 25 | % Remove unlabeled bin and convert to uint64 26 | area_intersection = area_intersection(2:end); 27 | area_union = area_union(2:end); -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/plot_pr.m: -------------------------------------------------------------------------------- 1 | function plot_pr(scoreDir, methodName, numCls, plotDir, objectNames) 2 | numMtd = length(scoreDir); 3 | assert(length(scoreDir)==length(methodName), ... 4 | 'Number of input dirs must be equal to input method names!'); 5 | for idxCls = 1:numCls 6 | fprintf('Plotting class %d precision-recall curve\n', idxCls); 7 | resultCatLst = cell(numMtd, 1); 8 | 9 | for idxMtd = 1:numMtd 10 | load(fullfile(scoreDir{idxMtd}, ['/class_' num2str(idxCls, '%03d') '.mat'])) 11 | resultCatLst{idxMtd} = resultCat; 12 | end 13 | 14 | % plot figure 15 | [F_ODS, ~, ~, H] = plot_eval_multiple(resultCatLst); 16 | legendLst = cell(numMtd, 1); 17 | for idxMtd = 1:numMtd 18 | legendLst{idxMtd, 1} = ['[F=' num2str(F_ODS(idxMtd), '%1.3f') '] ' methodName{idxMtd, 1}]; 19 | end 20 | set(gca,'fontsize',10) 21 | title(objectNames{idxCls},'FontSize',14,'FontWeight','bold') 22 | hLegend = legend(H, legendLst, 'Location', 'SouthWest'); 23 | set(hLegend,'FontSize',10); 24 | xlabel('Recall','FontSize',14,'FontWeight','bold') 25 | ylabel('Precision','FontSize',14,'FontWeight','bold') 26 | 27 | % save figure 28 | print(gcf, fullfile(plotDir, ['pr_class_' num2str(idxCls, '%03d') '.pdf']),'-dpdf') 29 | close(gcf); 30 | end -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Exception.cc: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (C) 2002 David R. Martin 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation; either version 2 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, but 10 | // WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | // General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 18 | 19 | #include 20 | #include 21 | #include "Exception.hh" 22 | 23 | Exception::Exception (const char* msg) 24 | : _msg (strdup (msg)) 25 | { 26 | } 27 | 28 | Exception::Exception (const Exception& that) 29 | : _msg (strdup (that._msg)) 30 | { 31 | } 32 | 33 | Exception::~Exception () 34 | { 35 | free (_msg); 36 | } 37 | 38 | const char* 39 | Exception::msg () const 40 | { 41 | return _msg; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Point.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __Point_hh__ 3 | #define __Point_hh__ 4 | 5 | // Simple point template classes. 6 | // Probably only make sense for intrinsic types. 7 | 8 | // 2D Points 9 | 10 | template 11 | class Point2D 12 | { 13 | public: 14 | Point2D () { x = 0; y = 0; } 15 | Point2D (T x, T y) { this->x = x; this->y = y; } 16 | T x,y; 17 | }; 18 | 19 | template 20 | inline int operator== (const Point2D& a, const Point2D& b) 21 | { return (a.x == b.x) && (a.y == b.y); } 22 | 23 | template 24 | inline int operator!= (const Point2D& a, const Point2D& b) 25 | { return (a.x != b.x) || (a.y != b.y); } 26 | 27 | typedef Point2D Pixel; 28 | 29 | // 3D Points 30 | 31 | template 32 | class Point3D 33 | { 34 | public: 35 | Point3D () { x = 0; y = 0; z = 0; } 36 | Point3D (T x, T y) { this->x = x; this->y = y; this->z = z;} 37 | T x,y,z; 38 | }; 39 | 40 | template 41 | inline int operator== (const Point3D& a, const Point3D& b) 42 | { return (a.x == b.x) && (a.y == b.y) && (a.z == b.z); } 43 | 44 | template 45 | inline int operator!= (const Point3D& a, const Point3D& b) 46 | { return (a.x != b.x) || (a.y != b.y) || (a.z != b.z); } 47 | 48 | typedef Point3D Voxel; 49 | 50 | #endif // __Point_hh__ 51 | -------------------------------------------------------------------------------- /instancesegmentation/visualization/overlayAnno.m: -------------------------------------------------------------------------------- 1 | function im = overlayAnno(im, anno) 2 | %% This function encodes label maps into rgb images for better visualization 3 | % im: input image [h, w, 3] 4 | % anno: input annotation [h, w] 5 | 6 | % load class names 7 | load('instanceNames100.mat'); 8 | % set params 9 | trans = 0.3; 10 | 11 | % iterate over each valid instance, compute bbox & names, draw to image 12 | im = im2double(im); 13 | Om = anno(:,:,1); 14 | Oi = anno(:,:,2); 15 | for i=1:max(Oi(:)) 16 | % set random color 17 | curColor = random('unif', 0, 1, [1,3]) * 0.8 + 0.2; 18 | 19 | % draw mask 20 | curMask = (Oi==i); 21 | im = bsxfun(@times, im, (1 - curMask * trans)); 22 | im = im + bsxfun(@times, curMask * trans, reshape(curColor,1,1,3)); 23 | 24 | % insert bbox 25 | [row, col] = find(curMask); 26 | curBbox = [min(col(:)), min(row(:)), max(col(:))-min(col(:)), ... 27 | max(row(:))-min(row(:))]; 28 | im = insertShape(im, 'Rectangle', curBbox, 'Color', curColor); 29 | 30 | % insert object name 31 | objIdx = Om(curMask); 32 | objIdx = objIdx(1); 33 | im = insertText(im, [min(col(:)), min(row(:))+2], instanceNames(objIdx,:), ... 34 | 'AnchorPoint', 'LeftBottom','BoxOpacity',0,'TextColor','white'); 35 | end 36 | 37 | end 38 | 39 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/plot_eval_multiple.m: -------------------------------------------------------------------------------- 1 | function [F_ODS, F_OIS, AP, H] = plot_eval_multiple(resultCatLst) 2 | 3 | % color list 4 | cols={'r';'b';'m';'g';'c';'r--';'b--';'m--';'g--';'c--'} ; 5 | 6 | % load background and plot grid 7 | openfig('isoF.fig', 'new', 'invisible'); hold on % Certain Matlab versions may crash if visible 8 | for i = 0.1:0.1:0.9 9 | plot([0.01, 0.99], [i, i], 'linewidth', 0.5, 'color', [0.8 0.8 0.8]); 10 | plot([i, i], [0.01, 0.99], 'linewidth', 0.5, 'color', [0.8 0.8 0.8]); 11 | end 12 | 13 | % initialize output 14 | F_ODS = zeros(length(resultCatLst), 1); 15 | F_OIS = zeros(length(resultCatLst), 1); 16 | AP = zeros(length(resultCatLst), 1); 17 | H = zeros(1, length(resultCatLst)); 18 | 19 | for idxMtd = 1:length(resultCatLst) 20 | if(idxMtd>length(cols)) 21 | col = 'c--'; 22 | else 23 | col = cols{idxMtd}; 24 | end 25 | prvals = resultCatLst{idxMtd}{2}; 26 | f = prvals(:, 2)>=0.01; 27 | prvals = prvals(f, :); 28 | 29 | evalRes = resultCatLst{idxMtd}{1}; 30 | if size(prvals, 1)>1, 31 | H(idxMtd) = plot(prvals(1:end, 2), prvals(1:end, 3), 'color', col, 'LineWidth', 3); 32 | else 33 | H(idxMtd) = plot(evalRes(2), evalRes(3), 'o', 'MarkerFaceColor', col, 'MarkerEdgeColor', col, 'MarkerSize',6); 34 | end 35 | 36 | F_ODS(idxMtd) = evalRes(4); 37 | F_OIS(idxMtd) = evalRes(7); 38 | AP(idxMtd) = evalRes(8); 39 | end 40 | hold off -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, MIT CSAIL Computer Vision 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /sceneparsing/demoVisualization.m: -------------------------------------------------------------------------------- 1 | % This script demos how to use colorEncode() to visualize label maps 2 | close all; clc; clear; 3 | 4 | % Paths and options 5 | addpath(genpath('visualizationCode')); 6 | 7 | % path to image(.jpg), prediction(.png) and annotation(.png) 8 | pathImg = fullfile('sampleData', 'images'); 9 | pathPred = fullfile('sampleData', 'predictions'); 10 | pathLab = fullfile('sampleData', 'annotations'); 11 | 12 | % load class names 13 | load('objectName150.mat'); 14 | % load pre-defined colors 15 | load('color150.mat'); 16 | 17 | filesPred = dir(fullfile(pathPred, '*.png')); 18 | for i = 1: numel(filesPred) 19 | % read image 20 | fileImg = fullfile(pathImg, strrep(filesPred(i).name, '.png', '.jpg')); 21 | filePred = fullfile(pathPred, filesPred(i).name); 22 | fileLab = fullfile(pathLab, filesPred(i).name); 23 | im = imread(fileImg); 24 | imPred = imread(filePred); 25 | imAnno = imread(fileLab); 26 | 27 | % color encoding 28 | rgbPred = colorEncode(imPred, colors); 29 | rgbAnno = colorEncode(imAnno, colors); 30 | 31 | % colormaps 32 | colormap = colorMap(imPred, imAnno, objectNames); 33 | 34 | % plot 35 | set(gcf, 'Name', [fileImg ' [Press any key to the next image...]'], 'NumberTitle','off'); 36 | 37 | subplot(231); 38 | imshow(im); title('Image'); 39 | subplot(232); 40 | imshow(imPred); title('Prediction-gray'); 41 | subplot(233); 42 | imshow(imAnno); title('Annotation-gray'); 43 | subplot(234); 44 | imshow(colormap); title('Colormap'); 45 | subplot(235); 46 | imshow(rgbPred); title('Prediction-color'); 47 | subplot(236); 48 | imshow(rgbAnno); title('Annotation-color'); 49 | 50 | waitforbuttonpress; 51 | 52 | end 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/evaluate_imgs.m: -------------------------------------------------------------------------------- 1 | function [resultCatImg] = evaluate_imgs(fileLst, predDir, gtDir, idxCls, nthresh, margin) 2 | % Computes the precision recall values for every image 3 | % Input: 4 | % fileLst : List of file names to be evluated. 5 | % predDir : Directory containing predicted boundaries. 6 | % gtDir : Directory containing ground truth boundaries. 7 | % idxCls : Current category id. 8 | % [nthresh]: Number of thresholds applied in evaluation. 9 | % [margin] : Size of margin to be ignored in evaluation. 10 | % Output: 11 | % resultCatImg: [Threshold, TP, TP+FN, TP, TP+FP] of every image. 12 | 13 | numFile = length(fileLst); 14 | resultCatImg = cell(numFile, 1); 15 | parfor_progress(numFile); % Initialize parfor monitoring 16 | parfor idxFile = 1:numFile 17 | % Read predicted boundary 18 | assert(exist(fullfile(predDir, ['class_' num2str(idxCls, '%03d')], [fileLst{idxFile} '.png']), 'file') > 0, ... 19 | 'Failed to load predicted boundaries. Files do not exist.') 20 | bdryPred = double(imread(fullfile(predDir, ['class_' num2str(idxCls, '%03d')], [fileLst{idxFile} '.png'])))./255; 21 | 22 | % Load ground truth boundary 23 | assert(exist(fullfile(gtDir, [fileLst{idxFile} '.mat']), 'file') > 0, ... 24 | 'Failed to load ground truth files. Files do not exist.') 25 | gtLoad = load(fullfile(gtDir, [fileLst{idxFile} '.mat']), 'gt'); 26 | bdryGT = full(double(gtLoad.gt.bdry{idxCls})); 27 | 28 | % Perform evaluation 29 | [thresh, cntR, sumR, cntP, sumP] = evaluate_bdry(bdryPred, bdryGT, margin, nthresh); 30 | resultCatImg{idxFile, 1} = [thresh, cntR, sumR, cntP, sumP]; 31 | 32 | % Monitor the parfor progress 33 | parfor_progress(); 34 | end 35 | parfor_progress(0); % Clear parfor monitoring -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Exception.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __Exception_hh__ 3 | #define __Exception_hh__ 4 | 5 | // A simple exception class that contains an error message. 6 | 7 | // Copyright (C) 2002 David R. Martin 8 | // 9 | // This program is free software; you can redistribute it and/or 10 | // modify it under the terms of the GNU General Public License as 11 | // published by the Free Software Foundation; either version 2 of the 12 | // License, or (at your option) any later version. 13 | // 14 | // This program is distributed in the hope that it will be useful, but 15 | // WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with this program; if not, write to the Free Software 21 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 22 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 23 | 24 | #include 25 | 26 | class Exception 27 | { 28 | public: 29 | 30 | // Always construct exception with a message, so we can print 31 | // a useful error/log message. 32 | Exception (const char* msg); 33 | 34 | // We need to implement the copy constructor so that rethrowing 35 | // works. 36 | Exception (const Exception& that); 37 | 38 | virtual ~Exception (); 39 | 40 | // Retrieve the message that this exception carries. 41 | virtual const char* msg () const; 42 | 43 | protected: 44 | 45 | char* _msg; 46 | 47 | }; 48 | 49 | // write to output stream 50 | inline std::ostream& operator<< (std::ostream& out, const Exception& e) { 51 | out << e.msg(); 52 | return out; 53 | } 54 | 55 | #endif // __Exception_hh__ 56 | -------------------------------------------------------------------------------- /instancesegmentation/categoryMapping.txt: -------------------------------------------------------------------------------- 1 | Instacne100 SceneParse150 FullADE20K 2 | 1 8 165 3 | 2 9 3055 4 | 3 11 350 5 | 4 13 1831 6 | 5 15 774 7 | 5 15 783 8 | 6 16 2684 9 | 7 19 687 10 | 8 20 471 11 | 9 21 401 12 | 10 23 1735 13 | 11 24 2473 14 | 12 25 2329 15 | 13 28 1564 16 | 14 31 57 17 | 15 32 2272 18 | 16 33 907 19 | 17 34 724 20 | 18 36 2985 21 | 18 36 533 22 | 19 37 1395 23 | 20 38 155 24 | 21 39 2053 25 | 22 40 689 26 | 23 42 266 27 | 24 43 581 28 | 25 44 2380 29 | 26 45 491 30 | 27 46 627 31 | 28 48 2388 32 | 29 50 943 33 | 30 51 2096 34 | 31 54 2530 35 | 32 56 420 36 | 33 57 1948 37 | 34 58 1869 38 | 35 59 2251 39 | 36 63 239 40 | 37 65 571 41 | 38 66 2793 42 | 39 67 978 43 | 40 68 236 44 | 41 70 181 45 | 42 71 629 46 | 43 72 2598 47 | 44 73 1744 48 | 45 74 1374 49 | 46 75 591 50 | 47 76 2679 51 | 48 77 223 52 | 49 79 47 53 | 50 81 327 54 | 51 82 2821 55 | 52 83 1451 56 | 53 84 2880 57 | 54 86 480 58 | 55 87 77 59 | 56 88 2616 60 | 57 89 246 61 | 57 89 247 62 | 58 90 2733 63 | 59 91 14 64 | 60 93 38 65 | 61 94 1936 66 | 62 96 120 67 | 63 98 1702 68 | 64 99 249 69 | 65 103 2928 70 | 66 104 2337 71 | 67 105 1023 72 | 68 108 2989 73 | 69 109 1930 74 | 70 111 2586 75 | 71 112 131 76 | 72 113 146 77 | 73 116 95 78 | 74 117 1563 79 | 75 119 1708 80 | 76 120 103 81 | 77 121 1002 82 | 78 122 2569 83 | 79 124 2833 84 | 80 125 1551 85 | 81 126 1981 86 | 82 127 29 87 | 83 128 187 88 | 84 130 747 89 | 85 131 2254 90 | 86 133 2262 91 | 87 134 1260 92 | 88 135 2243 93 | 89 136 2932 94 | 90 137 2836 95 | 91 138 2850 96 | 92 139 64 97 | 93 140 894 98 | 94 143 1919 99 | 95 144 1583 100 | 96 145 318 101 | 97 147 2046 102 | 98 148 1098 103 | 99 149 530 104 | 100 150 954 105 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/kofn.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "Random.hh" 3 | #include "kofn.hh" 4 | 5 | // O(n) implementation. 6 | static void 7 | _kOfN_largeK (int k, int n, int* values) 8 | { 9 | assert (k > 0); 10 | assert (k <= n); 11 | int j = 0; 12 | for (int i = 0; i < n; i++) { 13 | double prob = (double) (k - j) / (n - i); 14 | assert (prob <= 1); 15 | double x = Random::rand.fp (); 16 | if (x < prob) { 17 | values[j++] = i; 18 | } 19 | } 20 | assert (j == k); 21 | } 22 | 23 | // O(k*lg(k)) implementation; constant factor is about 2x the constant 24 | // factor for the O(n) implementation. 25 | static void 26 | _kOfN_smallK (int k, int n, int* values) 27 | { 28 | assert (k > 0); 29 | assert (k <= n); 30 | if (k == 1) { 31 | values[0] = Random::rand.i32 (0, n - 1); 32 | return; 33 | } 34 | int leftN = n / 2; 35 | int rightN = n - leftN; 36 | int leftK = 0; 37 | int rightK = 0; 38 | for (int i = 0; i < k; i++) { 39 | int x = Random::rand.i32 (0, n - i - 1); 40 | if (x < leftN - leftK) { 41 | leftK++; 42 | } else { 43 | rightK++; 44 | } 45 | } 46 | if (leftK > 0) { _kOfN_smallK (leftK, leftN, values); } 47 | if (rightK > 0) { _kOfN_smallK (rightK, rightN, values + leftK); } 48 | for (int i = leftK; i < k; i++) { 49 | values[i] += leftN; 50 | } 51 | } 52 | 53 | // Return k randomly selected integers from the interval [0,n), in 54 | // increasing sorted order. 55 | void 56 | kOfN (int k, int n, int* values) 57 | { 58 | assert (k >= 0); 59 | assert (n >= 0); 60 | if (k == 0) { return; } 61 | static double log2 = log (2); 62 | double klogk = k * log (k) / log2; 63 | if (klogk < n / 2) { 64 | _kOfN_smallK (k, n, values); 65 | } else { 66 | _kOfN_largeK (k, n, values); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /sceneparsing/evaluationCode/utils_eval.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | # This function takes the prediction and label of a single image, returns intersection and union areas for each class 4 | # To compute over many images do: 5 | # for i in range(Nimages): 6 | # (area_intersection[:,i], area_union[:,i]) = intersectionAndUnion(imPred[i], imLab[i]) 7 | # IoU = 1.0 * np.sum(area_intersection, axis=1) / np.sum(np.spacing(1)+area_union, axis=1) 8 | def intersectionAndUnion(imPred, imLab, numClass): 9 | imPred = np.asarray(imPred) 10 | imLab = np.asarray(imLab) 11 | 12 | # Remove classes from unlabeled pixels in gt image. 13 | # We should not penalize detections in unlabeled portions of the image. 14 | imPred = imPred * (imLab>0) 15 | 16 | # Compute area intersection: 17 | intersection = imPred * (imPred==imLab) 18 | (area_intersection,_) = np.histogram(intersection, bins=numClass, range=(1, numClass)) 19 | 20 | # Compute area union: 21 | (area_pred,_) = np.histogram(imPred, bins=numClass, range=(1, numClass)) 22 | (area_lab,_) = np.histogram(imLab, bins=numClass, range=(1, numClass)) 23 | area_union = area_pred + area_lab - area_intersection 24 | 25 | return (area_intersection, area_union) 26 | 27 | # This function takes the prediction and label of a single image, returns pixel-wise accuracy 28 | # To compute over many images do: 29 | # for i = range(Nimages): 30 | # (pixel_accuracy[i], pixel_correct[i], pixel_labeled[i]) = pixelAccuracy(imPred[i], imLab[i]) 31 | # mean_pixel_accuracy = 1.0 * np.sum(pixel_correct) / (np.spacing(1) + np.sum(pixel_labeled)) 32 | def pixelAccuracy(imPred, imLab): 33 | imPred = np.asarray(imPred) 34 | imLab = np.asarray(imLab) 35 | 36 | # Remove classes from unlabeled pixels in gt image. 37 | # We should not penalize detections in unlabeled portions of the image. 38 | pixel_labeled = np.sum(imLab>0) 39 | pixel_correct = np.sum((imPred==imLab)*(imLab>0)) 40 | pixel_accuracy = 1.0 * pixel_correct / pixel_labeled 41 | 42 | return (pixel_accuracy, pixel_correct, pixel_labeled) 43 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Random.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "Random.hh" 8 | #include "String.hh" 9 | #include "Exception.hh" 10 | 11 | // Copyright (C) 2002 David R. Martin 12 | // 13 | // This program is free software; you can redistribute it and/or 14 | // modify it under the terms of the GNU General Public License as 15 | // published by the Free Software Foundation; either version 2 of the 16 | // License, or (at your option) any later version. 17 | // 18 | // This program is distributed in the hope that it will be useful, but 19 | // WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | // General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU General Public License 24 | // along with this program; if not, write to the Free Software 25 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 26 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 27 | 28 | Random Random::rand; 29 | 30 | Random::Random () 31 | { 32 | reseed (0); 33 | } 34 | 35 | Random::Random (u_int64_t seed) 36 | { 37 | reseed (seed); 38 | } 39 | 40 | Random::Random (Random& that) 41 | { 42 | u_int64_t a = that.ui32 (); 43 | u_int64_t b = that.ui32 (); 44 | u_int64_t seed = (a << 32) | b; 45 | _init (seed); 46 | } 47 | 48 | void 49 | Random::reset () 50 | { 51 | _init (_seed); 52 | } 53 | 54 | void 55 | Random::reseed (u_int64_t seed) 56 | { 57 | if (seed == 0) { 58 | struct timeval t; 59 | gettimeofday (&t, NULL); 60 | u_int64_t a = (t.tv_usec >> 3) & 0xffff; 61 | u_int64_t b = t.tv_sec & 0xffff; 62 | u_int64_t c = (t.tv_sec >> 16) & 0xffff; 63 | seed = a | (b << 16) | (c << 32); 64 | } 65 | _init (seed); 66 | } 67 | 68 | void 69 | Random::_init (u_int64_t seed) 70 | { 71 | _seed = seed & 0xffffffffffffull; 72 | _xsubi[0] = (seed >> 0) & 0xffff; 73 | _xsubi[1] = (seed >> 16) & 0xffff; 74 | _xsubi[2] = (seed >> 32) & 0xffff; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/correspondPixels.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "Matrix.hh" 5 | #include "csa.hh" 6 | #include "match.hh" 7 | 8 | extern "C" { 9 | 10 | static const double maxDistDefault = 0.0075; 11 | static const double outlierCostDefault = 100; 12 | 13 | void 14 | mexFunction ( 15 | int nlhs, mxArray* plhs[], 16 | int nrhs, const mxArray* prhs[]) 17 | { 18 | // check number of arguments 19 | if (nlhs < 2) { 20 | mexErrMsgTxt("Too few output arguments."); 21 | } 22 | if (nlhs > 4) { 23 | mexErrMsgTxt("Too many output arguments."); 24 | } 25 | if (nrhs < 2) { 26 | mexErrMsgTxt("Too few input arguments."); 27 | } 28 | if (nrhs > 4) { 29 | mexErrMsgTxt("Too many input arguments."); 30 | } 31 | 32 | // get arguments 33 | double* bmap1 = mxGetPr(prhs[0]); 34 | double* bmap2 = mxGetPr(prhs[1]); 35 | const double maxDist = 36 | (nrhs>2) ? mxGetScalar(prhs[2]) : maxDistDefault; 37 | const double outlierCost = 38 | (nrhs>3) ? mxGetScalar(prhs[3]) : outlierCostDefault; 39 | 40 | // check arguments 41 | if (mxGetM(prhs[0]) != mxGetM(prhs[1]) 42 | || mxGetN(prhs[0]) != mxGetN(prhs[1])) { 43 | mexErrMsgTxt("bmap1 and bmap2 must be the same size"); 44 | } 45 | if (maxDist < 0) { 46 | mexErrMsgTxt("maxDist must be >= 0"); 47 | } 48 | if (outlierCost <= 1) { 49 | mexErrMsgTxt("outlierCost must be >1"); 50 | } 51 | 52 | // do the computation 53 | const int rows = mxGetM(prhs[0]); 54 | const int cols = mxGetN(prhs[0]); 55 | const double idiag = sqrt( rows*rows + cols*cols ); 56 | const double oc = outlierCost*maxDist*idiag; 57 | Matrix m1, m2; 58 | const double cost = matchEdgeMaps( 59 | Matrix(rows,cols,bmap1), Matrix(rows,cols,bmap2), 60 | maxDist*idiag, oc, 61 | m1, m2); 62 | 63 | // set output arguments 64 | plhs[0] = mxCreateDoubleMatrix(rows, cols, mxREAL); 65 | plhs[1] = mxCreateDoubleMatrix(rows, cols, mxREAL); 66 | double* match1 = mxGetPr(plhs[0]); 67 | double* match2 = mxGetPr(plhs[1]); 68 | memcpy(match1,m1.data(),m1.numel()*sizeof(double)); 69 | memcpy(match2,m2.data(),m2.numel()*sizeof(double)); 70 | if (nlhs > 2) { plhs[2] = mxCreateScalarDouble(cost); } 71 | if (nlhs > 3) { plhs[3] = mxCreateScalarDouble(oc); } 72 | } 73 | 74 | }; // extern "C" 75 | -------------------------------------------------------------------------------- /instancesegmentation/evaluation/convert_anns_to_json_dataset.py: -------------------------------------------------------------------------------- 1 | # This script converts image annotations in a val/test into a RLE format json dataset 2 | 3 | import os 4 | import glob 5 | import argparse 6 | import json 7 | import numpy as np 8 | from scipy.misc import imread 9 | from pycocotools import mask as COCOmask 10 | 11 | 12 | def parse_args(): 13 | parser = argparse.ArgumentParser(description='Evaluation demo') 14 | parser.add_argument('--ann_dir', default='./annotations_instance/validation') # CHANGE ACCORDINGLY 15 | parser.add_argument('--imgCatIdsFile', default='../imgCatIds.json') 16 | parser.add_argument('--output_json', default='./instance_validation_gts.json') 17 | 18 | args = parser.parse_args() 19 | return args 20 | 21 | 22 | def convert(args): 23 | data_dict = json.load(open(args.imgCatIdsFile, 'r')) 24 | img2id = {x['file_name']: x['id'] 25 | for x in data_dict['images']} 26 | img2info = {x['file_name']: x 27 | for x in data_dict['images']} 28 | 29 | categories = data_dict['categories'] 30 | images = [] 31 | images_unique = set() 32 | annotations = [] 33 | ann_id = 0 34 | # loop over annotation files 35 | files_ann = sorted(glob.glob(os.path.join(args.ann_dir, '*.png'))) 36 | for i, file_ann in enumerate(files_ann): 37 | if i % 50 == 0: 38 | print('#files processed: {}'.format(i)) 39 | 40 | file_name = os.path.basename(file_ann).replace('.png', '.jpg') 41 | img_id = img2id[file_name] 42 | if file_name not in images_unique: 43 | images_unique.add(file_name) 44 | images.append(img2info[file_name]) 45 | 46 | ann_mask = imread(file_ann) 47 | Om = ann_mask[:, :, 0] 48 | Oi = ann_mask[:, :, 1] 49 | 50 | # loop over instances 51 | for instIdx in np.unique(Oi): 52 | if instIdx == 0: 53 | continue 54 | imask = (Oi == instIdx) 55 | cat_id = Om[imask][0] 56 | 57 | # RLE encoding 58 | rle = COCOmask.encode(np.asfortranarray(imask.astype(np.uint8))) 59 | 60 | ann = {} 61 | ann['id'] = ann_id 62 | ann_id += 1 63 | ann['image_id'] = img_id 64 | ann['segmentation'] = rle 65 | ann['category_id'] = int(cat_id) 66 | ann['iscrowd'] = 0 67 | ann['area'] = np.sum(imask) 68 | annotations.append(ann) 69 | 70 | # data_dict['annotations'] = annotations 71 | print('#files: {}, #instances: {}'.format(len(files_ann), len(annotations))) 72 | 73 | data_out = {'categories': categories, 'images': images, 'annotations': annotations} 74 | with open(args.output_json, 'w') as f: 75 | json.dump(data_out, f) 76 | 77 | 78 | if __name__ == '__main__': 79 | args = parse_args() 80 | convert(args) -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Timer.cc: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (C) 2002 David R. Martin 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation; either version 2 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, but 10 | // WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | // General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 18 | 19 | #include 20 | #include 21 | #include 22 | #include "Timer.hh" 23 | 24 | typedef unsigned long long uint64; 25 | 26 | void 27 | Timer::_compute () 28 | { 29 | // Compute elapsed time. 30 | long sec = _elapsed_stop.tv_sec - _elapsed_start.tv_sec; 31 | long usec = _elapsed_stop.tv_usec - _elapsed_start.tv_usec; 32 | if (usec < 0) { 33 | sec -= 1; 34 | usec += 1000000; 35 | } 36 | _elapsed += (double) sec + usec / 1e6; 37 | 38 | // Computer CPU user and system times. 39 | _user += (double) (_cpu_stop.tms_utime - _cpu_start.tms_utime) 40 | / sysconf(_SC_CLK_TCK); 41 | _system += (double) (_cpu_stop.tms_stime - _cpu_start.tms_stime) 42 | / sysconf(_SC_CLK_TCK); 43 | } 44 | 45 | // Convert time in seconds into a nice human-friendly format: h:mm:ss.ss 46 | // Return a pointer to a static buffer. 47 | const char* 48 | Timer::formatTime (double sec, int precision) 49 | { 50 | static char buf[128]; 51 | 52 | // Limit range of precision for safety and sanity. 53 | precision = (precision < 0) ? 0 : precision; 54 | precision = (precision > 9) ? 9 : precision; 55 | uint64 base = 1; 56 | for (int digit = 0; digit < precision; digit++) { base *= 10;} 57 | 58 | bool neg = (sec < 0); 59 | uint64 ticks = (uint64) rint (fabs (sec) * base); 60 | uint64 rsec = ticks / base; // Rounded seconds. 61 | uint64 frac = ticks % base; 62 | 63 | uint64 h = rsec / 3600; 64 | uint64 m = (rsec / 60) % 60; 65 | uint64 s = rsec % 60; 66 | 67 | sprintf (buf, "%s%llu:%02llu:%02llu", 68 | neg ? "-" : "", h, m, s); 69 | 70 | if (precision > 0) { 71 | static char fmt[10]; 72 | sprintf (fmt, ".%%0%dlld", precision); 73 | sprintf (buf + strlen (buf), fmt, frac); 74 | } 75 | 76 | return buf; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/parfor_progress.m: -------------------------------------------------------------------------------- 1 | function percent = parfor_progress(N) 2 | %PARFOR_PROGRESS Progress monitor (progress bar) that works with parfor. 3 | % PARFOR_PROGRESS works by creating a file called parfor_progress.txt in 4 | % your working directory, and then keeping track of the parfor loop's 5 | % progress within that file. This workaround is necessary because parfor 6 | % workers cannot communicate with one another so there is no simple way 7 | % to know which iterations have finished and which haven't. 8 | % 9 | % PARFOR_PROGRESS(N) initializes the progress monitor for a set of N 10 | % upcoming calculations. 11 | % 12 | % PARFOR_PROGRESS updates the progress inside your parfor loop and 13 | % displays an updated progress bar. 14 | % 15 | % PARFOR_PROGRESS(0) deletes parfor_progress.txt and finalizes progress 16 | % bar. 17 | % 18 | % To suppress output from any of these functions, just ask for a return 19 | % variable from the function calls, like PERCENT = PARFOR_PROGRESS which 20 | % returns the percentage of completion. 21 | % 22 | % Example: 23 | % 24 | % N = 100; 25 | % parfor_progress(N); 26 | % parfor i=1:N 27 | % pause(rand); % Replace with real code 28 | % parfor_progress; 29 | % end 30 | % parfor_progress(0); 31 | % 32 | % See also PARFOR. 33 | 34 | % By Jeremy Scheff - jdscheff@gmail.com - http://www.jeremyscheff.com/ 35 | 36 | if nargin < 1 37 | N = -1; 38 | end 39 | 40 | percent = 0; 41 | w = 50; % Width of progress bar 42 | 43 | if N > 0 44 | f = fopen('parfor_progress.txt', 'w'); 45 | if f<0 46 | error('Do you have write permissions for %s?', pwd); 47 | end 48 | fprintf(f, '%d\n', N); % Save N at the top of progress.txt 49 | fclose(f); 50 | 51 | if nargout == 0 52 | disp([' 0%[ ', repmat(' ', 1, w), ']']); 53 | end 54 | elseif N == 0 55 | delete('parfor_progress.txt'); 56 | percent = 100; 57 | 58 | if nargout == 0 59 | disp([repmat(char(8), 1, (w+9)), char(10), '100%[', repmat('.', 1, w+1), ']']); 60 | end 61 | else 62 | if ~exist('parfor_progress.txt', 'file') 63 | error('parfor_progress.txt not found. Run PARFOR_PROGRESS(N) before PARFOR_PROGRESS to initialize parfor_progress.txt.'); 64 | end 65 | 66 | f = fopen('parfor_progress.txt', 'a'); 67 | fprintf(f, '1\n'); 68 | fclose(f); 69 | 70 | f = fopen('parfor_progress.txt', 'r'); 71 | progress = fscanf(f, '%d'); 72 | fclose(f); 73 | percent = (length(progress)-1)/progress(1)*100; 74 | 75 | if nargout == 0 76 | perc = sprintf('%3.0f%%', percent); % 4 characters wide, percentage 77 | disp([repmat(char(8), 1, (w+9)), char(10), perc, '[', repmat('.', 1, round(percent*w/100)), ' ', repmat(' ', 1, w - round(percent*w/100)), ']']); 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/evaluate_bdry.m: -------------------------------------------------------------------------------- 1 | function [thresh, cntR, sumR, cntP, sumP] = evaluate_bdry(bdryPred, bdryGT, margin, nthresh, thinpb, maxDist) 2 | % Performs alignment between ground truth and predicted boundaries, and 3 | % calculates the precision/recall curve. 4 | % Input: 5 | % bdryPred: The candidate boundary image. Must be double. 6 | % bdryGT : Ground truth boundaries 7 | % margin : Size of margin to be ignored in evaluation. 8 | % nthresh : Number of points in PR curve. 9 | % [thinpb] : Option to apply morphological thinning on predicted boundaries. 10 | % [MaxDist]: Threshold controlling the maximum mis-alignment distance 11 | % tolerated. Maximum tolerated distance = MaxDist*ImgDiagSize. 12 | % Output: 13 | % thresh : Vector of threshold values. 14 | % cntR : True positive numbers. (TP) 15 | % sumR : Condition positive numbers. (TP+FN) 16 | % cntP : True positive numbers. (TP) 17 | % sumP : Prediction positive numbers. (TP+FP) 18 | 19 | if nargin<5, thinpb = true; end 20 | if nargin<6, maxDist = 0.0075; end 21 | 22 | %% Ignore evaluation at margin pixels 23 | assert(margin>=0 && abs(round(margin)-margin)=thresh(t); 47 | 48 | % Thin the thresholded prediction to make sure boundaries are standard thickness 49 | if(thinpb) 50 | bdryThre = bwmorph(bdryThre, 'thin', inf); 51 | end 52 | 53 | % Perform edge alignment if gt boundary exists, and accumulate cntR 54 | if(bdryExist) 55 | % align predicted boundaries and ground truth boundaries 56 | [match1, match2] = correspondPixels(double(bdryThre), double(bdryGT), maxDist); 57 | 58 | % compute recall 59 | cntR(t) = sum(match2(:)>0); 60 | sumR(t) = sum(bdryGT(:)>0); 61 | 62 | % compute precision 63 | cntP(t) = sum(match1(:)>0); 64 | sumP(t) = sum(bdryThre(:)>0); 65 | 66 | % perform sanity check 67 | assert(cntR(t)==cntP(t), 'Matched pixel numbers between predicted boundary and gt not equal.'); 68 | else 69 | % If boundary does not exist, all predicted positives are false positives 70 | sumP(t) = sum(bdryThre(:)>0); 71 | end 72 | end -------------------------------------------------------------------------------- /sceneparsing/demoEvaluation.m: -------------------------------------------------------------------------------- 1 | % This script demos evaluation on all the prediction maps in pathPred 2 | % make sure you have corresponding ground truth label maps in pathLab 3 | close all; clc; clear; 4 | 5 | %% Options and paths 6 | VERBOSE = 0; % to show individual image results, set it to 1 7 | 8 | % path to image(.jpg), prediction(.png) and annotation(.png) 9 | % *NOTE: change these paths while evaluating your own predictions 10 | pathImg = fullfile('sampleData', 'images'); 11 | pathPred = fullfile('sampleData', 'predictions'); 12 | pathAnno = fullfile('sampleData', 'annotations'); 13 | 14 | addpath(genpath('evaluationCode/')); 15 | addpath(genpath('visualizationCode')); 16 | 17 | % number of object classes: 150 18 | numClass = 150; 19 | % load class names 20 | load('objectName150.mat'); 21 | % load pre-defined colors 22 | load('color150.mat'); 23 | 24 | %% Evaluation 25 | % initialize statistics 26 | cnt=0; 27 | area_intersection = double.empty; 28 | area_union = double.empty; 29 | pixel_accuracy = double.empty; 30 | pixel_correct = double.empty; 31 | pixel_labeled = double.empty; 32 | 33 | % main loop 34 | filesPred = dir(fullfile(pathPred, '*.png')); 35 | for i = 1: numel(filesPred) 36 | % check file existence 37 | filePred = fullfile(pathPred, filesPred(i).name); 38 | fileLab = fullfile(pathAnno, filesPred(i).name); 39 | if ~exist(fileLab, 'file') 40 | fprintf('Label file [%s] does not exist!\n', fileLab); continue; 41 | end 42 | 43 | % read in prediction and label 44 | imPred = imread(filePred); 45 | imAnno = imread(fileLab); 46 | 47 | % check image size 48 | if size(imPred, 3) ~= 1 49 | fprintf('Label image [%s] should be a gray-scale image!\n', fileLab); continue; 50 | end 51 | if size(imPred, 1)~=size(imAnno, 1) || size(imPred, 2)~=size(imAnno, 2) 52 | fprintf('Label image [%s] should have the same size as label image! Resizing...\n', fileLab); 53 | imPred = imresize(imPred, size(imAnno)); 54 | end 55 | 56 | % compute IoU 57 | cnt = cnt + 1; 58 | fprintf('Evaluating %d/%d...\n', cnt, numel(filesPred)); 59 | [area_intersection(:,cnt), area_union(:,cnt)] = intersectionAndUnion(imPred, imAnno, numClass); 60 | 61 | % compute pixel-wise accuracy 62 | [pixel_accuracy(i), pixel_correct(i), pixel_labeled(i)] = pixelAccuracy(imPred, imAnno); 63 | 64 | % Verbose: show indivudual image results 65 | if (VERBOSE) 66 | % read image 67 | fileImg = fullfile(pathImg, strrep(filesPred(i).name, '.png', '.jpg')); 68 | im = imread(fileImg); 69 | 70 | % plot result 71 | plotResult(im, imPred, imAnno, objectNames, colors, fileImg); 72 | fprintf('[%s] Pixel-wise accuracy: %2.2f%%\n', fileImg, pixel_accuracy(i)*100.); 73 | waitforbuttonpress; 74 | end 75 | end 76 | 77 | %% Summary 78 | IoU = sum(area_intersection,2)./sum(eps+area_union,2); 79 | mean_IoU = mean(IoU); 80 | accuracy = sum(pixel_correct)/sum(pixel_labeled); 81 | 82 | fprintf('==== Summary IoU ====\n'); 83 | for i = 1:numClass 84 | fprintf('%3d %16s: %.4f\n', i, objectNames{i}, IoU(i)); 85 | end 86 | fprintf('Mean IoU over %d classes: %.4f\n', numClass, mean_IoU); 87 | fprintf('Pixel-wise Accuracy: %2.2f%%\n', accuracy*100.); 88 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Timer.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __Timer_hh__ 3 | #define __Timer_hh__ 4 | 5 | // Copyright (C) 2002 David R. Martin 6 | // 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License as 9 | // published by the Free Software Foundation; either version 2 of the 10 | // License, or (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class Timer 29 | { 30 | public: 31 | 32 | inline Timer (); 33 | inline ~Timer (); 34 | 35 | inline void start (); 36 | inline void stop (); 37 | inline void reset (); 38 | 39 | // All times are in seconds. 40 | inline double cpu (); 41 | inline double user (); 42 | inline double system (); 43 | inline double elapsed (); 44 | 45 | // Convert time in seconds into a nice human-friendly format: h:mm:ss.ss 46 | // Precision is the number of digits after the decimal. 47 | // Return a pointer to a static buffer. 48 | static const char* formatTime (double sec, int precision = 2); 49 | 50 | private: 51 | 52 | void _compute (); 53 | 54 | enum State { stopped, running }; 55 | 56 | State _state; 57 | 58 | struct timeval _elapsed_start; 59 | struct timeval _elapsed_stop; 60 | double _elapsed; 61 | 62 | struct tms _cpu_start; 63 | struct tms _cpu_stop; 64 | double _user; 65 | double _system; 66 | }; 67 | 68 | Timer::Timer () 69 | { 70 | reset (); 71 | } 72 | 73 | Timer::~Timer () 74 | { 75 | } 76 | 77 | void 78 | Timer::reset () 79 | { 80 | _state = stopped; 81 | _elapsed = _user = _system = 0; 82 | } 83 | 84 | void 85 | Timer::start () 86 | { 87 | assert (_state == stopped); 88 | _state = running; 89 | gettimeofday (&_elapsed_start, NULL); 90 | times (&_cpu_start); 91 | } 92 | 93 | void 94 | Timer::stop () 95 | { 96 | assert (_state == running); 97 | gettimeofday (&_elapsed_stop, NULL); 98 | times (&_cpu_stop); 99 | _compute (); 100 | _state = stopped; 101 | } 102 | 103 | double 104 | Timer::cpu () 105 | { 106 | assert (_state == stopped); 107 | return _user + _system; 108 | } 109 | 110 | double 111 | Timer::user () 112 | { 113 | assert (_state == stopped); 114 | return _user; 115 | } 116 | 117 | double 118 | Timer::system () 119 | { 120 | assert (_state == stopped); 121 | return _system; 122 | } 123 | 124 | double 125 | Timer::elapsed () 126 | { 127 | assert (_state == stopped); 128 | return _elapsed; 129 | } 130 | 131 | #endif // __Timer_hh__ 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/benchmark_category.m: -------------------------------------------------------------------------------- 1 | function resultCat = benchmark_category(fileLst, predDir, gtDir, scoreDir, idxCls, nthresh, margin, verbose, showFig) 2 | % Computes the precision recall values for a given category and the 3 | % corresponding F-measure at optimal dataset scale (ODS) 4 | % Input: 5 | % fileLst : List of file names to be evluated. 6 | % predDir : Directory containing predicted boundaries. 7 | % gtDir : Directory containing ground truth boundaries. 8 | % scoreDir : Directory to put evaluation scores. 9 | % idxCls : Current category id. 10 | % [nthresh]: Number of thresholds applied in evaluation. 11 | % [margin] : Size of margin to be ignored in evaluation. 12 | % [verbose]: Flag choose to display image-wise results or not 13 | % [showFig]: Flag choose to display the predicted boundary of a certain 14 | % class or not when verbose is on 15 | % Output: 16 | % resultCat: 1. [T_ODS, R_ODS, P_ODS, F_ODS, R_OIS, P_OIS, F_OIS, AP] 17 | % 2. P, R and F values at different thresholds of a category 18 | % 3. P, R, F, TP, TP+FN, TP+FP values at different thresholds 19 | % of an image 20 | 21 | if(nargin<6), nthresh = 99; end; 22 | if(nargin<7), margin = 0; end; 23 | if(nargin<8), verbose = false; end; 24 | if(nargin<9), showFig = false; end; 25 | 26 | % If results exist, load & skip evaluation. Otherwise, perform evaluation 27 | assert(exist(scoreDir, 'file') == 7) 28 | if(exist(fullfile(scoreDir, ['class_' num2str(idxCls, '%03d') '.mat']), 'file') == 2) 29 | fprintf('Evaluation result exists. Skipping evaluation.\n') 30 | load(fullfile(scoreDir, ['class_' num2str(idxCls, '%03d') '.mat'])); 31 | else 32 | resultCatImg = evaluate_imgs(fileLst, predDir, gtDir, idxCls, nthresh, margin); 33 | resultCat = collect_eval_bdry(resultCatImg); 34 | save(fullfile(scoreDir, ['class_' num2str(idxCls, '%03d') '.mat']), 'resultCat'); 35 | end 36 | 37 | if(verbose) 38 | fprintf('verbose is on. turn verbose off to suppress image-wise outputs.\n') 39 | if(showFig) 40 | fprintf('showFig is on. Press on the figure to jump to next one. Turn showFig off to suppress illustration.\n') 41 | load('objectName150.mat'); 42 | end 43 | for idxImg = 1:length(resultCat{3}) 44 | % show image-wise evaluated scores on a certain class 45 | scoreImg = resultCat{3}{idxImg}; % [thre, F, P, R, TP, TP+FN, TP+FP] 46 | [~, idxOIS] = max(scoreImg(:, 2)); 47 | scoreOIS = scoreImg(idxOIS, :); 48 | fprintf('Image:%4d F_OIS:%4.3f R:%4.3f P:%4.3f TP:%5d TP+FN:%5d TP+FP:%5d\n', ... 49 | idxImg, scoreOIS(2), scoreOIS(3), scoreOIS(4), scoreOIS(5), scoreOIS(6), scoreOIS(7)); 50 | % show image-wise predicted boundaries on a certain class 51 | if(showFig) 52 | gtLoad = load(fullfile(gtDir, [fileLst{idxImg} '.mat']), 'gt'); 53 | bdryGT = full(double(gtLoad.gt.bdry{idxCls})); 54 | bdryPred = imread(fullfile(predDir, ['class_' num2str(idxCls, '%03d')], [fileLst{idxImg} '.png'])); 55 | set(gcf, 'Name', [fileLst{idxImg} ' (Press any key or click figure for the next image)'], 'NumberTitle', 'off'); 56 | subaxis(1, 2, 1, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 57 | imshow(bdryGT); title(['GT Class ' num2str(idxCls) ': ' objectNames{idxCls}]); 58 | subaxis(1, 2, 2, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 59 | imshow(bdryPred); title(['Prediction Class ' num2str(idxCls) ': ' objectNames{idxCls}]); 60 | waitforbuttonpress; 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /boundarydetection/demoEvaluation.m: -------------------------------------------------------------------------------- 1 | % This script demos the evaluation of the predicted boundaries in predDir. 2 | % Make sure you have the corresponding files in both predDir and gtDir. 3 | % Parallel computing with multiple workers is strongly recommended, as 4 | % boundary evaluation can take much time. 5 | close all; clc; clear; 6 | addpath(genpath('evaluationCode')); 7 | addpath(genpath('visualizationCode')); 8 | 9 | %% Set directories 10 | gtDir = fullfile('annotations_boundary', 'validation'); % Directory to put ground truth boundaries 11 | predDir = fullfile('predictions_boundary', 'validation'); % Directory to put predicted boundaries 12 | scoreDir = fullfile('result_eval', 'scores'); % Directory to put evaluation scores 13 | plotDir = fullfile('result_eval', 'plots'); % Directory to put evaluation plots 14 | 15 | %% Set evaluation parameters 16 | numCls = 150; 17 | margin = 3; % Size of margin to be ignored in evaluation 18 | nthresh = 99; % Number of thresholds 19 | numWorker = 20; % Number of matlab workers for parallel computing 20 | verbose = true; % Choose to display image-wise OIS scores or not 21 | showFig = true; % choose to display the predicted boundary of a certain class or not when verbose is on 22 | 23 | %% Perform evaluation 24 | % Make directories for evaluation results 25 | if(~exist(scoreDir, 'file')) 26 | mkdir(scoreDir); 27 | end 28 | if(~exist(plotDir, 'file')) 29 | mkdir(plotDir); 30 | end 31 | 32 | % Define the set of files to be evaluated 33 | fileLst = dir(fullfile(gtDir, '*.mat')); 34 | fileLst = {fileLst.name}; 35 | numFile = length(fileLst); 36 | for idxFile = 1:numFile 37 | fileLst{idxFile} = fileLst{idxFile}(1:end-4); 38 | end 39 | 40 | % Load predefined class names and colors 41 | load('objectName150.mat'); 42 | load('color150.mat'); 43 | 44 | % Make sure parallel pool is created to guarantee correct parfor monitoring 45 | matlabVer = version('-release'); 46 | if( str2double(matlabVer(1:4)) > 2013 || (str2double(matlabVer(1:4)) == 2013 && strcmp(matlabVer(5), 'b')) ) 47 | delete(gcp('nocreate')); 48 | parpool('local', numWorker); 49 | else 50 | if(matlabpool('size')>0) %#ok<*DPOOL> 51 | matlabpool close 52 | end 53 | matlabpool open 8 54 | end 55 | 56 | % Main evaluation loop 57 | for idxCls = 1:numCls 58 | fprintf('Benchmarking boundaries for category %d: %s\n', idxCls, objectNames{idxCls}); 59 | resultCat = benchmark_category(fileLst, predDir, gtDir, scoreDir, idxCls, nthresh, margin, verbose, showFig); 60 | end 61 | 62 | %% Collect evaluation results 63 | fprintf('==== Summary F-ODS ====\n'); 64 | F_ODS = zeros(numCls, 1); 65 | for idxCls = 1:numCls 66 | load(fullfile(scoreDir, ['class_' num2str(idxCls, '%03d') '.mat'])) 67 | F_ODS(idxCls) = resultCat{1}(4); 68 | fprintf('%3d %16s: %.4f\n', idxCls, objectNames{idxCls}, F_ODS(idxCls)); 69 | end 70 | F_ODS_Mean = mean(F_ODS); 71 | fprintf('Mean F-ODS over %d classes: %.4f\n', numCls, F_ODS_Mean); 72 | save(fullfile(scoreDir, 'F_ODS.mat'), 'F_ODS'); 73 | 74 | %% Plot category-wise F-ODS histogram 75 | fprintf('Plotting f-ods histogram over %d classes\n', numCls); 76 | load(fullfile(scoreDir, 'F_ODS.mat')); 77 | figure('Visible', 'off') 78 | bar(1:length(F_ODS), F_ODS); 79 | ylim([0 1]) 80 | xlabel('Category ID') 81 | ylabel('F-ODS Score') 82 | title('F-ODS over 150 Classes') 83 | print(gcf, fullfile(plotDir, 'F_ODS.pdf'),'-dpdf') 84 | close(gcf) 85 | 86 | %% Plot PR curves 87 | % plot_pr supports plotting multiple evaluation results on the same figure. 88 | % To do that, input the first two arguments as: {scoreDir1; scoreDir2; ...} 89 | % and {methodName1; methodName2; ...} 90 | plot_pr({scoreDir}, {'baseline'}, numCls, plotDir, objectNames); 91 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/collect_eval_bdry.m: -------------------------------------------------------------------------------- 1 | function resultCat = collect_eval_bdry(resultCatImg) 2 | % Computes the F-measures at both optimal dataset scale (ODS) and optimal 3 | % image scale (OIS) 4 | % Input: 5 | % resultCatImg: [Threshold, TP, TP+FN, TP, TP+FP] of every image. 6 | % Output: 7 | % resultCat: 1. [T_ODS, R_ODS, P_ODS, F_ODS, R_OIS, P_OIS, F_OIS, AP] 8 | % 2. P, R and F values at different thresholds of a category 9 | % 3. P, R, F, TP, TP+FN, TP+FP values at different thresholds 10 | % of an image 11 | 12 | dR = 0.01; 13 | numFile = size(resultCatImg, 1); 14 | AA = resultCatImg{1, 1}; % thresh cntR sumR cntP sumP 15 | thresh = AA(:, 1); 16 | nthresh = numel(thresh); 17 | cntR_total = zeros(nthresh,1); 18 | sumR_total = zeros(nthresh,1); 19 | cntP_total = zeros(nthresh,1); 20 | sumP_total = zeros(nthresh,1); 21 | cntR_max = 0; 22 | sumR_max = 0; 23 | cntP_max = 0; 24 | sumP_max = 0; 25 | 26 | % main loop 27 | resultCat = cell(3, 1); 28 | resultCat{3} = cell(numFile, 1); 29 | for idxFile = 1:numFile 30 | AA = resultCatImg{idxFile, 1}; 31 | cntR = AA(:, 2); 32 | sumR = AA(:, 3); 33 | cntP = AA(:, 4); 34 | sumP = AA(:, 5); 35 | 36 | % accumulate for ODS scores 37 | cntR_total = cntR_total + cntR; 38 | sumR_total = sumR_total + sumR; 39 | cntP_total = cntP_total + cntP; 40 | sumP_total = sumP_total + sumP; 41 | 42 | % accumulate for OIS scores 43 | R = cntR ./ (sumR + (sumR==0)); 44 | P = cntP ./ (sumP + (sumP==0)); 45 | F = fmeasure(R, P); 46 | [~, idxOIS] = max(F); 47 | cntR_max = cntR_max + cntR(idxOIS); 48 | sumR_max = sumR_max + sumR(idxOIS); 49 | cntP_max = cntP_max + cntP(idxOIS); 50 | sumP_max = sumP_max + sumP(idxOIS); 51 | 52 | % store image-level scores 53 | resultCat{3}{idxFile} = [thresh, F, P, R, cntR, sumR, sumP]; 54 | end 55 | 56 | % compute ODS scores 57 | R = cntR_total ./ (sumR_total + (sumR_total==0)); 58 | P = cntP_total ./ (sumP_total + (sumP_total==0)); 59 | F = fmeasure(R, P); 60 | [T_ODS, R_ODS, P_ODS, F_ODS] = maxF(thresh, R, P); 61 | 62 | % compute OIS scores 63 | R_OIS = cntR_max ./ (sumR_max + (sumR_max==0)); 64 | P_OIS = cntP_max ./ (sumP_max + (sumP_max==0)); 65 | F_OIS = fmeasure(R_OIS, P_OIS); 66 | 67 | % compute average precision 68 | [Ru, indR, ~] = unique(R); 69 | Pu = P(indR); 70 | Ri = 0 : dR : 1; 71 | if numel(Ru)>1, 72 | P_int1 = interp1(Ru, Pu, Ri); 73 | P_int1(isnan(P_int1)) = 0; 74 | AP = sum(P_int1)*dR; 75 | else 76 | AP = 0; 77 | end 78 | 79 | % store category-level scores 80 | resultCat{1, 1} = [T_ODS, R_ODS, P_ODS, F_ODS, R_OIS, P_OIS, F_OIS, AP]; 81 | resultCat{2, 1} = [thresh, R, P, F]; 82 | end 83 | 84 | % compute f-measure fromm recall and precision 85 | function [f] = fmeasure(r,p) 86 | f = 2*p.*r./(p+r+((p+r)==0)); 87 | end 88 | 89 | % interpolate to find best F and coordinates thereof 90 | function [T_ODS, R_ODS, P_ODS, F_ODS] = maxF(thresh, R, P) 91 | T_ODS = thresh(1); 92 | R_ODS = R(1); 93 | P_ODS = P(1); 94 | F_ODS = fmeasure(R(1),P(1)); 95 | for idxThre = 2:numel(thresh), 96 | for d = linspace(0,1), 97 | t = thresh(idxThre)*d + thresh(idxThre-1)*(1-d); 98 | r = R(idxThre)*d + R(idxThre-1)*(1-d); 99 | p = P(idxThre)*d + P(idxThre-1)*(1-d); 100 | f = fmeasure(r,p); 101 | if f > F_ODS, 102 | T_ODS = t; 103 | R_ODS = r; 104 | P_ODS = p; 105 | F_ODS = f; 106 | end 107 | end 108 | end 109 | end 110 | -------------------------------------------------------------------------------- /instancesegmentation/instanceInfo100_val.txt: -------------------------------------------------------------------------------- 1 | Idx Object Names #Inst. #Pix. per Inst.(*1e3) 2 | 1 bed 229 53.14 3 | 2 windowpane 890 10.01 4 | 3 cabinet 690 13.27 5 | 4 person 2968 2.87 6 | 5 door 448 12.87 7 | 6 table 702 7.40 8 | 7 curtain 370 13.20 9 | 8 chair 1333 3.65 10 | 9 car 1423 2.95 11 | 10 painting 786 3.62 12 | 11 sofa 139 21.11 13 | 12 shelf 216 11.85 14 | 13 mirror 154 14.77 15 | 14 armchair 177 9.86 16 | 15 seat 184 8.32 17 | 16 fence 217 7.47 18 | 17 desk 99 12.94 19 | 18 wardrobe 53 35.17 20 | 19 lamp 533 2.35 21 | 20 bathtub 38 29.82 22 | 21 railing 194 6.59 23 | 22 cushion 482 2.37 24 | 23 box 499 2.18 25 | 24 column 215 5.49 26 | 25 signboard 730 1.50 27 | 26 chest of drawers 53 14.20 28 | 27 counter 45 18.87 29 | 28 sink 140 5.56 30 | 29 fireplace 38 22.60 31 | 30 refrigerator 45 21.11 32 | 31 stairs 119 8.07 33 | 32 case 13 58.89 34 | 33 pool table 22 32.08 35 | 34 pillow 243 3.93 36 | 35 screen door 19 38.31 37 | 36 bookcase 36 13.56 38 | 37 coffee table 79 9.24 39 | 38 toilet 56 13.70 40 | 39 flower 260 1.94 41 | 40 book 467 1.19 42 | 41 bench 166 3.99 43 | 42 countertop 32 14.41 44 | 43 stove 57 11.54 45 | 44 palm 110 3.37 46 | 45 kitchen island 9 37.56 47 | 46 computer 53 14.40 48 | 47 swivel chair 97 4.01 49 | 48 boat 111 3.09 50 | 49 arcade machine 19 13.55 51 | 50 bus 37 11.44 52 | 51 towel 122 3.04 53 | 52 light 1240 0.35 54 | 53 truck 53 3.34 55 | 54 chandelier 72 5.27 56 | 55 awning 114 2.39 57 | 56 streetlight 704 0.56 58 | 57 booth 22 12.93 59 | 58 television receiver 57 6.40 60 | 59 airplane 31 7.55 61 | 60 apparel 39 4.22 62 | 61 pole 221 1.64 63 | 62 bannister 83 2.95 64 | 63 ottoman 43 6.39 65 | 64 bottle 456 0.56 66 | 65 van 75 2.78 67 | 66 ship 5 59.17 68 | 67 fountain 5 75.14 69 | 68 washer 31 15.19 70 | 69 plaything 80 1.74 71 | 70 stool 77 2.68 72 | 71 barrel 5 1.76 73 | 72 basket 132 2.06 74 | 73 bag 186 1.83 75 | 74 minibike 69 2.65 76 | 75 oven 21 7.55 77 | 76 ball 94 0.89 78 | 77 food 212 2.43 79 | 78 step 37 7.11 80 | 79 trade name 154 2.22 81 | 80 microwave 45 11.26 82 | 81 pot 273 1.21 83 | 82 animal 137 3.58 84 | 83 bicycle 60 1.91 85 | 84 dishwasher 23 6.95 86 | 85 screen 13 20.74 87 | 86 sculpture 26 4.70 88 | 87 hood 27 6.90 89 | 88 sconce 201 0.88 90 | 89 vase 183 0.72 91 | 90 traffic light 147 1.12 92 | 91 tray 88 1.63 93 | 92 ashcan 120 1.51 94 | 93 fan 52 3.17 95 | 94 plate 197 1.05 96 | 95 monitor 34 6.72 97 | 96 bulletin board 26 6.17 98 | 97 radiator 30 6.44 99 | 98 glass 222 1.02 100 | 99 clock 104 1.01 101 | 100 flag 106 1.58 102 | -------------------------------------------------------------------------------- /instancesegmentation/instanceInfo100_train.txt: -------------------------------------------------------------------------------- 1 | Idx Object Names #Inst. #Pix. per Inst.(*1e3) 2 | 1 bed 2189 49.06 3 | 2 windowpane 8833 10.57 4 | 3 cabinet 6727 12.59 5 | 4 person 21441 3.47 6 | 5 door 4694 11.82 7 | 6 table 7285 7.09 8 | 7 curtain 4099 11.89 9 | 8 chair 12432 3.87 10 | 9 car 13554 3.44 11 | 10 painting 8083 3.94 12 | 11 sofa 1571 19.67 13 | 12 shelf 2187 13.24 14 | 13 mirror 1444 17.05 15 | 14 armchair 2143 9.77 16 | 15 seat 1624 13.51 17 | 16 fence 2060 7.35 18 | 17 desk 1227 12.08 19 | 18 wardrobe 414 33.66 20 | 19 lamp 5503 2.18 21 | 20 bathtub 405 27.86 22 | 21 railing 1235 8.93 23 | 22 cushion 4424 2.43 24 | 23 box 3858 2.65 25 | 24 column 1794 5.57 26 | 25 signboard 5377 1.76 27 | 26 chest of drawers 610 14.75 28 | 27 counter 422 20.83 29 | 28 sink 1340 6.44 30 | 29 fireplace 470 17.97 31 | 30 refrigerator 415 20.12 32 | 31 stairs 1078 7.23 33 | 32 case 236 33.52 34 | 33 pool table 242 32.60 35 | 34 pillow 2003 3.81 36 | 35 screen door 150 48.46 37 | 36 bookcase 493 14.13 38 | 37 coffee table 856 7.77 39 | 38 toilet 406 16.16 40 | 39 flower 2144 3.16 41 | 40 book 4616 1.35 42 | 41 bench 1186 5.09 43 | 42 countertop 349 16.20 44 | 43 stove 540 10.11 45 | 44 palm 1090 5.26 46 | 45 kitchen island 145 38.83 47 | 46 computer 502 9.45 48 | 47 swivel chair 987 4.99 49 | 48 boat 693 6.41 50 | 49 arcade machine 228 19.02 51 | 50 bus 440 9.27 52 | 51 towel 1012 3.90 53 | 52 light 9112 0.41 54 | 53 truck 619 6.31 55 | 54 chandelier 739 4.75 56 | 55 awning 909 3.88 57 | 56 streetlight 3952 0.86 58 | 57 booth 164 22.31 59 | 58 television receiver 636 5.14 60 | 59 airplane 286 11.85 61 | 60 apparel 427 7.60 62 | 61 pole 1887 1.58 63 | 62 bannister 701 4.28 64 | 63 ottoman 390 7.48 65 | 64 bottle 3187 0.92 66 | 65 van 739 3.90 67 | 66 ship 61 42.64 68 | 67 fountain 102 24.17 69 | 68 washer 159 14.44 70 | 69 plaything 985 2.62 71 | 70 stool 917 2.67 72 | 71 barrel 317 8.11 73 | 72 basket 1009 2.25 74 | 73 bag 984 2.15 75 | 74 minibike 605 3.74 76 | 75 oven 251 9.10 77 | 76 ball 639 3.65 78 | 77 food 587 3.17 79 | 78 step 313 6.41 80 | 79 trade name 551 3.33 81 | 80 microwave 329 4.94 82 | 81 pot 2243 0.80 83 | 82 animal 396 4.02 84 | 83 bicycle 561 3.34 85 | 84 dishwasher 247 7.28 86 | 85 screen 117 13.96 87 | 86 sculpture 510 3.39 88 | 87 hood 268 6.20 89 | 88 sconce 1711 0.95 90 | 89 vase 1938 0.85 91 | 90 traffic light 973 1.61 92 | 91 tray 679 2.34 93 | 92 ashcan 830 1.76 94 | 93 fan 440 3.35 95 | 94 plate 1561 0.90 96 | 95 monitor 567 2.40 97 | 96 bulletin board 282 5.02 98 | 97 radiator 199 5.93 99 | 98 glass 1487 0.67 100 | 99 clock 843 1.25 101 | 100 flag 802 1.11 102 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Random.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __Random_hh__ 3 | #define __Random_hh__ 4 | 5 | // Copyright (C) 2002 David R. Martin 6 | // 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License as 9 | // published by the Free Software Foundation; either version 2 of the 10 | // License, or (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // All random numbers are generated from a single seed. This is true 28 | // even when private random streams (seperate from the global 29 | // Random::rand stream) are spawned from existing streams, since the new 30 | // streams are seeded automatically from the parent's random stream. 31 | // Any random stream can be reset so that a sequence of random values 32 | // can be replayed. 33 | 34 | // If seed==0, then the seed is generated from the system clock. 35 | 36 | class Random 37 | { 38 | public: 39 | 40 | static Random rand; 41 | 42 | // These are defined in as the limits of int, but 43 | // here we need the limits of int32_t. 44 | static const int32_t int32_max = 2147483647; 45 | static const int32_t int32_min = -int32_max-1; 46 | static const u_int32_t u_int32_max = 4294967295u; 47 | 48 | // Seed from the system clock. 49 | Random (); 50 | 51 | // Specify seed. 52 | // If zero, seed from the system clock. 53 | Random (u_int64_t seed); 54 | 55 | // Spawn off a new random stream seeded from the parent's stream. 56 | Random (Random& that); 57 | 58 | // Restore initial seed so we can replay a random sequence. 59 | void reset (); 60 | 61 | // Set the seed. 62 | // If zero, seed from the system clock. 63 | void reseed (u_int64_t seed); 64 | 65 | // double in [0..1) or [a..b) 66 | inline double fp (); 67 | inline double fp (double a, double b); 68 | 69 | // 32-bit signed integer in [-2^31,2^31) or [a..b] 70 | inline int32_t i32 (); 71 | inline int32_t i32 (int32_t a, int32_t b); 72 | 73 | // 32-bit unsigned integer in [0,2^32) or [a..b] 74 | inline u_int32_t ui32 (); 75 | inline u_int32_t ui32 (u_int32_t a, u_int32_t b); 76 | 77 | protected: 78 | 79 | void _init (u_int64_t seed); 80 | 81 | // The original seed for this random stream. 82 | u_int64_t _seed; 83 | 84 | // The current state for this random stream. 85 | u_int16_t _xsubi[3]; 86 | 87 | }; 88 | 89 | inline u_int32_t 90 | Random::ui32 () 91 | { 92 | return ui32(0,u_int32_max); 93 | } 94 | 95 | inline u_int32_t 96 | Random::ui32 (u_int32_t a, u_int32_t b) 97 | { 98 | assert (a <= b); 99 | double x = fp (); 100 | return (u_int32_t) floor (x * ((double)b - (double)a + 1) + a); 101 | } 102 | 103 | inline int32_t 104 | Random::i32 () 105 | { 106 | return i32(int32_min,int32_max); 107 | } 108 | 109 | inline int32_t 110 | Random::i32 (int32_t a, int32_t b) 111 | { 112 | assert (a <= b); 113 | double x = fp (); 114 | return (int32_t) floor (x * ((double)b - (double)a + 1) + a); 115 | } 116 | 117 | inline double 118 | Random::fp () 119 | { 120 | return erand48 (_xsubi); 121 | } 122 | 123 | inline double 124 | Random::fp (double a, double b) 125 | { 126 | assert (a < b); 127 | return erand48 (_xsubi) * (b - a) + a; 128 | } 129 | 130 | #endif // __Random_hh__ 131 | 132 | -------------------------------------------------------------------------------- /instancesegmentation/README.md: -------------------------------------------------------------------------------- 1 | # Instruction for the Instance Segmentation Task 2 | 3 | 4 | 5 | Scene Instance Segmentation is to segment an image into object instances. The task is pixel-wise classification similar to scene parsing, but it requires the proposed algorithm to extract object instances from the image as well. The motivation of this task is two folds: 1) Push the research of semantic segmentation towards instance segmentation; 2) Let there be more synergy among object detection, semantic segmentation, and the scene parsing. The data share semantic categories with scene parsing task, but comes with object instance annotations for 100 categories. The evaluation metric is Average Precision (AP) over all the 100 semantic categories. 6 | * We encourage all participants of this task to take part in the COCO instance segmentation challenge as well. 7 | 8 | ## Data 9 | 10 | - Download the images [here](http://placeschallenge.csail.mit.edu/data/ChallengeData2017/images.tar). Note that Images are the same for all the three tasks in Places Challenge 2017. 11 | - Download the instance segmentation annotations [here](http://placeschallenge.csail.mit.edu/data/ChallengeData2017/annotations_instance.tar). After untarring the data file, the directory structure should be similar to the following, 12 | 13 | the training images: 14 | 15 | images/training/ADE_train_00000001.jpg 16 | images/training/ADE_train_00000002.jpg 17 | ... 18 | 19 | the validation images: 20 | 21 | images/training/ADE_val_00000001.jpg 22 | images/training/ADE_val_00000002.jpg 23 | ... 24 | 25 | the testing images: 26 | 27 | images/testing/ADE_test_00000001.jpg 28 | ... 29 | 30 | 31 | the corresponding instance annotation masks for the training images and validation images: 32 | 33 | annotations_instance/training/ADE_train_00000001.png 34 | annotations_instance/training/ADE_train_00000002.png 35 | ... 36 | 37 | annotations_instance/validation/ADE_val_00000001.png 38 | annotations_instance/validation/ADE_val_00000002.png 39 | ... 40 | 41 | In the instance annotation masks, the R(ed) channel encodes category ID, and the G(reen) channel encodes instance ID. Each object instance has a unique instance ID regardless of its category ID. 42 | In the dataset, all images have <256 object instances. 43 | 44 | 45 | ## Submission format 46 | 47 | The submission file should be a single .json file containing all the predictions in RLE: 48 | 49 | [{ 50 | "image_id" : int, # IMPORTANT: image_id should match file_name according to imgCatIds.json 51 | "category_id" : int, 52 | "segmentation" : RLE, 53 | "score" : float, 54 | }] 55 | 56 | 57 | ## Evaluation routines 58 | The performance of the instance segmentation algorithms will be evaluated by Average Precision (AP, or mAP), following COCO evaluation metrics. 59 | For each image, we take at most 255 top-scoring instance masks across all categories. 60 | For each instance mask prediction, we only count it when its IoU with ground truth is above a certain threshold. We take 10 IoU thresholds of 0.50:0.05:0.95 for evaluation. The final AP is averaged across 10 IoU thresholds and 100 categories. 61 | 62 | You can refer to COCO evaluation page for more explanation: http://mscoco.org/dataset/#detections-eval 63 | 64 | For everyone's reference, Mask-RCNN with ResNet-FPN-50 backbone achieves 20.0 mAP on the validation set. 65 | - Only backbone is pretrained on ImageNet; RPN+Bbox+Mask are jointly trained; single-scale training and testing. 66 | 67 | This was achieved by Hang Zhao when he was an intern at Facebook. We thank Kaiming He and Ross Girshick for the code pointers and suggestions. 68 | 69 | To run the evaluation demo: 70 | 71 | 0. ```cd instancesegmentation/evaluation``` 72 | 1. Convert annotations of validation set (*.png) into RLE format (.json), by ```python convert_anns_to_json_dataset.py``` 73 | 2. Install COCO API: https://github.com/pdollar/coco 74 | 3. Prepare your results in the submission format (.json) 75 | 4. python eval_main.py --dataset_json DATASET_JSON --preds_json PREDS_JSON 76 | 77 | -------------------------------------------------------------------------------- /sceneparsing/README.md: -------------------------------------------------------------------------------- 1 | # Instruction for the Scene Parsing Task 2 | 3 | Scene parsing is to segment and parse an image into different image regions associated with semantic categories, such as sky, road, person, and bed. It is similar to semantic segmentation tasks in COCO and Pascal Dataset, but the data is more scene-centric and with a diverse range of object categories. Specifically, the challenge data is divided into 20K images for training, 2K images for validation, and another batch of held-out images for testing. There are in total 150 semantic categories included in the benchmark for evaluation, which include stuffs like sky, road, grass, and discrete objects like person, car, bed. Note that non-uniform distribution of objects occurs in the images, mimicking a more natural object occurrence in daily scenes. 4 | 5 | The scene parsing is one of the three scene understanding tasks at the [Places Challenge 2017](http://placeschallenge.csail.mit.edu/). 6 | 7 | 8 | ## Data 9 | 10 | - Download the images at [here](http://placeschallenge.csail.mit.edu/data/ChallengeData2017/images.tar). Images are the same for all the three tasks in Places Challenge 2017. 11 | - Download the scene parsing data at [here](http://placeschallenge.csail.mit.edu/data/ChallengeData2017/sceneparsing.tar). After untarring the image file and annotation file, the directory structure should be similar to the following, 12 | 13 | the training images: 14 | 15 | images/training/ADE_train_00000001.jpg 16 | images/training/ADE_train_00000002.jpg 17 | ... 18 | images/training/ADE_train_00020210.jpg 19 | 20 | the validation images: 21 | images/training/ADE_train_00000001.jpg 22 | images/training/ADE_train_00000002.jpg 23 | ... 24 | images/training/ADE_train_00020210.jpg 25 | 26 | the testing images: 27 | images/testing/ADE_test_00000001.jpg 28 | ... 29 | 30 | the corresponding instance annotation masks for the training images and validation images: 31 | 32 | annotations_sceneparsing/training/ADE_train_00000001.png 33 | annotations_sceneparsing/training/ADE_train_00000002.png 34 | ... 35 | annotations_sceneparsing/training/ADE_train_00020210.png 36 | 37 | annotations_sceneparsing/validation/ADE_val_00000001.png 38 | annotations_sceneparsing/validation/ADE_val_00000002.png 39 | ... 40 | annotations_sceneparsing/validation/ADE_val_00002000.png 41 | 42 | In each instance annotation mask, balbalba 43 | 44 | ## Submission format to the evaluation server 45 | 46 | To evaluate the algorithm on the test set of the benchmark (link: TBD), participants are required to upload a zip file which contains the predicted annotation mask for the given testing images to the evaluation server. The naming of the predicted annotation mask should be the same as the name of the testing images, while the filename extension should be png instead of jpg. For example, the predicted annotation mask for file ADE_test_00000001.jpg should be ADE_test_00000001.png. 47 | 48 | Participants should check the zip file to make sure it could be decompressed correctly. 49 | 50 | ## Evaluation routines 51 | 52 | The performance of the segmentation algorithms will be evaluated by the mean of (1) pixel-wise accuracy over all the labeled pixels, and (2) IoU (intersection over union) avereaged over all the 150 semantic categories. 53 | 54 | Intersection over Union = (true positives) / (true positives + false positives + false negatives) 55 | Pixel-wise Accuracy = correctly classifield pixels / labeled pixels 56 | Final score = (Pixel-wise Accuracy + mean(Intersection over Union)) / 2 57 | 58 | ## Demo codes 59 | 60 | In demoEvaluation.m, we have included our implementation of the standard evaluation metrics (pixel-wise accuracy and IoU) for the benchmark. As mentioned before, we ignore pixels labeled with 0's. 61 | 62 | Please change the paths at the begining of the code accordingly to evalutate your own results. While running it correctly, you are expected to see output similar to: 63 | 64 | Mean IoU over 150 classes: 0.1000 65 | Pixel-wise Accuracy: 100.00% 66 | 67 | In this case, we will take (0.1+1.0)/2=0.55 as your final score. 68 | 69 | We have also provided demoVisualization.m, which helps you to visualize individual image results. 70 | -------------------------------------------------------------------------------- /boundarydetection/visualizationCode/subaxis/subaxis.m: -------------------------------------------------------------------------------- 1 | function h=subaxis(varargin) 2 | %SUBAXIS Create axes in tiled positions. (just like subplot) 3 | % Usage: 4 | % h=subaxis(rows,cols,cellno[,settings]) 5 | % h=subaxis(rows,cols,cellx,celly[,settings]) 6 | % h=subaxis(rows,cols,cellx,celly,spanx,spany[,settings]) 7 | % 8 | % SETTINGS: Spacing,SpacingHoriz,SpacingVert 9 | % Padding,PaddingRight,PaddingLeft,PaddingTop,PaddingBottom 10 | % Margin,MarginRight,MarginLeft,MarginTop,MarginBottom 11 | % Holdaxis 12 | % 13 | % all units are relative (i.e. from 0 to 1) 14 | % 15 | % Abbreviations of parameters can be used.. (Eg MR instead of MarginRight) 16 | % (holdaxis means that it wont delete any axes below.) 17 | % 18 | % 19 | % Example: 20 | % 21 | % >> subaxis(2,1,1,'SpacingVert',0,'MR',0); 22 | % >> imagesc(magic(3)) 23 | % >> subaxis(2,'p',.02); 24 | % >> imagesc(magic(4)) 25 | % 26 | % 2001-2014 / Aslak Grinsted (Feel free to modify this code.) 27 | 28 | f=gcf; 29 | 30 | 31 | 32 | UserDataArgsOK=0; 33 | Args=get(f,'UserData'); 34 | if isstruct(Args) 35 | UserDataArgsOK=isfield(Args,'SpacingHorizontal')&isfield(Args,'Holdaxis')&isfield(Args,'rows')&isfield(Args,'cols'); 36 | end 37 | OKToStoreArgs=isempty(Args)|UserDataArgsOK; 38 | 39 | if isempty(Args)&&(~UserDataArgsOK) 40 | Args=struct('Holdaxis',0, ... 41 | 'SpacingVertical',0.05,'SpacingHorizontal',0.05, ... 42 | 'PaddingLeft',0,'PaddingRight',0,'PaddingTop',0,'PaddingBottom',0, ... 43 | 'MarginLeft',.1,'MarginRight',.1,'MarginTop',.1,'MarginBottom',.1, ... 44 | 'rows',[],'cols',[]); 45 | end 46 | Args=parseArgs(varargin,Args,{'Holdaxis'},{'Spacing' {'sh','sv'}; 'Padding' {'pl','pr','pt','pb'}; 'Margin' {'ml','mr','mt','mb'}}); 47 | 48 | if (length(Args.NumericArguments)>2) 49 | Args.rows=Args.NumericArguments{1}; 50 | Args.cols=Args.NumericArguments{2}; 51 | %remove these 2 numerical arguments 52 | Args.NumericArguments={Args.NumericArguments{3:end}}; 53 | end 54 | 55 | if OKToStoreArgs 56 | set(f,'UserData',Args); 57 | end 58 | 59 | 60 | switch length(Args.NumericArguments) 61 | case 0 62 | return % no arguments but rows/cols.... 63 | case 1 64 | if numel(Args.NumericArguments{1}) > 1 % restore subplot(m,n,[x y]) behaviour 65 | [x1 y1] = ind2sub([Args.cols Args.rows],Args.NumericArguments{1}(1)); % subplot and ind2sub count differently (column instead of row first) --> switch cols/rows 66 | [x2 y2] = ind2sub([Args.cols Args.rows],Args.NumericArguments{1}(end)); 67 | else 68 | x1=mod((Args.NumericArguments{1}-1),Args.cols)+1; x2=x1; 69 | y1=floor((Args.NumericArguments{1}-1)/Args.cols)+1; y2=y1; 70 | end 71 | % x1=mod((Args.NumericArguments{1}-1),Args.cols)+1; x2=x1; 72 | % y1=floor((Args.NumericArguments{1}-1)/Args.cols)+1; y2=y1; 73 | case 2 74 | x1=Args.NumericArguments{1};x2=x1; 75 | y1=Args.NumericArguments{2};y2=y1; 76 | case 4 77 | x1=Args.NumericArguments{1};x2=x1+Args.NumericArguments{3}-1; 78 | y1=Args.NumericArguments{2};y2=y1+Args.NumericArguments{4}-1; 79 | otherwise 80 | error('subaxis argument error') 81 | end 82 | 83 | 84 | cellwidth=((1-Args.MarginLeft-Args.MarginRight)-(Args.cols-1)*Args.SpacingHorizontal)/Args.cols; 85 | cellheight=((1-Args.MarginTop-Args.MarginBottom)-(Args.rows-1)*Args.SpacingVertical)/Args.rows; 86 | xpos1=Args.MarginLeft+Args.PaddingLeft+cellwidth*(x1-1)+Args.SpacingHorizontal*(x1-1); 87 | xpos2=Args.MarginLeft-Args.PaddingRight+cellwidth*x2+Args.SpacingHorizontal*(x2-1); 88 | ypos1=Args.MarginTop+Args.PaddingTop+cellheight*(y1-1)+Args.SpacingVertical*(y1-1); 89 | ypos2=Args.MarginTop-Args.PaddingBottom+cellheight*y2+Args.SpacingVertical*(y2-1); 90 | 91 | if Args.Holdaxis 92 | h=axes('position',[xpos1 1-ypos2 xpos2-xpos1 ypos2-ypos1]); 93 | else 94 | h=subplot('position',[xpos1 1-ypos2 xpos2-xpos1 ypos2-ypos1]); 95 | end 96 | 97 | 98 | set(h,'box','on'); 99 | %h=axes('position',[x1 1-y2 x2-x1 y2-y1]); 100 | set(h,'units',get(gcf,'defaultaxesunits')); 101 | set(h,'tag','subaxis'); 102 | 103 | 104 | 105 | if (nargout==0), clear h; end; 106 | 107 | -------------------------------------------------------------------------------- /instancesegmentation/evaluation/evaluator.py: -------------------------------------------------------------------------------- 1 | # This script includes the evaluator for instance segmentation challenge 2 | # it works with COCO evaluator 3 | 4 | import numpy as np 5 | from pycocotools.coco import COCO 6 | from pycocotools.cocoeval import COCOeval 7 | 8 | 9 | class InstanceEvaluator(object): 10 | def __init__(self, dataset_json, preds_json): 11 | # load dataset ground truths 12 | self.dataset = COCO(dataset_json) 13 | category_ids = self.dataset.getCatIds() 14 | categories = [x['name'] for x in self.dataset.loadCats(category_ids)] 15 | self.category_to_id_map = dict(zip(categories, category_ids)) 16 | self.classes = ['__background__'] + categories 17 | self.num_classes = len(self.classes) 18 | 19 | # load predictions 20 | self.preds = self.dataset.loadRes(preds_json) 21 | self.coco_eval = COCOeval(self.dataset, self.preds, 'segm') 22 | self.coco_eval.params.maxDets = [1, 50, 255] 23 | 24 | def evaluate(self): 25 | self.coco_eval.evaluate() 26 | self.coco_eval.accumulate() 27 | 28 | def _summarize(self, ap=1, iouThr=None, areaRng='all', maxDets=255): 29 | p = self.coco_eval.params 30 | iStr = ' {:<18} {} @[ IoU={:<9} | area={:>6s} | maxDets={:>3d} ] = {:0.3f}' 31 | titleStr = 'Average Precision' if ap == 1 else 'Average Recall' 32 | typeStr = '(AP)' if ap==1 else '(AR)' 33 | iouStr = '{:0.2f}:{:0.2f}'.format(p.iouThrs[0], p.iouThrs[-1]) \ 34 | if iouThr is None else '{:0.2f}'.format(iouThr) 35 | 36 | aind = [i for i, aRng in enumerate(p.areaRngLbl) if aRng == areaRng] 37 | mind = [i for i, mDet in enumerate(p.maxDets) if mDet == maxDets] 38 | if ap == 1: 39 | # dimension of precision: [TxRxKxAxM] 40 | s = self.coco_eval.eval['precision'] 41 | # IoU 42 | if iouThr is not None: 43 | t = np.where(iouThr == p.iouThrs)[0] 44 | s = s[t] 45 | s = s[:,:,:,aind,mind] 46 | else: 47 | # dimension of recall: [TxKxAxM] 48 | s = self.coco_eval.eval['recall'] 49 | if iouThr is not None: 50 | t = np.where(iouThr == p.iouThrs)[0] 51 | s = s[t] 52 | s = s[:,:,aind,mind] 53 | if len(s[s>-1])==0: 54 | mean_s = -1 55 | else: 56 | mean_s = np.mean(s[s>-1]) 57 | print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, mean_s)) 58 | return mean_s 59 | 60 | def summarize(self, IoU_lo_thres=0.5, IoU_hi_thres=0.95): 61 | def _get_thr_ind(thr): 62 | ind = np.where((self.coco_eval.params.iouThrs > thr - 1e-5) & 63 | (self.coco_eval.params.iouThrs < thr + 1e-5))[0][0] 64 | iou_thr = self.coco_eval.params.iouThrs[ind] 65 | assert np.isclose(iou_thr, thr) 66 | return ind 67 | 68 | ind_lo = _get_thr_ind(IoU_lo_thres) 69 | ind_hi = _get_thr_ind(IoU_hi_thres) 70 | 71 | # (iou, recall, cls, area, max_dets) 72 | precision = self.coco_eval.eval['precision'][ind_lo:(ind_hi + 1), :, :, 0, 2] 73 | ap_mean = np.mean(precision[precision > -1]) 74 | print('* MeanAP: {}'.format(ap_mean)) 75 | 76 | print('* Performance by class:') 77 | ap_by_class = [] 78 | for cls_ind, cls_name in enumerate(self.classes): 79 | if cls_name == '__background__': 80 | continue 81 | cls_precision = self.coco_eval.eval['precision'][ind_lo: (ind_hi + 1), :, cls_ind - 1, 0, 2] 82 | cls_ap = np.mean(cls_precision[cls_precision > -1]) 83 | ap_by_class.append(cls_ap) 84 | print('{}, AP: {}'.format(cls_name, cls_ap)) 85 | ap_by_class = np.asarray(ap_by_class) 86 | 87 | print('* Performance at different thresholds:') 88 | ap_by_thres = np.zeros((12,)) 89 | ap_by_thres[0] = self._summarize(1) 90 | ap_by_thres[1] = self._summarize(1, iouThr=.5, maxDets=self.coco_eval.params.maxDets[2]) 91 | ap_by_thres[2] = self._summarize(1, iouThr=.75, maxDets=self.coco_eval.params.maxDets[2]) 92 | ap_by_thres[3] = self._summarize(1, areaRng='small', maxDets=self.coco_eval.params.maxDets[2]) 93 | ap_by_thres[4] = self._summarize(1, areaRng='medium', maxDets=self.coco_eval.params.maxDets[2]) 94 | ap_by_thres[5] = self._summarize(1, areaRng='large', maxDets=self.coco_eval.params.maxDets[2]) 95 | ap_by_thres[6] = self._summarize(0, maxDets=self.coco_eval.params.maxDets[0]) 96 | ap_by_thres[7] = self._summarize(0, maxDets=self.coco_eval.params.maxDets[1]) 97 | ap_by_thres[8] = self._summarize(0, maxDets=self.coco_eval.params.maxDets[2]) 98 | ap_by_thres[9] = self._summarize(0, areaRng='small', maxDets=self.coco_eval.params.maxDets[2]) 99 | ap_by_thres[10] = self._summarize(0, areaRng='medium', maxDets=self.coco_eval.params.maxDets[2]) 100 | ap_by_thres[11] = self._summarize(0, areaRng='large', maxDets=self.coco_eval.params.maxDets[2]) 101 | return ap_mean, ap_by_class, ap_by_thres -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/String.cc: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (C) 2002 David R. Martin 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation; either version 2 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, but 10 | // WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | // General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "String.hh" 24 | 25 | String::String () 26 | { 27 | _length = 0; 28 | _size = defaultMinSize + 1; 29 | _text = new char [_size]; 30 | _text[_length] = '\0'; 31 | } 32 | 33 | String::String (const String& that) 34 | { 35 | _length = that._length; 36 | _size = that._size; 37 | _text = new char [_size]; 38 | memcpy (_text, that._text, _length + 1); 39 | } 40 | 41 | String::String (const char* fmt, ...) 42 | { 43 | assert (fmt != NULL); 44 | 45 | _length = 0; 46 | _size = strlen (fmt) + 1; 47 | _text = new char [_size]; 48 | _text[_length] = '\0'; 49 | 50 | va_list ap; 51 | va_start (ap, fmt); 52 | _append (fmt, ap); 53 | va_end (ap); 54 | } 55 | 56 | String::~String () 57 | { 58 | assert (_text != NULL); 59 | delete [] _text; 60 | } 61 | 62 | String& 63 | String::operator= (const String& that) 64 | { 65 | if (&that == this) { return *this; } 66 | clear(); 67 | append ("%s", that.text()); 68 | return *this; 69 | } 70 | 71 | String& 72 | String::operator= (const char* s) 73 | { 74 | clear(); 75 | if (s != NULL) { 76 | append ("%s", s); 77 | } 78 | return *this; 79 | } 80 | 81 | void 82 | String::clear () 83 | { 84 | _length = 0; 85 | _text[0] = '\0'; 86 | } 87 | 88 | void 89 | String::append (char c) 90 | { 91 | _append (1, (const char*)&c); 92 | } 93 | 94 | void 95 | String::append (unsigned length, const char* s) 96 | { 97 | _append (length, s); 98 | } 99 | 100 | void 101 | String::append (const char* fmt, ...) 102 | { 103 | assert (fmt != NULL); 104 | va_list ap; 105 | va_start (ap, fmt); 106 | _append (fmt, ap); 107 | va_end (ap); 108 | } 109 | 110 | const char& 111 | String::operator[] (unsigned i) const 112 | { 113 | assert (i < _length); 114 | return _text[i]; 115 | } 116 | 117 | bool 118 | String::nextLine (FILE* fp) 119 | { 120 | assert (fp != NULL); 121 | 122 | const int bufLen = 128; 123 | char buf[bufLen]; 124 | 125 | clear (); 126 | 127 | while (fgets (buf, bufLen, fp) != NULL) { 128 | _append (strlen (buf), buf); 129 | if (_text[_length - 1] == '\n') { 130 | _length--; 131 | _text[_length] = '\0'; 132 | return true; 133 | } 134 | } 135 | 136 | if (_length > 0) { 137 | assert (_text[_length - 1] != '\n'); 138 | return true; 139 | } else { 140 | return false; 141 | } 142 | } 143 | 144 | void 145 | String::_append (unsigned length, const char* s) 146 | { 147 | _grow (length + _length + 1); 148 | if (length > 0) { 149 | memcpy (_text + _length, s, length); 150 | _length += length; 151 | _text[_length] = '\0'; 152 | } 153 | } 154 | 155 | // On solaris and linux, vsnprintf returns the number of characters needed 156 | // to format the entire string. 157 | // On irix, vsnprintf returns the number of characters written. This is 158 | // at most length(buf)-1. 159 | // On some sytems, vsnprintf returns -1 if there wasn't enough space. 160 | void 161 | String::_append (const char* fmt, va_list ap) 162 | { 163 | int bufLen = 128; 164 | char* buf; 165 | 166 | while (1) { 167 | buf = new char [bufLen]; 168 | int cnt = vsnprintf (buf, bufLen, fmt, ap); 169 | if (cnt < 0 || cnt >= bufLen - 1) { 170 | delete [] buf; 171 | bufLen *= 2; 172 | continue; 173 | } else { 174 | break; 175 | } 176 | } 177 | 178 | _append (strlen (buf), buf); 179 | delete [] buf; 180 | } 181 | 182 | void 183 | String::_grow (unsigned minSize) 184 | { 185 | if (minSize > _size) { 186 | char* old = _text; 187 | _size += minSize; 188 | _text = new char [_size]; 189 | memcpy (_text, old, _length + 1); 190 | delete [] old; 191 | } 192 | } 193 | 194 | -------------------------------------------------------------------------------- /boundarydetection/demoVisualization.m: -------------------------------------------------------------------------------- 1 | % This script demos how to use colorEncode() to visualize predicted 2 | % boundary maps. 3 | % Make sure you have the corresponding files in predDir. 4 | % To control, press "n" for the next class. Press other key 5 | % or click figure for the next image 6 | close all; clc; clear; 7 | addpath(genpath('evaluationCode')); 8 | addpath(genpath('visualizationCode')); 9 | 10 | % Set directories & parameters 11 | pathImg = fullfile('images', 'validation'); 12 | pathGT = fullfile('annotations_boundary', 'validation'); 13 | pathPred = fullfile('predictions_boundary', 'validation'); % Directory to put predicted boundaries 14 | pathScore = fullfile('result_eval', 'scores'); 15 | numCls = 150; 16 | useODS = true; % Set true to use ODS threshold instead of 0.5 17 | 18 | % Load optimal class-wise threshold 19 | if(useODS) 20 | threODS = zeros(numCls, 1); 21 | for idxCls = 1:numCls 22 | assert(exist(fullfile(pathScore, ['class_' num2str(idxCls, '%03d') '.mat']), 'file')==2, ... 23 | 'Need to complete and save evaluation before loading the ODS thresholds.') 24 | scoreLoad = load(fullfile(pathScore, ['class_' num2str(idxCls, '%03d') '.mat'])); 25 | threODS(idxCls) = scoreLoad.resultCat{1}(1); 26 | end 27 | end 28 | 29 | % Find the set of files to be visualized 30 | fileLst = dir(fullfile(pathImg, '*.jpg')); 31 | fileLst = {fileLst.name}; 32 | numFile = length(fileLst); 33 | for idxFile = 1:numFile 34 | fileLst{idxFile} = fileLst{idxFile}(1:end-4); 35 | end 36 | 37 | % Load predefined class names and colors 38 | load('objectName150.mat'); 39 | load('color150.mat'); 40 | 41 | % Visualization 42 | for idxFile = 1:numel(fileLst) 43 | % read image 44 | img = imread(fullfile(pathImg, [fileLst{idxFile} '.jpg'])); 45 | gtLoad = load(fullfile(pathGT, [fileLst{idxFile} '.mat']), 'gt'); 46 | [height, width, ~] = size(img); 47 | bdryGTVis = zeros(height, width, 3); 48 | bdryGTSum = zeros(height, width); 49 | bdryPredVis = zeros(height, width, 3); 50 | bdryPredSum = zeros(height, width); 51 | 52 | % visualization 53 | bdryPredAll = cell(numCls,1); 54 | for idxCls = 1:numCls 55 | % load class-wise gt and predictions 56 | bdryGT = full(double(gtLoad.gt.bdry{idxCls})); 57 | bdryPred = im2double(imread(fullfile(pathPred, ['class_' num2str(idxCls, '%03d')], [fileLst{idxFile} '.png']))); 58 | bdryPredAll{idxCls} = bdryPred; 59 | 60 | % choose ODS threshold or not 61 | if(useODS) 62 | bdryPred(bdryPred<=threODS(idxCls)) = 0; 63 | else 64 | bdryPred(bdryPred<=0.5) = 0; 65 | end 66 | 67 | % color encoding 68 | colorCls = squeeze(double(colorEncode(idxCls, colors)))'; 69 | bdryGTVis = bdryGTVis + reshape(bdryGT(:)*colorCls, [height, width, 3]); 70 | bdryGTSum = bdryGTSum + bdryGT; 71 | bdryPredVis = bdryPredVis + reshape(bdryPred(:)*colorCls, [height, width, 3]); 72 | bdryPredSum = bdryPredSum + bdryPred; 73 | end 74 | bdryGTVis = uint8(bdryGTVis./repmat(bdryGTSum, [1 1 3])); 75 | bdryPredVis = uint8(bdryPredVis./repmat(bdryPredSum, [1 1 3])); 76 | 77 | % visualization 78 | fprintf('Press "n" for the next class. Press other key or click figure for the next image\n') 79 | for idxCls = 1:numCls 80 | % load class-wise gt and predictions 81 | bdryGT = full(double(gtLoad.gt.bdry{idxCls})); 82 | 83 | % plot figures 84 | set(gcf, 'Name', [fileLst{idxFile} ' (Press "n" for the next class. Press other key or click figure for the next image)'], 'NumberTitle', 'off'); 85 | subaxis(2, 3, 1, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 86 | imshow(img); title('Original Image'); 87 | subaxis(2, 3, 2, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 88 | imshow(bdryGTVis); title('GT All Classes'); 89 | subaxis(2, 3, 3, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 90 | imshow(bdryPredVis); title('Pred All Classes'); 91 | subaxis(2, 3, 4, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 92 | imshow(bdryGT); title(['GT Class ' num2str(idxCls) ': ' objectNames{idxCls}]); 93 | subaxis(2, 3, 5, 'sh', 0.03, 'sv', 0, 'paddingtop', 0.08, 'margin', 0); 94 | imshow(bdryPredAll{idxCls}); title(['Prediction Class ' num2str(idxCls) ': ' objectNames{idxCls}]); 95 | 96 | % press "n" for next class, otherwise jump to next image 97 | w = waitforbuttonpress; 98 | if(w==1) 99 | key = get(gcf,'currentcharacter'); 100 | if(~strcmp(key, 'n')) 101 | break; 102 | end 103 | else 104 | break; 105 | end 106 | end 107 | end 108 | 109 | 110 | -------------------------------------------------------------------------------- /boundarydetection/README.md: -------------------------------------------------------------------------------- 1 | # Instruction for Semantic Boundary Detection 2 | 3 | The semantic boundary detection task is to simultaneously detect whether a pixel belongs to one or possibly multiple predefined semantic boundary classes, such as sky, road, person, and bed. The class definition in this task is identical to the scene parsing subtask, with a total of 150 semantic categories. 4 | 5 | Note that we not only consider the boundaries between different semantic categories, but also consider the boundaries between instances with the same semantic class. For example, a pixel between building and sky is labeled as both sky boundary and building boundary, while a pixel between two immediately neighboring persons is considered a person boundary. 6 | 7 | The challenge data is divided into 20K images for training, 2K images for validation, and another batch of held-out images for testing. 8 | 9 | ## Data 10 | 11 | - Download the images [here](http://placeschallenge.csail.mit.edu/data/ChallengeData2017/images.tar). Note that images are the same for all subtasks in Places Challenge 2017. After untarring the image files, the directories should follow the below examples: 12 | 13 | training images: 14 | 15 | images/training/ADE_train_00000001.jpg 16 | images/training/ADE_train_00000002.jpg 17 | ... 18 | images/training/ADE_train_00020210.jpg 19 | 20 | validation images: 21 | 22 | images/training/ADE_train_00000001.jpg 23 | images/training/ADE_train_00000002.jpg 24 | ... 25 | images/training/ADE_train_00002000.jpg 26 | 27 | ## Label 28 | 29 | - Download the corresponding annotations [here](http://placeschallenge.csail.mit.edu/data/ChallengeData2017/boundaries.tar). The annotation directories should follow the below examples: 30 | 31 | training annotations: 32 | 33 | annotations_boundary/training/ADE_train_00000001.mat 34 | annotations_boundary/training/ADE_train_00000002.mat 35 | ... 36 | annotations_boundary/training/ADE_train_00020210.mat 37 | 38 | validation annotations: 39 | 40 | annotations_boundary/validation/ADE_val_00000001.mat 41 | annotations_boundary/validation/ADE_val_00000002.mat 42 | ... 43 | annotations_boundary/validation/ADE_val_00002000.mat 44 | 45 | Each boundary annotation mat file contains a struct "gt" with two fields named "seg" and "bdry". The "gt.seg" field is a HxWx3 uint8 matrix, with gt.seg(:, :, 1) containing the category-level segmentation mask, and gt.seg(:, :, 2:3) containing the instance-level mask. Certain images may contain more than 255 instances. Therefore the third seg channel is needed to decode the instance label. The decoding protocol is defined as: 46 | 47 | labelInst = 256.*int32(gt.seg(:, :, 3)) + int32(gt.seg(:, :, 2)) 48 | 49 | The "gt.bdry" field is a 150x1 cell array of sparse HxW matrices containing category-wise boundary ground truth with single pixel width. The ground truth is generated from the masks in gt.seg and should be used in your evaluation. Similar ground truth will also be used for the final evaluation on the test set. 50 | 51 | You may, however, generate your own ground truth from either gt.seg or gt.bdry for training purposes. You may also feel free to make use of gt.seg in training your model. 52 | 53 | ## Submission format to the evaluation server 54 | 55 | The structure of your submitted result should EXACTLY follow the following example: 56 | 57 | predictions_boundary/testing/class_001/ADE_test_00000001.png 58 | predictions_boundary/testing/class_001/ADE_test_00000002.png 59 | ... 60 | predictions_boundary/testing/class_001/ADE_test_00003000.png 61 | 62 | predictions_boundary/testing/class_002/ADE_test_00000001.png 63 | predictions_boundary/testing/class_002/ADE_test_00000002.png 64 | ... 65 | predictions_boundary/testing/class_002/ADE_test_00003000.png 66 | ... 67 | predictions_boundary/testing/class_150/ADE_test_00000001.png 68 | predictions_boundary/testing/class_150/ADE_test_00000002.png 69 | ... 70 | predictions_boundary/testing/class_150/ADE_test_00003000.png 71 | 72 | where subfolders class_001 - class_150 contain the category-wise predicted boundary probability maps for every test image. The boundary maps can either be soft or hard, and must be saved in .png format where 255 indicates probability 1. 73 | 74 | ## Evaluation protocol 75 | 76 | The evaluation follows the same evaluation protocol as the Berkeley Segmentation Dataset and Benchmark (BSDS500), where we apply standard edge thinning to every predicted map, followed by boundary alignment and precession recall computation. Note that image margin pixels (margin size set to 3) will ignored in the evaluation. As a result you may also optionally ignore the margin pixels during training. 77 | 78 | Our challenge result will be determined by the F-measure at optimal dataset scale (F-ODS). The evaluation toolkit also provides F-measure at optimal image scale (F-OIS) and average precision (AP) to evaluate your model. For more details, please refer to the following papers: 79 | 80 | 1. Martin et al., "Learning to detect natural image boundaries using local brightness, color, and texture cues," IEEE Trans. PAMI 2004. 81 | 82 | 2. Arbelaez et al., "Contour detection and hierarchical image segmentation," IEEE Trans. PAMI 2011. 83 | 84 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/String.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __String_hh__ 3 | #define __String_hh__ 4 | 5 | // Class that makes it easy to construct strings in a safe manner. 6 | // The main bonus is the printf-style interface for creating and 7 | // appending strings. 8 | 9 | // This class implements strings so that they behave like intrinsic 10 | // types, i.e. assignment creates a copy, passing by value in a 11 | // function call creates a copy. 12 | 13 | // NOTE: Calling a constructor or append() method with a plain char* 14 | // is dangerous, since the string is interpreted by sprintf. To be 15 | // safe, always do append("%s",s) instead of append(s). 16 | 17 | // Copyright (C) 2002 David R. Martin 18 | // 19 | // This program is free software; you can redistribute it and/or 20 | // modify it under the terms of the GNU General Public License as 21 | // published by the Free Software Foundation; either version 2 of the 22 | // License, or (at your option) any later version. 23 | // 24 | // This program is distributed in the hope that it will be useful, but 25 | // WITHOUT ANY WARRANTY; without even the implied warranty of 26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | // General Public License for more details. 28 | // 29 | // You should have received a copy of the GNU General Public License 30 | // along with this program; if not, write to the Free Software 31 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 32 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | class String 40 | { 41 | public: 42 | 43 | // Constructors. 44 | String (); 45 | String (const String& that); 46 | String (const char* fmt, ...); 47 | 48 | // Destructor. 49 | ~String (); 50 | 51 | // Assignment operators. 52 | String& operator= (const String& that); 53 | String& operator= (const char* s); 54 | 55 | // Accessors. 56 | unsigned length () const { return _length; } 57 | const char* text () const { return _text; } 58 | const char& operator[] (unsigned i) const; 59 | 60 | // Modifiers. 61 | void clear (); 62 | void append (char c); 63 | void append (unsigned length, const char* s); 64 | void append (const char* fmt, ...); 65 | 66 | // Load next line from file; newline is discarded. 67 | // Return true if new data; false on EOF. 68 | bool nextLine (FILE* fp); 69 | 70 | // Implicit convertion to const char* is useful so that other 71 | // modules that take strings as arguments don't have to know about 72 | // the String class, and the caller doesn't have to explicitly 73 | // call the text() method. 74 | operator const char* () const { return text(); } 75 | 76 | private: 77 | 78 | static const unsigned defaultMinSize = 16; 79 | 80 | void _append (unsigned length, const char* s); 81 | void _append (const char* fmt, va_list ap); 82 | 83 | void _grow (unsigned minSize); 84 | 85 | unsigned _length; 86 | unsigned _size; 87 | char* _text; 88 | 89 | }; 90 | 91 | // == operator 92 | inline int operator== (const String& x, const String& y) 93 | { return strcmp (x, y) == 0; } 94 | inline int operator== (const String& x, const char* y) 95 | { return strcmp (x, y) == 0; } 96 | inline int operator== (const char* x, const String& y) 97 | { return strcmp (x, y) == 0; } 98 | 99 | // != operator 100 | inline int operator!= (const String& x, const String& y) 101 | { return strcmp (x, y) != 0; } 102 | inline int operator!= (const String& x, const char* y) 103 | { return strcmp (x, y) != 0; } 104 | inline int operator!= (const char* x, const String& y) 105 | { return strcmp (x, y) != 0; } 106 | 107 | // < operator 108 | inline int operator< (const String& x, const String& y) 109 | { return strcmp (x, y) < 0; } 110 | inline int operator< (const String& x, const char* y) 111 | { return strcmp (x, y) < 0; } 112 | inline int operator< (const char* x, const String& y) 113 | { return strcmp (x, y) < 0; } 114 | 115 | // > operator 116 | inline int operator> (const String& x, const String& y) 117 | { return strcmp (x, y) > 0; } 118 | inline int operator> (const String& x, const char* y) 119 | { return strcmp (x, y) > 0; } 120 | inline int operator> (const char* x, const String& y) 121 | { return strcmp (x, y) > 0; } 122 | 123 | // <= operator 124 | inline int operator<= (const String& x, const String& y) 125 | { return strcmp (x, y) <= 0; } 126 | inline int operator<= (const String& x, const char* y) 127 | { return strcmp (x, y) <= 0; } 128 | inline int operator<= (const char* x, const String& y) 129 | { return strcmp (x, y) <= 0; } 130 | 131 | // >= operator 132 | inline int operator>= (const String& x, const String& y) 133 | { return strcmp (x, y) >= 0; } 134 | inline int operator>= (const String& x, const char* y) 135 | { return strcmp (x, y) >= 0; } 136 | inline int operator>= (const char* x, const String& y) 137 | { return strcmp (x, y) >= 0; } 138 | 139 | // write to output stream 140 | inline std::ostream& operator<< (std::ostream& out, const String& s) { 141 | out << (const char*)s; 142 | return out; 143 | } 144 | 145 | #endif // __String_hh__ 146 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/csa_types.h: -------------------------------------------------------------------------------- 1 | #define PREC_COSTS 2 | 3 | #if defined(QUICK_MIN) && !defined(NUM_BEST) 4 | #define NUM_BEST 3 5 | #endif 6 | 7 | #if defined(USE_SP_AUG_FORWARD) || defined(USE_SP_AUG_BACKWARD) 8 | #ifndef USE_SP_AUG 9 | #define USE_SP_AUG 10 | #endif 11 | #endif 12 | 13 | #if defined(USE_P_UPDATE) || defined(BACK_PRICE_OUT) || \ 14 | defined(USE_SP_AUG_BACKWARD) 15 | #define STORE_REV_ARCS 16 | #endif 17 | 18 | typedef struct lhs_node { 19 | #if defined(QUICK_MIN) 20 | struct { 21 | /* 22 | flag used to indicate to 23 | double_push() that so few arcs 24 | are incident that best[] is 25 | useless. 26 | */ 27 | #ifdef QUICK_MIN 28 | unsigned few_arcs : 1; 29 | #endif 30 | } node_info; 31 | #ifdef QUICK_MIN 32 | /* 33 | list of arcs to consider first in 34 | calculating the minimum-reduced-cost 35 | incident arc; if we find it here, we 36 | need look no further. 37 | */ 38 | struct lr_arc *best[NUM_BEST]; 39 | /* 40 | bound on the reduced cost of an arc we 41 | can be certain still belongs among 42 | those in best[]. 43 | */ 44 | double next_best; 45 | #endif 46 | #endif 47 | #ifdef EXPLICIT_LHS_PRICES 48 | /* 49 | price of this node. 50 | */ 51 | double p; 52 | #endif 53 | /* 54 | first arc in the arc array associated 55 | with this node. 56 | */ 57 | struct lr_arc *priced_out; 58 | /* 59 | first priced-in arc in the arc array 60 | associated with this node. 61 | */ 62 | struct lr_arc *first; 63 | /* 64 | matching arc (if any) associated with 65 | this node; NULL if this node is 66 | unmatched. 67 | */ 68 | struct lr_arc *matched; 69 | #if defined(USE_P_UPDATE) 70 | /* 71 | price change required on this node (in 72 | units of epsilon) to ensure that its 73 | excess can reach a deficit in the 74 | admissible graph. computed and used in 75 | p_update(). 76 | */ 77 | long delta_reqd; 78 | #endif 79 | #ifdef USE_SP_AUG_BACKWARD 80 | struct lr_arc *aug_path; 81 | #endif 82 | } *lhs_ptr; 83 | 84 | typedef struct rhs_node { 85 | struct { 86 | #ifdef USE_P_REFINE 87 | /* 88 | depth-first search flags. 89 | dfs is to determine whether 90 | admissible graph contains a 91 | cycle in p_refine(). 92 | */ 93 | unsigned srchng : 1; 94 | unsigned srched : 1; 95 | #endif 96 | /* 97 | flag to indicate this node's 98 | matching arc (if any) is 99 | priced in. 100 | */ 101 | unsigned priced_in : 1; 102 | } node_info; 103 | /* 104 | lhs node this rhs node is matched to. 105 | */ 106 | lhs_ptr matched; 107 | /* 108 | price of this node. 109 | */ 110 | double p; 111 | #ifdef USE_SP_AUG_FORWARD 112 | struct lr_arc *aug_path; 113 | #endif 114 | #if defined(USE_P_REFINE) || defined(USE_P_UPDATE) || defined(USE_SP_AUG) 115 | /* 116 | number of epsilons of price change 117 | required at this node to accomplish 118 | p_refine()'s or p_update()'s goal. 119 | */ 120 | long key; 121 | /* 122 | fields to maintain buckets of nodes as 123 | lists in p_refine() and p_update(). 124 | */ 125 | struct rhs_node *prev, *next; 126 | #endif 127 | #ifdef STORE_REV_ARCS 128 | /* 129 | first back arc in the arc array 130 | associated with this node. 131 | */ 132 | struct rl_arc *priced_out; 133 | /* 134 | first priced-in back arc in the arc 135 | array associated with this node. 136 | */ 137 | struct rl_arc *back_arcs; 138 | #endif 139 | } *rhs_ptr; 140 | 141 | #ifdef STORE_REV_ARCS 142 | typedef struct rl_arc { 143 | /* 144 | lhs node associated with this back 145 | arc. some would have liked the name 146 | head better. 147 | */ 148 | lhs_ptr tail; 149 | #if defined(USE_P_UPDATE) || defined(USE_SP_AUG_BACKWARD) 150 | /* 151 | cost of this back arc. this cost gets 152 | modified to incorporate other arc 153 | costs in p_update() and sp_aug(), 154 | while forward arc costs remain 155 | constant throughout. 156 | */ 157 | double c; 158 | #endif 159 | #if defined(USE_PRICE_OUT) || defined(USE_SP_AUG_BACKWARD) 160 | /* 161 | this arc's reverse in the forward arc 162 | list. 163 | */ 164 | struct lr_arc *rev; 165 | #endif 166 | } *rl_aptr; 167 | #endif 168 | 169 | typedef struct lr_arc { 170 | /* 171 | rhs node associated with this arc. 172 | */ 173 | rhs_ptr head; 174 | /* 175 | arc cost. 176 | */ 177 | double c; 178 | #ifdef USE_SP_AUG_FORWARD 179 | lhs_ptr tail; 180 | #endif 181 | #ifdef STORE_REV_ARCS 182 | /* 183 | this arc's reverse in the back arc 184 | list. 185 | */ 186 | struct rl_arc *rev; 187 | #endif 188 | } *lr_aptr; 189 | 190 | typedef struct stack_st { 191 | /* 192 | Sometimes stacks have lhs nodes, and 193 | other times they have rhs nodes. So 194 | there's a little type clash; 195 | everything gets cast to (char *) so we 196 | can use the same structure for both. 197 | */ 198 | char **bottom; 199 | char **top; 200 | } *stack; 201 | 202 | typedef struct queue_st { 203 | /* 204 | Sometimes queues have lhs nodes, and 205 | other times they have rhs nodes. So 206 | there's a little type clash; 207 | everything gets cast to (char *) so we 208 | can use the same structure for both. 209 | */ 210 | char **head; 211 | char **tail; 212 | char **storage; 213 | char **end; 214 | unsigned max_size; 215 | } *queue; 216 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/csa_defs.h: -------------------------------------------------------------------------------- 1 | #define TRUE 1 2 | #define FALSE 0 3 | #define MAXLINE 100 4 | #define DEFAULT_SCALE_FACTOR 10 5 | #define DEFAULT_PO_COST_THRESH (2.0 * sqrt((double) n) * \ 6 | sqrt(sqrt((double) n))) 7 | #define DEFAULT_PO_WORK_THRESH 50 8 | #define DEFAULT_UPD_FAC 2 9 | #if defined(USE_SP_AUG_FORWARD) || defined(USE_SP_AUG_BACKWARD) 10 | #ifndef USE_SP_AUG 11 | #define USE_SP_AUG 12 | #endif 13 | #endif 14 | 15 | #ifdef USE_SP_AUG 16 | #define EXCESS_THRESH 127 17 | #else 18 | #define EXCESS_THRESH 0 19 | #endif 20 | 21 | #if defined(USE_P_UPDATE) || defined(STRONG_PO) 22 | #define WORK_TYPE unsigned 23 | #define REFINE_WORK relabelings 24 | #endif 25 | 26 | #if defined(DEBUG) && defined(ROUND_COSTS) 27 | #define MAGIC_MARKER 0xAAAAAAAA 28 | #endif 29 | 30 | #ifdef QUEUE_ORDER 31 | #define ACTIVE_TYPE queue 32 | #define create_active(size) active = q_create(size) 33 | #define make_active(v) enq(active, (char *) v) 34 | #define get_active_node(v) v = (lhs_ptr) deq(active) 35 | #else 36 | #define ACTIVE_TYPE stack 37 | #define create_active(size) active = st_create(size) 38 | #define make_active(v) st_push(active, (char *) v) 39 | #define get_active_node(v) v = (lhs_ptr) st_pop(active) 40 | #endif 41 | 42 | #define st_push(s, el) \ 43 | {\ 44 | *(s->top) = (char *) el;\ 45 | s->top++;\ 46 | } 47 | 48 | #define st_empty(s) (s->top == s->bottom) 49 | 50 | #define enq(q, el) \ 51 | {\ 52 | *(q->tail) = el;\ 53 | if (q->tail == q->end) q->tail = q->storage;\ 54 | else q->tail++;\ 55 | } 56 | 57 | #define q_empty(q) (q->head == q->tail ? 1 : 0) 58 | 59 | #define insert_list(node, head) \ 60 | {\ 61 | node->next = (*(head));\ 62 | (*(head))->prev = node;\ 63 | (*(head)) = node;\ 64 | node->prev = tail_rhs_node;\ 65 | } 66 | 67 | #define delete_list(node, head) \ 68 | {\ 69 | if (node->prev == tail_rhs_node)\ 70 | (*(head)) = node->next;\ 71 | node->prev->next = node->next;\ 72 | node->next->prev = node->prev;\ 73 | } 74 | 75 | /* 76 | The author hereby apologizes for the following incomprehensible 77 | muddle. Price-outs involve moving arcs around in the data structure, 78 | and it turns out to be faster to copy them field-by-field than to use 79 | memcpy() because they're so small. But the set of fields an arc has 80 | depends on lots of things, hence this mess. 81 | */ 82 | 83 | #if defined(USE_PRICE_OUT) || defined(ROUND_COSTS) 84 | #ifdef STORE_REV_ARCS 85 | #ifdef ROUND_COSTS 86 | #define copy_lr_arc(a, b) \ 87 | {\ 88 | b->head = a->head;\ 89 | b->c_init = a->c_init;\ 90 | b->c = a->c;\ 91 | b->rev = a->rev;\ 92 | } 93 | #else /* ROUND_COSTS */ 94 | #define copy_lr_arc(a, b) \ 95 | {\ 96 | b->head = a->head;\ 97 | b->c = a->c;\ 98 | b->rev = a->rev;\ 99 | } 100 | #endif /* ROUND_COSTS */ 101 | 102 | #ifdef USE_P_UPDATE 103 | #define copy_rl_arc(a, b) \ 104 | { b->tail = a->tail; b->c = a->c; b->rev = a->rev; } 105 | #else /* USE_P_UPDATE */ 106 | #define copy_rl_arc(a, b) \ 107 | { b->tail = a->tail; b->rev = a->rev; } 108 | #endif /* USE_P_UPDATE */ 109 | 110 | #define exch_rl_arcs(a, b) \ 111 | {\ 112 | copy_rl_arc(b, tail_rl_arc);\ 113 | copy_rl_arc(a, b);\ 114 | copy_rl_arc(tail_rl_arc, a);\ 115 | } 116 | #else /* STORE_REV_ARCS */ 117 | #ifdef PREC_COSTS 118 | #define copy_lr_arc(a, b) \ 119 | {\ 120 | b->head = a->head;\ 121 | b->c = a->c;\ 122 | } 123 | #else /* PREC_COSTS */ 124 | #define copy_lr_arc(a, b) \ 125 | {\ 126 | b->head = a->head;\ 127 | b->c_init = a->c_init;\ 128 | b->c = a->c;\ 129 | } 130 | #endif /* PREC_COSTS */ 131 | #endif /* STORE_REV_ARCS */ 132 | 133 | #define exch_lr_arcs(a, b) \ 134 | {\ 135 | copy_lr_arc(b, tail_lr_arc);\ 136 | copy_lr_arc(a, b);\ 137 | copy_lr_arc(tail_lr_arc, a);\ 138 | } 139 | 140 | extern lr_aptr tail_lr_arc; 141 | #ifdef STORE_REV_ARCS 142 | extern rl_aptr tail_rl_arc; 143 | #endif 144 | 145 | #ifdef STORE_REV_ARCS 146 | #define price_in_rev(a) \ 147 | { \ 148 | register rl_aptr b_a = --a->head->back_arcs; \ 149 | register rl_aptr a_r = a->rev; \ 150 | if (b_a != a_r) \ 151 | { \ 152 | register lr_aptr b_r = b_a->rev; \ 153 | exch_rl_arcs(b_a, a_r); \ 154 | b_r->rev = a_r; \ 155 | a->rev = b_a; \ 156 | } \ 157 | } 158 | 159 | #define price_out_rev(a) \ 160 | { \ 161 | register rl_aptr b_a = a->head->back_arcs; \ 162 | register rl_aptr a_r = a->rev; \ 163 | if (b_a != a_r) \ 164 | { \ 165 | register lr_aptr b_r = b_a->rev; \ 166 | exch_rl_arcs(b_a, a_r); \ 167 | b_r->rev = a_r; \ 168 | a->rev = b_a; \ 169 | } \ 170 | a->head->back_arcs++; \ 171 | } 172 | 173 | #define handle_rev_pointers(a, b) { a->rev->rev = b; b->rev->rev = a; } 174 | #else /* STORE_REV_ARCS */ 175 | #define price_in_rev(a) /* do nothing */ 176 | #define price_out_rev(a) /* do nothing */ 177 | #define handle_rev_pointers(a, b) /* do nothing */ 178 | #endif /* STORE_REV_ARCS */ 179 | 180 | #define price_in_unm_arc(v, a) \ 181 | { \ 182 | register lr_aptr f_a = --v->first; \ 183 | price_in_rev(a); \ 184 | if (f_a != a) \ 185 | { \ 186 | if (v->matched == f_a) v->matched = a; \ 187 | handle_rev_pointers(a, f_a); \ 188 | exch_lr_arcs(a, f_a); \ 189 | } \ 190 | } 191 | 192 | #define price_in_mch_arc(v, a) \ 193 | { \ 194 | register lr_aptr f_a = --v->first; \ 195 | price_in_rev(a); \ 196 | a->head->node_info.priced_in = TRUE; \ 197 | if (f_a != a) \ 198 | { \ 199 | v->matched = f_a; \ 200 | handle_rev_pointers(a, f_a); \ 201 | exch_lr_arcs(a, f_a); \ 202 | } \ 203 | } 204 | 205 | #define price_out_unm_arc(v, a) \ 206 | { \ 207 | register lr_aptr f_a = v->first++; \ 208 | price_out_rev(a); \ 209 | if (f_a != a) \ 210 | { \ 211 | if (v->matched == f_a) v->matched = a; \ 212 | handle_rev_pointers(a, f_a); \ 213 | exch_lr_arcs(a, f_a); \ 214 | } \ 215 | } 216 | 217 | #define price_out_mch_arc(v, a) \ 218 | { \ 219 | register lr_aptr f_a = v->first++; \ 220 | price_out_rev(a); \ 221 | a->head->node_info.priced_in = FALSE; \ 222 | if (f_a != a) \ 223 | { \ 224 | v->matched = f_a; \ 225 | handle_rev_pointers(a, f_a); \ 226 | exch_lr_arcs(a, f_a); \ 227 | } \ 228 | } 229 | #endif /* USE_PRICE_OUT || ROUND_COSTS */ 230 | -------------------------------------------------------------------------------- /sceneparsing/objectInfo150.txt: -------------------------------------------------------------------------------- 1 | Idx Ratio Train Val Name 2 | 1 0.1576 11664 1172 wall 3 | 2 0.1072 6046 612 building, edifice 4 | 3 0.0878 8265 796 sky 5 | 4 0.0621 9336 917 floor, flooring 6 | 5 0.0480 6678 641 tree 7 | 6 0.0450 6604 643 ceiling 8 | 7 0.0398 4023 408 road, route 9 | 8 0.0231 1906 199 bed 10 | 9 0.0198 4688 460 windowpane, window 11 | 10 0.0183 2423 225 grass 12 | 11 0.0181 2874 294 cabinet 13 | 12 0.0166 3068 310 sidewalk, pavement 14 | 13 0.0160 5075 526 person, individual, someone, somebody, mortal, soul 15 | 14 0.0151 1804 190 earth, ground 16 | 15 0.0118 6666 796 door, double door 17 | 16 0.0110 4269 411 table 18 | 17 0.0109 1691 160 mountain, mount 19 | 18 0.0104 3999 441 plant, flora, plant life 20 | 19 0.0104 2149 217 curtain, drape, drapery, mantle, pall 21 | 20 0.0103 3261 318 chair 22 | 21 0.0098 3164 306 car, auto, automobile, machine, motorcar 23 | 22 0.0074 709 75 water 24 | 23 0.0067 3296 315 painting, picture 25 | 24 0.0065 1191 106 sofa, couch, lounge 26 | 25 0.0061 1516 162 shelf 27 | 26 0.0060 667 69 house 28 | 27 0.0053 651 57 sea 29 | 28 0.0052 1847 224 mirror 30 | 29 0.0046 1158 128 rug, carpet, carpeting 31 | 30 0.0044 480 44 field 32 | 31 0.0044 1172 98 armchair 33 | 32 0.0044 1292 184 seat 34 | 33 0.0033 1386 138 fence, fencing 35 | 34 0.0031 698 61 desk 36 | 35 0.0030 781 73 rock, stone 37 | 36 0.0027 380 43 wardrobe, closet, press 38 | 37 0.0026 3089 302 lamp 39 | 38 0.0024 404 37 bathtub, bathing tub, bath, tub 40 | 39 0.0024 804 99 railing, rail 41 | 40 0.0023 1453 153 cushion 42 | 41 0.0023 411 37 base, pedestal, stand 43 | 42 0.0022 1440 162 box 44 | 43 0.0022 800 77 column, pillar 45 | 44 0.0020 2650 298 signboard, sign 46 | 45 0.0019 549 46 chest of drawers, chest, bureau, dresser 47 | 46 0.0019 367 36 counter 48 | 47 0.0018 311 30 sand 49 | 48 0.0018 1181 122 sink 50 | 49 0.0018 287 23 skyscraper 51 | 50 0.0018 468 38 fireplace, hearth, open fireplace 52 | 51 0.0018 402 43 refrigerator, icebox 53 | 52 0.0018 130 12 grandstand, covered stand 54 | 53 0.0018 561 64 path 55 | 54 0.0017 880 102 stairs, steps 56 | 55 0.0017 86 12 runway 57 | 56 0.0017 172 11 case, display case, showcase, vitrine 58 | 57 0.0017 198 18 pool table, billiard table, snooker table 59 | 58 0.0017 930 109 pillow 60 | 59 0.0015 139 18 screen door, screen 61 | 60 0.0015 564 52 stairway, staircase 62 | 61 0.0015 320 26 river 63 | 62 0.0015 261 29 bridge, span 64 | 63 0.0014 275 22 bookcase 65 | 64 0.0014 335 60 blind, screen 66 | 65 0.0014 792 75 coffee table, cocktail table 67 | 66 0.0014 395 49 toilet, can, commode, crapper, pot, potty, stool, throne 68 | 67 0.0014 1309 138 flower 69 | 68 0.0013 1112 113 book 70 | 69 0.0013 266 27 hill 71 | 70 0.0013 659 66 bench 72 | 71 0.0012 331 31 countertop 73 | 72 0.0012 531 56 stove, kitchen stove, range, kitchen range, cooking stove 74 | 73 0.0012 369 36 palm, palm tree 75 | 74 0.0012 144 9 kitchen island 76 | 75 0.0011 265 29 computer, computing machine, computing device, data processor, electronic computer, information processing system 77 | 76 0.0010 324 33 swivel chair 78 | 77 0.0009 304 27 boat 79 | 78 0.0009 170 20 bar 80 | 79 0.0009 68 6 arcade machine 81 | 80 0.0009 65 8 hovel, hut, hutch, shack, shanty 82 | 81 0.0009 248 25 bus, autobus, coach, charabanc, double-decker, jitney, motorbus, motorcoach, omnibus, passenger vehicle 83 | 82 0.0008 492 49 towel 84 | 83 0.0008 2510 269 light, light source 85 | 84 0.0008 440 39 truck, motortruck 86 | 85 0.0008 147 18 tower 87 | 86 0.0008 583 56 chandelier, pendant, pendent 88 | 87 0.0007 533 61 awning, sunshade, sunblind 89 | 88 0.0007 1989 239 streetlight, street lamp 90 | 89 0.0007 71 5 booth, cubicle, stall, kiosk 91 | 90 0.0007 618 53 television, television receiver, television set, tv, tv set, idiot box, boob tube, telly, goggle box 92 | 91 0.0007 135 12 airplane, aeroplane, plane 93 | 92 0.0007 83 5 dirt track 94 | 93 0.0007 178 17 apparel, wearing apparel, dress, clothes 95 | 94 0.0006 1003 104 pole 96 | 95 0.0006 182 12 land, ground, soil 97 | 96 0.0006 452 50 bannister, banister, balustrade, balusters, handrail 98 | 97 0.0006 42 6 escalator, moving staircase, moving stairway 99 | 98 0.0006 307 31 ottoman, pouf, pouffe, puff, hassock 100 | 99 0.0006 965 114 bottle 101 | 100 0.0006 117 13 buffet, counter, sideboard 102 | 101 0.0006 354 35 poster, posting, placard, notice, bill, card 103 | 102 0.0006 108 9 stage 104 | 103 0.0006 557 55 van 105 | 104 0.0006 52 4 ship 106 | 105 0.0005 99 5 fountain 107 | 106 0.0005 57 4 conveyer belt, conveyor belt, conveyer, conveyor, transporter 108 | 107 0.0005 292 31 canopy 109 | 108 0.0005 77 9 washer, automatic washer, washing machine 110 | 109 0.0005 340 38 plaything, toy 111 | 110 0.0005 66 3 swimming pool, swimming bath, natatorium 112 | 111 0.0005 465 49 stool 113 | 112 0.0005 50 4 barrel, cask 114 | 113 0.0005 622 75 basket, handbasket 115 | 114 0.0005 80 9 waterfall, falls 116 | 115 0.0005 59 3 tent, collapsible shelter 117 | 116 0.0005 531 72 bag 118 | 117 0.0005 282 30 minibike, motorbike 119 | 118 0.0005 73 7 cradle 120 | 119 0.0005 435 44 oven 121 | 120 0.0005 136 25 ball 122 | 121 0.0005 116 24 food, solid food 123 | 122 0.0004 266 31 step, stair 124 | 123 0.0004 58 12 tank, storage tank 125 | 124 0.0004 418 83 trade name, brand name, brand, marque 126 | 125 0.0004 319 43 microwave, microwave oven 127 | 126 0.0004 1193 139 pot, flowerpot 128 | 127 0.0004 97 23 animal, animate being, beast, brute, creature, fauna 129 | 128 0.0004 347 36 bicycle, bike, wheel, cycle 130 | 129 0.0004 52 5 lake 131 | 130 0.0004 246 22 dishwasher, dish washer, dishwashing machine 132 | 131 0.0004 108 13 screen, silver screen, projection screen 133 | 132 0.0004 201 30 blanket, cover 134 | 133 0.0004 285 21 sculpture 135 | 134 0.0004 268 27 hood, exhaust hood 136 | 135 0.0003 1020 108 sconce 137 | 136 0.0003 1282 122 vase 138 | 137 0.0003 528 65 traffic light, traffic signal, stoplight 139 | 138 0.0003 453 57 tray 140 | 139 0.0003 671 100 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin 141 | 140 0.0003 397 44 fan 142 | 141 0.0003 92 8 pier, wharf, wharfage, dock 143 | 142 0.0003 228 18 crt screen 144 | 143 0.0003 570 59 plate 145 | 144 0.0003 217 22 monitor, monitoring device 146 | 145 0.0003 206 19 bulletin board, notice board 147 | 146 0.0003 130 14 shower 148 | 147 0.0003 178 28 radiator 149 | 148 0.0002 504 57 glass, drinking glass 150 | 149 0.0002 775 96 clock 151 | 150 0.0002 421 56 flag 152 | -------------------------------------------------------------------------------- /boundarydetection/objectInfo150.txt: -------------------------------------------------------------------------------- 1 | Idx Ratio Train Val Name 2 | 1 0.1576 11664 1172 wall 3 | 2 0.1072 6046 612 building, edifice 4 | 3 0.0878 8265 796 sky 5 | 4 0.0621 9336 917 floor, flooring 6 | 5 0.0480 6678 641 tree 7 | 6 0.0450 6604 643 ceiling 8 | 7 0.0398 4023 408 road, route 9 | 8 0.0231 1906 199 bed 10 | 9 0.0198 4688 460 windowpane, window 11 | 10 0.0183 2423 225 grass 12 | 11 0.0181 2874 294 cabinet 13 | 12 0.0166 3068 310 sidewalk, pavement 14 | 13 0.0160 5075 526 person, individual, someone, somebody, mortal, soul 15 | 14 0.0151 1804 190 earth, ground 16 | 15 0.0118 6666 796 door, double door 17 | 16 0.0110 4269 411 table 18 | 17 0.0109 1691 160 mountain, mount 19 | 18 0.0104 3999 441 plant, flora, plant life 20 | 19 0.0104 2149 217 curtain, drape, drapery, mantle, pall 21 | 20 0.0103 3261 318 chair 22 | 21 0.0098 3164 306 car, auto, automobile, machine, motorcar 23 | 22 0.0074 709 75 water 24 | 23 0.0067 3296 315 painting, picture 25 | 24 0.0065 1191 106 sofa, couch, lounge 26 | 25 0.0061 1516 162 shelf 27 | 26 0.0060 667 69 house 28 | 27 0.0053 651 57 sea 29 | 28 0.0052 1847 224 mirror 30 | 29 0.0046 1158 128 rug, carpet, carpeting 31 | 30 0.0044 480 44 field 32 | 31 0.0044 1172 98 armchair 33 | 32 0.0044 1292 184 seat 34 | 33 0.0033 1386 138 fence, fencing 35 | 34 0.0031 698 61 desk 36 | 35 0.0030 781 73 rock, stone 37 | 36 0.0027 380 43 wardrobe, closet, press 38 | 37 0.0026 3089 302 lamp 39 | 38 0.0024 404 37 bathtub, bathing tub, bath, tub 40 | 39 0.0024 804 99 railing, rail 41 | 40 0.0023 1453 153 cushion 42 | 41 0.0023 411 37 base, pedestal, stand 43 | 42 0.0022 1440 162 box 44 | 43 0.0022 800 77 column, pillar 45 | 44 0.0020 2650 298 signboard, sign 46 | 45 0.0019 549 46 chest of drawers, chest, bureau, dresser 47 | 46 0.0019 367 36 counter 48 | 47 0.0018 311 30 sand 49 | 48 0.0018 1181 122 sink 50 | 49 0.0018 287 23 skyscraper 51 | 50 0.0018 468 38 fireplace, hearth, open fireplace 52 | 51 0.0018 402 43 refrigerator, icebox 53 | 52 0.0018 130 12 grandstand, covered stand 54 | 53 0.0018 561 64 path 55 | 54 0.0017 880 102 stairs, steps 56 | 55 0.0017 86 12 runway 57 | 56 0.0017 172 11 case, display case, showcase, vitrine 58 | 57 0.0017 198 18 pool table, billiard table, snooker table 59 | 58 0.0017 930 109 pillow 60 | 59 0.0015 139 18 screen door, screen 61 | 60 0.0015 564 52 stairway, staircase 62 | 61 0.0015 320 26 river 63 | 62 0.0015 261 29 bridge, span 64 | 63 0.0014 275 22 bookcase 65 | 64 0.0014 335 60 blind, screen 66 | 65 0.0014 792 75 coffee table, cocktail table 67 | 66 0.0014 395 49 toilet, can, commode, crapper, pot, potty, stool, throne 68 | 67 0.0014 1309 138 flower 69 | 68 0.0013 1112 113 book 70 | 69 0.0013 266 27 hill 71 | 70 0.0013 659 66 bench 72 | 71 0.0012 331 31 countertop 73 | 72 0.0012 531 56 stove, kitchen stove, range, kitchen range, cooking stove 74 | 73 0.0012 369 36 palm, palm tree 75 | 74 0.0012 144 9 kitchen island 76 | 75 0.0011 265 29 computer, computing machine, computing device, data processor, electronic computer, information processing system 77 | 76 0.0010 324 33 swivel chair 78 | 77 0.0009 304 27 boat 79 | 78 0.0009 170 20 bar 80 | 79 0.0009 68 6 arcade machine 81 | 80 0.0009 65 8 hovel, hut, hutch, shack, shanty 82 | 81 0.0009 248 25 bus, autobus, coach, charabanc, double-decker, jitney, motorbus, motorcoach, omnibus, passenger vehicle 83 | 82 0.0008 492 49 towel 84 | 83 0.0008 2510 269 light, light source 85 | 84 0.0008 440 39 truck, motortruck 86 | 85 0.0008 147 18 tower 87 | 86 0.0008 583 56 chandelier, pendant, pendent 88 | 87 0.0007 533 61 awning, sunshade, sunblind 89 | 88 0.0007 1989 239 streetlight, street lamp 90 | 89 0.0007 71 5 booth, cubicle, stall, kiosk 91 | 90 0.0007 618 53 television, television receiver, television set, tv, tv set, idiot box, boob tube, telly, goggle box 92 | 91 0.0007 135 12 airplane, aeroplane, plane 93 | 92 0.0007 83 5 dirt track 94 | 93 0.0007 178 17 apparel, wearing apparel, dress, clothes 95 | 94 0.0006 1003 104 pole 96 | 95 0.0006 182 12 land, ground, soil 97 | 96 0.0006 452 50 bannister, banister, balustrade, balusters, handrail 98 | 97 0.0006 42 6 escalator, moving staircase, moving stairway 99 | 98 0.0006 307 31 ottoman, pouf, pouffe, puff, hassock 100 | 99 0.0006 965 114 bottle 101 | 100 0.0006 117 13 buffet, counter, sideboard 102 | 101 0.0006 354 35 poster, posting, placard, notice, bill, card 103 | 102 0.0006 108 9 stage 104 | 103 0.0006 557 55 van 105 | 104 0.0006 52 4 ship 106 | 105 0.0005 99 5 fountain 107 | 106 0.0005 57 4 conveyer belt, conveyor belt, conveyer, conveyor, transporter 108 | 107 0.0005 292 31 canopy 109 | 108 0.0005 77 9 washer, automatic washer, washing machine 110 | 109 0.0005 340 38 plaything, toy 111 | 110 0.0005 66 3 swimming pool, swimming bath, natatorium 112 | 111 0.0005 465 49 stool 113 | 112 0.0005 50 4 barrel, cask 114 | 113 0.0005 622 75 basket, handbasket 115 | 114 0.0005 80 9 waterfall, falls 116 | 115 0.0005 59 3 tent, collapsible shelter 117 | 116 0.0005 531 72 bag 118 | 117 0.0005 282 30 minibike, motorbike 119 | 118 0.0005 73 7 cradle 120 | 119 0.0005 435 44 oven 121 | 120 0.0005 136 25 ball 122 | 121 0.0005 116 24 food, solid food 123 | 122 0.0004 266 31 step, stair 124 | 123 0.0004 58 12 tank, storage tank 125 | 124 0.0004 418 83 trade name, brand name, brand, marque 126 | 125 0.0004 319 43 microwave, microwave oven 127 | 126 0.0004 1193 139 pot, flowerpot 128 | 127 0.0004 97 23 animal, animate being, beast, brute, creature, fauna 129 | 128 0.0004 347 36 bicycle, bike, wheel, cycle 130 | 129 0.0004 52 5 lake 131 | 130 0.0004 246 22 dishwasher, dish washer, dishwashing machine 132 | 131 0.0004 108 13 screen, silver screen, projection screen 133 | 132 0.0004 201 30 blanket, cover 134 | 133 0.0004 285 21 sculpture 135 | 134 0.0004 268 27 hood, exhaust hood 136 | 135 0.0003 1020 108 sconce 137 | 136 0.0003 1282 122 vase 138 | 137 0.0003 528 65 traffic light, traffic signal, stoplight 139 | 138 0.0003 453 57 tray 140 | 139 0.0003 671 100 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin 141 | 140 0.0003 397 44 fan 142 | 141 0.0003 92 8 pier, wharf, wharfage, dock 143 | 142 0.0003 228 18 crt screen 144 | 143 0.0003 570 59 plate 145 | 144 0.0003 217 22 monitor, monitoring device 146 | 145 0.0003 206 19 bulletin board, notice board 147 | 146 0.0003 130 14 shower 148 | 147 0.0003 178 28 radiator 149 | 148 0.0002 504 57 glass, drinking glass 150 | 149 0.0002 775 96 clock 151 | 150 0.0002 421 56 flag 152 | -------------------------------------------------------------------------------- /boundarydetection/visualizationCode/subaxis/parseArgs.m: -------------------------------------------------------------------------------- 1 | function ArgStruct=parseArgs(args,ArgStruct,varargin) 2 | % Helper function for parsing varargin. 3 | % 4 | % 5 | % ArgStruct=parseArgs(varargin,ArgStruct[,FlagtypeParams[,Aliases]]) 6 | % 7 | % * ArgStruct is the structure full of named arguments with default values. 8 | % * Flagtype params is params that don't require a value. (the value will be set to 1 if it is present) 9 | % * Aliases can be used to map one argument-name to several argstruct fields 10 | % 11 | % 12 | % example usage: 13 | % -------------- 14 | % function parseargtest(varargin) 15 | % 16 | % %define the acceptable named arguments and assign default values 17 | % Args=struct('Holdaxis',0, ... 18 | % 'SpacingVertical',0.05,'SpacingHorizontal',0.05, ... 19 | % 'PaddingLeft',0,'PaddingRight',0,'PaddingTop',0,'PaddingBottom',0, ... 20 | % 'MarginLeft',.1,'MarginRight',.1,'MarginTop',.1,'MarginBottom',.1, ... 21 | % 'rows',[],'cols',[]); 22 | % 23 | % %The capital letters define abrreviations. 24 | % % Eg. parseargtest('spacingvertical',0) is equivalent to parseargtest('sv',0) 25 | % 26 | % Args=parseArgs(varargin,Args, ... % fill the arg-struct with values entered by the user 27 | % {'Holdaxis'}, ... %this argument has no value (flag-type) 28 | % {'Spacing' {'sh','sv'}; 'Padding' {'pl','pr','pt','pb'}; 'Margin' {'ml','mr','mt','mb'}}); 29 | % 30 | % disp(Args) 31 | % 32 | % 33 | % 34 | % 35 | % Aslak Grinsted 2004 36 | 37 | % ------------------------------------------------------------------------- 38 | % Copyright (C) 2002-2004, Aslak Grinsted 39 | % This software may be used, copied, or redistributed as long as it is not 40 | % sold and this copyright notice is reproduced on each copy made. This 41 | % routine is provided as is without any express or implied warranties 42 | % whatsoever. 43 | 44 | persistent matlabver 45 | 46 | if isempty(matlabver) 47 | matlabver=ver('MATLAB'); 48 | matlabver=str2double(matlabver.Version); 49 | end 50 | 51 | Aliases={}; 52 | FlagTypeParams=''; 53 | 54 | if (length(varargin)>0) 55 | FlagTypeParams=lower(strvcat(varargin{1})); %#ok 56 | if length(varargin)>1 57 | Aliases=varargin{2}; 58 | end 59 | end 60 | 61 | 62 | %---------------Get "numeric" arguments 63 | NumArgCount=1; 64 | while (NumArgCount<=size(args,2))&&(~ischar(args{NumArgCount})) 65 | NumArgCount=NumArgCount+1; 66 | end 67 | NumArgCount=NumArgCount-1; 68 | if (NumArgCount>0) 69 | ArgStruct.NumericArguments={args{1:NumArgCount}}; 70 | else 71 | ArgStruct.NumericArguments={}; 72 | end 73 | 74 | 75 | %--------------Make an accepted fieldname matrix (case insensitive) 76 | Fnames=fieldnames(ArgStruct); 77 | for i=1:length(Fnames) 78 | name=lower(Fnames{i,1}); 79 | Fnames{i,2}=name; %col2=lower 80 | Fnames{i,3}=[name(Fnames{i,1}~=name) ' ']; %col3=abreviation letters (those that are uppercase in the ArgStruct) e.g. SpacingHoriz->sh 81 | %the space prevents strvcat from removing empty lines 82 | Fnames{i,4}=isempty(strmatch(Fnames{i,2},FlagTypeParams)); %Does this parameter have a value? 83 | end 84 | FnamesFull=strvcat(Fnames{:,2}); %#ok 85 | FnamesAbbr=strvcat(Fnames{:,3}); %#ok 86 | 87 | if length(Aliases)>0 88 | for i=1:length(Aliases) 89 | name=lower(Aliases{i,1}); 90 | FieldIdx=strmatch(name,FnamesAbbr,'exact'); %try abbreviations (must be exact) 91 | if isempty(FieldIdx) 92 | FieldIdx=strmatch(name,FnamesFull); %&??????? exact or not? 93 | end 94 | Aliases{i,2}=FieldIdx; 95 | Aliases{i,3}=[name(Aliases{i,1}~=name) ' ']; %the space prevents strvcat from removing empty lines 96 | Aliases{i,1}=name; %dont need the name in uppercase anymore for aliases 97 | end 98 | %Append aliases to the end of FnamesFull and FnamesAbbr 99 | FnamesFull=strvcat(FnamesFull,strvcat(Aliases{:,1})); %#ok 100 | FnamesAbbr=strvcat(FnamesAbbr,strvcat(Aliases{:,3})); %#ok 101 | end 102 | 103 | %--------------get parameters-------------------- 104 | l=NumArgCount+1; 105 | while (l<=length(args)) 106 | a=args{l}; 107 | if ischar(a) 108 | paramHasValue=1; % assume that the parameter has is of type 'param',value 109 | a=lower(a); 110 | FieldIdx=strmatch(a,FnamesAbbr,'exact'); %try abbreviations (must be exact) 111 | if isempty(FieldIdx) 112 | FieldIdx=strmatch(a,FnamesFull); 113 | end 114 | if (length(FieldIdx)>1) %shortest fieldname should win 115 | [mx,mxi]=max(sum(FnamesFull(FieldIdx,:)==' ',2));%#ok 116 | FieldIdx=FieldIdx(mxi); 117 | end 118 | if FieldIdx>length(Fnames) %then it's an alias type. 119 | FieldIdx=Aliases{FieldIdx-length(Fnames),2}; 120 | end 121 | 122 | if isempty(FieldIdx) 123 | error(['Unknown named parameter: ' a]) 124 | end 125 | for curField=FieldIdx' %if it is an alias it could be more than one. 126 | if (Fnames{curField,4}) 127 | if (l+1>length(args)) 128 | error(['Expected a value for parameter: ' Fnames{curField,1}]) 129 | end 130 | val=args{l+1}; 131 | else %FLAG PARAMETER 132 | if (l=6 150 | ArgStruct.(Fnames{curField,1})=val; %try the line below if you get an error here 151 | else 152 | ArgStruct=setfield(ArgStruct,Fnames{curField,1},val); %#ok <-works in old matlab versions 153 | end 154 | end 155 | l=l+1+paramHasValue; %if a wildcard matches more than one 156 | else 157 | error(['Expected a named parameter: ' num2str(a)]) 158 | end 159 | end -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Sort.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __Sort_hh__ 3 | #define __Sort_hh__ 4 | 5 | // 6 | // A fast in-place sorting routine that can be customized to a 7 | // specific type with all swap and compare operations inlined. 8 | // 9 | // For arrays of types for which assignment, > and < exist (such as 10 | // int,float,etc. or appropriately-defined user types), the usage is 11 | // simple: 12 | // 13 | // double* a = new double [100]; 14 | // sort(a,100); 15 | // 16 | // This will sort the array into increasing order. To sort in another 17 | // order, or to sort more complex types, you must provide compare and 18 | // swap routines: 19 | // 20 | // sortSwap(cl,i,j) 21 | // - Swap elements i and j. 22 | // 23 | // sortCmp(cl,i,j) 24 | // - Compare elements i and j, returning -1,0,1 for <,=,>. 25 | // 26 | // The argument 'cl' is a closure. Note that the sorting routine does 27 | // not evaluate cl in any context other than these two routines. 28 | // 29 | // The postcondition of sort() is (sortCmp(cl,i,j) <= 0) for 30 | // all 0 <= i < j < n, i.e. increasing order. 31 | // 32 | // Here is an example of how to sort an array of points by x 33 | // coordinate in decreasing order: 34 | // 35 | // struct Point { int x, y; }; 36 | // static inline void sortSwap (Point* a, int i, int j) { 37 | // swap(a[i],a[j]); 38 | // } 39 | // static inline int sortCmp (Point* a, int i, int j) { 40 | // return a[j].x - a[i].x; 41 | // } 42 | // Point* points = new Point [100]; 43 | // sort(points,100); 44 | // 45 | 46 | // Copyright (C) 2002 David R. Martin 47 | // 48 | // This program is free software; you can redistribute it and/or 49 | // modify it under the terms of the GNU General Public License as 50 | // published by the Free Software Foundation; either version 2 of the 51 | // License, or (at your option) any later version. 52 | // 53 | // This program is distributed in the hope that it will be useful, but 54 | // WITHOUT ANY WARRANTY; without even the implied warranty of 55 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 56 | // General Public License for more details. 57 | // 58 | // You should have received a copy of the GNU General Public License 59 | // along with this program; if not, write to the Free Software 60 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 61 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 62 | 63 | #include 64 | 65 | // Public routines for sorting arrays of simple values that have 66 | // assignment, < and > defined. 67 | template 68 | static inline void sortSwap (T* a, int i, int j) { 69 | T tmp = a[i]; a[i] = a[j]; a[j] = tmp; 70 | } 71 | template 72 | static inline int sortCmp (T* a, int i, int j) { 73 | if (a[i] < a[j]) { return -1; } 74 | if (a[i] > a[j]) { return 1; } 75 | return 0; 76 | } 77 | 78 | // Private routine. 79 | // Sort elements [start,start+n) using insertion sort. 80 | template 81 | void 82 | __insertionSort (Closure cl, int start, int n) 83 | { 84 | for (int i = start; i < start+n-1; i++) { 85 | for (int j = i+1; j > start; j--) { 86 | if (sortCmp(cl,j-1,j) <= 0) { break; } 87 | sortSwap(cl,j-1,j); 88 | } 89 | } 90 | } 91 | 92 | // Private routine. 93 | // Sort elements [start,start+n) using selection sort. 94 | template 95 | void 96 | __selectionSort1 (Closure cl, int start, int n) 97 | { 98 | for (int i = start; i < start + n - 1; i++) { 99 | // Skip over duplicate elements. 100 | if (i > start && sortCmp(cl,i,i-1) == 0) { continue; } 101 | // Find the smallest element in [i,end] and move it to the front. 102 | int minLoc = i; 103 | for (int j = i + 1; j < start + n; j++) { 104 | if (sortCmp(cl,j,minLoc) < 0) { 105 | minLoc = j; 106 | } 107 | } 108 | if (minLoc > i) { 109 | sortSwap (cl, i, minLoc); 110 | } 111 | } 112 | } 113 | 114 | // Private routine. 115 | // Sort elements [start,start+n) using double-ended selection sort. 116 | template 117 | void 118 | __selectionSort2 (Closure cl, int start, int n) 119 | { 120 | int i = start; 121 | int j = start + n - 1; 122 | while (i < j) { 123 | // Skip over duplicate elements. 124 | if (i > start && sortCmp(cl,i,i-1) == 0) { i++; continue; } 125 | if (j < start+n-1 && sortCmp(cl,j,j+1) == 0) { j--; continue; } 126 | // Find the min and max elements in [i,j]. 127 | int minLoc=i, maxLoc=i; 128 | for (int k = i + 1; k <= j; k++) { 129 | if (sortCmp(cl,k,minLoc) < 0) { minLoc = k; } 130 | if (sortCmp(cl,k,maxLoc) > 0) { maxLoc = k; } 131 | } 132 | // Move the min element to the front and the max element to 133 | // the back. 134 | if (minLoc == maxLoc) { break; } 135 | if (minLoc > maxLoc) { 136 | sortSwap(cl,minLoc,maxLoc); 137 | int tmp=minLoc; minLoc=maxLoc; maxLoc=tmp; 138 | } 139 | if (minLoc > i) { sortSwap(cl,i,minLoc); } 140 | if (maxLoc < j) { sortSwap(cl,j,maxLoc); } 141 | i++; j--; 142 | } 143 | } 144 | 145 | // Private routine. 146 | // Return the median of the 3 arguments as defined by cmp##NAME. 147 | // Used internally in qsort to pick a pivot. 148 | template 149 | int 150 | __3median (Closure cl, int x, int y, int z) 151 | { 152 | return sortCmp(cl,x,y) > 0 153 | ? (sortCmp(cl,y,z) > 0 154 | ? y : (sortCmp(cl,x,z) > 0 ? z : x)) 155 | : (sortCmp(cl,y,z) < 0 156 | ? y : (sortCmp(cl,x,z) < 0 ? z : x)); 157 | } 158 | 159 | // Private routine. 160 | // Sort elements [start,start+n) using quick sort. 161 | template 162 | void 163 | __quickSort (Closure cl, int start, int n) 164 | { 165 | // Use selection-sort for small arrays. 166 | if (n < 16) { 167 | __insertionSort (cl, start, n); 168 | //__selectionSort1 (cl, start, n); 169 | //__selectionSort2 (cl, start, n); 170 | return; 171 | } 172 | 173 | // Pick the median of elements n/4, n/2, 3n/4 as the pivot, and 174 | // move it to the front. 175 | int x = start + (n >> 2); 176 | int y = start + (n >> 1); 177 | int z = x + (n >> 1); 178 | int pivotLoc = __3median (cl, x, y, z); 179 | sortSwap (cl, start, pivotLoc); 180 | 181 | // Segregate array elements into three groups. Those equal to the 182 | // pivot (=), those less than the pivot (<), and those greater 183 | // than the pivot (>). After this loop, the array will look like 184 | // this: 185 | // S P RL 186 | // =====<<<<<>>>>> 187 | // 188 | // Where S=start P=pivot R=right L=left. 189 | // 190 | int pivot = start; 191 | int left = start + 1; 192 | int right = start + n - 1; 193 | while (1) { 194 | restart: 195 | while (left <= right) { 196 | int c = sortCmp (cl, left, pivot); 197 | if (c > 0) { break; } 198 | if (c < 0) { left++; continue; } 199 | if (left != pivot+1) { sortSwap (cl, left, pivot+1); } 200 | pivot++; left++; 201 | } 202 | while (left <= right) { 203 | int c = sortCmp (cl, right, pivot); 204 | if (c < 0) { break; } 205 | if (c > 0) { right--; continue; } 206 | assert (left < right); 207 | sortSwap (cl, left, right); 208 | if (left != pivot+1) { sortSwap (cl, left, pivot+1); } 209 | pivot++; left++; right--; 210 | goto restart; 211 | } 212 | if (left > right) { break; } 213 | sortSwap (cl, left, right); 214 | } 215 | assert (pivot >= start); 216 | assert (right >= pivot); 217 | assert (left == right + 1); 218 | assert (left <= start + n); 219 | 220 | int numEq = pivot - start + 1; 221 | int numLt = right - pivot; 222 | int numLe = left - start; 223 | int numGt = n - numLe; 224 | assert (numEq + numLt + numGt == n); 225 | 226 | // Copy pivot values into middle. 227 | int count = (numEq < numLt) ? numEq : numLt; 228 | int dist = numLe - count; 229 | for (int i = 0; i < count; i++) { 230 | sortSwap (cl, start + i, start + i + dist); 231 | } 232 | 233 | // Recursively sort the < and > chunks. 234 | if (numLt > 0) { __quickSort (cl, start, numLt); } 235 | if (numGt > 0) { __quickSort (cl, left, numGt); } 236 | } 237 | 238 | // Public sort routine. 239 | template 240 | inline void 241 | sort (Closure cl, int n) 242 | { 243 | __quickSort (cl, 0, n); 244 | // Check the postcondition. 245 | for (int i = 1; i < n; i++) { 246 | assert (sortCmp (cl, i-1, i) <= 0); 247 | } 248 | } 249 | 250 | #endif // __Sort_hh__ 251 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/Array.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __Array_hh__ 3 | #define __Array_hh__ 4 | 5 | // Arrays that reduce bugs by: 6 | // - Being allocatable on the stack, so destructors get called 7 | // automatically. 8 | // - Doing bounds checking. 9 | // - Providing easy initialization. 10 | // - Encapsulating the address calculation. 11 | 12 | // The arrays are allocated as single blocks so that all elements are 13 | // contiguous in memory. Latter indices change more quickly than 14 | // former indices. Clients can rely on this ordering. 15 | 16 | // Copyright (C) 2003 David R. Martin 17 | // 18 | // This program is free software; you can redistribute it and/or 19 | // modify it under the terms of the GNU General Public License as 20 | // published by the Free Software Foundation; either version 2 of the 21 | // License, or (at your option) any later version. 22 | // 23 | // This program is distributed in the hope that it will be useful, but 24 | // WITHOUT ANY WARRANTY; without even the implied warranty of 25 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | // General Public License for more details. 27 | // 28 | // You should have received a copy of the GNU General Public License 29 | // along with this program; if not, write to the Free Software 30 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 31 | // 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. 32 | 33 | #include 34 | #include 35 | 36 | template 37 | class Array1D 38 | { 39 | public: 40 | 41 | Array1D () { 42 | _alloc(0); 43 | } 44 | Array1D (unsigned n) { 45 | _alloc(n); 46 | } 47 | ~Array1D () { 48 | _delete(); 49 | } 50 | void resize (unsigned n) { 51 | if (!issize(n)) { 52 | _delete(); 53 | _alloc(n); 54 | } 55 | } 56 | void init (const Elem& elem) { 57 | for (unsigned i = 0; i < _n; i++) { 58 | _array[i] = elem; 59 | } 60 | } 61 | bool issize (unsigned n) const { 62 | return (_n == n); 63 | } 64 | int size () const { 65 | return _n; 66 | } 67 | Elem* data () { 68 | return _array; 69 | } 70 | Elem& operator() (unsigned i) { 71 | assert (i < _n); 72 | return _array[i]; 73 | } 74 | const Elem& operator() (unsigned i) const { 75 | assert (i < _n); 76 | return _array[i]; 77 | } 78 | 79 | private: 80 | 81 | void _alloc (unsigned n) { 82 | _n = n; 83 | _array = new Elem [_n]; 84 | } 85 | void _delete () { 86 | assert (_array != NULL); 87 | delete [] _array; 88 | _array = NULL; 89 | } 90 | 91 | unsigned _n; 92 | Elem* _array; 93 | 94 | }; // class Array1D 95 | 96 | template 97 | class Array2D 98 | { 99 | public: 100 | 101 | Array2D () { 102 | _alloc(0,0); 103 | } 104 | Array2D (unsigned d0, unsigned d1) { 105 | _alloc(d0,d1); 106 | } 107 | ~Array2D () { 108 | _delete(); 109 | } 110 | void resize (unsigned d0, unsigned d1) { 111 | if (!issize(d0,d1)) { 112 | _delete(); 113 | _alloc(d0,d1); 114 | } 115 | } 116 | void init (const Elem& elem) { 117 | for (unsigned i = 0; i < _n; i++) { 118 | _array[i] = elem; 119 | } 120 | } 121 | bool issize (unsigned d0, unsigned d1) const { 122 | return (_dim[0] == d0 && _dim[1] == d1); 123 | } 124 | int size (unsigned d) const { 125 | assert (d < 2); 126 | return _dim[d]; 127 | } 128 | Elem* data () { 129 | return _array; 130 | } 131 | Elem& operator() (unsigned i, unsigned j) { 132 | assert (i < _dim[0]); 133 | assert (j < _dim[1]); 134 | unsigned index = i * _dim[1] + j; 135 | assert (index < _n); 136 | return _array[index]; 137 | } 138 | const Elem& operator() (unsigned i, unsigned j) const { 139 | assert (i < _dim[0]); 140 | assert (j < _dim[1]); 141 | unsigned index = i * _dim[1] + j; 142 | assert (index < _n); 143 | return _array[index]; 144 | } 145 | 146 | private: 147 | 148 | void _alloc (unsigned d0, unsigned d1) { 149 | _n = d0 * d1; 150 | _dim[0] = d0; 151 | _dim[1] = d1; 152 | _array = new Elem [_n]; 153 | } 154 | void _delete () { 155 | assert (_array != NULL); 156 | delete [] _array; 157 | _array = NULL; 158 | } 159 | 160 | unsigned _n; 161 | Elem* _array; 162 | unsigned _dim[2]; 163 | 164 | }; // class Array2D 165 | 166 | template 167 | class Array3D 168 | { 169 | public: 170 | 171 | Array3D () { 172 | _alloc(0,0,0); 173 | } 174 | Array3D (unsigned d0, unsigned d1, unsigned d2) { 175 | _alloc(d0,d1,d2); 176 | } 177 | ~Array3D () { 178 | _delete(); 179 | } 180 | void resize (unsigned d0, unsigned d1, unsigned d2) { 181 | if (!issize(d0,d1,d2)) { 182 | _delete(); 183 | _alloc(d0,d1,d2); 184 | } 185 | } 186 | void init (const Elem& elem) { 187 | for (unsigned i = 0; i < _n; i++) { 188 | _array[i] = elem; 189 | } 190 | } 191 | bool issize (unsigned d0, unsigned d1, unsigned d2) const { 192 | return (_dim[0] == d0 && _dim[1] == d1 && _dim[2] == d2); 193 | } 194 | int size (unsigned d) const { 195 | assert (d < 3); 196 | return _dim[d]; 197 | } 198 | Elem* data () { 199 | return _array; 200 | } 201 | Elem& operator() (unsigned i, unsigned j, unsigned k) { 202 | assert (i < _dim[0]); 203 | assert (j < _dim[1]); 204 | assert (k < _dim[2]); 205 | unsigned index = (i * _dim[1] + j) * _dim[2] + k; 206 | assert (index < _n); 207 | return _array[index]; 208 | } 209 | const Elem& operator() (unsigned i, unsigned j, unsigned k) const { 210 | assert (i < _dim[0]); 211 | assert (j < _dim[1]); 212 | assert (k < _dim[2]); 213 | unsigned index = (i * _dim[1] + j) * _dim[2] + k; 214 | assert (index < _n); 215 | return _array[index]; 216 | } 217 | 218 | private: 219 | 220 | void _alloc (unsigned d0, unsigned d1, unsigned d2) { 221 | _n = d0 * d1 * d2; 222 | _array = new Elem [_n]; 223 | _dim[0] = d0; 224 | _dim[1] = d1; 225 | _dim[2] = d2; 226 | } 227 | void _delete () { 228 | assert (_array != NULL); 229 | delete [] _array; 230 | _array = NULL; 231 | } 232 | 233 | unsigned _n; 234 | Elem* _array; 235 | unsigned _dim[3]; 236 | 237 | }; // class Array3D 238 | 239 | template 240 | class Array4D 241 | { 242 | public: 243 | 244 | Array4D () { 245 | _alloc(0,0,0,0); 246 | } 247 | Array4D (unsigned d0, unsigned d1, unsigned d2, unsigned d3) { 248 | _alloc(d0,d1,d2,d3); 249 | } 250 | ~Array4D () { 251 | _delete(); 252 | } 253 | void resize (unsigned d0, unsigned d1, unsigned d2, unsigned d3) { 254 | if (!issize(d0,d1,d2,d3)) { 255 | _delete(); 256 | _alloc(d0,d1,d2,d3); 257 | } 258 | } 259 | void init (const Elem& elem) { 260 | for (unsigned i = 0; i < _n; i++) { 261 | _array[i] = elem; 262 | } 263 | } 264 | bool issize (unsigned d0, unsigned d1, unsigned d2, unsigned d3) const { 265 | return (_dim[0] == d0 && _dim[1] == d1 && _dim[2] == d2 && _dim[3] == d3); 266 | } 267 | int size (unsigned d) const { 268 | assert (d < 4); 269 | return _dim[d]; 270 | } 271 | Elem* data () { 272 | return _array; 273 | } 274 | Elem& operator() (unsigned i, unsigned j, unsigned k, unsigned m) { 275 | assert (i < _dim[0]); 276 | assert (j < _dim[1]); 277 | assert (k < _dim[2]); 278 | assert (m < _dim[3]); 279 | unsigned index = ((i * _dim[1] + j) * _dim[2] + k) * _dim[3] + m; 280 | assert (index < _n); 281 | return _array[index]; 282 | } 283 | const Elem& operator() (unsigned i, unsigned j, unsigned k, unsigned m) const { 284 | assert (i < _dim[0]); 285 | assert (j < _dim[1]); 286 | assert (k < _dim[2]); 287 | assert (m < _dim[3]); 288 | unsigned index = ((i * _dim[1] + j) * _dim[2] + k) * _dim[3] + m; 289 | assert (index < _n); 290 | return _array[index]; 291 | } 292 | 293 | private: 294 | 295 | void _alloc (unsigned d0, unsigned d1, unsigned d2, unsigned d3) { 296 | _n = d0 * d1 * d2 * d3; 297 | _array = new Elem [_n]; 298 | _dim[0] = d0; 299 | _dim[1] = d1; 300 | _dim[2] = d2; 301 | _dim[3] = d3; 302 | } 303 | void _delete () { 304 | assert (_array != NULL); 305 | delete [] _array; 306 | _array = NULL; 307 | } 308 | 309 | unsigned _n; 310 | Elem* _array; 311 | unsigned _dim[4]; 312 | 313 | }; // class Array4D 314 | 315 | #endif // __Array_hh__ 316 | -------------------------------------------------------------------------------- /boundarydetection/evaluationCode/cp_src/match.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "csa.hh" 7 | #include "kofn.hh" 8 | #include "Point.hh" 9 | #include "Matrix.hh" 10 | #include "Array.hh" 11 | #include "match.hh" 12 | #include "Timer.hh" 13 | 14 | struct Edge { 15 | int i,j; // node ids, 0-based 16 | double w; // distance between pixels 17 | }; 18 | 19 | // CSA code needs integer weights. Use this multiplier to convert 20 | // floating-point weights to integers. 21 | static const int multiplier = 100; 22 | 23 | // The degree of outlier connections. 24 | static const int degree = 6; 25 | 26 | double 27 | matchEdgeMaps ( 28 | const Matrix& bmap1, const Matrix& bmap2, 29 | double maxDist, double outlierCost, 30 | Matrix& m1, Matrix& m2) 31 | { 32 | // Check global constants. 33 | assert (degree > 0); 34 | assert (multiplier > 0); 35 | 36 | // Check arguments. 37 | assert (bmap1.nrows() == bmap2.nrows()); 38 | assert (bmap1.ncols() == bmap2.ncols()); 39 | assert (maxDist >= 0); 40 | assert (outlierCost > maxDist); 41 | 42 | const int height = bmap1.nrows(); 43 | const int width = bmap1.ncols(); 44 | 45 | // Initialize to zeros. 46 | m1 = Matrix(height,width); 47 | m2 = Matrix(height,width); 48 | 49 | // Initialize match[12] arrays to (-1,-1). 50 | Array2D match1 (width,height); 51 | Array2D match2 (width,height); 52 | for (int x = 0; x < width; x++) { 53 | for (int y = 0; y < height; y++) { 54 | match1(x,y) = Pixel(-1,-1); 55 | match2(x,y) = Pixel(-1,-1); 56 | } 57 | } 58 | 59 | // Radius of search window. 60 | const int r = (int) ceil (maxDist); 61 | 62 | // Figure out which nodes are matchable, i.e. within maxDist 63 | // of another node. 64 | Array2D matchable1 (width,height); 65 | Array2D matchable2 (width,height); 66 | matchable1.init(false); 67 | matchable2.init(false); 68 | for (int y1 = 0; y1 < height; y1++) { 69 | for (int x1 = 0; x1 < width; x1++) { 70 | if (!bmap1(y1,x1)) { continue; } 71 | for (int v = -r; v <= r; v++) { 72 | for (int u = -r; u <= r; u++) { 73 | const double d2 = u*u + v*v; 74 | if (d2 > maxDist*maxDist) { continue; } 75 | const int x2 = x1 + u; 76 | const int y2 = y1 + v; 77 | if (x2 < 0 || x2 >= width) { continue; } 78 | if (y2 < 0 || y2 >= height) { continue; } 79 | if (!bmap2(y2,x2)) { continue; } 80 | matchable1(x1,y1) = true; 81 | matchable2(x2,y2) = true; 82 | } 83 | } 84 | } 85 | } 86 | 87 | // Count the number of nodes on each side of the match. 88 | // Construct nodeID->pixel and pixel->nodeID maps. 89 | // Node IDs range from [0,n1) and [0,n2). 90 | int n1=0, n2=0; 91 | std::vector nodeToPix1; 92 | std::vector nodeToPix2; 93 | Array2D pixToNode1 (width,height); 94 | Array2D pixToNode2 (width,height); 95 | for (int x = 0; x < width; x++) { 96 | for (int y = 0; y < height; y++) { 97 | pixToNode1(x,y) = -1; 98 | pixToNode2(x,y) = -1; 99 | Pixel pix (x,y); 100 | if (matchable1(x,y)) { 101 | pixToNode1(x,y) = n1; 102 | nodeToPix1.push_back(pix); 103 | n1++; 104 | } 105 | if (matchable2(x,y)) { 106 | pixToNode2(x,y) = n2; 107 | nodeToPix2.push_back(pix); 108 | n2++; 109 | } 110 | } 111 | } 112 | 113 | // Construct the list of edges between pixels within maxDist. 114 | std::vector edges; 115 | for (int x1 = 0; x1 < width; x1++) { 116 | for (int y1 = 0; y1 < height; y1++) { 117 | if (!matchable1(x1,y1)) { continue; } 118 | for (int u = -r; u <= r; u++) { 119 | for (int v = -r; v <= r; v++) { 120 | const double d2 = u*u + v*v; 121 | if (d2 > maxDist*maxDist) { continue; } 122 | const int x2 = x1 + u; 123 | const int y2 = y1 + v; 124 | if (x2 < 0 || x2 >= width) { continue; } 125 | if (y2 < 0 || y2 >= height) { continue; } 126 | if (!matchable2(x2,y2)) { continue; } 127 | Edge e; 128 | e.i = pixToNode1(x1,y1); 129 | e.j = pixToNode2(x2,y2); 130 | e.w = sqrt(d2); 131 | assert (e.i >= 0 && e.i < n1); 132 | assert (e.j >= 0 && e.j < n2); 133 | assert (e.w < outlierCost); 134 | edges.push_back(e); 135 | } 136 | } 137 | } 138 | } 139 | 140 | // The cardinality of the match is n. 141 | const int n = n1 + n2; 142 | const int nmin = std::min(n1,n2); 143 | const int nmax = std::max(n1,n2); 144 | 145 | // Compute the degree of various outlier connections. 146 | const int d1 = std::max(0,std::min(degree,n1-1)); // from map1 147 | const int d2 = std::max(0,std::min(degree,n2-1)); // from map2 148 | const int d3 = std::min(degree,std::min(n1,n2)); // between outliers 149 | const int dmax = std::max(d1,std::max(d2,d3)); 150 | 151 | assert (n1 == 0 || (d1 >= 0 && d1 < n1)); 152 | assert (n2 == 0 || (d2 >= 0 && d2 < n2)); 153 | assert (d3 >= 0 && d3 <= nmin); 154 | 155 | // Count the number of edges. 156 | int m = 0; 157 | m += edges.size(); // real connections 158 | m += d1 * n1; // outlier connections 159 | m += d2 * n2; // outlier connections 160 | m += d3 * nmax; // outlier-outlier connections 161 | m += n; // high-cost perfect match overlay 162 | 163 | // If the graph is empty, then there's nothing to do. 164 | if (m == 0) { 165 | return 0; 166 | } 167 | 168 | // Weight of outlier connections. 169 | const int ow = (int) ceil (outlierCost * multiplier); 170 | 171 | // Scratch array for outlier edges. 172 | Array1D outliers (dmax); 173 | 174 | // Construct the input graph for the assignment problem. 175 | Array2D igraph (m,3); 176 | int count = 0; 177 | // real edges 178 | for (int a = 0; a < (int)edges.size(); a++) { 179 | int i = edges[a].i; 180 | int j = edges[a].j; 181 | assert (i >= 0 && i < n1); 182 | assert (j >= 0 && j < n2); 183 | igraph(count,0) = i; 184 | igraph(count,1) = j; 185 | igraph(count,2) = (int) rint (edges[a].w * multiplier); 186 | count++; 187 | } 188 | // outliers edges for map1, exclude diagonal 189 | for (int i = 0; i < n1; i++) { 190 | kOfN(d1,n1-1,outliers.data()); 191 | for (int a = 0; a < d1; a++) { 192 | int j = outliers(a); 193 | if (j >= i) { j++; } 194 | assert (i != j); 195 | assert (j >= 0 && j < n1); 196 | igraph(count,0) = i; 197 | igraph(count,1) = n2 + j; 198 | igraph(count,2) = ow; 199 | count++; 200 | } 201 | } 202 | // outliers edges for map2, exclude diagonal 203 | for (int j = 0; j < n2; j++) { 204 | kOfN(d2,n2-1,outliers.data()); 205 | for (int a = 0; a < d2; a++) { 206 | int i = outliers(a); 207 | if (i >= j) { i++; } 208 | assert (i != j); 209 | assert (i >= 0 && i < n2); 210 | igraph(count,0) = n1 + i; 211 | igraph(count,1) = j; 212 | igraph(count,2) = ow; 213 | count++; 214 | } 215 | } 216 | // outlier-to-outlier edges 217 | for (int i = 0; i < nmax; i++) { 218 | kOfN(d3,nmin,outliers.data()); 219 | for (int a = 0; a < d3; a++) { 220 | const int j = outliers(a); 221 | assert (j >= 0 && j < nmin); 222 | if (n1 < n2) { 223 | assert (i >= 0 && i < n2); 224 | assert (j >= 0 && j < n1); 225 | igraph(count,0) = n1 + i; 226 | igraph(count,1) = n2 + j; 227 | } else { 228 | assert (i >= 0 && i < n1); 229 | assert (j >= 0 && j < n2); 230 | igraph(count,0) = n1 + j; 231 | igraph(count,1) = n2 + i; 232 | } 233 | igraph(count,2) = ow; 234 | count++; 235 | } 236 | } 237 | // perfect match overlay (diagonal) 238 | for (int i = 0; i < n1; i++) { 239 | igraph(count,0) = i; 240 | igraph(count,1) = n2 + i; 241 | igraph(count,2) = ow * multiplier; 242 | count++; 243 | } 244 | for (int i = 0; i < n2; i++) { 245 | igraph(count,0) = n1 + i; 246 | igraph(count,1) = i; 247 | igraph(count,2) = ow * multiplier; 248 | count++; 249 | } 250 | assert (count == m); 251 | 252 | // Check all the edges, and set the values up for CSA. 253 | for (int i = 0; i < m; i++) { 254 | assert(igraph(i,0) >= 0 && igraph(i,0) < n); 255 | assert(igraph(i,1) >= 0 && igraph(i,1) < n); 256 | igraph(i,0) += 1; 257 | igraph(i,1) += 1+n; 258 | } 259 | 260 | // Solve the assignment problem. 261 | CSA csa(2*n,m,igraph.data()); 262 | assert(csa.edges()==n); 263 | 264 | Array2D ograph (n,3); 265 | for (int i = 0; i < n; i++) { 266 | int a,b,c; 267 | csa.edge(i,a,b,c); 268 | ograph(i,0)=a-1; ograph(i,1)=b-1-n; ograph(i,2)=c; 269 | } 270 | 271 | // Check the solution. 272 | // Count the number of high-cost edges from the perfect match 273 | // overlay that were used in the match. 274 | int overlayCount = 0; 275 | for (int a = 0; a < n; a++) { 276 | const int i = ograph(a,0); 277 | const int j = ograph(a,1); 278 | const int c = ograph(a,2); 279 | assert (i >= 0 && i < n); 280 | assert (j >= 0 && j < n); 281 | assert (c >= 0); 282 | // edge from high-cost perfect match overlay 283 | if (c == ow * multiplier) { overlayCount++; } 284 | // skip outlier edges 285 | if (i >= n1) { continue; } 286 | if (j >= n2) { continue; } 287 | // for edges between real nodes, check the edge weight 288 | const Pixel pix1 = nodeToPix1[i]; 289 | const Pixel pix2 = nodeToPix2[j]; 290 | const int dx = pix1.x - pix2.x; 291 | const int dy = pix1.y - pix2.y; 292 | const int w = (int) rint (sqrt(dx*dx+dy*dy)*multiplier); 293 | assert (w == c); 294 | } 295 | 296 | // Print a warning if any of the edges from the perfect match overlay 297 | // were used. This should happen rarely. If it happens frequently, 298 | // then the outlier connectivity should be increased. 299 | if (overlayCount > 5) { 300 | fprintf (stderr, "%s:%d: WARNING: The match includes %d " 301 | "outlier(s) from the perfect match overlay.\n", 302 | __FILE__, __LINE__, overlayCount); 303 | } 304 | 305 | // Compute match arrays. 306 | for (int a = 0; a < n; a++) { 307 | // node ids 308 | const int i = ograph(a,0); 309 | const int j = ograph(a,1); 310 | // skip outlier edges 311 | if (i >= n1) { continue; } 312 | if (j >= n2) { continue; } 313 | // map node ids to pixels 314 | const Pixel pix1 = nodeToPix1[i]; 315 | const Pixel pix2 = nodeToPix2[j]; 316 | // record edges 317 | match1(pix1.x,pix1.y) = pix2; 318 | match2(pix2.x,pix2.y) = pix1; 319 | } 320 | for (int x = 0; x < width; x++) { 321 | for (int y = 0; y < height; y++) { 322 | if (bmap1(y,x)) { 323 | if (match1(x,y) != Pixel(-1,-1)) { 324 | m1(y,x) = match1(x,y).x*height + match1(x,y).y + 1; 325 | } 326 | } 327 | if (bmap2(y,x)) { 328 | if (match2(x,y) != Pixel(-1,-1)) { 329 | m2(y,x) = match2(x,y).x*height + match2(x,y).y + 1; 330 | } 331 | } 332 | } 333 | } 334 | 335 | // Compute the match cost. 336 | double cost = 0; 337 | for (int x = 0; x < width; x++) { 338 | for (int y = 0; y < height; y++) { 339 | if (bmap1(y,x)) { 340 | if (match1(x,y) == Pixel(-1,-1)) { 341 | cost += outlierCost; 342 | } else { 343 | const int dx = x - match1(x,y).x; 344 | const int dy = y - match1(x,y).y; 345 | cost += 0.5 * sqrt (dx*dx + dy*dy); 346 | } 347 | } 348 | if (bmap2(y,x)) { 349 | if (match2(x,y) == Pixel(-1,-1)) { 350 | cost += outlierCost; 351 | } else { 352 | const int dx = x - match2(x,y).x; 353 | const int dy = y - match2(x,y).y; 354 | cost += 0.5 * sqrt (dx*dx + dy*dy); 355 | } 356 | } 357 | } 358 | } 359 | 360 | // Return the match cost. 361 | return cost; 362 | } 363 | --------------------------------------------------------------------------------