Function iabinary

namespace:morph
page:iabinary

Synopse

Convert a gray-scale image into a binary image

  • y = iabinary(f, k1=1)
    • y: Image
    • f: Image
    • k1: Double Threshold value.
1. from numpy import *
2. 
3. def iabinary(f, k1=1):
4. 
5.     f = asarray(f)
6.     y = f >= k1
7.     return y

Description

iabinary converts a gray-scale image f into a binary image y by a threshold rule. A pixel in y has the value 1 if and only if the corresponding pixel in f has a value greater or equal k1.

Examples

Example 1

1. from ia870 import iabinary
2. 
3. 
4. a = array([0, 1, 2, 3, 4])
5. b=iabinary(a)
6. print b
[False  True  True  True  True]

Example 2

1. a=mmreadgray('mm3.tif')
2. b=iabinary(a,82)
3. adshow(a)
4. adshow(b)

Equation

See Also