# Synopse

Superpose points, rectangles and lines on an image.

• y = iadrawv(f, data, value, GEOM)
• y: Image
• f: Image
• data: Image vector of points. Each row gives information regarding a geometrical primitive. The interpretation of this data is dependent on the parameter GEOM.
• value: Image pixel gray-scale value associated to each point in parameter data. It can be a column vector of values or a single value.
• GEOM: String geometrical figure. One of 'point','line', 'rect', or 'frect' for drawing points, lines, rectangles or filled rectangles respectively.
```01. from numpy import *
02. from string import upper
03.
04. def iadrawv(f, data, value, GEOM):
05.
06.     GEOM  = GEOM.upper()
07.     data  = array(data)
08.     y     = array(f)
09.     value = array(value)
10.     lin, col = data[1,:], data[0,:]
11.     i = lin*f.shape[1] + col
12.     i = i.astype(int32)
13.     if len(f.shape) == 1: f = f[newaxis,:]
14.     if value.shape == (): value = value + zeros(lin.shape)
15.     if len(lin) != len(value):
16.         print 'Number of points must match n. of colors.'
17.         return None
18.     if GEOM == 'POINT':
19.         ravel(y)[i] = value
20.     elif GEOM == 'LINE':
21.         for k in range(len(value)-1):
22.             delta = 1.*(lin[k+1]-lin[k])/(1e-10 + col[k+1]-col[k])
23.             if abs(delta) <= 1:
24.                 if col[k] < col[k+1]: x_ = arange(col[k],col[k+1]+1)
25.                 else                : x_ = arange(col[k+1],col[k]+1)
26.                 y_ = floor(delta*(x_-col[k]) + lin[k] + 0.5)
27.             else:
28.                 if lin[k] < lin[k+1]: y_ = arange(lin[k],lin[k+1]+1)
29.                 else                : y_ = arange(lin[k+1],lin[k]+1)
30.                 x_ = floor((y_-lin[k])/delta + col[k] + 0.5)
31.             i_ = y_*f.shape[1] + x_; i_ = i_.astype(int32)
32.             ravel(y)[i_]=value[k]
33.     elif GEOM == 'RECT':
34.         for k in range(data.shape[1]):
35.             d = data[:,k]
36.             x0,y0,x1,y1 = d[1],d[0],d[3],d[2]
37.             y[x0:x1,y0]   = value[k]
38.             y[x0:x1,y1]   = value[k]
39.             y[x0,y0:y1]   = value[k]
40.             y[x1,y0:y1+1] = value[k]
41.     elif GEOM == 'FRECT':
42.         for k in range(data.shape[1]):
43.             d = data[:,k]
44.             x0,y0,x1,y1 = d[1],d[0],d[3],d[2]
45.             y[x0:x1+1,y0:y1+1] = value[k]
46.     else:
47.         print "GEOM should be 'POINT', 'LINE', 'RECT', or 'FRECT'."
48.     return y```

# Description

iadrawv creates the image y by a superposition of points, rectangles and lines of gray-level k1 on the image f. The parameters for each geometrical primitive are defined by each line in the 'data' parameter. For points, they are represented by a matrix where each row gives the point's row and column, in this order. For lines, they are drawn with the same convention used by points, with a straight line connecting them in the order given by the data matrix. For rectangles and filled rectangles, each row in the data matrix gives the two points of the diagonal of the rectangle, where the points use the same row, column convention.

# Examples

## Example 1

```01. from ia870 import iadrawv
02.
03.
04. f=uint8(zeros((3,5)))
05. pcoords=array([[0,2,4],
06.                 [0,0,2]])
07. pvalue=uint8([1,2,3])
10. rectcoords= array([[0],
11.                    [0],
12.                    [3],
13.                    [2]])
```[[1 0 2 0 0]
[0 0 0 0 0]
[0 0 0 0 3]]
[[1 1 2 0 0]
[0 0 0 2 0]
[0 0 0 0 2]]
[[5 5 5 5 0]
[5 0 0 5 0]
[5 5 5 5 0]]
```

## Example 2

```1. from ia870 import iablob
2. from ia870 import ialabel
3. from ia870 import iaintersec
4.
5.