# Synopse

Convert a binary image into a gray-scale image.

• y = iagray(f, TYPE="uint8", k1=NULL)
• y: Image
• f: Image
• TYPE: String Image data type: 'uint8', 'uint16', 'int32' or 'float64'.
• k1: Double
01. from numpy import *
02.
03. def iagray(f, TYPE="uint8", k1=None):
04.     from ia870 import iabinary, iais, iamaxleveltype, ianeg, ialimits
05.
06.     #f = (f > 0)
07.     ff = array([0],TYPE)
08.     kk1,kk2 = ialimits(ff)
09.     if k1!=None:
10.         kk2=k1
11.     if   TYPE == 'uint8'  : y = where(f,kk2,kk1).astype(uint8)
12.     elif TYPE == 'uint16' : y = where(f,kk2,kk1).astype(uint16)
13.     elif TYPE == 'int32'  : y = where(f,kk2,kk1).astype(int32)
14.     elif TYPE == 'int64'  : y = where(f,kk2,kk1).astype(int64)
15.     elif TYPE == 'float64': y = where(f,kk2,kk1).astype(float64)
16.     else:
17.         assert 0, 'type not supported:'+TYPE
18.     return y

# Description

iagray converts a binary image into a gray-scale image of a specified data type. The value k1 is assigned to the 1 pixels of f, while the 0 pixels are assigned to the minimum value associated to the specified data type.

# Examples

## Example 1

01. from ia870 import iagray,iabinary
02.
03. b=iabinary([0, 1, 0, 1])
04. print b
05. c=iagray(b)
06. print c
07. d=iagray(b,'uint8',100)
08. print d
09. e=iagray(b,'uint16')
10. print e
11. f=iagray(b,'int32')
12. print f
13. f=iagray(b,'float64')
14. print f
15. f=iagray(b,'float64',0)
16. print f
[False  True False  True]
[  0 255   0 255]
[  0 100   0 100]
[    0 65535     0 65535]
[-2147483647  2147483647 -2147483647  2147483647]
[-inf  inf -inf  inf]
[-inf   0. -inf   0.]