问题
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