# Synopse

Converts image representation from set to matrix

• M = iaset2mat(A)
• M: Image
• A: Image Tuple with array of pixel coordinates and optional array of corresponding pixel values
01. from numpy import *
02.
03. def iaset2mat(A):
04.     from iabinary import iabinary
05.     from ialimits import ialimits
06.
07.     if len(A) == 2:
08.         x, v = A
09.         v = asarray(v)
10.     elif len(A) == 1:
11.         x = A[0]
12.         v = ones((len(x),),bool)
13.     else:
14.         raise TypeError, 'Argument must be a tuple of length 1 or 2'
15.     if len(x) == 0:  return array([0]).astype(v.dtype)
16.     if len(x.shape) == 1: x = x[newaxis,:]
17.     dh, dw = abs(x).max(0)
18.     h,w = (2*dh) + 1, (2*dw) + 1
19.     M=ones((h, w)) * ialimits(v)[0]
20.     offset = x[:,0] * w + x[:,1] + (dh*w + dw)
21.     M.flat[offset] = v
22.     M = M.astype(v.dtype)
23.
24.     return M

# Description

Return an image in the matrix format built from a tuple of an array of pixel coordinates and a corresponding array of pixel values

# Examples

## Example 1

01. from ia870 import iaset2mat
03.
04. coord=array([
05.   [ 0,0],
06.   [-1,0],
07.   [ 1,1]])
08. A=iaset2mat((coord,))
09. print 'A=\n', A
10.
11. vu = array([1,2,3],'uint8')
12. f=iaset2mat((coord,vu))
13. print 'f=\n', f
14.
15. vi = array([1,2,3],'int32')
16. g=iaset2mat((coord,vi))
17. print 'g=\n', g