Function iatile

namespace:ia636
page:iatile

Synopse

Replicate the image until reach a new size.

  • g = iatile(f, new_size)
    • g: Image.
    • f: Image. input image.
    • new_size: Image. [rows cols], output image dimensions.
01. from numpy import *
02. 
03. def iatile(f, new_size):
04. 
05.     f = asarray(f)
06.     if len(f.shape) == 1: f = f[newaxis,:]
07. 
08.     aux = resize(f, (new_size[0], f.shape[1]))
09.     aux = transpose(aux)
10.     aux = resize(aux, (new_size[1], new_size[0]))
11.     g = transpose(aux)
12.     return g

Examples

Example 1

This is a simple numeric example.

1. from ia636 import iatile
2. 
3. f = array([[1,2],[3,4]])
4. print 'f=\n', f
5. g = iatile(f, (3,6))
6. print 'g=\n', g
f=
[[1 2]
 [3 4]]
g=
[[1 2 1 2 1 2]
 [3 4 3 4 3 4]
 [1 2 1 2 1 2]]

Example 2

This is a simple image example.

1. from ia636 import iatile
2. 
3. f = adread('unilogo.tif')
4. adshow(f, title='original')
5. g = iatile(f, (200,300))
6. adshow(g, title='replicated')

original

replicated

Using np.tile

1. import numpy as np
2. 
3. f = adreadgray('unilogo.tif')
4. g1 = np.tile(f,(3,4))
5. adshow(g1, title='using np.tile')

using np.tile