Exemple #1
0
def iaimg2se(fd, FLAT="FLAT", f=None):
    from iaisbinary import iaisbinary
    from iaseshow import iaseshow
    from ialimits import ialimits

    fd = (fd > 0)
    #assert iaisbinary(fd),'First parameter must be binary'
    FLAT = upper(FLAT)
    if FLAT == 'FLAT':
        return iaseshow(fd)
    else:
        B = choose(fd, (ialimits(int32([0]))[0] * ones(fd.shape), f))
    B = iaseshow(int32(B), 'NON-FLAT')

    return B
Exemple #2
0
def iaimg2se(fd, FLAT="FLAT", f=None):
    from iaisbinary import iaisbinary
    from iaseshow import iaseshow
    from ialimits import ialimits

    fd = (fd > 0)
    #assert iaisbinary(fd),'First parameter must be binary'
    FLAT = upper(FLAT)
    if FLAT == 'FLAT':
        return iaseshow(fd)
    else:
        B = choose(fd, ( ialimits(int32([0]))[0]*ones(fd.shape),f) )
    B = iaseshow(int32(B),'NON-FLAT')

    return B
Exemple #3
0
def iaunpad(f, B=iasecross()):
    from iamat2set import iamat2set
    from iaseshow import iaseshow

    i,v=iamat2set( iaseshow(B));
    mni=minimum.reduce(i)
    mxi=maximum.reduce(i)
    g = f[-mni[0]:f.shape[0]-mxi[0], -mni[1]:f.shape[1]-mxi[1]]

    return g
Exemple #4
0
def iaunpad(f, B=iasecross()):
    from iamat2set import iamat2set
    from iaseshow import iaseshow

    i, v = iamat2set(iaseshow(B))
    mni = minimum.reduce(i)
    mxi = maximum.reduce(i)
    g = f[-mni[0]:f.shape[0] - mxi[0], -mni[1]:f.shape[1] - mxi[1]]

    return g
Exemple #5
0
def iapad4n(f, Bc, value, scale=1):
    from iaseshow import iaseshow

    if type(Bc) is not array:
        Bc = iaseshow(Bc)
    Bh, Bw = Bc.shape
    assert Bh % 2 and Bw % 2, 'structuring element must be odd sized'
    ch, cw = scale * Bh / 2, scale * Bw / 2
    g = value * ones(f.shape + scale * (array(Bc.shape) - 1))
    g[ch:-ch, cw:-cw] = f
    y = g.astype(f.dtype.char)

    return y
Exemple #6
0
def iapad(f, B=iasecross(), value=0):
    from iamat2set import iamat2set
    from iaseshow import iaseshow

    i, v = iamat2set(iaseshow(B))
    mni = i.min(axis=0)
    mxi = i.max(axis=0)
    f = asarray(f)
    if size(f.shape) == 1: f = f[newaxis, :]
    g = (value * ones(array(f.shape) + mxi - mni)).astype(f.dtype)
    g[-mni[0]:g.shape[0] - mxi[0], -mni[1]:g.shape[1] - mxi[1]] = f

    return g
Exemple #7
0
def iapad(f, B=iasecross(), value=0):
    from iamat2set import iamat2set
    from iaseshow import iaseshow

    i,v=iamat2set( iaseshow(B));
    mni=i.min(axis=0)
    mxi=i.max(axis=0)
    f = asarray(f)
    if size(f.shape) == 1: f = f[newaxis,:]
    g = (value * ones(array(f.shape)+mxi-mni)).astype(f.dtype)
    g[-mni[0]:g.shape[0]-mxi[0], -mni[1]:g.shape[1]-mxi[1]] = f

    return g
Exemple #8
0
def iapad4n(f, Bc, value, scale=1):
    from iaseshow import iaseshow

    if type(Bc) is not array:
      Bc = iaseshow(Bc)
    Bh, Bw = Bc.shape
    assert Bh%2 and Bw%2, 'structuring element must be odd sized'
    ch, cw = scale * Bh/2, scale * Bw/2
    g = value * ones( f.shape + scale * (array(Bc.shape) - 1))
    g[ ch: -ch, cw: -cw] = f
    y = g.astype( f.dtype.char)


    return y