필터 지우기
필터 지우기

what does an handle for imshow mean

조회 수: 1 (최근 30일)
Adithya Chakilam
Adithya Chakilam 2017년 1월 17일
답변: Image Analyst 2017년 1월 17일
What does this line mean? This is described as "Create a handle to an imshow figure for faster updating", but how?
hShow = imshow(zeros(480,640,3,'uint8'));
title('Security Camera');
  댓글 수: 2
Stephen23
Stephen23 2017년 1월 17일
편집: Stephen23 2017년 1월 17일
"but how"
How what ?
Adam
Adam 2017년 1월 17일
Faster updating comes from the fact you get a handle to the image object and you can then change individual properties of this (e.g. CData) rather than replotting the whole image if you are making changes to it.

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2017년 1월 17일
The handles, hShow, is used here:
set(hShow,'CData',object_detected);
By changing just the CData, which is the pixels themselves, you can update the screen much faster than calling imshow(). imshow() does some overhead (setting magnification, etc.) that slows down the process. This will not be noticeable for just a single call to imshow() but if you are doing it in real time -- video at 30 frames per second -- using imshow() will be noticeably slower than setting the CData property to the updated pixel array.

Stephen23
Stephen23 2017년 1월 17일
편집: Stephen23 2017년 1월 17일
According to the imshow documentation this syntax:
himage = imshow(___) returns the image object created by imshow.
If you do not know what graphics objects are, and how to use their handles, then you can learn about them in the documentation:
You will also find hundreds of tutorials online that introduce and explain graphics handles.
  댓글 수: 2
Adithya Chakilam
Adithya Chakilam 2017년 1월 17일
hey stephen, why dose he take time to add that line to the code when he can execute simply without that line. can you just say me the work done that by line?
Stephen23
Stephen23 2017년 1월 17일
편집: Stephen23 2017년 1월 17일
@Adithya Chakilam: aha, I think understand your question now: you want to know how this line speeds up the code (as the code comment states).
The answer is: it doesn't.
But that handle can be used later in the code to speed up the code quite a lot.
The handle to a graphics object (in this case an image object) can be used to access this object and change its properties. Changing the object properties is faster than calling imshow again, or calling other functions to change how this image is displayed. For example, you might plot some lines:
plot(X,Y)
and want to do this thousand of times in your code. It would be slow to call plot each time. Much faster would be to call plot once and return a handle to the line objects:
H = plot(X,Y);
and then later update the line data points:
set(H,'XData',1:3,'YData',[0,1,0])
You will learn more about this by reading the documentation links that I gave in my answer. For fast and robust code it is recommended to use graphics handles explicitly for every graphics operation: generating figures, axes, lines, etc. using the Parent property. For example do not simply call functions that assume the desired axes are the current axes.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by