Constructing image data as dictionaries

7 visualizaciones (últimos 30 días)
Sankalp R
Sankalp R el 8 de Jul. de 2019
Respondida: Jalaj Gambhir el 19 de Jul. de 2019
I need to create dictionaries of my image dataset to run an implementation of a research paper. But I have no ideo how to.
I'm including the snippets of code
load('AR_1260_occu')
for n=1:1 % Controlling R index
trainDict= AR_1260_neutral; %trainDict= AR_1260_neutral12;
train_faces=igo(trainDict,u,v); train_facesL2=igo2(trainDict,u,v); train_facesL3=igo3(trainDict,u,v);
alpha = 100; % balancing parameter
people=100; % How many people
M=size(train_faces,1);
trainsize=size(train_faces,2); testsize=size(r,2);
factor_train=trainsize/people;
count=0; countS1=0; countS2=0; countS3=0;
a1=1; a2=1e-6; % Parameters for NIG
end
In the function called igo,
function y=igo(x,a,c)
[s1,s2]=size(x);
y=zeros(s1,s2);
if s1==1260
nn=[42 30];
end
for i=1:s2
t1=reshape(x(:,i),nn);
fh=[-1 0 1;-2 0 2;-1 0 1]; fv=[-1 -2 -1;0 0 0;1 2 1]; % Sobel Filter can be change to others
Gh=filter2(fh,t1); Gv=filter2(fv,t1);
t2=tanh(a*(Gv./Gh-c));
%t2=atan(a*(Gv./Gh-c));
% t2= d*sigmf(Gv./Gh,[a c]);
% t2 = softsign(Gv./Gh,[a c]);
y(:,i)=reshape(t2,[s1,1]);
y(find(isnan(y)==1))=0;
end
end
I hope this information is enough. The dictionaries, as I think, are AR_1260_occu, AR_1260_neutral and AR_1260_neutral12.

Respuestas (1)

Jalaj Gambhir
Jalaj Gambhir el 19 de Jul. de 2019
Hi,
The code does not provide information on the keys and values used in the dictionary. You can use containers.Map to create a key-value pairs according to your use. You can create the same by:
keys = {1,2,4,5}
values = {'one','two','four','five'}
Dict = containers.Map(keys,values)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by