I have an matrix (image) and information about interesting part within circles (center corrdinates and radii given). I want to cut for all the circles the parts of the matri
Try
mask = bsxfun(@lt, ((1:dim_y) - c(i,1)).^2, r(i)^2 - ((1:dim_x).' - c(i,2)).^2);
According to my MATLAB profiler, this is about 4 times faster than your version. Also, the B = A.*mask
line takes about the same amount of time as the original mask = ...
line. Not sure there's much you can do about that.