├── LICENSE.md ├── README.md ├── collect_test_subset.m ├── collect_train_subset.m ├── convert_dataset.m ├── crop_dataset.m ├── list_test.txt ├── list_test_subset.txt ├── list_train.txt ├── list_train_subset.txt ├── mediannan_int.m ├── relabel_dataset.m └── seg2bdry.m /LICENSE.md: -------------------------------------------------------------------------------- 1 | For detailed license information on the original code, contact Liefeng Bo . 2 | 3 | The remaining part of the code is licensed as stated below. 4 | 5 | Copyright (c) 2014, David Stutz All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 11 | * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NYU Depth V2 Tools for Evaluating Superpixel Algorithms 2 | 3 | This repository contains several tools to pre-process the ground truth segmentations as provided by the NYU Depth Dataset V2 [1]: 4 | 5 | [1] N. Silberman, D. Hoiem, P. Kohli, R. Fergus. 6 | Indoor segmentation and support inference from RGBD images. 7 | In Computer Vision, European Conference on, volume 7576 of Lecture Notes in Computer Science, pages 746–760. Springer Berlin Heidelberg, 2012. 8 | 9 | The code was used to evaluate several superpixel algorithms in [2] and [3]. The corresponding benchmark can be found here: [https://github.com/davidstutz/extended-berkeley-segmentation-benchmark](https://github.com/davidstutz/extended-berkeley-segmentation-benchmark). 10 | 11 | [2] D. Stutz. 12 | Superpixel Segmentation using Depth Information. 13 | Bachelor thesis, RWTH Aachen University, Aachen, Germany, 2014. 14 | [3] D. Stutz. 15 | Superpixel Segmentation: An Evaluation. 16 | Pattern Recognition (J. Gall, P. Gehler, B. Leibe (Eds.)), Lecture Notes in Computer Science, vol. 9358, pages 555 - 562, 2015. 17 | 18 | The code was originally written by Liefeng Bo and used in [4]: 19 | 20 | [4] X. Ren, L. Bo. 21 | Discriminatively trained sparse code gradients for contour detection. 22 | In Advances in Neural Information Processing Systems, volume 25, pages 584–592. Curran Associates, 2012. 23 | 24 | ## Usage 25 | 26 | Overview: 27 | 28 | * `convert_dataset.m`: Used to split the dataset into training and test set according to `list_train.txt` and `list_test.txt`. In addition, the ground truth segmentations are converted to the format used by the Berkeley Segmentation Benchmark [4] and its extended versio (see above). 29 | * `collect_train_subset.m`: A training subset comprising 200 images is depicted in `list_train_subset.txt` and this function is used to copy all files within this subset in separate folders.`. 30 | * `collect_test_subset.m`: Copies all files belonging to a subset of the test set in separate folders (as above). 31 | 32 | Detailed usage information can be found in the corresponding MatLab files. 33 | 34 | ## License 35 | 36 | Licenses for source code corresponding to: 37 | 38 | D. Stutz. **Superpixel Segmentation using Depth Information.** Bachelor Thesis, RWTH Aachen University, 2014. 39 | 40 | D. Stutz. **Superpixel Segmentation: An Evaluation.** Pattern Recognition (J. Gall, P. Gehler, B. Leibe (Eds.)), Lecture Notes in Computer Science, vol. 9358, pages 555 - 562, 2015. 41 | 42 | Note that the source code and/or data is based on the following projects for which separate licenses apply: 43 | 44 | * code by Liefeng Bo 45 | 46 | Copyright (c) 2014-2018 David Stutz, RWTH Aachen University 47 | 48 | **Please read carefully the following terms and conditions and any accompanying documentation before you download and/or use this software and associated documentation files (the "Software").** 49 | 50 | The authors hereby grant you a non-exclusive, non-transferable, free of charge right to copy, modify, merge, publish, distribute, and sublicense the Software for the sole purpose of performing non-commercial scientific research, non-commercial education, or non-commercial artistic projects. 51 | 52 | Any other use, in particular any use for commercial purposes, is prohibited. This includes, without limitation, incorporation in a commercial product, use in a commercial service, or production of other artefacts for commercial purposes. 53 | 54 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 55 | 56 | You understand and agree that the authors are under no obligation to provide either maintenance services, update services, notices of latent defects, or corrections of defects with regard to the Software. The authors nevertheless reserve the right to update, modify, or discontinue the Software at any time. 57 | 58 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. You agree to cite the corresponding papers (see above) in documents and papers that report on research using the Software. 59 | -------------------------------------------------------------------------------- /collect_test_subset.m: -------------------------------------------------------------------------------- 1 | function [] = collect_test_subsets() 2 | % function [] = collect_test_subsets() 3 | % 4 | % Collects the test subset given by list_test_subset.txt. 5 | % 6 | % David Stutz 7 | 8 | load './nyu_tools/list_test_subset.txt' list_test_subset 9 | 10 | baseDir = './NYUDepthV2/cropped-original/data'; 11 | 12 | depthSubDir = sprintf('%s/depth/test_subset', baseDir); 13 | if ~exist(depthSubDir) 14 | system(sprintf('mkdir %s', depthSubDir)); 15 | end; 16 | 17 | rawDepthSubDir = sprintf('%s/rawDepth/test_subset', baseDir); 18 | if ~exist(rawDepthSubDir) 19 | system(sprintf('mkdir %s', rawDepthSubDir)); 20 | end; 21 | 22 | groundTruthSubDir = sprintf('%s/groundTruth/test_subset', baseDir); 23 | if ~exist(groundTruthSubDir) 24 | system(sprintf('mkdir %s', groundTruthSubDir)); 25 | end; 26 | 27 | for i = 1: size(list_test_subset, 1) 28 | system(sprintf('cp %s/images/test/%08d.jpg %s/images/test_subset/%08d.jpg', baseDir, list_test_subset(i), baseDir, list_test_subset(i))); 29 | system(sprintf('cp %s/groundTruth/test/%08d.mat %s/groundTruth/test_subset/%08d.mat', baseDir, list_test_subset(i), baseDir, list_test_subset(i))); 30 | system(sprintf('cp %s/depth/test/%08d.png %s/depth/test_subset/%08d.png', baseDir, list_test_subset(i), baseDir, list_test_subset(i))); 31 | end; 32 | 33 | end 34 | 35 | -------------------------------------------------------------------------------- /collect_train_subset.m: -------------------------------------------------------------------------------- 1 | function [] = collect_train_subsets() 2 | % function [] = collect_train_subsets() 3 | % 4 | % Collects the train subsets given by list_train_subset.txt and 5 | % list_train_subset_2.txt which both contain 100 images hand chosen such 6 | % that multiple different scenes are represented in both subsets. 7 | % 8 | % David Stutz 9 | 10 | load list_train_subset.txt 11 | 12 | baseDir = './NYUDepthV2/cropped-original/data'; 13 | 14 | imageSubDir = sprintf('%s/images/train_subset', baseDir); 15 | if ~exist(imageSubDir) 16 | system(sprintf('mkdir %s', imageSubDir)); 17 | end; 18 | 19 | depthSubDir = sprintf('%s/depth/train_subset', baseDir); 20 | if ~exist(depthSubDir) 21 | system(sprintf('mkdir %s', depthSubDir)); 22 | end; 23 | 24 | groundTruthSubDir = sprintf('%s/groundTruth/train_subset', baseDir); 25 | if ~exist(groundTruthSubDir) 26 | system(sprintf('mkdir %s', groundTruthSubDir)); 27 | end; 28 | 29 | for i = 1: size(list_train_subset, 1) 30 | system(sprintf('cp %s/images/train/%08d.jpg %s/images/train_subset/%08d.jpg', baseDir, list_train_subset(i), baseDir, list_train_subset(i))); 31 | system(sprintf('cp %s/groundTruth/train/%08d.mat %s/groundTruth/train_subset/%08d.mat', baseDir, list_train_subset(i), baseDir, list_train_subset(i))); 32 | system(sprintf('cp %s/depth/train/%08d.png %s/depth/train_subset/%08d.png', baseDir, list_train_subset(i), baseDir, list_train_subset(i))); 33 | end; 34 | 35 | end 36 | 37 | -------------------------------------------------------------------------------- /convert_dataset.m: -------------------------------------------------------------------------------- 1 | function [] = convert_dataset(dir, factor) 2 | % function [] = convert_dataset() 3 | % 4 | % Converts the NYU Depth V2 dataset to be BSDS500 conform. Therefore, the 5 | % images are halfed in size and split into a training and test set 6 | % according to list_train.txt and list_test.txt. 7 | % 8 | % The output directory can be adjusted by having a look at the functions 9 | % generate_half, generate_depth and 10 | % generate_groundtruth_medfilt. 11 | % 12 | % Original README.txt by Liefeng Bo: 13 | % Run the script convert_dataset.m to download the dataset, reduce the resolution 14 | % to half (320x240), clean up some "double contours" in the groundtruth, and save 15 | % them in the Berkeley Segmentation Benchmark (BSDS) format. Once in BSDS format, 16 | % it is easy to modify the Berkeley gPb benchmarking code to point to the new 17 | % dataset locations. The data is split into 60% training and 40% test, randomly. 18 | % 19 | % "Double contours" refer to minor artifacts in the NYU groundtruth where the 20 | % labels are given as semantic regions, not scene segmentations. Thus 21 | % occassionally a thin strip of unlabeled pixels exist between two regions that 22 | % should be adjacent, and it is a problem for a boundary/segmentation evaluation. 23 | % We have a simple median filtering step to remedy the issue. 24 | % 25 | % seg2bdry.m is from the Berkeley gPb software. 26 | % mediannan_int.m is modified from the code shown at http://www.mathworks.com/matlabcentral/newsreader/view_thread/251787. 27 | % 28 | % INPUT: 29 | % dir: output directory 30 | % 31 | % factor: factor for resampling (for example 0.5 for half the 32 | % image size) 33 | % 34 | % Original by Liefeng Bo 35 | % Adapted by David Stutz 36 | 37 | if nargin < 1 38 | dir ='./NYUDepthV2/data' 39 | end; 40 | 41 | % Defines the factor of which the width and height of the image is 42 | % reduced. 43 | if nargin < 2 44 | factor = 1.; 45 | end; 46 | 47 | generateImages = 1; 48 | generateDepth = 1; 49 | generateGroundTruth = 1; 50 | 51 | load list_train.txt 52 | load list_test.txt 53 | 54 | if generateImages 55 | load ./NYUDepthV2/nyu_depth_v2_labeled.mat images 56 | fprintf('Generating color images ...\n'); 57 | generate_images(images, list_train, [dir '/images/train'], factor); 58 | generate_images(images, list_test, [dir '/images/test'], factor); 59 | clear images 60 | end; 61 | 62 | if generateDepth 63 | load ./NYUDepthV2/nyu_depth_v2_labeled.mat depths 64 | fprintf('Generating depth images ...\n'); 65 | generate_depth(depths, list_train, [dir '/depth/train'], factor); 66 | generate_depth(depths, list_test, [dir '/depth/test'], factor); 67 | clear depths 68 | end; 69 | 70 | if generateGroundTruth 71 | % generate cleaned-up groundtruth in BSDS format 72 | fprintf('Generating ground truth ...\n'); 73 | load ./NYUDepthV2/nyu_depth_v2_labeled.mat images labels instances 74 | mask_border = find_border_region(images); 75 | generate_groundtruth_medfilt(labels, instances, mask_border, list_train, [dir '/groundTruth/train'], factor); 76 | generate_groundtruth_medfilt(labels, instances, mask_border, list_test, [dir '/groundTruth/test'], factor); 77 | clear labels 78 | clear instances 79 | end; 80 | 81 | fprintf('Done.\n'); 82 | end 83 | 84 | function mask_border = find_border_region(images) 85 | 86 | [im_h, im_w, ~, nframe] = size(images); 87 | 88 | mask_border = ones(im_h,im_w); 89 | for ii = 1: nframe 90 | im = rgb2gray(images(:,:,:,ii)); 91 | mask_border = (mask_border & (im >= 253)); 92 | end; 93 | end 94 | 95 | function generate_images(images, list, outdir, factor) 96 | % function generate_half(images, list, outdir, factor) 97 | % 98 | % This function is used to resize the images of NYU. The factor defines the 99 | % resizing factor. 100 | 101 | if ~exist(outdir) 102 | system(['mkdir -p ' outdir]); 103 | end; 104 | 105 | for ii = list', 106 | id = num2str(ii, '%08d'); 107 | img = images(:, :, :, ii); 108 | 109 | img = imresize(img, factor); 110 | imwrite(img, [outdir '/' id '.jpg'], 'Quality', 98); 111 | end; 112 | end 113 | 114 | function generate_raw_depth(rawDepths, list, outdir, factor) 115 | % function generate_raw_depth(rawDepths, list, outdir, factor) 116 | % 117 | % Similar to generate_depth(depths, list, outdir, factor), this function 118 | % generates the raw depth images in the given list and directory. 119 | % The images are resampled using the given factor and every pixel where 120 | % no depth information is given is indicated by a zero. 121 | % 122 | % David Stutz 123 | 124 | step = 1./factor; 125 | 126 | if ~exist(outdir) 127 | system(['mkdir -p ' outdir]); 128 | end; 129 | 130 | if step > 1 131 | fprintf('Filling holes after subsampling the image with step %d ...\n', step); 132 | end; 133 | 134 | for ii = list', 135 | id = num2str(ii, '%08d'); 136 | rawDepth = rawDepths(:, :, ii); 137 | depth = rawDepth(step:step:end, step:step:end); 138 | 139 | % fill small holes in depth after subsampling. 140 | if step > 1 141 | for i = 1: step: size(depth, 1) 142 | for j = 1: step: size(depth, 2) 143 | if depth(i, j) == 0 144 | if i > 1 && depth(i - 1, j) ~= 0 145 | depth(i, j) = depth(i - 1, j); 146 | end; 147 | if j > 1 && depth(i, j - 1) ~= 0 148 | depth(i, j) = depth(i, j - 1); 149 | end; 150 | if i < size(depth, 1) && depth(i + 1, j) ~= 0 151 | depth(i, j) = depth(i + 1, j); 152 | end; 153 | if j < size(depth, 2) && depth(i, j + 1) ~= 0 154 | depth(i, j) = depth(i, j + 1); 155 | end; 156 | end; 157 | end; 158 | end; 159 | end; 160 | 161 | imwrite(uint16(depth*1000), [outdir '/' id '.png']); 162 | end; 163 | 164 | end 165 | 166 | function generate_depth(depths, list, outdir, factor) 167 | % function generate_depth(depths, list, outdir, factor) 168 | % 169 | % Subsamples the depth images by the defined step size. 170 | 171 | step = 1./factor; 172 | 173 | if ~exist(outdir) 174 | system(['mkdir -p ' outdir]); 175 | end; 176 | 177 | for ii = list', 178 | id = num2str(ii, '%08d'); 179 | depth = depths(:, :, ii); 180 | depth = depth(step:step:end, step:step:end); 181 | imwrite(uint16(depth*1000), [outdir '/' id '.png']); 182 | end; 183 | end 184 | 185 | function generate_groundtruth_medfilt(labels, instances, mask_border, list, outdir, factor) 186 | % function generate_groundtruth_medfilt(labels, instances, mask_border, list, outdir, factor) 187 | % 188 | % This function is used to find and fill regions of the depth images that 189 | % require filling. 190 | % 191 | % The factor defines the resizing factor for the images. 192 | 193 | if ~exist(outdir) 194 | system(['mkdir -p ' outdir]); 195 | end; 196 | 197 | maxlabel = 1000; 198 | assert(max(labels(:)) <= maxlabel); 199 | 200 | for ii=list' 201 | id = num2str(ii, '%08d'); 202 | 203 | % find out the region that needs to be filled, use dilate/erode 204 | margin = 5; 205 | foreground = (labels(:, :, ii) > 0); 206 | foreground = imerode(imdilate(foreground, strel('disk', margin)), strel('disk', margin)); 207 | cc = bwconncomp(~foreground); 208 | A = regionprops(cc, 'Area'); 209 | min_background_area = 500; 210 | indA = find([A.Area] < min_background_area); 211 | 212 | for k = indA 213 | foreground(cc.PixelIdxList{k}) = 1; 214 | end; 215 | 216 | % now do repeated median filter to fill in foreground 217 | seg = double(instances(:, :, ii))*maxlabel + double(labels(:, :, ii)); 218 | seg0 = seg; 219 | seg(seg == 0) = nan; 220 | 221 | for iter = 1: 100 222 | seg2 = mediannan_int(seg, 5); 223 | ind = find(isnan(seg) & ~isnan(seg2) & foreground); 224 | 225 | if isempty(ind) 226 | break; 227 | end; 228 | 229 | seg(ind) = seg2(ind); 230 | end; 231 | seg(isnan(seg)) = 0; 232 | 233 | % groundTruth{1}.Segmentation=uint16(seg .* (1-mask_border)); % objects start with 1; 0 is background 234 | % groundTruth{1}.Boundaries=logical(seg2bdry(seg,'imageSize')) & ~imdilate(mask_border,strel('disk',5)); 235 | % save([outdir '/' id '.mat'],'groundTruth'); 236 | 237 | step = 1./factor; 238 | 239 | groundTruth{1}.Segmentation = uint16(seg(step:step:end, step:step:end).*(1 - mask_border(step:step:end, step:step:end))); 240 | groundTruth{1}.Boundaries = logical(seg2bdry(seg(step:step:end, step:step:end), 'imageSize')) & ~imdilate(mask_border(step:step:end, step:step:end), strel('disk', 2)); 241 | 242 | save([outdir '/' id '.mat'], 'groundTruth'); 243 | end; 244 | end 245 | -------------------------------------------------------------------------------- /crop_dataset.m: -------------------------------------------------------------------------------- 1 | function [] = crop_dataset() 2 | % function [] = crop_dataset() 3 | % 4 | % Due to the Kinect, there is a small border around the image which is 5 | % white and not important for the labelling. For using superpixel 6 | % algorithms, this area should be removed. 7 | % 8 | % This function removes this border for all images of the dataset which has 9 | % been converted using convert_dataset.m. 10 | % 11 | % Therefore it first determines the maximum white region at each border and 12 | % prints them (maxLeft, maxRight, maxTop, maxBottom). The maximum of these 13 | % values is the number of pixels to be cut off at each border. 14 | % 15 | % Currently the number of pixels cropped at each border is 16px! See below 16 | % to change this! 17 | % 18 | % Note that in the adapted version of convert_dataset.m the background 19 | % label is one. 20 | % 21 | % David Stutz 22 | 23 | directories = {'train'; 'test'}; 24 | 25 | % The directories to use for cropping the dataset. 26 | % Remember to relabel the ground truth segmentations first if semantic 27 | % segmentation is not needed. 28 | imgBaseDir = './NYUDepthV2/original/data/images/'; 29 | depthBaseDir = './NYUDepthV2/original/data/depth/'; 30 | gtBaseDir = './NYUDepthV2/original/data/groundTruth/'; 31 | 32 | % The output directories, use different directories to not overwrite 33 | % the original dataset. 34 | imgOutBaseDir = './NYUDepthV2/cropped-original/data/images/'; 35 | depthOutBaseDir = './NYUDepthV2/cropped-original/data/depth/'; 36 | gtOutBaseDir = './NYUDepthV2/cropped-original/data/groundTruth/'; 37 | 38 | maxLeft = 0; 39 | maxRight = 0; 40 | maxTop = 0; 41 | maxBottom = 0; 42 | 43 | for d = 1: size(directories, 1) 44 | inDir = [imgBaseDir directories{d}]; 45 | segDir = [gtBaseDir directories{d}]; 46 | 47 | images = dir(sprintf('%s/*.jpg', inDir)); 48 | for i = 1: numel(images) 49 | 50 | image = imread(sprintf('%s/%s', inDir, images(i).name)); 51 | groundTruth = load(sprintf('%s/%s.mat', segDir, images(i).name(1:end - 4))); 52 | seg = groundTruth.groundTruth{1,1}.Segmentation; 53 | 54 | % determine the number of white pixels at the left and right border 55 | for k = 10: size(image, 1) - 10 56 | 57 | % left border 58 | l = 1; 59 | count = 0; 60 | while l <= size(image, 2) && image(k, l, 1) == 255 && image(k, l, 2) == 255 && image(k, l, 3) == 255 && seg(k, l) == 1 61 | l = l + 1; 62 | count = count + 1; 63 | end; 64 | 65 | if count > maxLeft 66 | maxLeft = count; 67 | end; 68 | 69 | % right border 70 | l = size(image, 2); 71 | count = 0; 72 | while l > 0 && image(k, l, 1) == 255 && image(k, l, 2) == 255 && image(k, l, 3) == 255 && seg(k, l) == 1 73 | l = l - 1; 74 | count = count + 1; 75 | end; 76 | 77 | if count > maxRight 78 | maxRight = count; 79 | end; 80 | end; 81 | 82 | % determine the number of white pixels at top and bottom border 83 | for l = 10: size(image, 2) - 10 84 | k = 1; 85 | count = 0; 86 | while k <= size(image, 1) && image(k, l, 1) == 255 && image(k, l, 2) == 255 && image(k, l, 3) == 255 && seg(k, l) == 1 87 | k = k + 1; 88 | count = count + 1; 89 | end; 90 | 91 | if count > maxTop 92 | maxTop = count; 93 | end; 94 | 95 | % right border 96 | k = size(image, 1); 97 | count = 0; 98 | while k > 0 && image(k, l, 1) == 255 && image(k, l, 2) == 255 && image(k, l, 3) == 255 && seg(k, l) == 1 99 | k = k - 1; 100 | count = count + 1; 101 | end; 102 | 103 | if count > maxBottom 104 | maxBottom = count; 105 | end; 106 | end; 107 | end; 108 | end; 109 | 110 | cutOff = maxTop; 111 | if maxBottom > cutOff 112 | cutOff = maxBottom; 113 | end; 114 | if maxLeft > cutOff 115 | cutOff = maxLeft; 116 | end; 117 | if maxRight > cutOff 118 | cutOff = maxRight; 119 | end; 120 | 121 | cutOff = 16; 122 | 123 | fprintf('%d pixels will be cut off at each border!\n', cutOff); 124 | 125 | for d = 1: size(directories, 1) 126 | inDir = [imgBaseDir directories{d}]; 127 | depthDir = [depthBaseDir directories{d}]; 128 | segDir = [gtBaseDir directories{d}]; 129 | 130 | outDir = [imgOutBaseDir directories{d}]; 131 | outDepthDir = [depthOutBaseDir directories{d}]; 132 | outSegDir = [gtOutBaseDir directories{d}]; 133 | 134 | if ~exist(outDir) 135 | system(['mkdir -p ' outDir]); 136 | end; 137 | 138 | if ~exist(outDepthDir) 139 | system(['mkdir -p ' outDepthDir]); 140 | end; 141 | 142 | if ~exist(outSegDir) 143 | system(['mkdir -p ' outSegDir]); 144 | end; 145 | 146 | images = dir(sprintf('%s/*.jpg', inDir)); 147 | for i = 1: numel(images) 148 | 149 | % crop image 150 | imagePath = sprintf('%s/%s', inDir, images(i).name); 151 | image = imread(imagePath); 152 | 153 | height = size(image, 1); 154 | width = size(image, 2); 155 | 156 | newImage = image(cutOff + 1:height - cutOff, cutOff + 1:width - cutOff, :); 157 | imwrite(newImage, sprintf('%s/%s.jpg', outDir, images(i).name(1:end - 4))); 158 | 159 | % crop depth image 160 | depthPath = sprintf('%s/%s.png', depthDir, images(i).name(1:end - 4)); 161 | depthImage = imread(depthPath); 162 | newDepthImage = depthImage(cutOff + 1:height - cutOff, cutOff + 1:width - cutOff, :); 163 | imwrite(newDepthImage, sprintf('%s/%s.png', outDepthDir, images(i).name(1:end - 4))); 164 | 165 | % crop ground truth segmentation 166 | gtPath = sprintf('%s/%s.mat', segDir, images(i).name(1:end - 4)); 167 | oldGroundTruth = load(gtPath); 168 | seg = oldGroundTruth.groundTruth{1,1}.Segmentation; 169 | bdry = oldGroundTruth.groundTruth{1,1}.Boundaries; 170 | 171 | newSeg = seg(cutOff + 1:height - cutOff, cutOff + 1:width - cutOff); 172 | newBdry = bdry(cutOff + 1:height - cutOff, cutOff + 1:width - cutOff); 173 | 174 | groundTruth = cell(1); 175 | groundTruth{1}.Segmentation = newSeg; 176 | groundTruth{1}.Boundaries = newBdry; 177 | 178 | save(sprintf('%s/%s.mat', outSegDir, images(i).name(1:end - 4)), 'groundTruth'); 179 | 180 | csvwrite(sprintf('%s/%s.csv', outStructureGTDir, images(i).name(1:end - 4)), newLabels); 181 | end; 182 | end; 183 | end -------------------------------------------------------------------------------- /list_test.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 4 4 | 5 5 | 9 6 | 10 7 | 12 8 | 13 9 | 15 10 | 18 11 | 19 12 | 20 13 | 21 14 | 23 15 | 24 16 | 25 17 | 26 18 | 27 19 | 29 20 | 31 21 | 36 22 | 37 23 | 39 24 | 43 25 | 44 26 | 48 27 | 49 28 | 50 29 | 52 30 | 53 31 | 57 32 | 61 33 | 64 34 | 65 35 | 66 36 | 71 37 | 73 38 | 75 39 | 79 40 | 82 41 | 85 42 | 87 43 | 88 44 | 94 45 | 95 46 | 102 47 | 108 48 | 109 49 | 110 50 | 114 51 | 116 52 | 118 53 | 122 54 | 124 55 | 125 56 | 126 57 | 130 58 | 132 59 | 137 60 | 141 61 | 142 62 | 153 63 | 154 64 | 158 65 | 161 66 | 167 67 | 168 68 | 173 69 | 177 70 | 178 71 | 179 72 | 183 73 | 185 74 | 188 75 | 189 76 | 191 77 | 192 78 | 199 79 | 200 80 | 201 81 | 203 82 | 206 83 | 207 84 | 209 85 | 215 86 | 222 87 | 225 88 | 226 89 | 234 90 | 243 91 | 245 92 | 246 93 | 251 94 | 256 95 | 257 96 | 260 97 | 262 98 | 263 99 | 264 100 | 268 101 | 270 102 | 272 103 | 274 104 | 275 105 | 276 106 | 277 107 | 279 108 | 282 109 | 285 110 | 286 111 | 287 112 | 288 113 | 289 114 | 293 115 | 297 116 | 298 117 | 302 118 | 307 119 | 308 120 | 309 121 | 311 122 | 313 123 | 314 124 | 315 125 | 318 126 | 323 127 | 324 128 | 329 129 | 330 130 | 334 131 | 341 132 | 342 133 | 344 134 | 348 135 | 350 136 | 352 137 | 353 138 | 355 139 | 356 140 | 359 141 | 363 142 | 364 143 | 368 144 | 370 145 | 371 146 | 383 147 | 385 148 | 386 149 | 387 150 | 391 151 | 392 152 | 393 153 | 405 154 | 406 155 | 407 156 | 412 157 | 414 158 | 415 159 | 416 160 | 420 161 | 421 162 | 430 163 | 432 164 | 433 165 | 434 166 | 436 167 | 438 168 | 439 169 | 443 170 | 444 171 | 446 172 | 447 173 | 451 174 | 456 175 | 458 176 | 462 177 | 466 178 | 468 179 | 470 180 | 472 181 | 477 182 | 480 183 | 481 184 | 482 185 | 483 186 | 484 187 | 486 188 | 489 189 | 492 190 | 493 191 | 495 192 | 497 193 | 498 194 | 500 195 | 503 196 | 507 197 | 508 198 | 510 199 | 512 200 | 514 201 | 516 202 | 524 203 | 525 204 | 526 205 | 527 206 | 528 207 | 531 208 | 535 209 | 538 210 | 539 211 | 546 212 | 549 213 | 551 214 | 553 215 | 554 216 | 561 217 | 563 218 | 565 219 | 567 220 | 568 221 | 571 222 | 572 223 | 574 224 | 576 225 | 577 226 | 579 227 | 580 228 | 582 229 | 587 230 | 588 231 | 589 232 | 595 233 | 601 234 | 603 235 | 604 236 | 606 237 | 607 238 | 608 239 | 610 240 | 611 241 | 612 242 | 615 243 | 618 244 | 620 245 | 621 246 | 624 247 | 626 248 | 627 249 | 628 250 | 629 251 | 630 252 | 631 253 | 633 254 | 637 255 | 639 256 | 642 257 | 644 258 | 654 259 | 657 260 | 663 261 | 664 262 | 668 263 | 671 264 | 676 265 | 679 266 | 680 267 | 681 268 | 683 269 | 684 270 | 685 271 | 686 272 | 687 273 | 693 274 | 698 275 | 700 276 | 702 277 | 707 278 | 709 279 | 711 280 | 713 281 | 714 282 | 718 283 | 719 284 | 728 285 | 729 286 | 731 287 | 733 288 | 734 289 | 741 290 | 747 291 | 753 292 | 760 293 | 761 294 | 764 295 | 765 296 | 768 297 | 771 298 | 774 299 | 777 300 | 778 301 | 779 302 | 781 303 | 785 304 | 787 305 | 788 306 | 793 307 | 794 308 | 795 309 | 799 310 | 800 311 | 801 312 | 803 313 | 806 314 | 808 315 | 809 316 | 811 317 | 813 318 | 814 319 | 815 320 | 819 321 | 821 322 | 825 323 | 830 324 | 833 325 | 842 326 | 844 327 | 845 328 | 847 329 | 848 330 | 850 331 | 852 332 | 855 333 | 857 334 | 861 335 | 864 336 | 867 337 | 868 338 | 874 339 | 875 340 | 878 341 | 889 342 | 890 343 | 895 344 | 896 345 | 900 346 | 901 347 | 906 348 | 908 349 | 910 350 | 914 351 | 915 352 | 917 353 | 920 354 | 928 355 | 935 356 | 936 357 | 937 358 | 940 359 | 941 360 | 942 361 | 943 362 | 945 363 | 949 364 | 952 365 | 953 366 | 955 367 | 957 368 | 959 369 | 961 370 | 962 371 | 972 372 | 973 373 | 974 374 | 976 375 | 977 376 | 981 377 | 984 378 | 985 379 | 986 380 | 987 381 | 990 382 | 992 383 | 993 384 | 994 385 | 996 386 | 997 387 | 1000 388 | 1001 389 | 1003 390 | 1005 391 | 1006 392 | 1012 393 | 1014 394 | 1015 395 | 1018 396 | 1020 397 | 1024 398 | 1027 399 | 1029 400 | 1031 401 | 1033 402 | 1034 403 | 1035 404 | 1036 405 | 1038 406 | 1045 407 | 1046 408 | 1050 409 | 1051 410 | 1053 411 | 1055 412 | 1056 413 | 1058 414 | 1059 415 | 1060 416 | 1066 417 | 1067 418 | 1070 419 | 1071 420 | 1072 421 | 1073 422 | 1074 423 | 1076 424 | 1079 425 | 1083 426 | 1089 427 | 1090 428 | 1092 429 | 1094 430 | 1100 431 | 1101 432 | 1102 433 | 1104 434 | 1105 435 | 1106 436 | 1109 437 | 1110 438 | 1113 439 | 1115 440 | 1118 441 | 1119 442 | 1120 443 | 1126 444 | 1130 445 | 1136 446 | 1137 447 | 1143 448 | 1144 449 | 1146 450 | 1149 451 | 1150 452 | 1151 453 | 1152 454 | 1154 455 | 1156 456 | 1157 457 | 1158 458 | 1160 459 | 1161 460 | 1164 461 | 1167 462 | 1169 463 | 1172 464 | 1173 465 | 1175 466 | 1176 467 | 1177 468 | 1180 469 | 1183 470 | 1184 471 | 1186 472 | 1191 473 | 1192 474 | 1194 475 | 1196 476 | 1200 477 | 1203 478 | 1206 479 | 1208 480 | 1210 481 | 1212 482 | 1214 483 | 1215 484 | 1218 485 | 1219 486 | 1229 487 | 1231 488 | 1235 489 | 1236 490 | 1238 491 | 1239 492 | 1244 493 | 1245 494 | 1246 495 | 1249 496 | 1250 497 | 1253 498 | 1254 499 | 1255 500 | 1260 501 | 1262 502 | 1267 503 | 1268 504 | 1269 505 | 1274 506 | 1275 507 | 1277 508 | 1278 509 | 1280 510 | 1281 511 | 1283 512 | 1287 513 | 1290 514 | 1291 515 | 1292 516 | 1295 517 | 1296 518 | 1297 519 | 1299 520 | 1302 521 | 1303 522 | 1304 523 | 1306 524 | 1308 525 | 1309 526 | 1310 527 | 1314 528 | 1315 529 | 1316 530 | 1320 531 | 1323 532 | 1324 533 | 1325 534 | 1327 535 | 1328 536 | 1332 537 | 1334 538 | 1335 539 | 1338 540 | 1339 541 | 1340 542 | 1344 543 | 1345 544 | 1346 545 | 1348 546 | 1352 547 | 1362 548 | 1363 549 | 1364 550 | 1366 551 | 1377 552 | 1378 553 | 1379 554 | 1381 555 | 1388 556 | 1391 557 | 1393 558 | 1394 559 | 1395 560 | 1396 561 | 1399 562 | 1402 563 | 1403 564 | 1408 565 | 1409 566 | 1410 567 | 1411 568 | 1417 569 | 1419 570 | 1420 571 | 1424 572 | 1425 573 | 1427 574 | 1428 575 | 1429 576 | 1430 577 | 1437 578 | 1439 579 | 1441 580 | 1446 -------------------------------------------------------------------------------- /list_test_subset.txt: -------------------------------------------------------------------------------- 1 | 00000002 2 | 00000004 3 | 00000009 4 | 00000010 5 | 00000023 6 | 00000024 7 | 00000025 8 | 00000029 9 | 00000036 10 | 00000039 11 | 00000043 12 | 00000044 13 | 00000048 14 | 00000049 15 | 00000050 16 | 00000057 17 | 00000061 18 | 00000064 19 | 00000066 20 | 00000073 21 | 00000075 22 | 00000079 23 | 00000082 24 | 00000087 25 | 00000094 26 | 00000095 27 | 00000102 28 | 00000108 29 | 00000109 30 | 00000110 31 | 00000116 32 | 00000118 33 | 00000124 34 | 00000125 35 | 00000126 36 | 00000130 37 | 00000137 38 | 00000141 39 | 00000142 40 | 00000153 41 | 00000158 42 | 00000167 43 | 00000173 44 | 00000177 45 | 00000178 46 | 00000179 47 | 00000189 48 | 00000191 49 | 00000192 50 | 00000225 51 | 00000226 52 | 00000243 53 | 00000245 54 | 00000257 55 | 00000260 56 | 00000262 57 | 00000268 58 | 00000270 59 | 00000272 60 | 00000275 61 | 00000276 62 | 00000277 63 | 00000279 64 | 00000285 65 | 00000287 66 | 00000288 67 | 00000289 68 | 00000293 69 | 00000297 70 | 00000302 71 | 00000308 72 | 00000309 73 | 00000311 74 | 00000313 75 | 00000314 76 | 00000318 77 | 00000323 78 | 00000329 79 | 00000330 80 | 00000334 81 | 00000342 82 | 00000344 83 | 00000348 84 | 00000352 85 | 00000353 86 | 00000355 87 | 00000356 88 | 00000359 89 | 00000363 90 | 00000368 91 | 00000370 92 | 00000371 93 | 00000383 94 | 00000385 95 | 00000386 96 | 00000387 97 | 00000391 98 | 00000392 99 | 00000393 100 | 00000406 101 | 00000416 102 | 00000420 103 | 00000430 104 | 00000436 105 | 00000438 106 | 00000443 107 | 00000444 108 | 00000446 109 | 00000447 110 | 00000451 111 | 00000458 112 | 00000462 113 | 00000468 114 | 00000470 115 | 00000472 116 | 00000477 117 | 00000480 118 | 00000482 119 | 00000484 120 | 00000486 121 | 00000492 122 | 00000493 123 | 00000495 124 | 00000497 125 | 00000498 126 | 00000500 127 | 00000503 128 | 00000507 129 | 00000508 130 | 00000510 131 | 00000514 132 | 00000516 133 | 00000524 134 | 00000525 135 | 00000528 136 | 00000531 137 | 00000535 138 | 00000538 139 | 00000539 140 | 00000546 141 | 00000549 142 | 00000551 143 | 00000553 144 | 00000561 145 | 00000563 146 | 00000568 147 | 00000572 148 | 00000576 149 | 00000577 150 | 00000580 151 | 00000587 152 | 00000588 153 | 00000589 154 | 00000595 155 | 00000606 156 | 00000607 157 | 00000608 158 | 00000611 159 | 00000612 160 | 00000615 161 | 00000620 162 | 00000621 163 | 00000624 164 | 00000627 165 | 00000628 166 | 00000629 167 | 00000630 168 | 00000631 169 | 00000637 170 | 00000639 171 | 00000642 172 | 00000644 173 | 00000654 174 | 00000668 175 | 00000671 176 | 00000676 177 | 00000683 178 | 00000685 179 | 00000686 180 | 00000687 181 | 00000693 182 | 00000698 183 | 00000700 184 | 00000702 185 | 00000709 186 | 00000713 187 | 00000714 188 | 00000718 189 | 00000729 190 | 00000731 191 | 00000733 192 | 00000734 193 | 00000747 194 | 00000753 195 | 00000760 196 | 00000761 197 | 00000765 198 | 00000774 199 | 00000777 200 | 00000778 201 | 00000779 202 | 00000781 203 | 00000785 204 | 00000787 205 | 00000788 206 | 00000799 207 | 00000800 208 | 00000801 209 | 00000803 210 | 00000806 211 | 00000808 212 | 00000811 213 | 00000813 214 | 00000819 215 | 00000821 216 | 00000825 217 | 00000830 218 | 00000842 219 | 00000844 220 | 00000850 221 | 00000852 222 | 00000855 223 | 00000857 224 | 00000867 225 | 00000868 226 | 00000878 227 | 00000889 228 | 00000890 229 | 00000895 230 | 00000896 231 | 00000900 232 | 00000901 233 | 00000908 234 | 00000914 235 | 00000917 236 | 00000920 237 | 00000928 238 | 00000935 239 | 00000937 240 | 00000940 241 | 00000941 242 | 00000942 243 | 00000952 244 | 00000953 245 | 00000955 246 | 00000957 247 | 00000959 248 | 00000961 249 | 00000962 250 | 00000972 251 | 00000973 252 | 00000974 253 | 00000977 254 | 00000981 255 | 00000985 256 | 00000986 257 | 00000987 258 | 00000990 259 | 00000992 260 | 00000993 261 | 00000997 262 | 00001000 263 | 00001001 264 | 00001003 265 | 00001005 266 | 00001006 267 | 00001012 268 | 00001014 269 | 00001018 270 | 00001029 271 | 00001033 272 | 00001034 273 | 00001046 274 | 00001050 275 | 00001051 276 | 00001053 277 | 00001055 278 | 00001056 279 | 00001058 280 | 00001059 281 | 00001060 282 | 00001066 283 | 00001067 284 | 00001070 285 | 00001071 286 | 00001072 287 | 00001073 288 | 00001074 289 | 00001076 290 | 00001089 291 | 00001090 292 | 00001100 293 | 00001101 294 | 00001102 295 | 00001104 296 | 00001109 297 | 00001113 298 | 00001115 299 | 00001119 300 | 00001120 301 | 00001126 302 | 00001130 303 | 00001136 304 | 00001137 305 | 00001143 306 | 00001144 307 | 00001149 308 | 00001150 309 | 00001151 310 | 00001152 311 | 00001154 312 | 00001160 313 | 00001161 314 | 00001164 315 | 00001169 316 | 00001175 317 | 00001176 318 | 00001177 319 | 00001180 320 | 00001184 321 | 00001186 322 | 00001194 323 | 00001200 324 | 00001206 325 | 00001208 326 | 00001212 327 | 00001214 328 | 00001218 329 | 00001229 330 | 00001235 331 | 00001238 332 | 00001245 333 | 00001246 334 | 00001249 335 | 00001250 336 | 00001253 337 | 00001254 338 | 00001255 339 | 00001260 340 | 00001262 341 | 00001267 342 | 00001268 343 | 00001269 344 | 00001274 345 | 00001275 346 | 00001278 347 | 00001280 348 | 00001283 349 | 00001287 350 | 00001291 351 | 00001295 352 | 00001296 353 | 00001297 354 | 00001299 355 | 00001302 356 | 00001303 357 | 00001304 358 | 00001306 359 | 00001308 360 | 00001309 361 | 00001310 362 | 00001314 363 | 00001315 364 | 00001316 365 | 00001324 366 | 00001325 367 | 00001327 368 | 00001328 369 | 00001332 370 | 00001335 371 | 00001339 372 | 00001340 373 | 00001345 374 | 00001346 375 | 00001352 376 | 00001363 377 | 00001364 378 | 00001366 379 | 00001378 380 | 00001379 381 | 00001381 382 | 00001388 383 | 00001393 384 | 00001395 385 | 00001396 386 | 00001399 387 | 00001402 388 | 00001409 389 | 00001410 390 | 00001411 391 | 00001417 392 | 00001424 393 | 00001425 394 | 00001427 395 | 00001428 396 | 00001429 397 | 00001430 398 | 00001437 399 | 00001441 400 | 00001446 401 | -------------------------------------------------------------------------------- /list_train.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 6 3 | 7 4 | 8 5 | 11 6 | 14 7 | 16 8 | 17 9 | 22 10 | 28 11 | 30 12 | 32 13 | 33 14 | 34 15 | 35 16 | 38 17 | 40 18 | 41 19 | 42 20 | 45 21 | 46 22 | 47 23 | 51 24 | 54 25 | 55 26 | 56 27 | 58 28 | 59 29 | 60 30 | 62 31 | 63 32 | 67 33 | 68 34 | 69 35 | 70 36 | 72 37 | 74 38 | 76 39 | 77 40 | 78 41 | 80 42 | 81 43 | 83 44 | 84 45 | 86 46 | 89 47 | 90 48 | 91 49 | 92 50 | 93 51 | 96 52 | 97 53 | 98 54 | 99 55 | 100 56 | 101 57 | 103 58 | 104 59 | 105 60 | 106 61 | 107 62 | 111 63 | 112 64 | 113 65 | 115 66 | 117 67 | 119 68 | 120 69 | 121 70 | 123 71 | 127 72 | 128 73 | 129 74 | 131 75 | 133 76 | 134 77 | 135 78 | 136 79 | 138 80 | 139 81 | 140 82 | 143 83 | 144 84 | 145 85 | 146 86 | 147 87 | 148 88 | 149 89 | 150 90 | 151 91 | 152 92 | 155 93 | 156 94 | 157 95 | 159 96 | 160 97 | 162 98 | 163 99 | 164 100 | 165 101 | 166 102 | 169 103 | 170 104 | 171 105 | 172 106 | 174 107 | 175 108 | 176 109 | 180 110 | 181 111 | 182 112 | 184 113 | 186 114 | 187 115 | 190 116 | 193 117 | 194 118 | 195 119 | 196 120 | 197 121 | 198 122 | 202 123 | 204 124 | 205 125 | 208 126 | 210 127 | 211 128 | 212 129 | 213 130 | 214 131 | 216 132 | 217 133 | 218 134 | 219 135 | 220 136 | 221 137 | 223 138 | 224 139 | 227 140 | 228 141 | 229 142 | 230 143 | 231 144 | 232 145 | 233 146 | 235 147 | 236 148 | 237 149 | 238 150 | 239 151 | 240 152 | 241 153 | 242 154 | 244 155 | 247 156 | 248 157 | 249 158 | 250 159 | 252 160 | 253 161 | 254 162 | 255 163 | 258 164 | 259 165 | 261 166 | 265 167 | 266 168 | 267 169 | 269 170 | 271 171 | 273 172 | 278 173 | 280 174 | 281 175 | 283 176 | 284 177 | 290 178 | 291 179 | 292 180 | 294 181 | 295 182 | 296 183 | 299 184 | 300 185 | 301 186 | 303 187 | 304 188 | 305 189 | 306 190 | 310 191 | 312 192 | 316 193 | 317 194 | 319 195 | 320 196 | 321 197 | 322 198 | 325 199 | 326 200 | 327 201 | 328 202 | 331 203 | 332 204 | 333 205 | 335 206 | 336 207 | 337 208 | 338 209 | 339 210 | 340 211 | 343 212 | 345 213 | 346 214 | 347 215 | 349 216 | 351 217 | 354 218 | 357 219 | 358 220 | 360 221 | 361 222 | 362 223 | 365 224 | 366 225 | 367 226 | 369 227 | 372 228 | 373 229 | 374 230 | 375 231 | 376 232 | 377 233 | 378 234 | 379 235 | 380 236 | 381 237 | 382 238 | 384 239 | 388 240 | 389 241 | 390 242 | 394 243 | 395 244 | 396 245 | 397 246 | 398 247 | 399 248 | 400 249 | 401 250 | 402 251 | 403 252 | 404 253 | 408 254 | 409 255 | 410 256 | 411 257 | 413 258 | 417 259 | 418 260 | 419 261 | 422 262 | 423 263 | 424 264 | 425 265 | 426 266 | 427 267 | 428 268 | 429 269 | 431 270 | 435 271 | 437 272 | 440 273 | 441 274 | 442 275 | 445 276 | 448 277 | 449 278 | 450 279 | 452 280 | 453 281 | 454 282 | 455 283 | 457 284 | 459 285 | 460 286 | 461 287 | 463 288 | 464 289 | 465 290 | 467 291 | 469 292 | 471 293 | 473 294 | 474 295 | 475 296 | 476 297 | 478 298 | 479 299 | 485 300 | 487 301 | 488 302 | 490 303 | 491 304 | 494 305 | 496 306 | 499 307 | 501 308 | 502 309 | 504 310 | 505 311 | 506 312 | 509 313 | 511 314 | 513 315 | 515 316 | 517 317 | 518 318 | 519 319 | 520 320 | 521 321 | 522 322 | 523 323 | 529 324 | 530 325 | 532 326 | 533 327 | 534 328 | 536 329 | 537 330 | 540 331 | 541 332 | 542 333 | 543 334 | 544 335 | 545 336 | 547 337 | 548 338 | 550 339 | 552 340 | 555 341 | 556 342 | 557 343 | 558 344 | 559 345 | 560 346 | 562 347 | 564 348 | 566 349 | 569 350 | 570 351 | 573 352 | 575 353 | 578 354 | 581 355 | 583 356 | 584 357 | 585 358 | 586 359 | 590 360 | 591 361 | 592 362 | 593 363 | 594 364 | 596 365 | 597 366 | 598 367 | 599 368 | 600 369 | 602 370 | 605 371 | 609 372 | 613 373 | 614 374 | 616 375 | 617 376 | 619 377 | 622 378 | 623 379 | 625 380 | 632 381 | 634 382 | 635 383 | 636 384 | 638 385 | 640 386 | 641 387 | 643 388 | 645 389 | 646 390 | 647 391 | 648 392 | 649 393 | 650 394 | 651 395 | 652 396 | 653 397 | 655 398 | 656 399 | 658 400 | 659 401 | 660 402 | 661 403 | 662 404 | 665 405 | 666 406 | 667 407 | 669 408 | 670 409 | 672 410 | 673 411 | 674 412 | 675 413 | 677 414 | 678 415 | 682 416 | 688 417 | 689 418 | 690 419 | 691 420 | 692 421 | 694 422 | 695 423 | 696 424 | 697 425 | 699 426 | 701 427 | 703 428 | 704 429 | 705 430 | 706 431 | 708 432 | 710 433 | 712 434 | 715 435 | 716 436 | 717 437 | 720 438 | 721 439 | 722 440 | 723 441 | 724 442 | 725 443 | 726 444 | 727 445 | 730 446 | 732 447 | 735 448 | 736 449 | 737 450 | 738 451 | 739 452 | 740 453 | 742 454 | 743 455 | 744 456 | 745 457 | 746 458 | 748 459 | 749 460 | 750 461 | 751 462 | 752 463 | 754 464 | 755 465 | 756 466 | 757 467 | 758 468 | 759 469 | 762 470 | 763 471 | 766 472 | 767 473 | 769 474 | 770 475 | 772 476 | 773 477 | 775 478 | 776 479 | 780 480 | 782 481 | 783 482 | 784 483 | 786 484 | 789 485 | 790 486 | 791 487 | 792 488 | 796 489 | 797 490 | 798 491 | 802 492 | 804 493 | 805 494 | 807 495 | 810 496 | 812 497 | 816 498 | 817 499 | 818 500 | 820 501 | 822 502 | 823 503 | 824 504 | 826 505 | 827 506 | 828 507 | 829 508 | 831 509 | 832 510 | 834 511 | 835 512 | 836 513 | 837 514 | 838 515 | 839 516 | 840 517 | 841 518 | 843 519 | 846 520 | 849 521 | 851 522 | 853 523 | 854 524 | 856 525 | 858 526 | 859 527 | 860 528 | 862 529 | 863 530 | 865 531 | 866 532 | 869 533 | 870 534 | 871 535 | 872 536 | 873 537 | 876 538 | 877 539 | 879 540 | 880 541 | 881 542 | 882 543 | 883 544 | 884 545 | 885 546 | 886 547 | 887 548 | 888 549 | 891 550 | 892 551 | 893 552 | 894 553 | 897 554 | 898 555 | 899 556 | 902 557 | 903 558 | 904 559 | 905 560 | 907 561 | 909 562 | 911 563 | 912 564 | 913 565 | 916 566 | 918 567 | 919 568 | 921 569 | 922 570 | 923 571 | 924 572 | 925 573 | 926 574 | 927 575 | 929 576 | 930 577 | 931 578 | 932 579 | 933 580 | 934 581 | 938 582 | 939 583 | 944 584 | 946 585 | 947 586 | 948 587 | 950 588 | 951 589 | 954 590 | 956 591 | 958 592 | 960 593 | 963 594 | 964 595 | 965 596 | 966 597 | 967 598 | 968 599 | 969 600 | 970 601 | 971 602 | 975 603 | 978 604 | 979 605 | 980 606 | 982 607 | 983 608 | 988 609 | 989 610 | 991 611 | 995 612 | 998 613 | 999 614 | 1002 615 | 1004 616 | 1007 617 | 1008 618 | 1009 619 | 1010 620 | 1011 621 | 1013 622 | 1016 623 | 1017 624 | 1019 625 | 1021 626 | 1022 627 | 1023 628 | 1025 629 | 1026 630 | 1028 631 | 1030 632 | 1032 633 | 1037 634 | 1039 635 | 1040 636 | 1041 637 | 1042 638 | 1043 639 | 1044 640 | 1047 641 | 1048 642 | 1049 643 | 1052 644 | 1054 645 | 1057 646 | 1061 647 | 1062 648 | 1063 649 | 1064 650 | 1065 651 | 1068 652 | 1069 653 | 1075 654 | 1077 655 | 1078 656 | 1080 657 | 1081 658 | 1082 659 | 1084 660 | 1085 661 | 1086 662 | 1087 663 | 1088 664 | 1091 665 | 1093 666 | 1095 667 | 1096 668 | 1097 669 | 1098 670 | 1099 671 | 1103 672 | 1107 673 | 1108 674 | 1111 675 | 1112 676 | 1114 677 | 1116 678 | 1117 679 | 1121 680 | 1122 681 | 1123 682 | 1124 683 | 1125 684 | 1127 685 | 1128 686 | 1129 687 | 1131 688 | 1132 689 | 1133 690 | 1134 691 | 1135 692 | 1138 693 | 1139 694 | 1140 695 | 1141 696 | 1142 697 | 1145 698 | 1147 699 | 1148 700 | 1153 701 | 1155 702 | 1159 703 | 1162 704 | 1163 705 | 1165 706 | 1166 707 | 1168 708 | 1170 709 | 1171 710 | 1174 711 | 1178 712 | 1179 713 | 1181 714 | 1182 715 | 1185 716 | 1187 717 | 1188 718 | 1189 719 | 1190 720 | 1193 721 | 1195 722 | 1197 723 | 1198 724 | 1199 725 | 1201 726 | 1202 727 | 1204 728 | 1205 729 | 1207 730 | 1209 731 | 1211 732 | 1213 733 | 1216 734 | 1217 735 | 1220 736 | 1221 737 | 1222 738 | 1223 739 | 1224 740 | 1225 741 | 1226 742 | 1227 743 | 1228 744 | 1230 745 | 1232 746 | 1233 747 | 1234 748 | 1237 749 | 1240 750 | 1241 751 | 1242 752 | 1243 753 | 1247 754 | 1248 755 | 1251 756 | 1252 757 | 1256 758 | 1257 759 | 1258 760 | 1259 761 | 1261 762 | 1263 763 | 1264 764 | 1265 765 | 1266 766 | 1270 767 | 1271 768 | 1272 769 | 1273 770 | 1276 771 | 1279 772 | 1282 773 | 1284 774 | 1285 775 | 1286 776 | 1288 777 | 1289 778 | 1293 779 | 1294 780 | 1298 781 | 1300 782 | 1301 783 | 1305 784 | 1307 785 | 1311 786 | 1312 787 | 1313 788 | 1317 789 | 1318 790 | 1319 791 | 1321 792 | 1322 793 | 1326 794 | 1329 795 | 1330 796 | 1331 797 | 1333 798 | 1336 799 | 1337 800 | 1341 801 | 1342 802 | 1343 803 | 1347 804 | 1349 805 | 1350 806 | 1351 807 | 1353 808 | 1354 809 | 1355 810 | 1356 811 | 1357 812 | 1358 813 | 1359 814 | 1360 815 | 1361 816 | 1365 817 | 1367 818 | 1368 819 | 1369 820 | 1370 821 | 1371 822 | 1372 823 | 1373 824 | 1374 825 | 1375 826 | 1376 827 | 1380 828 | 1382 829 | 1383 830 | 1384 831 | 1385 832 | 1386 833 | 1387 834 | 1389 835 | 1390 836 | 1392 837 | 1397 838 | 1398 839 | 1400 840 | 1401 841 | 1404 842 | 1405 843 | 1406 844 | 1407 845 | 1412 846 | 1413 847 | 1414 848 | 1415 849 | 1416 850 | 1418 851 | 1421 852 | 1422 853 | 1423 854 | 1426 855 | 1431 856 | 1432 857 | 1433 858 | 1434 859 | 1435 860 | 1436 861 | 1438 862 | 1440 863 | 1442 864 | 1443 865 | 1444 866 | 1445 867 | 1447 868 | 1448 869 | 1449 -------------------------------------------------------------------------------- /list_train_subset.txt: -------------------------------------------------------------------------------- 1 | 7 2 | 16 3 | 30 4 | 34 5 | 41 6 | 45 7 | 55 8 | 56 9 | 63 10 | 68 11 | 70 12 | 78 13 | 81 14 | 84 15 | 89 16 | 92 17 | 97 18 | 104 19 | 107 20 | 115 21 | 117 22 | 123 23 | 131 24 | 136 25 | 138 26 | 143 27 | 146 28 | 150 29 | 156 30 | 164 31 | 166 32 | 170 33 | 172 34 | 174 35 | 181 36 | 186 37 | 190 38 | 196 39 | 202 40 | 204 41 | 210 42 | 213 43 | 216 44 | 217 45 | 219 46 | 220 47 | 224 48 | 229 49 | 233 50 | 237 51 | 240 52 | 249 53 | 253 54 | 258 55 | 261 56 | 267 57 | 271 58 | 278 59 | 281 60 | 284 61 | 294 62 | 299 63 | 300 64 | 304 65 | 312 66 | 319 67 | 322 68 | 328 69 | 333 70 | 338 71 | 343 72 | 346 73 | 349 74 | 354 75 | 362 76 | 366 77 | 372 78 | 378 79 | 380 80 | 384 81 | 390 82 | 395 83 | 399 84 | 403 85 | 410 86 | 417 87 | 419 88 | 424 89 | 426 90 | 429 91 | 431 92 | 440 93 | 441 94 | 448 95 | 450 96 | 455 97 | 459 98 | 464 99 | 471 100 | 474 101 | 478 102 | 485 103 | 487 104 | 491 105 | 496 106 | 499 107 | 501 108 | 504 109 | 506 110 | 509 111 | 517 112 | 519 113 | 520 114 | 523 115 | 532 116 | 533 117 | 534 118 | 537 119 | 541 120 | 544 121 | 545 122 | 550 123 | 555 124 | 557 125 | 559 126 | 562 127 | 564 128 | 570 129 | 578 130 | 583 131 | 585 132 | 590 133 | 593 134 | 596 135 | 600 136 | 605 137 | 613 138 | 617 139 | 623 140 | 632 141 | 634 142 | 638 143 | 641 144 | 646 145 | 649 146 | 653 147 | 658 148 | 659 149 | 661 150 | 669 151 | 673 152 | 677 153 | 688 154 | 699 155 | 704 156 | 710 157 | 717 158 | 720 159 | 724 160 | 726 161 | 735 162 | 736 163 | 739 164 | 742 165 | 744 166 | 746 167 | 749 168 | 755 169 | 762 170 | 767 171 | 772 172 | 780 173 | 789 174 | 791 175 | 797 176 | 798 177 | 810 178 | 818 179 | 823 180 | 826 181 | 827 182 | 832 183 | 836 184 | 841 185 | 859 186 | 866 187 | 871 188 | 876 189 | 879 190 | 881 191 | 888 192 | 894 193 | 902 194 | 909 195 | 913 196 | 919 197 | 924 198 | 930 199 | 932 200 | 938 201 | -------------------------------------------------------------------------------- /mediannan_int.m: -------------------------------------------------------------------------------- 1 | function M = mediannan(A, sz) 2 | 3 | if nargin < 2 4 | sz = 5; 5 | end; 6 | 7 | if length(sz) == 1 8 | sz = [sz sz]; 9 | end; 10 | 11 | if any(mod(sz, 2) == 0) 12 | error('Kernel size SZ must be odd!') 13 | end; 14 | 15 | margin = (sz - 1)/2; 16 | AA = nan(size(A) + 2*margin); 17 | AA(1 + margin(1):end - margin(1),1 + margin(2):end - margin(2)) = A; 18 | [iB jB] = ndgrid(1:sz(1), 1:sz(2)); 19 | is = sub2ind(size(AA), iB, jB); 20 | [iA jA] = ndgrid(1:size(A,1), 1:size(A,2)); 21 | iA = sub2ind(size(AA), iA, jA); 22 | idx = bsxfun(@plus, iA(:).', is(:)-1); 23 | 24 | B = sort(AA(idx), 1); 25 | j = any(isnan(B), 1); 26 | last = zeros(1, size(B,2)) + size(B,1); 27 | [trash last(j)] = max(isnan(B(:,j)), [], 1); 28 | last(j) = last(j) - 1; 29 | 30 | M = nan(1, size(B, 2)); 31 | valid = find(last > 0); 32 | mid = (1 + last)/2; 33 | i1 = floor(mid(valid)); 34 | i2 = ceil(mid(valid)); 35 | i1 = sub2ind(size(B), i1, valid); 36 | i2 = sub2ind(size(B), i2, valid); 37 | %M(valid) = 0.5*(B(i1) + B(i2)); 38 | M(valid) = (B(i1)); 39 | M = reshape(M,size(A)); 40 | 41 | end 42 | 43 | -------------------------------------------------------------------------------- /relabel_dataset.m: -------------------------------------------------------------------------------- 1 | function [] = relabel_dataset() 2 | % function [] = relabel_dataset() 3 | % 4 | % Used to relabel the labels given by the NYU dataset. For evaluation, the 5 | % semantic segmentation is irrelevant, but to speed up evaluation it is 6 | % beneficial that the labels are bounded to the smallest possible range. 7 | % 8 | % David Stutz 9 | 10 | load list_train.txt 11 | load list_test.txt 12 | 13 | % Will take ground truth from inputBaseDir, relabel them and save them 14 | % to outputBaseDir. 15 | inputBaseDir = './NYUDepthV2/original/data/groundTruth'; 16 | outputBaseDir = './NYUDepthV2/relabeled/data/groundTruth'; 17 | 18 | types = {'train'; 'test'}; 19 | 20 | for t = 1: size(types, 1) 21 | if strcmp(types{t}, 'train') 22 | list = list_train; 23 | else 24 | list = list_test; 25 | end; 26 | 27 | inputDir = sprintf('%s/%s', inputBaseDir, types{t}); 28 | outputDir = sprintf('%s/%s', outputBaseDir, types{t}); 29 | 30 | if ~exist(outputDir) 31 | system(sprintf('mkdir -p %s', outputDir)); 32 | end; 33 | 34 | for l = 1: size(list) 35 | groundTruthFile = sprintf('%s/%08d.mat', inputDir, list(l)); 36 | 37 | load(groundTruthFile); 38 | 39 | groundTruth{1}.Segmentation = groundTruth{1}.Segmentation + 1; 40 | 41 | label = 2; 42 | labels = ones(max(max(groundTruth{1}.Segmentation)), 1)*(-1); 43 | labels(1) = 1; 44 | 45 | for i = 1: size(groundTruth{1}.Segmentation, 1) 46 | for j = 1: size(groundTruth{1}.Segmentation, 2) 47 | % check whether this is a new label 48 | if labels(groundTruth{1}.Segmentation(i, j)) == -1 49 | labels(groundTruth{1}.Segmentation(i, j)) = label; 50 | label = label + 1; 51 | end; 52 | 53 | % set new label 54 | groundTruth{1}.Segmentation(i, j) = labels(groundTruth{1}.Segmentation(i, j)); 55 | end; 56 | end; 57 | 58 | save(sprintf('%s/%08d.mat', outputDir, list(l)), 'groundTruth'); 59 | end; 60 | end; 61 | 62 | end 63 | 64 | -------------------------------------------------------------------------------- /seg2bdry.m: -------------------------------------------------------------------------------- 1 | function [bdry] = seg2bdry(seg, fmt) 2 | 3 | if nargin < 2 4 | fmt = 'doubleSize'; 5 | end; 6 | 7 | if ~strcmp(fmt,'imageSize') && ~strcmp(fmt,'doubleSize') 8 | error('possible values for fmt are: imageSize and doubleSize'); 9 | end; 10 | 11 | [tx, ty, nch] = size(seg); 12 | 13 | if nch ~= 1 14 | error('seg must be a scalar image'); 15 | end; 16 | 17 | bdry = zeros(2*tx+1, 2*ty+1); 18 | 19 | edgels_v = ( seg(1:end-1, :) ~= seg(2:end, :) ); 20 | edgels_v(end+1, :) = 0; 21 | edgels_h = ( seg(:, 1:end-1) ~= seg(:, 2:end) ); 22 | edgels_h(:, end+1) = 0; 23 | 24 | bdry(3:2:end, 2:2:end) = edgels_v; 25 | bdry(2:2:end, 3:2:end) = edgels_h; 26 | bdry(3:2:end-1, 3:2:end-1)= max ( max(edgels_h(1:end-1, 1:end-1), edgels_h(2:end, 1:end-1)), max(edgels_v(1:end-1,1:end-1), edgels_v(1:end-1,2:end)) ); 27 | 28 | bdry(1, :) = bdry(2, :); 29 | bdry(:, 1) = bdry(:, 2); 30 | bdry(end, :) = bdry(end-1, :); 31 | bdry(:, end) = bdry(:, end-1); 32 | 33 | if strcmp(fmt,'imageSize') 34 | bdry = bdry(3:2:end, 3:2:end); 35 | end; 36 | end --------------------------------------------------------------------------------