How to resizing predicted mask images size based on its original test images size

155 views Asked by At

I have 1000 test images, and I obtained predicted mask images with 512x512 size. But my original test images size varying from 1024x768 to 6601x4422. How do I resize mask images based on its original test images size?

1

There are 1 answers

0
Hakan ÖCAL On

from PIL import Image import csv
def resizing():

i=0
root_dir=''
with open('.../dimension.csv', "rt", encoding='ascii') as infile:
    read = csv.reader(infile)
    for row in read :
        print(row)
        #str1=','.join(str(e) for e in row)
        #print(str1)
        
       
         
      
        filename=root_dir + "/"+str(i)+ ".png" 
        print(filename)
        im = Image.open(filename)
        imResize = im.resize((int(row[0]),int(row[1])), Image.ANTIALIAS)
        imResize.save(filename , 'PNG', quality=100)
        i+=1