Here's a code snippet in MATLAB that creates a binary circular mask with center at (x, y) and radius r:
main.m323 chars13 lines
This code creates a grid of points and computes the distance of each point on the grid from the center of the circle. Then, a binary mask is created where each pixel inside the circle is set to 1 and outside the circle is set to 0.
gistlibby LogSnag