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 );
  댓글 수: 1
Peter John
Peter John 2018년 11월 28일
Thank you so much!!

댓글을 달려면 로그인하십시오.

추가 답변 (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