MATLAB/Octave: cut a lot of circles from a image

前端 未结 4 2003
刺人心
刺人心 2021-01-18 15:07

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

4条回答
  •  北海茫月
    2021-01-18 15:40

    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.

提交回复
热议问题