Function iaframe

namespace:morph
page:iaframe

Synopse

Create a frame image.

  • y = iaframe(f, WT=1, HT=1, DT=0, k1=NULL, k2=NULL)
    • y: Image
    • f: Image
    • WT: Double Positive integer ( width thickness).
    • HT: Double Positive integer ( height thickness).
    • DT: Double Positive integer ( depth thickness).
    • k1: Double Frame gray-level.
    • k2: Double Background gray level.
01. from numpy import *
02. 
03. def iaframe(f, WT=1, HT=1, DT=0, k1=None, k2=None):
04.     from iaunion import iaunion
05.     from iaintersec import iaintersec
06.     from ialimits import ialimits
07. 
08.     if k1 is None: k1 = ialimits(f)[1]
09.     if k2 is None: k2 = ialimits(f)[0]
10.     assert len(f.shape)==2,'Supports 2D only'
11.     y = iaintersec(f,k2)
12.     y[:,0:WT] = k1
13.     y[:,-WT:] = k1
14.     y[0:HT,:] = k1
15.     y[-HT:,:] = k1
16.     return y

Description

iaframe creates an image y, with the same dimensions (W,H,D) and same pixel type of the image f, such that the value of the pixels in the image frame is k1 and the value of the other pixels is k2. The thickness of the image frame is DT.

Examples

1. import numpy as np
2. import ia870 as mm
3. 
4. a = np.ones((5,9),np.bool)
5. b = mm.iaframe(a,4,2)
6. print 'a=\n',a *1
7. print 'b=\n',b *1
a=
[[1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]]
b=
[[1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]
 [1 1 1 1 0 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1 1]]
1. import ia870 as mm
2. 
3. a = mm.iatext('a')
4. b = mm.iaframe(a)
5. adshow(mm.iabshow(a))
6. adshow(mm.iabshow(b))

Equation

Where