str2num for looping through images
2 views (last 30 days)
Show older comments
Hi Everyone! I'm trying to have a for loop that will cycle through multiple images. Take my trainer pic for example. There are 3 pictures. Instead of reading the file 3 times, can someone help?
Keep in mind the following
- trainer1.png,trainer2.png, and trainer3.png are 3 different pictures
- trainerPic is the axes in which it will be displayed
Here's what I have:
[handles.v1,handles.b,handles.a1] = imread('trainer1.png');
[handles.v2,handles.b,handles.a2] = imread('trainer2.png');
[handles.v3,handles.b,handles.a3] = imread('trainer3.png');
i=true
while(i==true)
% trainer sequence
axes(handles.trainerPic)
handles.V = imshow(handles.v1)
set(handles.V,'AlphaData',handles.a1)
pause(0.3)
handles.V = imshow(handles.v2)
set(handles.V,'AlphaData',handles.a2)
pause(0.3)
handles.V = imshow(handles.v3)
set(handles.V,'AlphaData',handles.a3)
end
0 Comments
Answers (1)
Image Analyst
on 22 Aug 2014
What is handles.a1, a2, and a3? Where did you see that imread() returns 3 outputs? What do you think the third output is supposed to be? I've never used more than 2 outputs and don't see anything in the help about 3 outputs.
2 Comments
Image Analyst
on 22 Aug 2014
I'm really not sure what you want to do and why you have a loop. Do you want to show images #2 and 3 in the overlay (alpha channel) above image #1? Or maybe you want to process a sequence of images, like the FAQ shows you http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Let us know if we can help further (after you explain better).
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!