Transform a 2D plot into a black and white image
2 次查看(过去 30 天)
显示 更早的评论
Hello.
I want to do something and i can not really think of any method to do it.
Here is the idea, I want to be able to transform a 2D closed shape plot ( like a square, a circle, a triangle,... ) into a 2D image, with the "interior" of the closed shape filled with white pixel, and the exterior of the shape with black pixels.
Do you think it is feasible, and if yes, by which means ?
Thank you very much !
2 个评论
jonas
2018-3-23
编辑:jonas
2018-3-23
Not sure exactly what you want as output, but I made you an image of a white square on a black background. Change data in fill to obtain any arbitrary shape
figure;
fill([-.5 .5 .5 -.5],[-.5 -.5 .5 .5],'w')
axis([-1 1 -1 1])
set(gca,'visible','off')
set(gcf,'color',[0 0 0])
F = getframe(gcf);
figure;
imshow(F.cdata)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!