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

C# OpenCvSharp 图片模糊检测(拉普拉斯算子)

效果

项目

代码

using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using static System.Net.Mime.MediaTypeNames;namespace OpenCvSharp_模糊检测_拉普拉斯算子_
{public partial class Form1 : Form{public Form1(){InitializeComponent();}string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string image_path = "";Mat image = new Mat();Mat gray = new Mat();Mat laplacian = new Mat();double threshold = 100;double measure = 0;private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;image_path = ofd.FileName;pictureBox1.Image = new Bitmap(image_path);textBox1.Text = "";image = new Mat(image_path);}private void button3_Click(object sender, EventArgs e){if (image_path == ""){return;}Cv2.CvtColor(image, gray, ColorConversionCodes.BGR2GRAY);Cv2.Laplacian(gray, laplacian, gray.Type(), 3, 1, 0, BorderTypes.Default);Cv2.MeanStdDev(laplacian, out var mean, out var stddev);measure = stddev.Val0 * stddev.Val0;if (measure > threshold){textBox1.Text = "不模糊,拉普拉斯算子方差: " + measure.ToString();}else{textBox1.Text = "模糊,拉普拉斯算子方差: " + measure.ToString();}}}
}

Demo下载

模糊度检测算法来自 :https://pyimagesearch.com/2015/09/07/blur-detection-with-opencv/

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

相关文章:

  • 志高团队:广阔前景 全新的投资理财体验
  • 基于自编译的onlyoffice镜像,关于修改字体的问题
  • 1.wifi开发,wifi连接初次连接电脑没有识别,搭建环境
  • 【JAVA-Day25】解密进制转换:十进制向R进制和R进制向十进制的过程
  • 牛客网字节面试算法刷题记录
  • QT连接Sqlite
  • ChatGPT AIGC 完成各省份销售动态可视化分析
  • 基于SpringBoot+Vue的餐饮管理系统设计与实现
  • 2023 亲测好用版VScode配置文件
  • jmeter基础压力教程
  • 图片格式大全
  • 5.14.1.2 Get Log Page – Smart Log
  • 【深度学习实验】线性模型(一):使用NumPy实现简单线性模型:搭建、构造损失函数、计算损失值
  • springcloud3 分布式事务-seata的四种模式总结以及异地容灾
  • 【办公类-16-06】20230901大班运动场地分配表-斜线排列、5天循环、不跳节日,手动修改节日”(python 排班表系列)
  • java学习--day13 (static关键字、异常)
  • 英飞凌TC3xx--深度手撕HSM安全启动(五)--TC3xx HSM启动流程、通信机制分析
  • 【窗体】Winform两个窗体之间通过委托事件进行值传递,基础篇
  • mac使用指南
  • Git 版本控制系统 笔记
  • VRTK4⭐四.和 UI 元素交互
  • 【STM32】SDIO—SD 卡读写01
  • SpringCloud Alibaba 整合Sentinel的基本使用
  • Linux中如何执行命令
  • 基于51单片机的智能病房呼叫系统的设计与实现
  • js在一个时间范围内产生一个随机时间
  • Javascript Date 对象相关知识
  • Vim快捷用法
  • Stream流的常用方法(自用)
  • 【python函数】torch.nn.Embedding函数用法图解