zuo
zuo

Reputation: 11

How can i create circles in a image ....not using plot function?

basically, i am supposed to create a image with circles and lines... not using plot function. because the final output is to pop out by imshow().or image().or imagesc()... and the created image will contiune the color processing.

Upvotes: 1

Views: 5190

Answers (3)

Amro
Amro

Reputation: 124563

If you are trying to draw lines and circles directly on a raster image (matrix of pixels), then check out the Bresenham line-drawing algorithm and its variants for circles.

I am sure you can find existing implementations for them on FEX

Another possibility is to show the image (IMSHOW, IMAGESC, ..), use the plotting functions as usual (PLOT, LINE, ...), then grab the displayed figure as image again using GETFRAME as Nzbuu suggested.

Upvotes: 1

John
John

Reputation: 5915

Use the matlab function "rectangle" and specify the 'Curvature" parameter to one. i.e.

rectangle('Position',[0 0 100 100],'Curvature',[1 1])

This is obviously counter intuitive, but in Matlab, rectangle is the function you use to draw ellipses and circles.

Here is the appropriate mathworks doc:

http://www.mathworks.com/help/techdoc/ref/rectangle.html

Upvotes: 0

Nzbuu
Nzbuu

Reputation: 5251

The simplest way is to draw it as usual, then use getframe to grab an image of the figure.

EDIT: I don't have time for much detail, but look at the following:

The MATLAB help is really very useful.

Upvotes: 1

Related Questions