Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

PENGOLAHAN CITRA

Tugas
Cropping Image

Nama : Viky Alfahrezi


Nim : 2070231074
Kelas : A1 – Reguler Pagi

FAKULTAS TEKNIK
PRODI TEKNIK INFORMATIKA
UNIVERSITAS KRISNADWIPAYANA
2022
JAKARTA
Input

from PIL import Image

infile = 'monas.tif'
chopsize = 200

img = Image.open(infile)
width, height = img.size

for x0 in range(0, width, chopsize):


for y0 in range(0, height, chopsize):
box = (x0, y0,
x0+chopsize if x0+chopsize < width else width - 1,
y0+chopsize if y0+chopsize < height else height - 1)
print('%s %s' % (infile, box))
img.crop(box).save('sample.%s.x%03d.y%03d.tif' % (infile.rep
lace('.tif',''), x0, y0))

Output

monas.tif (0, 200, 200, 393)


monas.tif (200, 200, 400, 393)
monas.tif (400, 200, 600, 393)
monas.tif (600, 200, 699, 393)
Cropping Image
 X00 Y200

 X200 Y200

 X400 Y200
 X600 Y200

You might also like