필터 지우기
필터 지우기

How to save volshow(data,config) as fig or img [volumeViewer]?

조회 수: 65 (최근 30일)
shubham kumar gupta
shubham kumar gupta 2023년 5월 11일
답변: Edmund Pickering 2023년 9월 14일
Hi, I was using this volshow() function from volume viewer i wanted to save the output as figure file or image of that figure.
I have exported the config file
I have the data
volshow() opens a window
h=volshow(data,config);
viewer = h.Parent;
hFig = viewer.Parent;
but hFig is blank
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 5월 12일
In my test, hFig is a figure with number [] and name '' -- but that does not mean that the figure is empty. It is a handle

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

채택된 답변

Simon Chan
Simon Chan 2023년 5월 12일
이동: Matt J 2023년 5월 12일
In case a new window is open after using function volshow, you should be able to find the figure object and save the image using function getframe as mentioned in the documentation.
vs = volshow(data);
obj = ancestor(vs,'figure','toplevel');
I = getframe(obj);
imshow(I.cdata);
  댓글 수: 2
Simon Chan
Simon Chan 2023년 5월 12일
Here is my test:
clear; clc;
vs = volshow(randi(10,[256 256 100]));
vs.Parent.Position = [0 0 300 250];
obj = ancestor(vs,'figure','toplevel');
set(obj,'Position',[580 230 300 250]);
pause(5);
F = getframe(obj);
f2 = figure('Position',[880 230 300 250]);
ax2 = axes(f2);
imagesc(ax2,F.cdata);

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

추가 답변 (2개)

Matt J
Matt J 2023년 5월 11일

Edmund Pickering
Edmund Pickering 2023년 9월 14일
I have this working with the following code.
% create viewer
viewer = viewer3d(BackgroundColor="white", GradientColor=[0.5 0.5 0.5],Lighting="on",BackgroundGradient="off");
% volshow
volBone = volshow(stack_(180:400,1:240,1179:1309)>250,'colormap',[214 184 150]/255,Parent=viewer);
% capture frame
frame = getframe(viewer.Parent);
If running in a loop, capturing succesive frames, I've found this helpful
viewer = viewer3d(...)
pause(5) % pause to give viewer time to fully open
for i = 1:...
viewer.clear % clear previous
pause(1) % pause to clear
volshow(...)
frame = getframe(viewer.Parent);
writeVideo(v,frame)
end

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by