How to capture the view in volshow as an image?

53 ビュー (過去 30 日間)
Lars Nelson
Lars Nelson 2023 年 5 月 9 日
移動済み: Matt J 2023 年 9 月 14 日
I have rendered a volume using volshow in viewer3d (shown below). I would like to save a capture of this view similarly to how I have taken a Windows screenshot below but without needing to use Windows screenshot so that I can automate my code to load in these volumes and output images of the desired view.
Print, saveas, and imsave do not seem to be working for this.

採用された回答

Matt J
Matt J 2023 年 5 月 9 日
編集済み: Matt J 2023 年 5 月 9 日
  2 件のコメント
Lars Nelson
Lars Nelson 2023 年 5 月 9 日
Thank you! I'm still interested as to whether or not there's a way to create an image in a figure of the current view so that you could utilize MATLAB's normal image saving options. Is this function the only way you can think of to do this?
Matt J
Matt J 2023 年 5 月 9 日
編集済み: Matt J 2023 年 5 月 9 日
Yes. volshow is not part of the mainstream graphics system. I don't like it any more than you do.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2023 年 5 月 12 日
I'm still interested as to whether or not there's a way to create an image in a figure of the current view so that you could utilize MATLAB's normal image saving options.
This example shows how to do so with getframe:
  2 件のコメント
Lars Nelson
Lars Nelson 2023 年 5 月 12 日
I also found a method by opening up a uifigure first and then placing the 3D viewer and volshow in that. That way you can use exportapp to capture an image.
Edmund Pickering
Edmund Pickering 2023 年 9 月 14 日
移動済み: Matt J 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

サインインしてコメントする。

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by