Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何保存背景图像并将其他图像置于其上(使用Psychtoolbox)?_Image_Matlab_Location_Psychtoolbox - Fatal编程技术网

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

Image 如何保存背景图像并将其他图像置于其上(使用Psychtoolbox)?,image,matlab,location,psychtoolbox,Image,Matlab,Location,Psychtoolbox,我们正在使用Matlab中的Psychtoolbox进行实验。我们要做的是把较小的图像放置在一个较大的图像上。问题是,一旦我们尝试将较小的图像放在背景图像上,就会丢失背景图像。此外,每个图像始终居中,我们很难确定如何将图像放置在指定的位置 我们曾尝试使用“DrawTextures”和“PutImage”来实现这一点,但到目前为止还没有成功。你能帮我们吗 以下是我们的一些代码: [w,screenrect]=Screen('OpenWindow',screennr); Screen(w,'fill

我们正在使用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])

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

发布一些最简单的代码,以便我们能够看到确切的问题