如何保存背景图像并将其他人置于其上(使用Psychtoolbox)?

时间:2014-06-10 14:25:41

标签: image matlab location psychtoolbox

我们正在使用Matlab中的Psychtoolbox进行实验。我们想做的是将较小的图像(预先指定位置)放在较大的图像上。麻烦的是,一旦我们尝试将较小的背景图像置于其上,我们就会丢失背景图像。此外,每个图像始终居中,我们无法确定如何将图像放置在指定的位置。

我们尝试使用' DrawTextures'和' PutImage',但到目前为止失败了。你能帮助我们吗?

以下是我们的一些代码:

[w,screenrect]=Screen('OpenWindow',screennr);
Screen(w,'fillrect',background_color);
Screen('Flip', w);

sr = [0 0 s_grootte s_grootte];
dst = CenterRect(sr,screenrect);

nr=max(Screen('Screens'));
Screen('PutImage', w, image); %% image is defined beforehand, ofcourse

%% We want to put smaller images on top of this

for i = 1:n_images:

% coordinates should be picked randomly from beforehand specified matrix
location_number = r(1,i);
coordinates = locations(location_number,:);
x = coordinates(1,1);
y = coordinates(1,2);

%% Now we have selected the coordinates, we want to place the smaller image on 
%% that location

end

1 个答案:

答案 0 :(得分:0)

我发现自己该怎么做。问题是翻转屏幕的时间(将矩阵放在屏幕上)。

刺激的位置必须以这种方式编码:

Screen('DrawTexture',window,ImageArray,[size],[location])

大小和位置按此顺序编码:[左,上,右,下]。完成所有计算后,必须翻转屏幕,否则屏幕将被覆盖。希望我将来可以帮助其他人。