-
Notifications
You must be signed in to change notification settings - Fork 0
/
preproc.py
34 lines (30 loc) · 1.11 KB
/
preproc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from PIL import Image
import os
sourceFolder = './train/pneumonia/'
for filename in os.listdir(sourceFolder):
im = Image.open(sourceFolder+filename)
imFlip = im.transpose(Image.FLIP_LEFT_RIGHT)
crop = im.crop((100,100,300,300))
im.thumbnail((200,200))
im.save(sourceFolder + filename)
sourceFolder = './train/normal/'
for filename in os.listdir(sourceFolder):
im = Image.open(sourceFolder+filename)
imFlip = im.transpose(Image.FLIP_LEFT_RIGHT)
crop = im.crop((100,100,300,300))
im.thumbnail((200,200))
im.save(sourceFolder + filename)
sourceFolder = './val/pneumonia/'
for filename in os.listdir(sourceFolder):
im = Image.open(sourceFolder+filename)
imFlip = im.transpose(Image.FLIP_LEFT_RIGHT)
crop = im.crop((100,100,300,300))
im.thumbnail((200,200))
im.save(sourceFolder + filename)
sourceFolder = './val/normal/'
for filename in os.listdir(sourceFolder):
im = Image.open(sourceFolder+filename)
imFlip = im.transpose(Image.FLIP_LEFT_RIGHT)
crop = im.crop((100,100,300,300))
im.thumbnail((200,200))
im.save(sourceFolder + filename)