Rasterize an alpha shape, export to bitmap
Afficher commentaires plus anciens
I build an alpha shape from some points (example given in code) and want to export the shape to a raster graphics format. I need the shape only, not the plot markings (axis, scales ect).
I need only the resulting triangle on white ground as a bitmap. Scale needs to be 1 unit = 1 pixel.
x = [0 10 20 30 30 30 15];
y = [0 0 0 0 15 30 15];
shape = alphaShape (x',y');
plot (shape, 'FaceColor', 'black');

I have not found anything on how to export shapes or how to rasterize them. Is there any way to do that?
Réponses (1)
F = getframe(gca);
imwrite(F.cdata, 'YourFile.png');
This exports a screenshot of the axes' contents to a PNG file. You can create the image manually also without the alphaShape function.
d = round(linspace(1, 200, 100));
x = 200:-1:1;
M = double(bsxfun(@gt, x, d'));
M3 = cat(3, M, M, M);
imwrite(M3, 'YourFile.png');
2 commentaires
Sir Askalot
le 22 Août 2017
This let the axes vanish:
set(gca, 'Visible', 'off');
drawnow;
Catégories
En savoir plus sur Lidar Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
