Read Multiple images on a folder in OpenCv (python)

前端 未结 6 1319
孤独总比滥情好
孤独总比滥情好 2021-01-31 06:15

I want to read multiple images on a same folder using opencv (python). To do that do I need to use for loop or while loop with imread func

6条回答
  •  太阳男子
    2021-01-31 06:41

    def flatten_images(folder): # Path of folder (dataset)

    images=[]                             # list contatining  all images
    
    for filename in os.listdir(folder):
    
        print(filename)
    
        img=plt.imread(folder+filename)  # reading image (Folder path and image name )
    
        img=np.array(img)                #
    
        img=img.flatten()                # Flatten image 
    
        images.append(img)               # Appending all images in 'images' list 
    
    return(images)
    

提交回复
热议问题