In [18]:
import numpy as np
def circle(s, r, c):
rows, cols = s[0], s[1]
rr0, cc0 = c[0], c[1]
rr, cc = np.meshgrid(range(rows), range(cols), indexing='ij')
g = (rr - rr0)**2 + (cc - cc0)**2 <= r**2
return g
In [1]:
testing = (__name__ == "__main__")
if testing:
! jupyter nbconvert --to python circle.ipynb
import numpy as np
import sys,os
ia898path = os.path.abspath('../../')
if ia898path not in sys.path:
sys.path.append(ia898path)
import ia898.src as ia
In [2]:
if testing:
F = ia.circle([5,7], 2, [2,3])
print (F.astype(np.uint8))
In [4]:
if testing:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
f = ia.circle([200,300], 90, [100,150])
ia.adshow(f,'circle')