[iabwlp] [Up] [iaramp] Image Creation

iacircle
Create a binary circle image.

Synopsis

g = iacircle( s, r, c )

Implemented in Python.

Input

s Image. Gray-scale (uint8 or uint16) or binary image (logical).

[rows cols], output image dimensions.

r Double. Non-negative integer.

radius.

c Image. Gray-scale (uint8 or uint16) or binary image (logical).

[row0 col0], center of the circle.

Output

g Image. Binary image (logical).

Description

Creates a binary image with dimensions given by s, radius given by r and center given by c. The pixels inside the circle are one and outside zero.

Examples

>>> F = iacircle([5,7], 2, [2,3])

              
>>> print F
[[0 0 0 1 0 0 0]
 [0 0 1 1 1 0 0]
 [0 1 1 1 1 1 0]
 [0 0 1 1 1 0 0]
 [0 0 0 1 0 0 0]]

>>> F = iacircle([200,300], 90, [100,150])

              
>>> iashow(F)
(200, 300) Min= 0 Max= 1 Mean=0.424 Std=0.49
F

Equation

Source Code

def iacircle(s, r, c):
    rows, cols = s[0], s[1]
    y0, x0 = c[0], c[1]
    x, y = iameshgrid(range(cols), range(rows))
    g = (x - x0)**2 + (y - y0)**2 <= r**2
    return g
    

See also

iarectangle Create a binary rectangle image.
[iabwlp] [Up] [iaramp] http://www.python.org