How could I update the imshow?

10 views (last 30 days)
Shaofan Guo
Shaofan Guo on 26 Feb 2017
Commented: Shaofan Guo on 27 Feb 2017
Hi,all,
I have a GUI which receive the data through the serial port continuously. And I want to use these data to show the location trace in the picture using imshow.
Afterwards I realize the memory is reduced bacause I continuing creat a new image in the same axes.
So I would like to know how can I updating the imshow rather than creating a new image.
ditu =imread('google.bmp');
[M,N]=size(ditu(:,:,1))
ditu((M-y-1):(M-y+1),((x-1):(x+1)),1)=255;
ditu((M-y-1):(M-y+1),((x-1):(x+1)),2)=0;
ditu((M-y-1):(M-y+1),((x-1):(x+1)),3)=0;
imshow(ditu, 'Parent', handles.axes1);
Thank you,
Shaofan

Accepted Answer

Image Analyst
Image Analyst on 26 Feb 2017
Calling imshow() multiple times will put multiple images into your axes. To avoid that and keep just one image at a time in there, use cla or cla reset
axes(handles.axes1);
cla reset;
imshow(ditu, 'Parent', handles.axes1);
  1 Comment
Shaofan Guo
Shaofan Guo on 27 Feb 2017
thanks! This method truely solved my problem.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects 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!