joining two images reading from one folder

0 votes

Hi, i am trying to generating joined images with two or three individual images . so, i am reading the individual images from the same folder which contains 200840 images of handwritten Bangla characters . but i am having issue with reading the images simultaneously and joining them . here i have attached me code .  its showing error like 

Cannot understand given URI: ['Train_169700.png', 'Train_66828.png', 'Train_123835.png....


def get_concat_h_resize(im1, im2, resample=Image.BICUBIC, resize_big_image=True):
    if im1.height == im2.height:
        _im1 = im1
        _im2 = im2
    elif (((im1.height > im2.height) and resize_big_image) or
          ((im1.height < im2.height) and not resize_big_image)):
        _im1 = im1.resize((int(im1.width * im2.height / im1.height), im2.height), resample=resample)
        _im2 = im2
    else:
        _im1 = im1
        _im2 = im2.resize((int(im2.width * im1.height / im2.height), im1.height), resample=resample)
    dst = Image.new('RGB', (_im1.width + _im2.width, _im1.height))
    dst.paste(_im1, (0, 0))
    dst.paste(_im2, (_im1.width, 0))
    return ds
train_data_path = os.path.join(data_path, 'train_images128')
images = os.listdir(train_data_path)
train_dir = '../input/resized128shapna/train_images128'
images1 = images[1::2]
images2= images[::2]

h= 64
w= 64

x_train = np.zeros((len(images1), h, w), dtype=np.uint8)
index = 0
for x in range(len(images1)):
 image1 = imread(os.path.join(train_dir, images1[x]))
 image2 = imread(os.path.join(train_dir, images2[x]))
 joined = get_concat_h_resize(image1,image2)

 x_train[index] = joined
 index += 1
 imshow(y_train[0])

Jan 3, 2021 in Python by shapna
• 120 points
665 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

Exclusive values from two Sets in Python

There is a direct function available to ...READ MORE

answered Mar 27, 2019 in Python by Mugdha
• 600 points
1,349 views
0 votes
1 answer

Reading server response from requests module in Python.

You can read the response using the text option ...READ MORE

answered May 14, 2019 in Python by Kunal
801 views
0 votes
1 answer
0 votes
4 answers

Is it possible to call one python script from another Python Script?

Try using os.system: os.system("script2.py 1") execfile is different because it is ...READ MORE

answered Dec 16, 2020 in Python by Gitika
• 65,770 points
70,413 views
0 votes
1 answer

How to create a train and test sample from one dataframe using pandas?

Hi, The below written code can help you ...READ MORE

answered Jul 4, 2019 in Python by Taj
• 1,080 points
5,750 views
0 votes
1 answer

Animated sprite from few images

You could try modifying your sprite so ...READ MORE

answered Jul 11, 2019 in Python by SDeb
• 13,300 points
724 views
0 votes
0 answers

pass optional or keyword parameters from one function to another in python?

How can I pass optional or keyword ...READ MORE

Jul 24, 2019 in Python by Hari
775 views
+1 vote
0 answers

Sum the values of column matching and not matching from a .txt file and write output to a two different files using Python

Name                                                    value DR_CNDAOFSZAPZP_GPFS_VOL.0 139264 DR_CNDAOFSZAPZP_GPFS_VOL.1 15657 DR_CNDAOFSZAPZP_GPFS_VOL.0 139264 DR_CNDAOFSZAPZP_GPFS_VOL.1 156579 DR_CNDAOFSZAPZP_GPFS_VOL.2 156579 DR_CNDAOFSZAPZP_GPFS_VOL.3 ...READ MORE

Nov 20, 2019 in Python by Sagar
• 130 points
1,191 views
0 votes
1 answer

How to Install Python packages from local file system folder to virtualenv with pip?

Hello @kartik, You can try the code below: pip ...READ MORE

answered May 12, 2020 in Python by Niroj
• 82,840 points

edited Oct 7, 2021 by Sarfaraz 13,364 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP