How to present a sequence of random images full screen?
2 views (last 30 days)
Show older comments
Sarah Jenner
on 5 Jan 2020
Commented: Image Analyst
on 7 Jan 2020
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
0 Comments
Accepted Answer
Image Analyst
on 5 Jan 2020
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 Comments
Image Analyst
on 7 Jan 2020
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?
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!