From: Kevin on
I have this image and I want to cut out a circle from it with an arbitrary center and radius that I can change. Can anyone help me with this code? I can cut out a square from the image easily but a circle is harder...Assume that the image is a large matrix and I am cutting a smaller matrix out of it.

Thanks in advance,
Kevin
From: Jan Simon on
Dear Kevin,

> I have this image and I want to cut out a circle from it with an arbitrary center and radius that I can change. Can anyone help me with this code? I can cut out a square from the image easily but a circle is harder...Assume that the image is a large matrix and I am cutting a smaller matrix out of it.

The points on a circle are defined by the equation:
(x - cx)^2 + (y - cy)^2 = r^2
with x and y are the coordinates of the points, cx, cy are the coordinates of the center and r is the radius.
To get a disk, use the points inside the circle.
Now you can create a mask using logical index to select all pixels of the image, which belong to the disk.

Good luck, Jan
From: Kevin on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i1mdns$slk$1(a)fred.mathworks.com>...
> Dear Kevin,
>
> > I have this image and I want to cut out a circle from it with an arbitrary center and radius that I can change. Can anyone help me with this code? I can cut out a square from the image easily but a circle is harder...Assume that the image is a large matrix and I am cutting a smaller matrix out of it.
>
> The points on a circle are defined by the equation:
> (x - cx)^2 + (y - cy)^2 = r^2
> with x and y are the coordinates of the points, cx, cy are the coordinates of the center and r is the radius.
> To get a disk, use the points inside the circle.
> Now you can create a mask using logical index to select all pixels of the image, which belong to the disk.
>
> Good luck, Jan

Hey Jan,

Thanks for your help, but can you give me a little more information about the mask and the logical index part? The circle equation and selecting all points inside of it, should be manageable code for me to write.

Thanks,
Kevin
From: Jan Simon on
Dear Kevin,

> Thanks for your help, but can you give me a little more information about the mask and the logical index part?

The documentation shipped with Matlab and the huge amount of posts in this newsgroup containing the term "logical indexing" are surely a quite better source for getting help.

Kind regards, Jan