Question

I am trying to cut out the circle from the image using Matlab.

c(1) and c(2) are x,y coordinates to the center of circle and r is the radius.

mask = bsxfun(@plus, (1:256) - c(1)^2, (transpose(1:256) - c(2)^2)) < r^2;

figure
imshow(im(mask));

Everything seems to work but instead of mask I am getting a vector.

Was it helpful?

Solution

It is the ((1:256) - c(1))^2 instead of (1:256) - c(1)^2

mask = bsxfun(@plus, ((1:256) - c(1)).^2, (transpose(1:256) - c(2)).^2) < r^2;

figure
imshow((mask));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top