Advertisement
KDOXG

circle

Nov 24th, 2020
3,378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.45 KB | None | 0 0
  1. function out = circle(Im,value,center_x,center_y,r)     #Image to insert a circle, the color value of the circle, the x coordinate of the circle center, the y coordinate of the circle center, the radius of the circle
  2.   out = [];
  3.   if value != 0 && value != 1
  4.     return
  5.   endif
  6.   for i = 1:rows(Im)
  7.     for j = 1:columns(Im)
  8.       Im(i,j) = ifelse(sqrt((j-center_x)^2 + (i-center_y)^2) <= r,value,Im(i,j));
  9.     endfor
  10.   endfor
  11.   out = Im;
  12. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement