[iacomb] [Up] [iaroi] | Image Creation |
Creates a binary image with dimensions given by s, rectangle dimensions given by r and center given by c. The pixels inside the rectangle are one and outside zero.
>>> F = iarectangle([7,9], [3,2], [3,4])
>>> print F
[[0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 1 1 0 0 0 0] [0 0 0 1 1 0 0 0 0] [0 0 0 1 1 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0]]
>>> F = iarectangle([200,300], [90,120], [70,120])
>>> iashow(F)
(200, 300) Min= 0 Max= 1 Mean=0.180 Std=0.38
F |
def iarectangle(s, r, c): rows, cols = s[0], s[1] rrows, rcols = r[0], r[1] y0, x0 = c[0], c[1] x, y = iameshgrid(range(cols), range(rows)) min_row, max_row = y0-rrows/2.0, y0+rrows/2.0 min_col, max_col = x0-rcols/2.0, x0+rcols/2.0 g1 = (min_row <= y) & (max_row > y) g2 = (min_col <= x) & (max_col > x) g = g1 & g2 return g
iacircle | Create a binary circle image. |
[iacomb] [Up] [iaroi] | |