Overlay a scale bar over a running movie

2 views (last 30 days)
Hi,
I have a GUI (made with GUIDE) in which an image sequence stored as a movie container is displayed inside an axes. The displayed movie is actually made of 2 movies, an original movie concatenated with a filtered movie. I made another GUI which opens on the press of a button, allowing the user to draw a scale bar with customizable length, color and location. I use a"line" graphics object to draw the scale bar, which works very well on the current frame in the movie. Since the line is a graphics object I guess we can store it as selected and use the handles inside the while loop, but when I do this only the handle to the line object is displayed in the workspace (eg. 180.223...) and not the scale bar on the movie.
I can't figure out how to get the scale bar still visible as the movie is playing without having to define it inside the loop. I do have the handles to the line, but I can't keep it displayed over the movie. I thought of using set(handles.ScaleBar,'HandleVisibility','on') but in vain.
Here is a simplified part of the code used to display the movie. Any clue would be really appreciated. Thanks.
while frame <= TotalTFrameNumber
if frame == 0 || frame == TotalTFrameNumber % Boundary conditions...
frame = 1; % i.e first frame
end
hold on
imshow(mov(frame).cdata,'parent',gca) % Display the current
frame in the axes.
%%%%This is where I would like to display the line/scale bar.
handles.ScaleBar = line(...); % It only displays the handles in the
workspace instead of actually drawing the line
hold off
drawnow
frame = frame +1;
if MovieIsPlaying == false % Stop condition, which stops the movie running
on the press of a button.
break;
end
end

Accepted Answer

Image Analyst
Image Analyst on 7 Mar 2014
Did you try the movie() function instead of imshow()?
  3 Comments
Image Analyst
Image Analyst on 7 Mar 2014
Well imshow probably wipes it away. The way around that is to write the image directly to the 'cdata' property of the axes instead of using imshow():
set(gca, 'CData', yourImage);
Try that. Hopefully doing that won't blow away the line once it's there. You should have to do it just once and it should stay there as long as you don't call imshow() or cla().

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!