如何在CNN网络中处理不同大小的图像

问题描述 投票:0回答:1

我正在做图像以适应拼图和识别完美的对。在这里我的数据

solution.head()
id  pair
0   1   686
1   2   540
2   3   971
3   4   910
4   5   616

我有这样的图像形状:

    png = []
    for image_path in glob.glob("training/training/*.png"):
        png.append(misc.imread(image_path))    

    im = np.asarray(png)

    print ('Importing done...', im.shape)

Importing done... (1000,)

array([array([[[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       ...,

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]]], dtype=uint8),
       array([[[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,
        [165, 255, 102],
        [165, 255, 102],
        [165, 255, 102]],

       [[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,
        [165, 255, 102],
        [165, 255, 102],
        [165, 255, 102]],

       [[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,
        [165, 255, 102],
        [165, 255, 102],
        [165, 255, 102]],

       ...,

       [[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,

我不明白如何找到完美的双图像。我试图调整它们并转换为灰色,但它的错误。请帮我找到成对的图像。在这里我的colab链接:https://colab.research.google.com/drive/1bCQUHrXNjdWX8-WKSq6LK01XpR4D52J_

image-processing deep-learning computer-vision image-segmentation
1个回答
0
投票

你可以试试这段代码:

   import numpy as np
    import cv2
    import os
    df=pd.read_csv(os.path.join(file_path,'solution.csv'))
    training_data = []
    IMG_SIZE = 100
    for img in  os.listdir('training/training') :  
      path = 'training/training/'+img
      id = img.split('.')[0]
      img = cv2.imread(path,1)
      img = cv2.resize(img, (IMG_SIZE,IMG_SIZE),3)     
      img = np.array(img)
      target = df['pair][int(id)]
      training_data.append([img ,target  ])
© www.soinside.com 2019 - 2024. All rights reserved.