Gender identification using Deep Learning (Matlab code)
Coding:
%
Matlab code: Complete Joint-scale LBP
%----------------------------------------
rootpic
= 'Outex_TC_00010\';
%
picture number of the database
picNum
= 4320;
%
Radius and Neighborhood
R=[1
2 3];
R
= sort(R,'descend')
P=8;
%
Sample points Extraction
for i=1:length(R)
sp
= Sample_points(R(i),R(i)*8);
spoints{i}=sp;
end
%
genearte CLBP features
patternMappingriu2
= getmapping(P,'riu2');
for i=1:picNum;
filename = sprintf('%s\\images\\%06d.ras', rootpic, i-1);
Gray = imread(filename);
Gray = im2double(Gray);
Gray =
(Gray-mean(Gray(:)))/std(Gray(:))*20+128; %
image normalization, to remove global intensity
[CJLBP_S,CJLBP_M,CJLBP_C] =
CJLBP(Gray,R,P,patternMappingriu2,'x',spoints);
%
Generate histogram of CLBP_S
CJLBP_SH(i,:) =
hist(CJLBP_S(:),0:patternMappingriu2.num-1);
%
Generate histogram of CLBP_M
CJLBP_MH(i,:) =
hist(CJLBP_M(:),0:patternMappingriu2.num-1);
%
Generate histogram of CLBP_M/C
CJLBP_MC = [CJLBP_M(:),CJLBP_C(:)];
Hist3D =
hist3(CJLBP_MC,[patternMappingriu2.num,2]);
CJLBP_MCH(i,:) =
reshape(Hist3D,1,numel(Hist3D));
%
Generate histogram of CLBP_S_M/C
CJLBP_S_MCH(i,:) =
[CJLBP_SH(i,:),CJLBP_MCH(i,:)];
%
Generate histogram of CLBP_S/M
CJLBP_SM = [CJLBP_S(:),CJLBP_M(:)];
Hist3D =
hist3(CJLBP_SM,[patternMappingriu2.num,patternMappingriu2.num]);
CJLBP_SMH(i,:) =
reshape(Hist3D,1,numel(Hist3D));
%
Generate histogram of CLBP_S/M/C
CJLBP_MCSum = CJLBP_M;
idx = find(CJLBP_C);
CJLBP_MCSum(idx) =
CJLBP_MCSum(idx)+patternMappingriu2.num;
CJLBP_SMC = [CJLBP_S(:),CJLBP_MCSum(:)];
Hist3D =
hist3(CJLBP_SMC,[patternMappingriu2.num,patternMappingriu2.num*2]);
CJLBP_SMCH(i,:) = reshape(Hist3D,1,numel(Hist3D));
end
%
read picture ID of training and test samples, and read class ID of
%
training and test samples
trainTxt
= sprintf('%s000\\train.txt', rootpic);
testTxt
= sprintf('%s000\\test.txt', rootpic);
[trainIDs,
trainClassIDs] = ReadOutexTxt(trainTxt);
[testIDs,
testClassIDs] = ReadOutexTxt(testTxt);
%
classification test using CLBP_S, original LBP
trains
= CJLBP_SH(trainIDs,:);
tests
= CJLBP_SH(testIDs,:);
trainNum
= size(trains,1);
testNum
= size(tests,1);
DistMat
= zeros(P,trainNum);
DM
= zeros(testNum,trainNum);
for i=1:testNum;
test = tests(i,:);
DM(i,:) = distMATChiSquare(trains,test)';
end
CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
%
classification test using CLBP_M
trains
= CJLBP_MH(trainIDs,:);
tests
= CJLBP_MH(testIDs,:);
trainNum
= size(trains,1);
testNum
= size(tests,1);
DistMat
= zeros(P,trainNum);
DM
= zeros(testNum,trainNum);
for i=1:testNum;
test = tests(i,:);
DM(i,:) = distMATChiSquare(trains,test)';
end
CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
%
classification test using CLBP_M/C
trains
= CJLBP_MCH(trainIDs,:);
tests
= CJLBP_MCH(testIDs,:);
trainNum
= size(trains,1);
testNum
= size(tests,1);
DistMat
= zeros(P,trainNum);
DM
= zeros(testNum,trainNum);
for i=1:testNum;
test = tests(i,:);
DM(i,:) = distMATChiSquare(trains,test)';
end
CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
%
classification test using CLBP_S_M/C
trains
= CJLBP_S_MCH(trainIDs,:);
tests
= CJLBP_S_MCH(testIDs,:);
trainNum
= size(trains,1);
testNum
= size(tests,1);
DistMat
= zeros(P,trainNum);
DM
= zeros(testNum,trainNum);
for i=1:testNum;
test = tests(i,:);
DM(i,:) = distMATChiSquare(trains,test)';
end
CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
%
classification test using CLBP_S/M
trains
= CJLBP_SMH(trainIDs,:);
tests
= CJLBP_SMH(testIDs,:);
trainNum
= size(trains,1);
testNum
= size(tests,1);
DistMat
= zeros(P,trainNum);
DM
= zeros(testNum,trainNum);
for i=1:testNum;
test = tests(i,:);
DM(i,:) = distMATChiSquare(trains,test)';
end
CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
%
classification test using CLBP_S/M/C
trains
= CJLBP_SMCH(trainIDs,:);
tests
= CJLBP_SMCH(testIDs,:);
trainNum
= size(trains,1);
testNum
= size(tests,1);
DistMat
= zeros(P,trainNum);
DM
= zeros(testNum,trainNum);
for i=1:testNum;
test = tests(i,:);
DM(i,:) = distMATChiSquare(trains,test)';
end
CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
No comments