source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/LearningCode/Features/OldBatchVersion/GenTextureFeature.m @ 86

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

Added original make3d

File size: 5.5 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 [TextureFeature]=GenTextureFeature(Default, Img, SmallSup, HiSup, FeatureType)
40
41% This function calculate all features that using the
42% output from calculateFilterBanks_old (Time and ram comsuming)
43% These Feature including AbsFeature DiffFeature HistogramFeature
44% FeatureTypr:            1          2           3
45
46% Interface:
47% Input---
48% 1) Default is the structure contain all the default parameter setting
49% 2) Img is the RGB image matrix
50% 3) SmallSup is Superpixel index matrix of size Default.VertYNuDepth Default.HoriXNuDepth
51% 4) HiSup is HiResolution Superpixel index matrix of size Default.SegVertYSize Default.SegHoriXSize or smaller
52% 5) FeatureType AbsFeature(1) DiffFeature(2) HistogramFeature(3)
53% Output---
54% 1) TextureFeature.Abs:
55% 2) TextureFeature.Diff:
56% 3) TextureFeature.Hist:
57
58
59% Flag set up for testing purpose ========================================
60% Must be stablized after testing XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
61NormalizeFlag = 1; % NormalizeFlag set to 1 if we want to normalize the Feature according to the Trainning Set
62DominateSupFilter = 1; % DominateSupFilter set to 1 if we want to use only the dominate superpixel area for acerage feature calculation
63% ========================================================================
64
65% load FeaMax to do normalizeing
66load([Default.GeneralDataFolder '/FeaMax.mat']);
67if NormalizeFlag == 1
68   FeaMax = 10.^floor(log10(FeaMax));
69else
70   FeaMax(:) = 1;
71end
72
73% Initial Setting of TextureFeature Structure:
74% size(TextureFeature.Abs) = (No of Depth Point, No of Features: 17 texture filters, H2 and H4 kinds, 3 Scales)
75TextureFeature.Abs = zeros(Default.VertYNuDepth*Default.HoriXNuDepth, 17*2*3);
76TextureFeature.Diff = zeros(1,1);
77TextureFeature.Hist = zeros(1,1);
78
79% Start the loop for 3 Scale
80fInd = 2;
81for i = 1:3
82   
83    if DominateSupFilter && i==1 % only if DominateSupFilter and the largest scale will use superpixel mask
84       SupMaskFlag = 1;
85    else
86       SupMaskFlag = 0;
87    end 
88 
89    % Scale Setting
90    ResY = round(Default.TrainVerYSize/(3^(i-1))); % ResY ResX will be the new image size     
91    ResX = round(Default.TrainHoriXSize/(3^(i-1)));
92    Img = imresize(Img,[ResY ResX],'nearest');
93
94    % Generate the 17 texture filter output
95    [H2] = calculateFilterBanks_old(Img); % (hard work 1min) use Ashutaosh's code
96    H2 = H2.^2; % Now H2 stand for H2 22222222222222222222222222222222222222222222222222222222222222222222222222222
97 
98    if any(FeatureType == 1) % calculate the AbsFeatures
99       StartAbs = 34*(i-1)+1;
100%       [TextureFeature.Abs(:, (StartAbs):(StartAbs+16)) fInd]= AbsFeatureGenMex(Default, H2, SmallSup, HiSup, SupMaskFlag, FeaMax, fInd);
101       [TextureFeature.Abs(:, (StartAbs):(StartAbs+16)) fInd]= AbsFeatureGenMex(Default, H2, SmallSup, HiSup, SupMaskFlag, FeaMax, fInd);
102    end
103
104    if any(FeatureType == 3) % calculate the HistogramFeature
105       [relativeFeatureVector] = makeRelativeFeatureVector(H2,1);
106    end
107
108    if any(FeatureType == 2) % calculate the DiffFeature
109
110    end
111    % 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
112
113    H2 = H2.^2; % This H2 is H4 44444444444444444444444444444444444444444444444444444444444444444444444444444444444
114
115    if any(FeatureType == 1) % calculate the AbsFeatures
116       StartAbs = 34*(i-1)+1+17;
117%       [TextureFeature.Abs(:, (StartAbs):(StartAbs+16)) fInd]= AbsFeatureGenMex(Default, H2, SmallSup, HiSup, SupMaskFlag, FeaMax, fInd);
118       [TextureFeature.Abs(:, (StartAbs):(StartAbs+16)) fInd]= AbsFeatureGenMex(Default, H2, SmallSup, HiSup, SupMaskFlag, FeaMax, fInd);
119    end
120    % 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
121    clear H2;
122end
123
124return;
Note: See TracBrowser for help on using the repository browser.