Rasterize an alpha shape, export to bitmap
Ältere Kommentare anzeigen
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?
Antworten (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 Kommentare
Sir Askalot
am 22 Aug. 2017
This let the axes vanish:
set(gca, 'Visible', 'off');
drawnow;
Kategorien
Mehr zu Lidar Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
