如何保留背景图像并将其他图像放在它们上面(使用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

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

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

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

其中大小和位置按以下顺序编码:[Left, Top, Right, Bottom]。在所有计算完成后,必须翻转屏幕,否则屏幕将被覆盖。希望我以后能帮到别人。

最新更新