├── Code_RGDR ├── Images │ ├── art_big.png │ ├── art_color.png │ ├── depth_1_n.png │ ├── depth_2_n.png │ ├── depth_3_n.png │ ├── depth_3_n_.png │ └── depth_4_n.png ├── mexGetRelSmooth.mexw64 ├── mexConstantMinMax.mexw64 ├── mexGetColorWeight.mexw64 ├── mexGetDepthWeight.mexw64 ├── mexGetWeightedDepth.mexw64 ├── MexFile.m ├── GetRelSmooth.m ├── mexGetRelSmooth.cpp ├── Main.m ├── mexGetColorWeight.cpp ├── mexGetWeightedDepth.cpp ├── mexGetDepthWeight.cpp └── mexConstantMinMax.cpp ├── Input & Results ├── Input │ ├── art_big.png │ ├── book_big.png │ ├── art_color.png │ ├── book_color.png │ ├── dolls_big.png │ ├── dolls_color.png │ ├── laundry_big.png │ ├── moebius_big.png │ ├── art_depth_1_n.png │ ├── art_depth_2_n.png │ ├── art_depth_3_n.png │ ├── art_depth_4_n.png │ ├── laundry_color.png │ ├── moebius_color.png │ ├── reindeer_big.png │ ├── book_depth_1_n.png │ ├── book_depth_2_n.png │ ├── book_depth_3_n.png │ ├── book_depth_4_n.png │ ├── dolls_depth_1_n.png │ ├── dolls_depth_2_n.png │ ├── dolls_depth_3_n.png │ ├── dolls_depth_4_n.png │ ├── input │ │ ├── art_clean.png │ │ ├── art_color.png │ │ ├── art_small.png │ │ ├── art_tiny.png │ │ ├── book_clean.png │ │ ├── book_color.png │ │ ├── book_small.png │ │ ├── book_tiny.png │ │ ├── dolls_tiny.png │ │ ├── dolls_clean.png │ │ ├── dolls_color.png │ │ ├── dolls_small.png │ │ ├── laundry_tiny.png │ │ ├── moebius_tiny.png │ │ ├── laundry_clean.png │ │ ├── laundry_color.png │ │ ├── laundry_small.png │ │ ├── moebius_clean.png │ │ ├── moebius_color.png │ │ ├── moebius_small.png │ │ ├── reindeer_clean.png │ │ ├── reindeer_color.png │ │ ├── reindeer_small.png │ │ ├── reindeer_tiny.png │ │ └── DepthMapExtract.m │ ├── reindeer_color.png │ ├── laundry_depth_1_n.png │ ├── laundry_depth_2_n.png │ ├── laundry_depth_3_n.png │ ├── laundry_depth_4_n.png │ ├── moebius_depth_1_n.png │ ├── moebius_depth_2_n.png │ ├── moebius_depth_3_n.png │ ├── moebius_depth_4_n.png │ ├── reindeer_depth_1_n.png │ ├── reindeer_depth_2_n.png │ ├── reindeer_depth_3_n.png │ └── reindeer_depth_4_n.png └── Results │ ├── art_16_My.png │ ├── art_2_My.png │ ├── art_4_My.png │ ├── art_8_My.png │ ├── book_2_My.png │ ├── book_4_My.png │ ├── book_8_My.png │ ├── book_16_My.png │ ├── dolls_16_My.png │ ├── dolls_2_My.png │ ├── dolls_4_My.png │ ├── dolls_8_My.png │ ├── laundry_16_My.png │ ├── laundry_2_My.png │ ├── laundry_4_My.png │ ├── laundry_8_My.png │ ├── moebius_16_My.png │ ├── moebius_2_My.png │ ├── moebius_4_My.png │ ├── moebius_8_My.png │ ├── reindeer_16_My.png │ ├── reindeer_2_My.png │ ├── reindeer_4_My.png │ └── reindeer_8_My.png └── README.md /Code_RGDR/Images/art_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/art_big.png -------------------------------------------------------------------------------- /Code_RGDR/Images/art_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/art_color.png -------------------------------------------------------------------------------- /Code_RGDR/Images/depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/depth_1_n.png -------------------------------------------------------------------------------- /Code_RGDR/Images/depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/depth_2_n.png -------------------------------------------------------------------------------- /Code_RGDR/Images/depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/depth_3_n.png -------------------------------------------------------------------------------- /Code_RGDR/Images/depth_3_n_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/depth_3_n_.png -------------------------------------------------------------------------------- /Code_RGDR/Images/depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/Images/depth_4_n.png -------------------------------------------------------------------------------- /Code_RGDR/mexGetRelSmooth.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/mexGetRelSmooth.mexw64 -------------------------------------------------------------------------------- /Code_RGDR/mexConstantMinMax.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/mexConstantMinMax.mexw64 -------------------------------------------------------------------------------- /Code_RGDR/mexGetColorWeight.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/mexGetColorWeight.mexw64 -------------------------------------------------------------------------------- /Code_RGDR/mexGetDepthWeight.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/mexGetDepthWeight.mexw64 -------------------------------------------------------------------------------- /Input & Results/Input/art_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/art_big.png -------------------------------------------------------------------------------- /Input & Results/Input/book_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/book_big.png -------------------------------------------------------------------------------- /Code_RGDR/mexGetWeightedDepth.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Code_RGDR/mexGetWeightedDepth.mexw64 -------------------------------------------------------------------------------- /Input & Results/Input/art_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/art_color.png -------------------------------------------------------------------------------- /Input & Results/Input/book_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/book_color.png -------------------------------------------------------------------------------- /Input & Results/Input/dolls_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/dolls_big.png -------------------------------------------------------------------------------- /Input & Results/Input/dolls_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/dolls_color.png -------------------------------------------------------------------------------- /Input & Results/Input/laundry_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/laundry_big.png -------------------------------------------------------------------------------- /Input & Results/Input/moebius_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/moebius_big.png -------------------------------------------------------------------------------- /Input & Results/Results/art_16_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/art_16_My.png -------------------------------------------------------------------------------- /Input & Results/Results/art_2_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/art_2_My.png -------------------------------------------------------------------------------- /Input & Results/Results/art_4_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/art_4_My.png -------------------------------------------------------------------------------- /Input & Results/Results/art_8_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/art_8_My.png -------------------------------------------------------------------------------- /Input & Results/Results/book_2_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/book_2_My.png -------------------------------------------------------------------------------- /Input & Results/Results/book_4_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/book_4_My.png -------------------------------------------------------------------------------- /Input & Results/Results/book_8_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/book_8_My.png -------------------------------------------------------------------------------- /Input & Results/Input/art_depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/art_depth_1_n.png -------------------------------------------------------------------------------- /Input & Results/Input/art_depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/art_depth_2_n.png -------------------------------------------------------------------------------- /Input & Results/Input/art_depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/art_depth_3_n.png -------------------------------------------------------------------------------- /Input & Results/Input/art_depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/art_depth_4_n.png -------------------------------------------------------------------------------- /Input & Results/Input/laundry_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/laundry_color.png -------------------------------------------------------------------------------- /Input & Results/Input/moebius_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/moebius_color.png -------------------------------------------------------------------------------- /Input & Results/Input/reindeer_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/reindeer_big.png -------------------------------------------------------------------------------- /Input & Results/Results/book_16_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/book_16_My.png -------------------------------------------------------------------------------- /Input & Results/Results/dolls_16_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/dolls_16_My.png -------------------------------------------------------------------------------- /Input & Results/Results/dolls_2_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/dolls_2_My.png -------------------------------------------------------------------------------- /Input & Results/Results/dolls_4_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/dolls_4_My.png -------------------------------------------------------------------------------- /Input & Results/Results/dolls_8_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/dolls_8_My.png -------------------------------------------------------------------------------- /Input & Results/Input/book_depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/book_depth_1_n.png -------------------------------------------------------------------------------- /Input & Results/Input/book_depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/book_depth_2_n.png -------------------------------------------------------------------------------- /Input & Results/Input/book_depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/book_depth_3_n.png -------------------------------------------------------------------------------- /Input & Results/Input/book_depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/book_depth_4_n.png -------------------------------------------------------------------------------- /Input & Results/Input/dolls_depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/dolls_depth_1_n.png -------------------------------------------------------------------------------- /Input & Results/Input/dolls_depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/dolls_depth_2_n.png -------------------------------------------------------------------------------- /Input & Results/Input/dolls_depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/dolls_depth_3_n.png -------------------------------------------------------------------------------- /Input & Results/Input/dolls_depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/dolls_depth_4_n.png -------------------------------------------------------------------------------- /Input & Results/Input/input/art_clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/art_clean.png -------------------------------------------------------------------------------- /Input & Results/Input/input/art_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/art_color.png -------------------------------------------------------------------------------- /Input & Results/Input/input/art_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/art_small.png -------------------------------------------------------------------------------- /Input & Results/Input/input/art_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/art_tiny.png -------------------------------------------------------------------------------- /Input & Results/Input/input/book_clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/book_clean.png -------------------------------------------------------------------------------- /Input & Results/Input/input/book_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/book_color.png -------------------------------------------------------------------------------- /Input & Results/Input/input/book_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/book_small.png -------------------------------------------------------------------------------- /Input & Results/Input/input/book_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/book_tiny.png -------------------------------------------------------------------------------- /Input & Results/Input/input/dolls_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/dolls_tiny.png -------------------------------------------------------------------------------- /Input & Results/Input/reindeer_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/reindeer_color.png -------------------------------------------------------------------------------- /Input & Results/Results/laundry_16_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/laundry_16_My.png -------------------------------------------------------------------------------- /Input & Results/Results/laundry_2_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/laundry_2_My.png -------------------------------------------------------------------------------- /Input & Results/Results/laundry_4_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/laundry_4_My.png -------------------------------------------------------------------------------- /Input & Results/Results/laundry_8_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/laundry_8_My.png -------------------------------------------------------------------------------- /Input & Results/Results/moebius_16_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/moebius_16_My.png -------------------------------------------------------------------------------- /Input & Results/Results/moebius_2_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/moebius_2_My.png -------------------------------------------------------------------------------- /Input & Results/Results/moebius_4_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/moebius_4_My.png -------------------------------------------------------------------------------- /Input & Results/Results/moebius_8_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/moebius_8_My.png -------------------------------------------------------------------------------- /Input & Results/Results/reindeer_16_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/reindeer_16_My.png -------------------------------------------------------------------------------- /Input & Results/Results/reindeer_2_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/reindeer_2_My.png -------------------------------------------------------------------------------- /Input & Results/Results/reindeer_4_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/reindeer_4_My.png -------------------------------------------------------------------------------- /Input & Results/Results/reindeer_8_My.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Results/reindeer_8_My.png -------------------------------------------------------------------------------- /Input & Results/Input/input/dolls_clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/dolls_clean.png -------------------------------------------------------------------------------- /Input & Results/Input/input/dolls_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/dolls_color.png -------------------------------------------------------------------------------- /Input & Results/Input/input/dolls_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/dolls_small.png -------------------------------------------------------------------------------- /Input & Results/Input/input/laundry_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/laundry_tiny.png -------------------------------------------------------------------------------- /Input & Results/Input/input/moebius_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/moebius_tiny.png -------------------------------------------------------------------------------- /Input & Results/Input/laundry_depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/laundry_depth_1_n.png -------------------------------------------------------------------------------- /Input & Results/Input/laundry_depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/laundry_depth_2_n.png -------------------------------------------------------------------------------- /Input & Results/Input/laundry_depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/laundry_depth_3_n.png -------------------------------------------------------------------------------- /Input & Results/Input/laundry_depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/laundry_depth_4_n.png -------------------------------------------------------------------------------- /Input & Results/Input/moebius_depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/moebius_depth_1_n.png -------------------------------------------------------------------------------- /Input & Results/Input/moebius_depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/moebius_depth_2_n.png -------------------------------------------------------------------------------- /Input & Results/Input/moebius_depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/moebius_depth_3_n.png -------------------------------------------------------------------------------- /Input & Results/Input/moebius_depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/moebius_depth_4_n.png -------------------------------------------------------------------------------- /Input & Results/Input/reindeer_depth_1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/reindeer_depth_1_n.png -------------------------------------------------------------------------------- /Input & Results/Input/reindeer_depth_2_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/reindeer_depth_2_n.png -------------------------------------------------------------------------------- /Input & Results/Input/reindeer_depth_3_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/reindeer_depth_3_n.png -------------------------------------------------------------------------------- /Input & Results/Input/reindeer_depth_4_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/reindeer_depth_4_n.png -------------------------------------------------------------------------------- /Input & Results/Input/input/laundry_clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/laundry_clean.png -------------------------------------------------------------------------------- /Input & Results/Input/input/laundry_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/laundry_color.png -------------------------------------------------------------------------------- /Input & Results/Input/input/laundry_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/laundry_small.png -------------------------------------------------------------------------------- /Input & Results/Input/input/moebius_clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/moebius_clean.png -------------------------------------------------------------------------------- /Input & Results/Input/input/moebius_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/moebius_color.png -------------------------------------------------------------------------------- /Input & Results/Input/input/moebius_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/moebius_small.png -------------------------------------------------------------------------------- /Input & Results/Input/input/reindeer_clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/reindeer_clean.png -------------------------------------------------------------------------------- /Input & Results/Input/input/reindeer_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/reindeer_color.png -------------------------------------------------------------------------------- /Input & Results/Input/input/reindeer_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/reindeer_small.png -------------------------------------------------------------------------------- /Input & Results/Input/input/reindeer_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/Robust-Color-Guided-Depth-Map-Restoration/master/Input & Results/Input/input/reindeer_tiny.png -------------------------------------------------------------------------------- /Code_RGDR/MexFile.m: -------------------------------------------------------------------------------- 1 | function MexFile 2 | mex -largeArrayDims mexGetColorWeight.cpp 3 | mex -largeArrayDims mexGetDepthWeight.cpp 4 | mex -largeArrayDims mexGetWeightedDepth.cpp 5 | mex mexConstantMinMax.cpp 6 | mex mexGetRelSmooth.cpp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Robust-Color-Guided-Depth-Map-Restoration 2 | This is the implementation of the following paper: 3 | Liu, W., Chen, X., Yang, J., & Wu, Q. (2017). Robust color guided depth map restoration. IEEE Transactions on Image Processing, 26(1), 315-327. 4 | ********************************************************* 5 | How to use: 6 | 1. run MexFile.m 7 | 2. run Main.m 8 | 9 | ******************************* 10 | If out of memory, set the value of r to a smaller one. 11 | -------------------------------------------------------------------------------- /Input & Results/Input/input/DepthMapExtract.m: -------------------------------------------------------------------------------- 1 | % function DepthMapExtract 2 | 3 | mkdir('.\input') 4 | 5 | Name = {'art', 'book', 'dolls', 'laundry', 'moebius', 'reindeer'}; 6 | 7 | for i = 1: 6 8 | 9 | Color = imread([Name{i}, '_color.png']); 10 | Depth = imread([Name{i}, '_big.png']); 11 | imwrite(Color, ['.\input\',Name{i}, '_color.png']); 12 | imwrite(Depth, ['.\input\',Name{i}, '_clean.png']); 13 | 14 | DepthSmall = imread(['.\',Name{i},'_big\depth_1_n.png']); 15 | imwrite(DepthSmall, ['.\input\',Name{i}, '_small.png']); 16 | 17 | DepthSmall = imread(['.\',Name{i},'_big\depth_2_n.png']); 18 | imwrite(DepthSmall, ['.\input\',Name{i}, '_tiny.png']); 19 | 20 | end -------------------------------------------------------------------------------- /Code_RGDR/GetRelSmooth.m: -------------------------------------------------------------------------------- 1 | function [RS] = GetRelSmooth(Depth, winR, patchR) 2 | 3 | [m, n] = size(Depth); 4 | 5 | Depth = padarray(Depth, [winR, winR], 'symmetric'); 6 | 7 | % ====================== min operation ============================= 8 | Temp = Depth(1:2*winR + 1, :); 9 | 10 | [Seed, SeedX] = min(Temp, [], 1); 11 | SeedX = abs(winR - SeedX) + 1; % substract the patchR caused by padarray 12 | SeedY_ = 1:n; 13 | Seed = Seed(winR + 1: end - winR); 14 | SeedX = SeedX(winR + 1: end - winR); 15 | 16 | 17 | % tic 18 | [MinMapV, MinCoorX, ~, ~] = mexConstantMinMax(Depth, Seed, SeedX, SeedY_, winR, 0, 0); 19 | % toc 20 | 21 | 22 | 23 | MinMapV = MinMapV'; 24 | MinMapV = padarray(MinMapV, [winR, winR], 'symmetric'); 25 | 26 | Temp = MinMapV(1:2*winR + 1, :); 27 | 28 | [Seed, SeedY] = min(Temp, [], 1); 29 | SeedY = abs(winR - SeedY) + 1; 30 | SeedX_ = 1:m; 31 | Seed = Seed(winR + 1: end - winR); 32 | SeedY = SeedY(winR + 1: end - winR); 33 | 34 | [MinMap, MinCoorY, ~, ~] = mexConstantMinMax(MinMapV, Seed, SeedY, SeedX_, winR, 0, 0); 35 | 36 | MinMap = MinMap'; 37 | MinCoorY = MinCoorY'; 38 | 39 | % ====================== max operation ============================= 40 | Temp = Depth(1:2*winR + 1, :); 41 | 42 | [Seed, SeedX] = max(Temp, [], 1); 43 | SeedX = abs(winR - SeedX) + 1; % substract the patchR caused by padarray 44 | SeedY_ = 1:n; 45 | Seed = Seed(winR + 1: end - winR); 46 | SeedX = SeedX(winR + 1: end - winR); 47 | 48 | [MaxMapV, MaxCoorX, ~, ~] = mexConstantMinMax(Depth, Seed, SeedX, SeedY_, winR, 1, 0); 49 | 50 | MaxMapV = MaxMapV'; 51 | MaxMapV = padarray(MaxMapV, [winR, winR], 'symmetric'); 52 | 53 | Temp = MaxMapV(1:2*winR + 1, :); 54 | 55 | [Seed, SeedY] = max(Temp, [], 1); 56 | Seed = Seed(winR + 1: end - winR); 57 | SeedY = abs(winR - SeedY) + 1; 58 | SeedY = SeedY(winR + 1: end - winR); 59 | SeedX_ = 1:m; 60 | 61 | 62 | [MaxMap, MaxCoorY, ~, ~] = mexConstantMinMax(MaxMapV, Seed, SeedY, SeedX_, winR, 1, 0); 63 | 64 | MaxMap = MaxMap'; 65 | MaxCoorY = MaxCoorY'; 66 | 67 | Depth = Depth(winR + 1: end - winR, winR + 1: end - winR); 68 | 69 | % tic 70 | RS = mexGetRelSmooth(Depth, MinCoorX, MinCoorY, MaxCoorX, MaxCoorY, patchR); 71 | % toc -------------------------------------------------------------------------------- /Code_RGDR/mexGetRelSmooth.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | ///////////////////////////////////////////////////////////////////////// 5 | 6 | void mexFunction(int nlhs, mxArray *plhs[], 7 | int nrhs, const mxArray *prhs[]) 8 | { 9 | 10 | double *Depth, *MinCoorX, *MinCoorY, *MaxCoorX, *MaxCoorY, *RS; 11 | double tempMin, tempMax, RelSmooth; 12 | int patchR, i, j, m, n, s, t, i_offset_min, j_offset_min, i_offset_max, j_offset_max; 13 | 14 | Depth = mxGetPr(prhs[0]); // NOT padarray 15 | MinCoorX = mxGetPr(prhs[1]); 16 | MinCoorY = mxGetPr(prhs[2]); 17 | MaxCoorX = mxGetPr(prhs[3]); 18 | MaxCoorY = mxGetPr(prhs[4]); 19 | patchR = (int)mxGetScalar(prhs[5]); 20 | 21 | m = mxGetM(prhs[0]); 22 | n = mxGetN(prhs[0]); 23 | 24 | plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL); 25 | RS = mxGetPr(plhs[0]); 26 | 27 | 28 | for(i=0;im-1) i_offset_min = m-1; 40 | 41 | i_offset_max = MaxCoorX[j*m+i] + s - 1; 42 | if(i_offset_max<0) i_offset_max = 0; 43 | if(i_offset_max>m-1) i_offset_max = m-1; 44 | 45 | for(t=-patchR;t<=patchR;t++) 46 | { 47 | j_offset_min = MinCoorY[j*m+i] + t - 1; 48 | if(j_offset_min<0) j_offset_min = 0; 49 | if(j_offset_min>n-1) j_offset_min = n-1; 50 | 51 | j_offset_max = MaxCoorY[j*m+i] + t -1 ; 52 | if(j_offset_max<0) j_offset_max = 0; 53 | if(j_offset_max>n-1) j_offset_max = n-1; 54 | 55 | 56 | tempMin = tempMin + Depth[j_offset_min*m + i_offset_min]; 57 | tempMax = tempMax + Depth[j_offset_max*m + i_offset_max]; 58 | 59 | } 60 | } 61 | 62 | RelSmooth = tempMin/tempMax; 63 | RS[j*m + i] = RelSmooth; 64 | 65 | } 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /Code_RGDR/Main.m: -------------------------------------------------------------------------------- 1 | % This is the implementation of the following paper: 2 | % Liu, Wei, et al. "Robust Color Guided Depth Map Restoration." IEEE Transactions on Image Processing 26.1 (2017): 315-327. 3 | 4 | % Please run function MexFile.m to compile the C code first. 5 | 6 | % Note that the implementation uses the Look Up Table (LUT) technique. All 7 | % the images are required to normalized into [0, 255]! 8 | 9 | Depth = double(imread('.\Images\art_big.png')); 10 | Color = double(imread('.\Images\art_color.png')); 11 | DepthNoise = double(imread('.\Images\depth_3_n.png')); 12 | 13 | [m, n] = size(Depth); 14 | 15 | DepthNoise = imresize(DepthNoise, [m, n]); 16 | 17 | alpha = 0.95; 18 | 19 | rSmooth = 9; 20 | sigmaSSmooth = 9; 21 | 22 | rRelSmooth = 7; 23 | sigmaC = 10; 24 | 25 | BW = ones(m, n); 26 | BWAdp = [10, 4, 7, 10]; 27 | 28 | IterNumFixedPoint = 16; % 4/8/16/32 for 2X/4X/8X/16X upsampling 29 | 30 | DepthUpdate = DepthNoise; 31 | 32 | t11 = tic; 33 | RS = GetRelSmooth(DepthUpdate, rRelSmooth, rRelSmooth); 34 | BW(RS>=0.96) = BWAdp(1); 35 | BW(RS<0.96) = BWAdp(2); 36 | BW(RS<0.8) = BWAdp(3); 37 | BW(RS<0.7) = BWAdp(4); 38 | t12 = toc(t11); 39 | fprintf('Computing relative smoothness costs %f s\n', t12); 40 | 41 | 42 | %%%%%%%%%%% prepear LUT %%%%%%%%%%%%% 43 | t11 = tic; 44 | colorMax = 255; % both the color images and depth maps are normalized into [0, 255] 45 | depthMax = 255; 46 | 47 | ColorRange = 0:3*(colorMax + 10)^2; 48 | ColorRange = ColorRange'; 49 | DepthRange = 0:(depthMax + 10)^2; 50 | DepthRange = DepthRange'; 51 | 52 | ColorWeightLUT = exp(-ColorRange/(3*2*sigmaC^2)); 53 | 54 | DepthWeightLUT = zeros(length(DepthRange), length(BWAdp)); 55 | for i = 1: length(BWAdp) 56 | DepthWeightLUT(:, i) = exp(-DepthRange/(2*BWAdp(i)^2)); 57 | end 58 | 59 | t12 = toc(t11); 60 | fprintf('Prepearing LUT costs %f s\n', t12); 61 | 62 | 63 | %%%%% Color Weight %%%%%%%% 64 | t11 = tic; 65 | [ColorWeight] = mexGetColorWeight(Color(:,:,1), Color(:,:,2), Color(:,:,3), sigmaC, rSmooth, ColorWeightLUT); 66 | t12=toc(t11); 67 | fprintf('Computing color weight costs %f s\n', t12); 68 | 69 | 70 | %%%%%%%%%%% 71 | 72 | for i = 1: IterNumFixedPoint 73 | 74 | t11 = tic; 75 | [DepthWeightSmooth] = mexGetDepthWeight(DepthUpdate, rSmooth, BW, sigmaSSmooth, BWAdp, DepthWeightLUT); 76 | t12=toc(t11); 77 | fprintf('Computing depth weight costs %f s\n', t12); 78 | 79 | t11 = tic; 80 | [WeightSumSmooth, WeightedDepthUpd] = mexGetWeightedDepth(DepthUpdate, DepthWeightSmooth, ColorWeight, m, n, rSmooth); 81 | t12=toc(t11); 82 | fprintf('Computing weighted sum costs %f s\n', t12); 83 | 84 | 85 | t11 = tic; 86 | ResFixedPoint = ((1-alpha)*DepthNoise + 2*alpha*WeightedDepthUpd)./((1-alpha) + 2*alpha*WeightSumSmooth); 87 | t12=toc(t11); 88 | fprintf('Computing results using fixed point equation costs %f s\n', t12); 89 | 90 | DepthUpdate = ResFixedPoint; 91 | 92 | Diff = abs(Depth - DepthUpdate); 93 | MAE = sum(Diff(:))/(m*n); 94 | fprintf('Iteration %d, MAE is %f \n\n', i, MAE); 95 | 96 | 97 | % figure 98 | imshow(uint8(ResFixedPoint)) 99 | 100 | end 101 | 102 | Res = ResFixedPoint; 103 | 104 | -------------------------------------------------------------------------------- /Code_RGDR/mexGetColorWeight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void GetBlock(int cur_i, int cur_j, int m, int n, int winR, double *Image, double *Block, double *Coor, int InvFlag); 5 | 6 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 7 | { 8 | double *CR, *CG, *CB, *ColorWeightLUT; 9 | double sigmaC; 10 | int m, n, rSmooth, winSizeSmooth; 11 | 12 | CR = mxGetPr(prhs[0]); 13 | CG = mxGetPr(prhs[1]); 14 | CB = mxGetPr(prhs[2]); 15 | sigmaC = mxGetScalar(prhs[3]); 16 | rSmooth = (int)mxGetScalar(prhs[4]); 17 | ColorWeightLUT = mxGetPr(prhs[5]); 18 | 19 | m = mxGetM(prhs[0]); // row number 20 | n = mxGetN(prhs[0]); // column number 21 | 22 | winSizeSmooth = 2*rSmooth + 1; //window size of the smoothness term 23 | 24 | 25 | 26 | /************* compute weight for the smoothness term **********************/ 27 | plhs[0] = mxCreateSparse(m*n, m*n, winSizeSmooth*winSizeSmooth*m*n, mxREAL); 28 | double *WeightColorPr = mxGetPr(plhs[0]); // the output depth weight sparse matrix for data term 29 | mwIndex *WeightColorIr = mxGetIr(plhs[0]); 30 | mwIndex *WeightColorJc = mxGetJc(plhs[0]); 31 | 32 | 33 | /************ compute weight *************/ 34 | int i, j, s, t, counter; 35 | int InvFlag = -1; // if the pixle in the window is outside the image, set the corresponding coordinate in Coor as InvFlag. 36 | double diffR, diffG, diffB; 37 | 38 | double *BlockR = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 39 | double *BlockG = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 40 | double *BlockB = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 41 | double *Coor = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); // to label the coordinate of the pixel in the sparse matrix 42 | 43 | 44 | WeightColorJc[0] = 0; 45 | counter = 0; 46 | 47 | for(j=0;j m - 1) sMax = winR + m - 1 - cur_i; 102 | else sMax = winSize - 1; 103 | 104 | if(cur_j < winR) tMin = winR - cur_j; 105 | else tMin = 0; 106 | 107 | if(cur_j + winR > n - 1) tMax = winR + n - 1 - cur_j; 108 | else tMax = winSize - 1; 109 | 110 | for(i=sMin;i<=sMax;i++) 111 | { 112 | for(j=tMin;j<=tMax;j++) 113 | { 114 | Block[j*winSize + i] = Image[(cur_j - winR + j)*m + cur_i - winR + i]; 115 | Coor[j*winSize + i] = (cur_j - winR + j)*m + cur_i - winR + i; 116 | } 117 | } 118 | 119 | } -------------------------------------------------------------------------------- /Code_RGDR/mexGetWeightedDepth.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void GetBlock(int cur_i, int cur_j, int m, int n, int winR, double *Image, double *Block, double *Coor, int InvFlag); 4 | 5 | int GetBlockFromSparse(int winSize, double *WeightPr, int WeightPrCount, double *FlagMask, double *WeightBlock, int InvFlag); 6 | ///////////////////////////////////////// 7 | 8 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 9 | { 10 | double *DepthUpd; 11 | double *DepthWeightSmoothPr, *ColorWeightPr; 12 | int m, n, rSmooth, winSizeSmooth; 13 | 14 | DepthUpd = mxGetPr(prhs[0]); 15 | DepthWeightSmoothPr = mxGetPr(prhs[1]); 16 | ColorWeightPr = mxGetPr(prhs[2]); 17 | 18 | m = (int)mxGetScalar(prhs[3]); 19 | n = (int)mxGetScalar(prhs[4]); 20 | rSmooth = (int)mxGetScalar(prhs[5]); 21 | 22 | winSizeSmooth = 2*rSmooth + 1; 23 | 24 | 25 | ////////// Output //////// 26 | plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL); 27 | plhs[1] = mxCreateDoubleMatrix(m, n, mxREAL); 28 | 29 | 30 | double *WeightSumSmooth = mxGetPr(plhs[0]); 31 | double *WeightedDepthUpd = mxGetPr(plhs[1]); 32 | 33 | double *DepthWeightSmoothBlock = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 34 | double *DepthUpdBlock = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 35 | double *ColorWeightBlock = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 36 | double *FlagMaskSmooth = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL)); 37 | 38 | int DepthSmoothPrCount = 0, ColorPrCount = 0, counter = 0, InvFlag = -1; 39 | double WeightSum, WeightedDepthSum; 40 | int i, j, s, t; 41 | 42 | for(j=0;j m - 1) sMax = winR + m - 1 - cur_i; 98 | else sMax = winSize - 1; 99 | 100 | if(cur_j < winR) tMin = winR - cur_j; 101 | else tMin = 0; 102 | 103 | if(cur_j + winR > n - 1) tMax = winR + n - 1 - cur_j; 104 | else tMax = winSize - 1; 105 | 106 | for(i=sMin;i<=sMax;i++) 107 | { 108 | for(j=tMin;j<=tMax;j++) 109 | { 110 | Block[j*winSize + i] = Image[(cur_j - winR + j)*m + cur_i - winR + i]; 111 | Coor[j*winSize + i] = (cur_j - winR + j)*m + cur_i - winR + i; 112 | } 113 | } 114 | 115 | } 116 | 117 | 118 | ////////////////////////// 119 | 120 | 121 | int GetBlockFromSparse(int winSize, double *WeightPr, int WeightPrCount, double *FlagMask, double *WeightBlock, int InvFlag) 122 | { 123 | int i, j, count = 0; 124 | 125 | for(j=0;j 2 | #include 3 | 4 | void GetBlock(int cur_i, int cur_j, int m, int n, int winR, double *Image, double *Block, double *Coor, double *BW, double *BWBlock, int InvFlag); 5 | 6 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 7 | { 8 | double *DepthOri, *DepthUpd; 9 | double *BW, *BWAdp, *DepthWeightLUT, sigmaSData, sigmaSSmooth; 10 | int m, n, rData, rSmooth, winSizeData, winSizeSmooth; 11 | 12 | DepthUpd = mxGetPr(prhs[0]); // the newly updated depth map 13 | rSmooth = (int)mxGetScalar(prhs[1]); // radius of the smoothness term 14 | BW = mxGetPr(prhs[2]); // bandwidth matrix 15 | sigmaSSmooth = mxGetScalar(prhs[3]);// spatial sigma for the smoothness term 16 | BWAdp = mxGetPr(prhs[4]); 17 | DepthWeightLUT = mxGetPr(prhs[5]); 18 | 19 | m = mxGetM(prhs[0]); // row number 20 | n = mxGetN(prhs[0]); // column number 21 | 22 | int mLUT = mxGetM(prhs[5]); 23 | int nLUT = mxGetN(prhs[5]); 24 | 25 | winSizeSmooth = 2*rSmooth + 1; //window size of the smoothness term 26 | 27 | int i, j; 28 | 29 | //////////////////////// 30 | 31 | 32 | double *WeightSpatialSmooth = mxGetPr(mxCreateDoubleMatrix(winSizeSmooth, winSizeSmooth, mxREAL));// spatial weight for the smoothness term 33 | double WeightSum = 0; 34 | 35 | for(i=0;i m - 1) sMax = winR + m - 1 - cur_i; 148 | else sMax = winSize - 1; 149 | 150 | if(cur_j < winR) tMin = winR - cur_j; 151 | else tMin = 0; 152 | 153 | if(cur_j + winR > n - 1) tMax = winR + n - 1 - cur_j; 154 | else tMax = winSize - 1; 155 | 156 | for(i=sMin;i<=sMax;i++) 157 | { 158 | for(j=tMin;j<=tMax;j++) 159 | { 160 | Block[j*winSize + i] = Image[(cur_j - winR + j)*m + cur_i - winR + i]; 161 | Coor[j*winSize + i] = (cur_j - winR + j)*m + cur_i - winR + i; 162 | BWBlock[j*winSize + i] = BW[(cur_j - winR + j)*m + cur_i - winR + i]; 163 | } 164 | } 165 | 166 | } 167 | 168 | -------------------------------------------------------------------------------- /Code_RGDR/mexConstantMinMax.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | //////////////////////////////////////////////////// 4 | 5 | double MyMinMax(double *A, int m, int *Position, int Choice); 6 | 7 | ///////////////////////////////////////////////////////////////////////// 8 | 9 | void GetVector(double *Input, int i, int j, int padm, int patchR, double *Vector); 10 | 11 | ///////////////////////////////////////////////////////////////////////// 12 | 13 | void mexFunction(int nlhs, mxArray *plhs[], 14 | int nrhs, const mxArray *prhs[]) 15 | { 16 | double *Input, *Output, *Seed, *SeedX, *SeedY, *Vector, *counter, *CoorX, *CoorY; 17 | int m, padm, n, padn, i, padi, j, padj, patchR, patchSize, ChoiceM, ChoiceDir, Position[1]; 18 | 19 | Input = mxGetPr(prhs[0]); // has been padarray 20 | Seed = mxGetPr(prhs[1]); // the very first min/max value for vertical/horizontal min/max performance 21 | SeedX = mxGetPr(prhs[2]); // the X Coordinate of the very first min/max value 22 | SeedY = mxGetPr(prhs[3]); // the Y Coordinate of the very first min/max value 23 | patchR = (int)mxGetScalar(prhs[4]); // the radius of the support 24 | ChoiceM = (int)mxGetScalar(prhs[5]); // 0 for min performance, 1 for max performance 25 | ChoiceDir = (int)mxGetScalar(prhs[6]); // 0 for vertical mim/max, 1 for horizontal min/max 26 | 27 | padm = mxGetM(prhs[0]); 28 | padn = mxGetN(prhs[0]); 29 | 30 | m = padm - 2*patchR; 31 | n = padn - 2*patchR; 32 | patchSize = 2*patchR + 1; 33 | 34 | 35 | plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL); 36 | Output = mxGetPr(plhs[0]); 37 | 38 | plhs[1] = mxCreateDoubleMatrix(m, n, mxREAL); 39 | CoorX = mxGetPr(plhs[1]); // X coordinate of min/max value (in REAL WORLD coordinate) 40 | 41 | plhs[2] = mxCreateDoubleMatrix(m, n, mxREAL); 42 | CoorY = mxGetPr(plhs[2]); 43 | 44 | plhs[3] = mxCreateDoubleMatrix(1, 1, mxREAL); 45 | counter = mxGetPr(plhs[3]); // this is the counter for the third case (the else case) 46 | 47 | Vector = mxGetPr(mxCreateDoubleMatrix(1,patchSize, mxREAL)); 48 | 49 | counter[0] = 0; 50 | 51 | if(ChoiceDir==0) // vertical min/max 52 | { 53 | for(j=0;j Input[padj*padm + padi + patchR]) 78 | { 79 | Output[j*m+i]= Input[padj*padm + padi + patchR]; 80 | CoorX[j*m+i] = (i + 1) + patchR; // translate the coordinate in C into real world coordinate 81 | CoorY[j*m+i] = j + 1; 82 | } 83 | 84 | else 85 | { 86 | GetVector(Input, i, j, padm, patchR, Vector); 87 | Output[j*m+i] = MyMinMax(Vector, patchSize,Position, 0); 88 | 89 | CoorX[j*m+i] = (i + 1) + Position[0]; // translate the coordinate in C into real world coordinate 90 | if(CoorX[j*m + i]<=0) CoorX[j*m + i] = CoorX[j*m + i] + patchR; 91 | CoorY[j*m+i] = j + 1; 92 | 93 | counter[0] = counter[0] + 1; 94 | } 95 | 96 | } 97 | 98 | if(ChoiceM == 1) // max operation 99 | { 100 | if((Output[j*m + i-1] >= Input[padj*padm + padi + patchR])&&(Output[j*m + i-1]!=Input[padj*padm + padi - patchR - 1])) 101 | { 102 | Output[j*m+i]= Output[j*m + i-1]; 103 | CoorX[j*m+i] = CoorX[j*m + i-1]; 104 | CoorY[j*m+i] = CoorY[j*m + i-1]; 105 | } 106 | 107 | else if(Input[padj*padm + padi + patchR] > Output[j*m + i-1] ) 108 | { 109 | Output[j*m+i]= Input[padj*padm + padi + patchR]; 110 | CoorX[j*m+i] = (i + 1) + patchR; // translate the coordinate in C into real world coordinate 111 | CoorY[j*m+i] = j + 1; 112 | } 113 | else 114 | { 115 | GetVector(Input, i, j, padm, patchR, Vector); 116 | Output[j*m+i] = MyMinMax(Vector, patchSize, Position, 1); 117 | 118 | CoorX[j*m+i] = (i + 1) + Position[0]; // translate the coordinate in C into real world coordinate 119 | if(CoorX[j*m + i]<=0) CoorX[j*m + i] = CoorX[j*m + i] + patchR; 120 | CoorY[j*m+i] = j + 1; 121 | 122 | counter[0] = counter[0] + 1; 123 | } 124 | 125 | 126 | } 127 | } 128 | } 129 | 130 | 131 | } 132 | 133 | /* if(ChoiceDir==1) // horizontal min/max 134 | { 135 | for(i=0;i= Input[(padj - patchR - 1)*padm + padi]) && (Output[j*m + i-1] >= Input[(padj + patchR)*padm + padi])) 170 | { 171 | Output[j*m+i]= Output[j*m + i-1]; 172 | } 173 | 174 | if((Input[(padj - patchR - 1)*padm + padi] > Output[(j-1)*m + i]) && (Input[(padj - patchR - 1)*padm + padi] >= Input[(padj + patchR)*padm + padi])) 175 | { 176 | Output[j*m+i]= Input[(padj - patchR - 1)*padm + padi]; 177 | } 178 | 179 | if((Input[(padj + patchR)*padm + padi] > Output[(j-1)*m + i]) && (Input[(padj + patchR)*padm + padi] > Input[(padj - patchR - 1)*padm + padi])) 180 | { 181 | Output[j*m+i]= Input[(padj + patchR)*padm + padi]; 182 | } 183 | 184 | } 185 | } 186 | } 187 | 188 | }*/ 189 | 190 | } 191 | 192 | 193 | double MyMinMax(double *A, int m, int *Position, int Choice) 194 | { 195 | double temp = A[0]; 196 | int i; 197 | 198 | Position[0] = -(m-1)/2; 199 | 200 | if(Choice == 0)// min 201 | { 202 | for(i=0;iA[i]) 205 | { 206 | temp = A[i]; 207 | Position[0] = i - (m-1)/2; 208 | } 209 | } 210 | } 211 | 212 | if(Choice == 1)// max 213 | { 214 | for(i=0;i