How to present a sequence of random images full screen?

조회 수: 2 (최근 30일)
Sarah Jenner
Sarah Jenner 2020년 1월 5일
댓글: Image Analyst 2020년 1월 7일
I'm trying to present a sequence of images in random order, where each randomly selected image is followed by an image of a fixation cross.
I've managed to write code to do this, however each time an image is presented, it starts in the small window and is then maximised. Is there a way to get it so that each image opens immediately full screen and the window stays constant throughout the sequence (similar to a powerpoint presentation?)
I have never done any coding before and I am a psychologist who usually deals with qualitative data so this is all very new to me and I have no idea what i'm doing! Any help would be much appreciated.
This is what I've got so far:
H = imread ('fixcross.jpg');
L = [ 'x','y','z'] ;
p = L(randi(numel(L)))
files = dir([p '\*.jpg']) ; % all jp gimages in folder
N = length(files) ; % total files
idx = randperm(N) ; % random order of numbers till N
for i = 1:N % loop for each file
A = files(idx(i)).name % Filename of random image
imread(A);
imshow(A);
set(gcf,'MenuBar','none')
set(gca,'DataAspectRatioMode','auto')
set(gca,'Position',[0 0 1 1])
set(gcf, 'Position', get(0, 'Screensize'));
pause(2);
imshow(H);
set(gcf,'MenuBar','none')
set(gca,'DataAspectRatioMode','auto')
set(gca,'Position',[0 0 1 1])
set(gcf, 'Position', get(0, 'Screensize'));
pause(0.5);
end

채택된 답변

Image Analyst
Image Analyst 2020년 1월 5일
Try this:
H = imread ('fixcross.jpg');
L = [ 'x','y','z'] ;
p = L(randi(numel(L)))
files = dir([p '\*.jpg']) ; % All jpg images in folder starting with one of the letters in L
%files = dir('*.jpg') ; % All jpg images in folder
numberOfFiles = length(files) % total files
randomIndexes = randperm(numberOfFiles); % random order of numbers till N
% Make a maximized figure with no tool bar and pulldown menus that are along top of figure.
hFig = figure('Toolbar', 'none', 'Menu', 'none', 'WindowState', 'maximized');
for k = 1 : numberOfFiles % loop for each file
% Display random image for 2 seconds.
thisFileName = files(randomIndexes(k)).name % Filename of random image
rgbImage = imread(thisFileName);
image(rgbImage);
axis('image', 'off');
pause(2);
% Display H image for 0.5 seconds.
image(H);
axis('image', 'off');
pause(0.5);
end
% Close the figure when done
close(hFig);
  댓글 수: 2
Sarah Jenner
Sarah Jenner 2020년 1월 7일
Thank you!! It did work but i've found that I actually need to download a separate piece of software called Psychtoolbox in order to achieve exactly what I want.
Image Analyst
Image Analyst 2020년 1월 7일
Glad it worked. Can you then "Accept this answer"?
I'm not familiar with that toolbox though I've heard of it. I guess it bundles together a bunch of MATLAB code into convenient functions for doing certain things. What does it do that makes it easier to use than using built-in MATLAB functions? What are you using it for?

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

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