# Spatial Examples¶

[1]:

from easycv import Image
from easycv.transforms import Resize, Rescale, Rotate, Crop, Translate, Mirror, Paste


For this example we will load an image with random(). For more examples of image loading check Image examples.

[2]:

img = Image.random()
img

[2]:


## Resize¶

To resize an image we simply apply the Rezise Transform, for more information check the reference.

[3]:

img.apply(Resize(width=300, height=250))

[3]:


## Rescale¶

To rescale an image we simply apply the Rescale Transform with the factors of x and y, for more information check the reference.

[4]:

img.apply(Rescale(fx=2, fy=1))

[4]:


## Rotate¶

To rotate an image we simply apply the Rotate Transform with the degrees to rotate, for more information check the reference.

[5]:

img.apply(Rotate(degrees=50))

[5]:


## Crop¶

To crop an image we simply apply the Crop Transform with the boundaries of each side, for more information check the reference.

[6]:

img.apply(Crop(rectangle=[[50,50],[100,100]]))

[6]:


## Translate¶

To translate an image we simply apply the Translate Transform with the vector to translate, for more information check the reference.

[7]:

img.apply(Translate(x=10,y=50))

[7]:


## Mirror¶

To flip an image we simply apply the Mirror Transform with the desired axis to flip, for more information check the reference.

[8]:

img.apply(Mirror(axis="y"))

[8]:


## Paste¶

To paste an image on to another simply apply the Paste transform with the image to use and the rectangle to paste, for more information check the reference.

[9]:

img.apply(Paste(paste=Image.random(), rectangle=[[20,20],[200,200]]))

[9]: