source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/LearningCode/Features/OldBatchVersion/AbsFeatureGen.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 4.7 KB
Line 
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% */
39function [f, fInd] = AbsFeatureGen(Default, H2, SmallSup, HiSupi, SupMaskFlag, FeaMax, fInd)
40
41% This function generate the average of the feature within a certain mask of a sample point
42% Input--
43% H2: texture filter output
44% HiSup: the Hi resolution superpixel index matrix
45% SupMaskFlag: if SupMaskFlag is 1, we calculate the averaging using superpixel mask (irregular mask)
46% Output--
47% f: Feature matrix of size(No od depth point, No of feature vector)
48
49% Parameter
50[ImgResY ImgResX] = size(H2(:,:,1));
51   
52% define image and sample point and patch size infomation
53gridinfo = [Default.TrainHoriXSize Default.HoriXNuDepth Default.HoriXNuPatch; Default.TrainVerYSize Default.VertYNuDepth Default.VertYNuPatch];
54
55% Grid Info
56ratio(1:2) = gridinfo(:,1)./gridinfo(:,end);
57ratio(3:4) = gridinfo(:,1)./gridinfo(:,2);
58   
59% Patch shape infomation
60hcol = ones(floor(ratio(2)),1);
61hrow = ones(1,floor(ratio(1)));
62   
63if SupMaskFlag == 1 % Need to use irregular Superpixel Mask
64
65    % calculate how many mask we need
66   NuMask = ceil(gridinfo(:,2)./gridinfo(:,3));
67   
68   % calcuate the position of the mask
69   hight(1) = round((floor(ratio(2))-1)/2);
70   hight(2) = floor(ratio(2)) - 1 - hight(1);
71   width(1) = round((floor(ratio(1))-1)/2);
72   width(2) = floor(ratio(1)) - 1 - width(1);
73
74   row_start = 1;
75   f = [];
76   for j = 1:NuMask(1)
77       for k = 1:NuMask(2);
78           f_pics_mask = [];
79           fIndNew = fInd;
80           % first generate the mask respect to the dominate subsuperpixel
81           [mask,SupIndex,PixelMask,PatchMask] = makeSubSupMask(gridinfo, HiSupi, SmallSup, [j; k], width, hight);
82
83           % calculaing the normalize value
84           NormalizeValue = conv2(hcol,hrow,mask,'same');
85
86           % generate the 1:34 features for H2  for 1 center and 4 neighbor (left right top bottom)
87           for m = 1:17
88               %temp1 = conv2(hcol,hrow,H2(:,:,m).*(mask),'same');
89               temp = conv2(hcol, hrow, H2(:,:,m).*(mask), 'same');
90               f_pics_mask = [f_pics_mask temp(PixelMask)./NormalizeValue(PixelMask)...
91                             ./FeaMax(1,fIndNew)];
92               fIndNew = fIndNew+1;
93           end
94
95           f(PatchMask, row_start:row_start+size(f_pics_mask,2)-1) = f_pics_mask;
96       end
97   end
98   fInd = fIndNew;
99
100else
101   NormalizeValue = conv2(hcol,hrow,ones(ImgResY,ImgResX),'same');
102   DepthGridSizeY = ImgResY/Default.VertYNuDepth;
103   DepthGridSizeX= ImgResX/Default.HoriXNuDepth;
104   % 1) generating the PixelMask
105   PixelMask = logical(zeros(ImgResY,ImgResX));
106   [X Y] = meshgrid(ceil((1/2)*DepthGridSizeX:DepthGridSizeX:ImgResX),...
107                    ceil((1/2)*DepthGridSizeY:DepthGridSizeY:ImgResY));
108   PixelMask = sub2ind(size(PixelMask),Y(:),X(:));
109   for m = 1:17
110       temp = conv2(hcol,hrow,H2(:,:,m),'same');% 102.533776 seconds
111       f(:,m) = temp(PixelMask)./NormalizeValue(PixelMask)...
112                        ./FeaMax(1,fInd);
113       fInd = fInd +1;
114   end
115
116end
117
118return;
Note: See TracBrowser for help on using the repository browser.