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

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

Added original make3d

File size: 5.2 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] = AbsFeatureGenMex(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] = makeSubSupMaskNew(gridinfo, HiSupi, SmallSup, [j; k], width, hight);
82%           [mask,SupIndex,PixelM,PatchMask] = makeSubSupMask(gridinfo, HiSupi, SmallSup, [j; k], width, hight);
83
84           % calculaing the normalize value
85 %          NormalizeValue = conv2(hcol,hrow,mask,'same');%///////////////////////////////////////////////
86
87           % generate the 1:34 features for H2  for 1 center and 4 neighbor (left right top bottom)
88           for m = 1:17
89               
90%               temp = conv2(hcol, hrow, H2(:,:,m).*mask, 'same');%///////////////////////////////////////////
91%               tt = temp(PixelM)./NormalizeValue(PixelM);
92%               vv =SparseAverageSample2D(H2(:,:,m), floor(ratio(2)), floor(ratio(1)),PixelMask,mask);
93%               [floor(ratio(1)), floor(ratio(2))]
94               f_pics_mask = [f_pics_mask SparseAverageSample2D(H2(:,:,m), floor(ratio(2)), floor(ratio(1)),PixelMask,double(mask))...
95                             ./FeaMax(1,fIndNew)];
96%               f_pics_mask = [f_pics_mask SparseAverageSample2D(H2(:,:,m).*mask, floor(ratio(1)), floor(ratio(2)),PixelMask)...
97%                             ./FeaMax(1,fIndNew)];
98               fIndNew = fIndNew+1;
99           end
100
101           f(PatchMask, row_start:row_start+size(f_pics_mask,2)-1) = f_pics_mask;
102       end
103   end
104   fInd = fIndNew;
105
106else
107   DepthGridSizeY = ImgResY/Default.VertYNuDepth;
108   DepthGridSizeX= ImgResX/Default.HoriXNuDepth;
109   % 1) generating the PixelMask
110%   PixelMask = logical(zeros(ImgResY,ImgResX));
111   [X Y] = meshgrid(ceil((1/2)*DepthGridSizeX:DepthGridSizeX:ImgResX),...
112                    ceil((1/2)*DepthGridSizeY:DepthGridSizeY:ImgResY));
113   %PixelMask = sub2ind(size(PixelMask),Y(:),X(:));
114   for m = 1:17
115       f(:,m) = SparseAverageSample2D(H2(:,:,m),floor(ratio(2)),floor(ratio(1)),[Y(:) X(:)], double(ones(size(H2(:,:,m)))))...
116                        ./FeaMax(1,fInd);
117       fInd = fInd +1;
118   end
119
120end
121
122return;
Note: See TracBrowser for help on using the repository browser.