jeffheaton/t81_558_deep_learning

Part# 6.4 square chopping

Closed this issue · 2 comments

Thank for the great notebook to learn ,especially during the cov-19 homestay.
I don't know if mis-understood but the function below seems to make the image rectangle instead of square.
Do you mean .eg. crop((pad,0,pad+cols,cols) like in the previous course?

def make_square(img):
cols,rows = img.size

if rows>cols:
    pad = (rows-cols)/2
    img = img.crop((pad,0,cols,cols))
else:
    pad = (cols-rows)/2
    img = img.crop((0,pad,rows,rows))  

Thanks, will take a look.

I tried the code, as I have it and got the below result. What are you suggesting I change?

Before: 744x1157
After: 200x200
Before: 2592x3888
After: 200x200
Before: 2419x3888
After: 200x200
Before: 1704x2272
After: 200x200
Before: 2185x3700
After: 200x200
Before: 1834x2816
After: 200x200
Before: 1696x2544
After: 200x200