How to present a sequence of random images full screen?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 个评论
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!