Scan a folder having multiple images to find the darker images

邮差的信 提交于 2019-12-10 12:20:41

问题


I have a folder having bunch of images, out of which few images are almost dark like this: Dark Images, and few images are good images like this: Good images

Basically i am able to identify the darker images by using the below code, for the darker images the np.mean(image) comes below 0.1, and for good images it comes above 0.1 range:

from skimage import io, img_as_float
import numpy as np

image = io.imread('C:/Data/Testing/Image_0_5.jpg')
image = img_as_float(image)
print(np.mean(image))

But what i want is to pass the specific folder having all the images so that my code can parse through all the images, and list down the images having dark images. Need help on this.


回答1:


Thanks for the direction guys, appreciated.

Here's my code:

import matplotlib.image as mpimg
import os
def load_images(folder):
    images = []
    for filename in os.listdir(folder):
        img = mpimg.imread(os.path.join(folder, filename))
        img = img_as_float(img)
        #print(np.mean(img))
        if img is not None:
            images.append(img)
        if(np.mean(img) < 0.1):
            print filename

load_images('C:/Data/Testing')

I have achieved what i was looking for :)



来源:https://stackoverflow.com/questions/49643631/scan-a-folder-having-multiple-images-to-find-the-darker-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!