Best way to export image / animation from GUI, including colorbar
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi, am am trying to export a graphics file from a uifigure. The plot has several layers and elements, and also features a colorbar outside of the axes. I tried getframe(gcf) and getframe(gca), both are not suitable (one does not include the colorbar, the other does include the whole uifigure, see attachments).
In the past, I was copying all elements from the uifigure to a new, invisible figure using copyobj, then using getframe(gca) to get a clean image that includes the colorbar. But this involves a lot of extra code to deal with all the details, and this is prone to errors I think.
I wonder if there are good ways to achieve this?
My GUI does not only display still images, but also image sequences. Hence, I additionally want to write videofiles directly from this Matlab GUI. So I think exportfig is not really an option?
Thanks for your input!
댓글 수: 2
Mario Malic
2023년 11월 13일
I would suggest to output an image, open it and remove the portion which you don't want to be in the picture. By this, I mean to "crop" the part you want to save.
답변 (1개)
William Thielicke
2023년 11월 13일
댓글 수: 2
Viktor Janzen
2024년 4월 9일
I have a similar problem. Because I am offering my uifigure within a webapp, it is not possible to open a second figure (visible or hidden), beacuse Web Apps do not support multi-window application.
I had a solution with getframe. But the big problem with getframe is that it makes a snapshot from the whle uiffigure, considering also all hidden UI components and then reduces the frame to the axes, which is the input argument. For my animation it takes about 4 seconds per frame.
I tested with deleting many hidden UI components. Then it takes half of the time.
You can also put the uifigure as input argument. Then a video from the whole app is made.
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!