扫描包含多张图像的文件夹以查找较暗的图像 [英] Scan a folder having multiple images to find the darker images

查看:101
本文介绍了扫描包含多张图像的文件夹以查找较暗的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一堆图像的文件夹,其中几乎没有像这样的深色图像:深色图像,很少有像这样的好图像:好图像

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

基本上,我可以使用下面的代码来识别较暗的图像,对于较暗的图像,np.mean(image)小于0.1,对于良好的图像,其大于0.1范围:

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.

推荐答案

感谢指导老师,谢谢.

这是我的代码:

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 :)

这篇关于扫描包含多张图像的文件夹以查找较暗的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆