How to convert a volumetric image into a video frame?
26 views (last 30 days)
Show older comments
Hi everyone! I am working on converting a batch of volumetric images (H x W x D) into a video, in order to show the evolution process of the volume. However, the 'volshow' function that is widely used to display volumetric data in MATLAB seems to output a 'Volume' object rather than a 'Image' object, which does not allow to form a frame in a video (provided by the 'writeVideo' function). Could you please help solve this issue? Thank you so much!
0 Comments
Accepted Answer
Poorna
on 4 Apr 2024
Hi Shuaibin,
I see you want a capture the output of the "volshow" function as an image so that you could create a video from the images showing the evolution of the volume.
You could use the "getframe" function to capture the current data as shown in the figure as a movie frame. The input to the "getframe" function is the figure object the output of "volshow" is using.
And then you can use the "frame2im" function to convert the frame object to rgb data.
For example, you could do as below
%vol is the volumetric data that you want to visualize
h = volshow(vol);
fig = h.parent.parent; %get the figure object
F = getframe(fig); %get the current frame
rgb = frame2im(F); %convert the frame to rgb data
To know more about "getframe" and "frame2im" functions, refer to the following documentation:
You can also refer to the "Create Animation of Rotating Volume" section from the following documentation. The example uses "getframe" function to generate a gif from the output of the "volshow" function:
Hope this Helps!
More Answers (0)
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!