[37] | 1 | % * This code was used in the following articles:
|
---|
| 2 | % * [1] Learning 3-D Scene Structure from a Single Still Image,
|
---|
| 3 | % * Ashutosh Saxena, Min Sun, Andrew Y. Ng,
|
---|
| 4 | % * In ICCV workshop on 3D Representation for Recognition (3dRR-07), 2007.
|
---|
| 5 | % * (best paper)
|
---|
| 6 | % * [2] 3-D Reconstruction from Sparse Views using Monocular Vision,
|
---|
| 7 | % * Ashutosh Saxena, Min Sun, Andrew Y. Ng,
|
---|
| 8 | % * In ICCV workshop on Virtual Representations and Modeling
|
---|
| 9 | % * of Large-scale environments (VRML), 2007.
|
---|
| 10 | % * [3] 3-D Depth Reconstruction from a Single Still Image,
|
---|
| 11 | % * Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
|
---|
| 12 | % * International Journal of Computer Vision (IJCV), Aug 2007.
|
---|
| 13 | % * [6] Learning Depth from Single Monocular Images,
|
---|
| 14 | % * Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
|
---|
| 15 | % * In Neural Information Processing Systems (NIPS) 18, 2005.
|
---|
| 16 | % *
|
---|
| 17 | % * These articles are available at:
|
---|
| 18 | % * http://make3d.stanford.edu/publications
|
---|
| 19 | % *
|
---|
| 20 | % * We request that you cite the papers [1], [3] and [6] in any of
|
---|
| 21 | % * your reports that uses this code.
|
---|
| 22 | % * Further, if you use the code in image3dstiching/ (multiple image version),
|
---|
| 23 | % * then please cite [2].
|
---|
| 24 | % *
|
---|
| 25 | % * If you use the code in third_party/, then PLEASE CITE and follow the
|
---|
| 26 | % * LICENSE OF THE CORRESPONDING THIRD PARTY CODE.
|
---|
| 27 | % *
|
---|
| 28 | % * Finally, this code is for non-commercial use only. For further
|
---|
| 29 | % * information and to obtain a copy of the license, see
|
---|
| 30 | % *
|
---|
| 31 | % * http://make3d.stanford.edu/publications/code
|
---|
| 32 | % *
|
---|
| 33 | % * Also, the software distributed under the License is distributed on an
|
---|
| 34 | % * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
---|
| 35 | % * express or implied. See the License for the specific language governing
|
---|
| 36 | % * permissions and limitations under the License.
|
---|
| 37 | % *
|
---|
| 38 | % */
|
---|
| 39 | function [] = RunCompleteMRF_efficient( Default, img, Predicted, MedSup, Sup, SupOri, TextSup,... |
---|
| 40 | SupNeighborTable, SupSize, maskSky, maskg); |
---|
| 41 | %function [] = RunCompleteMRF(BatchNu,LearnType,LearnSkyEx,LearnLog,LearnNear,... |
---|
| 42 | % LearnAlg,baseline,step); |
---|
| 43 | |
---|
| 44 | % This Function prepare the Two things for the ReportPlaneParaMRF |
---|
| 45 | % 1) align the superpixel onto the straight line boundary |
---|
| 46 | % and the superpixel bounary |
---|
| 47 | % 2) Using Multiple segmentation hurestic to determine occlusion |
---|
| 48 | % (right now it works sucks) |
---|
| 49 | |
---|
| 50 | % Stup Flags |
---|
| 51 | MultiScaleSup = true; % If yes, analyze Multiple segmentation for relation weights |
---|
| 52 | STNeeded = true; % If yes, align the ray to the bundary of the superpixels |
---|
| 53 | DisplayFlag = Default.Flag.DisplayFlag; % set to display or not |
---|
| 54 | |
---|
| 55 | % initalize the RayOri and Ray (this is after stitching) |
---|
| 56 | SampleIndexYSmall = repmat((1:Default.VertYNuDepth)',[1 Default.HoriXNuDepth]); |
---|
| 57 | SampleIndexXSmall = repmat((1:Default.HoriXNuDepth),[Default.VertYNuDepth 1]); |
---|
| 58 | SampleImCoordYSmall = (( Default.VertYNuDepth+1-SampleIndexYSmall)-0.5)/Default.VertYNuDepth - Default.Oy_default; |
---|
| 59 | SampleImCoordXSmall = ( SampleIndexXSmall-0.5)/Default.HoriXNuDepth - Default.Ox_default; |
---|
| 60 | RayOri = RayImPosition( SampleImCoordYSmall, SampleImCoordXSmall,... |
---|
| 61 | Default.a_default, Default.b_default, ... |
---|
| 62 | Default.Ox_default,Default.Oy_default); %[ horiXSizeLowREs VertYSizeLowREs 3] |
---|
| 63 | RayOri = permute(RayOri,[3 1 2]); %[ 3 horiXSizeLowREs VertYSizeLowREs] |
---|
| 64 | |
---|
| 65 | % Img = imread([GeneralDataFolder '/' ImgFolder '/' filename{i} '.jpg'],'jpg'); |
---|
| 66 | img = imresize(img, [ Default.SegVertYSize Default.SegHoriXSize]); |
---|
| 67 | [seglist]=edgeSegDetection(img,i,0); % Run long edge detection |
---|
| 68 | if DisplayFlag |
---|
| 69 | DisplaySup(MedSup,300); |
---|
| 70 | hold on; drawseg(seglist,300); |
---|
| 71 | end |
---|
| 72 | |
---|
| 73 | % since edge detection using a image size different from the depthmap (55x 305) |
---|
| 74 | % so do the following coordinate transform |
---|
| 75 | seglist(:,1:2) = Matrix2ImgCo(Default.SegHoriXSize, Default.SegVertYSize, seglist(:,1:2)); |
---|
| 76 | seglist(:,3:4) = Matrix2ImgCo(Default.SegHoriXSize, Default.SegVertYSize, seglist(:,3:4)); |
---|
| 77 | seglist(:,1:2) = ImgCo2Matrix(Default.HoriXNuDepth, Default.VertYNuDepth, seglist(:,1:2)); |
---|
| 78 | seglist(:,3:4) = ImgCo2Matrix(Default.HoriXNuDepth, Default.VertYNuDepth, seglist(:,3:4)); |
---|
| 79 | |
---|
| 80 | VB = MedSup(:,round(linspace(1, Default.SegHoriXSize, Default.HoriXNuDepth))); |
---|
| 81 | HB = MedSup(round(linspace(1, Default.SegVertYSize, Default.VertYNuDepth)),:); |
---|
| 82 | |
---|
| 83 | if STNeeded |
---|
| 84 | % stitch the regular grid to the seglist |
---|
| 85 | TextCoor = SupRayAlign( Sup{1}, VB, HB, seglist, SampleIndexXSmall, SampleIndexYSmall, SupSize); |
---|
| 86 | % transform the TextCoor back into ImgCoord |
---|
| 87 | SampleImCoordYSmall = (( Default.VertYNuDepth+1-TextCoor(:,:,2))-0.5)/Default.VertYNuDepth - Default.Oy_default; |
---|
| 88 | SampleImCoordXSmall = ( TextCoor(:,:,1)-0.5)/Default.HoriXNuDepth - Default.Ox_default; |
---|
| 89 | % generate the New Ray which is stitched into the long lines |
---|
| 90 | Ray = RayImPosition( SampleImCoordYSmall, SampleImCoordXSmall, ... |
---|
| 91 | Default.a_default, Default.b_default, ... |
---|
| 92 | Default.Ox_default,Default.Oy_default); %[ horiXSizeLowREs VertYSizeLowREs 3] |
---|
| 93 | Ray = permute(Ray,[3 1 2]); %[ 3 horiXSizeLowREs VertYSizeLowREs] |
---|
| 94 | else |
---|
| 95 | Ray = RayOri; |
---|
| 96 | end |
---|
| 97 | |
---|
| 98 | % ===================================END OF STraight Line aligning vertices=========================================== |
---|
| 99 | |
---|
| 100 | % Multiple segmentation |
---|
| 101 | if MultiScaleSup ==1 |
---|
| 102 | % MultiScaleSupTable is a table record the group index of sup in higher level of segmentation |
---|
| 103 | [MultiScaleSupTable] = MultiScalAnalyze( Sup{1}, permute( cat( 3, Sup{2},... |
---|
| 104 | TextSup{1,1}, TextSup{1,2},... |
---|
| 105 | TextSup{2,1}, TextSup{2,2},... |
---|
| 106 | TextSup{3,1}, TextSup{3,2},... |
---|
| 107 | TextSup{4,1}, TextSup{4,2},... |
---|
| 108 | TextSup{5,1}, TextSup{5,2},... |
---|
| 109 | TextSup{6,1}, TextSup{6,2}),... |
---|
| 110 | [3 1 2])); |
---|
| 111 | else |
---|
| 112 | MultiScaleSupTable = []; |
---|
| 113 | end |
---|
| 114 | % =================================END OF Multiple Segmentation Occlusion Decision===================================== |
---|
| 115 | ReportPlaneParaMRF_Conditioned( Default, Sup{1}, SupOri, full(Predicted.depthMap), zeros( size(Predicted.VarMap)), ... |
---|
| 116 | RayOri, Ray, SupNeighborTable, maskSky, maskg, MultiScaleSupTable, []); % not really using the Straight line constrains |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | return; |
---|