当前位置: 首页 > news >正文

【深度学习】图片预处理,分辨出模糊图片

ref:https://pyimagesearch.com/2015/09/07/blur-detection-with-opencv/
论文 ref:https://www.cse.cuhk.edu.hk/leojia/all_final_papers/blur_detect_cvpr08.pdf
遇到模糊的图片,还要处理一下,把它挑出来,要么修复,要么弃用。否则影响后续效果。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

根据模糊值排序即可,写在文件名中,自动排序,然后对模糊的去掉即可

import os.pathfrom imutils import paths
import argparse
import cv2
import shutildef variance_of_laplacian(image):# compute the Laplacian of the image and then return the focus# measure, which is simply the variance of the Laplacianreturn cv2.Laplacian(image, cv2.CV_64F).var()# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--images", default=r"D:\dataset\imgs_bk\imgs_bk",help="path to input directory of images")
ap.add_argument("-t", "--threshold", type=float, default=400.0,help="focus measures that fall below this value will be considered 'blurry'")
args = vars(ap.parse_args())
count_num = 0
for imagePath in paths.list_images(args["images"]):# load the image, convert it to grayscale, and compute the# focus measure of the image using the Variance of Laplacian# methodimage = cv2.imread(imagePath)gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)fm = variance_of_laplacian(gray)text = "Not Blurry"print("res:", imagePath, fm)# if the focus measure is less than the supplied threshold,# then the image should be considered "blurry"# for threshold in [100, 200, 300, 400, 500]:# if fm < threshold:# text = "Blurry"# # show the image# cv2.putText(image, "{}: {:.2f}".format(text, fm), (10, 30),#             cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 3)# # cv2.imshow("Image", image)_, file_name = os.path.split(imagePath)# dst_dir = r"D:\code\baidu-spider\blur_img"# os.makedirs(dst_dir, exist_ok=True)# dst_path = os.path.join(dst_dir, str(fm) + "-" + file_name)# cv2.imwrite(dst_path, image)dst_path_blank = os.path.join(r"D:\dataset\blank-blur-order", str(fm) + '-' + file_name)shutil.copy(imagePath, dst_path_blank)count_num += 1# key = cv2.waitKey(0)

本质是一个拉普拉斯变换!!
还挺好用的。
我感觉300,400的阈值,就会好很多了。

http://www.lryc.cn/news/326740.html

相关文章:

  • 基础NLP知识了解
  • Android 性能优化(六):启动优化的详细流程
  • QT程序打包
  • ARMday7作业
  • Unity构建详解(4)——SBP的依赖后处理
  • 使用GO对PostgreSQL进行有意思的多线程压测
  • CI/CI实战-jenkis结合gitlab 4
  • 修复ubuntu引导
  • 11.Notepad++
  • 实现阻塞队列
  • MySQL8.X驱动datetime映射问题
  • 【Selenium】隐藏元素的定位和操作|隐藏与isDisplay方法
  • 视图的作用
  • 动态ip白名单频繁更改问题解决方案
  • 什么是物联网监控平台?部署物联网平台有什么作用?
  • netty构建udp服务器以及发送报文到客户端客户端详细案例
  • Selenium 学习(0.22)——软件测试之小结
  • 贪心算法问题
  • 深入理解 @Transactional 注解在 Spring 中的应用
  • Python爬虫之爬取网页图片
  • AI Agent(LLM Agent)入门解读
  • 自动化面试常见算法题!
  • CCF-CSP真题202206-2《寻宝!大冒险!》
  • Rust编程(三)生命周期与异常处理
  • 【办公类-21-11】 20240327三级育婴师 多个二级文件夹的docx合并成docx有页码,转PDF
  • OSG编程指南<二十一>:OSG视图与相机视点更新设置及OSG宽屏变形
  • Laplace变换-3
  • LVS负载均衡-DR模式配置
  • 【unity】如何汉化unity Hub
  • 【算法】KMP-快速文本匹配