Filter löschen
Filter löschen

Transform a 2D plot into a black and white image

6 Ansichten (letzte 30 Tage)
Boris Huljak
Boris Huljak am 23 Mär. 2018
Kommentiert: Boris Huljak am 26 Mär. 2018
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 Kommentare
jonas
jonas am 23 Mär. 2018
Bearbeitet: jonas am 23 Mär. 2018
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)
Boris Huljak
Boris Huljak am 26 Mär. 2018
Sorry if I was not clear enough.
Your code helped me indeed ! Thank you very much.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by