teeters/GeometricContext
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Below is an overview of the important files in the implementation, with instructions on how to reproduce my experiments.
The implementation lives in the folder GeometricContext. To work with it, open Matlab and add the folder and all of its subfolders to your Matlab path. GeometricContext contains two versions of the project, one from the original paper in 2003 and one from a later version present to IJCV in 2006. My code interacts with the 2003 version, which is generally identified by the prefix APP.
The main driver script for my experiments is STrunTest. This script calls the test function APPtestImage on a couple of images contained in the folder testdir and writes the results to a subdirectory specified by the user. In order to use the different regional segmentation algorithms I developed, you will need to modify APPtestImage -- see line 56 where the variable "maps" is generated. By default, segmentations are generated by the function APPsp2regions. To use my kmeans approaches, simply change the function signature.
The two alternative regional segmentation functions are called STsp2regions and density_kmeans. Each one takes as input a map of the superpixel pairwise affinity function (segDensity), data for all superpixels in an image (spData), an array containing the number of segments for each regional hypothesis (nSegments), and in the case of STsp2regions, a scalar specifying the extra weight to be given to spatial location features. To interact with these functions directly you will need to load or generate these variables manually. An example call to Stsp2regions might look like this:
load('/home/teeters/Documents/Classes/computer_vision/final_project/GeometricContext/data/classifiers_08_22_2005.mat'); %gives us the segment_density variable
load('/home/teeters/Documents/Classes/computer_vision/final_project/GeometricContext/src/dataset/allimsegs2.mat'); %gives us the imsegs variable, which contains image segmentation data for the whole dataset.
[doog_filters, texton_data] = APPgetImageFilters; %loads precursors to generating SpData
test_image = imread('alley01.jpg'); %the input image
test_imsegs = imsegs(strcmp({imsegs.imname}, 'alley01.jpg')); %fetches segmentation data for the test image
spdata = APPgetSpData(test_image, doog_filters, texton_data.tim, test_imsegs); %get superpixel data
maps = Stsp2regions(segment_density, spdata, [3,10,20], 100); %generate 3, 10, and 20 region hypotheses on the test image with spatial weight of 100.
To view the map with 3 regions, you would then run
visualize_regions(test_image, test_imsegs.segimage, maps(:,1));
Finally, the function STcheckAccuracy produces confusion matrices and accuracy estimates for all of the test images bundled together. This function is called automatically by STrunTest and the output is written to testdir/user_specified_outdir.