str2num for looping through images

1 次查看(过去 30 天)
Anand
Anand 2014-8-22
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

回答(1 个)

Image Analyst
Image Analyst 2014-8-22
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 个评论
Anand
Anand 2014-8-22
Sorry for the missing details. The while loop works and the 3 images are displayed. I'm just not sure how to use str2num for the trainer 1 .png to trainer 2 .png to trainer*3*.png and forward
Don't worry about the other details. They work :)
Image Analyst
Image Analyst 2014-8-22
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).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by