-
Notifications
You must be signed in to change notification settings - Fork 1
/
pickImage.m
79 lines (71 loc) · 2.58 KB
/
pickImage.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function [LeftTop,RightTop,LeftBottom,RightBottom,LeftTop2,RightTop2,LeftBottom2,RightBottom2,ImageList]=pickImage(TargetSide,ContentType,Match,EmotionType)
index={'a','b'}; index=Shuffle(index);
selectdrink=randperm(6);
selectalcohol=randperm(6);
if EmotionType == 1
emo = 'Neutral'; selectimage=randperm(6);
elseif EmotionType == 2
emo = 'Joy'; selectimage=randperm(6);
elseif EmotionType == 3
emo = 'Fear'; selectimage=randperm(6);
elseif EmotionType == 9
emo='Practice'; selectimage=randperm(6);
selectimage=randperm(4);
end
image1=[emo num2str(selectimage(1)) index{1} '_cropped']; % only image 1 and 2 can be targets
image2=[emo num2str(selectimage(2)) index{1} '_cropped'];
noMatchImage1=[emo num2str(selectimage(1)) index{2} '_cropped'];
noMatchImage2=[emo num2str(selectimage(2)) index{2} '_cropped'];
if ContentType < 3
image3=['Neutral' num2str(selectdrink(1))];
image4=['Neutral' num2str(selectdrink(2))];
else
image3=['Alcohol' num2str(selectalcohol(1))];
image4=['Alcohol' num2str(selectalcohol(2))];
end
if TargetSide < 3 % top
LeftTop=imread(['faces/' image1],'png');
RightTop=imread(['faces/' image2],'png');
LeftBottom=imread(['drinks/' image3],'png');
RightBottom=imread(['drinks/' image4],'png');
else % bottom
LeftBottom=imread(['faces/' image1],'png');
RightBottom=imread(['faces/' image2],'png');
LeftTop=imread(['drinks/' image3],'png');
RightTop=imread(['drinks/' image4],'png');
end
if Match == 0
if TargetSide == 1 % top left
LeftTop2=imread(['faces/' noMatchImage1],'png'); changedimage=noMatchImage1;
RightTop2=RightTop;
LeftBottom2=LeftBottom;
RightBottom2=RightBottom;
elseif TargetSide == 2 % top right
RightTop2=imread(['faces/' noMatchImage2],'png'); changedimage=noMatchImage2;
LeftTop2=LeftTop;
LeftBottom2=LeftBottom;
RightBottom2=RightBottom;
elseif TargetSide == 3 % bottom left
LeftBottom2=imread(['faces/' noMatchImage1],'png'); changedimage=noMatchImage1;
LeftTop2=LeftTop;
RightTop2=RightTop;
RightBottom2=RightBottom;
elseif TargetSide == 4 % bottom right
RightBottom2=imread(['faces/' noMatchImage2],'png'); changedimage=noMatchImage2;
LeftTop2=LeftTop;
RightTop2=RightTop;
LeftBottom2=LeftBottom;
end
else
LeftTop2=LeftTop;
RightTop2=RightTop;
LeftBottom2=LeftBottom;
RightBottom2=RightBottom;
changedimage='NoChange';
end
ImageList{1,1}=image1;
ImageList{1,2}=image2;
ImageList{1,3}=image3;
ImageList{1,4}=image4;
ImageList{1,5}=changedimage;
end