How to choose image

2 次查看(过去 30 天)
Peter John
Peter John 2018-11-28
编辑: Peter John 2018-12-3
Hi all,
I'm initially randomly choosing two images from a folder (both with different specifications) and then I want to randomly display one on the left and one on the right. However, I don't know how to do the randomization before selecting them for either left or right.

采纳的回答

Jos (10584)
Jos (10584) 2018-11-28
Do not store them in two separate variables, but use a cell or struct array! It is the contents of variable that should vary, not the name ...
img{1} = imread( i1 );
img{2} = imread( i2 );
%drawing it on the back buffer
X = randperm(2) % [1 2] in random order
myTexture = Screen( 'MakeTexture', window, img{X(1)} );
Screen( 'DrawTexture', window, myTexture, [], rectL );
myTexture2 = Screen( 'MakeTexture', window, img{X(2)} );
Screen( 'DrawTexture', window, myTexture2, [], rectR );

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by