Vectorized supported saving using Computer Vision Toolbox

24 views (last 30 days)
Hi all!
My name is Alonso, and I'm here looking to a solution to my problem. I'm writting my thesis, so I want to have beautiful vectorized images in it regarding 3D mapping plots.
For obtaining this mapping plots, I'm using functions from the Computer Vision Toolbox. Concretely, this is the easy script that I'm implementing to gather these plots:
% Load the .pcd file
pc = pcread("~\mapping\lio_sam\nowake_pcd.pcd");
% Visualize the point cloud
figure;
pcshow(pc);
title('$\textbf{Estimated Point Cloud Visualization from LIO-SAM using Real Data}$', 'Interpreter', 'latex');
xlabel('$X$', 'Interpreter', 'latex');
ylabel('$Y$', 'Interpreter', 'latex');
zlabel('$Z$', 'Interpreter', 'latex');
% Set LaTeX interpreter for figure labels
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');
The problem comes, when I want to save this as a vectorized picture. I've tried the easiest ways, like trying to go trough the route of File-Save As and selecting the .svg/.eps format, but it didn't work. Even in this format, when zooming-in, I see a disorted image, with a very low resolution.
I also tried to configure the export options, and selecting the vectorized format, but in that way my MATLAB crashes.
I don't know if there's another way to obtain cool vectorized figures for point cloud data visualizations, so in case you know a different way I'll appreciate your guidance!
Thank you in advance,
Alonso

Answers (1)

Alberto Alvarez Polegre
Alberto Alvarez Polegre on 17 Apr 2024 at 6:42
Hi Alonso,
Using exportgraphics should work. See this example:
% Generate sample ply figure
ptCloud = pcread('teapot.ply');
% Plot point cloud
figure
pcshow(ptCloud)
% Set X and Y axis labels
xlabel("$X$","Interpreter","latex")
ylabel("$Y$","Interpreter","latex")
zlabel("$Z$","Interpreter","latex")
% Set axis font to LaTeX
set(gca,"TickLabelInterpreter","latex")
% Get current figure handler
h = gcf;
% Export vectorized figure
exportgraphics(h,'sample_figure.pdf','ContentType','vector','BackgroundColor','black')
If you're writing your thesis with LaTeX, you can insert the image by:
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{sample_figure.pdf}
\caption{Sample figure.}
\label{fig:sample_figure}
\end{figure}
Hope that helps!
Alberto

Categories

Find more on Printing and Saving 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!