Reputation: 23
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.
Upvotes: 1
Views: 1164
Reputation: 12689
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));
Upvotes: 1