How to save volshow(data,config) as fig or img [volumeViewer]?
    40 views (last 30 days)
  
       Show older comments
    
    shubham kumar gupta
      
 on 11 May 2023
  
    
    
    
    
    Answered: Edmund Pickering
 on 14 Sep 2023
            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 Comment
  Walter Roberson
      
      
 on 12 May 2023
				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
Accepted Answer
  Simon Chan
      
 on 12 May 2023
        
      Moved: Matt J
      
      
 on 12 May 2023
  
      2 Comments
  Simon Chan
      
 on 12 May 2023
				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);

More Answers (2)
  Edmund Pickering
 on 14 Sep 2023
        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
0 Comments
See Also
Categories
				Find more on Basic Display 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!



