File Exchange

image thumbnail

ellipseMatrix(y0, x0, a, b, theta, im, c1, c2, pInterp)

version 1.3 (1.48 KB) by

Drawing an ellipse into a matrix image.



View License

Set the elements of the matrix im which are in the interior of the
ellipse E to the value 'c1'. The ellipse E has center (y0, x0), the
major axis = a, the minor axis = b, and theta is the angle made by the
major axis with the orizontal axis.
ret = ellipseMatrix(y0, x0, a, b, theta, im, color)
ret is a matrix of the same size as the matrix im.
The input parameters c2 and pInterp are optional. If they are present
the ellipse will have a smoother border (of size pInterp pixels) with
variations of color between c1 and c2.
Function: ellipseMatrix
Version: 1.2
% October 14, 2014
% Author: Nicolae Cindea

Comments and Ratings (6)

Henry Tsang

This code sets elements WITHIN the ellipse to value 'color'. Where can I modify it such that as long as the element touches (and need not be fully enclosed) by the ellipse to also set value to 'color'?


Athi (view profile)

piao lin

very useful for me ,Thank you very much

Gaurav Jain

Gaurav Jain (view profile)

Works well, Thank you for posting this.


Tony (view profile)

Very good ellipse function.

Eric Dick

This is a great function for creating ellipses in an image matrix. Since circles are simplified ellipses it can be used to make those too. V1.1 puts a single pixel nerd on the NSEW ends for the circle (semimajor = semiminor) and for some ellipses.



fixing some typos in the description


An example of utilisation is added.


A simpler code and some new options.

MATLAB Release
MATLAB 7.13 (R2011b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today