# Synopse

Resizes an image.

• g = iaresize(f, new_shape)
• g: Image.
• f: Image.
• new_shape: Image. [h w], new image dimensions
• interpolation:
``` 1 #:show_output: no
2 #:show_images: no
3
4 from numpy import *
5 from numpy.linalg import *
6
7 from ia636 import *
8
10     m,n = F.shape
11     if m % 2 == 0: # n linhas impar, preciso zerar a primeira linha
12         F[0,:] = 0
13     if n % 2 == 0: # n colunas impar, preciso zerar a primeira coluna
14         F[:,0] = 0
15
16     G = zeros(array(F.shape)+2*thick,complex)
17
18     G[
19         thick[0]:-thick[0],
20         thick[1]:-thick[1]
21         ] = F
22     return G
23
24 def iaresize(f, new_shape,interpolation=None):
25
26     def calc(f, new_shape=new_shape):
28         F = iafftshift(F)
29
30         delta = array(new_shape) - array(f.shape)
31         thick = ceil(maximum(delta, zeros(delta.shape))/2)
32
34
35         # Expand DFT
37         M,N = F.shape
38
40
41         # Reduce DFT
42         #dif = array(new_shape)%2 - array(f.shape)%2
43         #print dif
44
45         print 'simétrica?', iaisdftsym(iaifftshift(F))
46
47         return iaidft(iaifftshift(F)).real
48
49     f = asarray(f)
50     if len(f.shape) == 3: # imagem colorida
51         g = zeros(concatenate(([3],new_shape)))
52         for i in range(f.shape[0]):
53             g[i,:,:] = calc(f[i,:,:])
54     else:
55         g = calc(f)
56     return g
```

# Examples

## Example 1

```1 #from ia636 import iaresize
2
3 f = array([[10,20,30],[40,50,60]])
4 print f
5 g = iaresize(f, [5,7])
6 print g
```
```[[10 20 30]
[40 50 60]]
simétrica? False
[[ 3.57142857  2.1600533  -1.00441055 -5.34205803 -5.9869018  -1.36227184
2.96416033]
[ 3.57142857  2.1600533  -1.00441055 -5.34205803 -5.9869018  -1.36227184
2.96416033]
[ 3.57142857  2.1600533  -1.00441055 -5.34205803 -5.9869018  -1.36227184
2.96416033]
[ 3.57142857  2.1600533  -1.00441055 -5.34205803 -5.9869018  -1.36227184
2.96416033]
[ 3.57142857  2.1600533  -1.00441055 -5.34205803 -5.9869018  -1.36227184
2.96416033]
[ 3.57142857  2.1600533  -1.00441055 -5.34205803 -5.9869018  -1.36227184
2.96416033]]
```
``` 1 f1 = mmreadgray('Attachments/ia636-2009/gkaneblai_ex12_1/original.gif')
3
4 #f1 = f2[0]
5
6 mmshow(f1)
7 f1 = ianormalize(iaresize(f1,array(f1.shape)*2),[0,255])
8 print f1.shape
9 mmshow(ianormalize(f1,[0,255]))
10
```simétrica? True