Emgu 学习笔记(二)---图像二值化,自适应阈值化,Otsu二值化
来源:互联网 发布:网络空间安全理事会 编辑:程序博客网 时间:2024/05/17 07:09
图像二值化,自适应阈值化,Otsu二值化
Emgu灰度化、二值化操作方法和OpenCV中区别不大,Threshold()来实现的。
自适应阈值是整幅图像使用一个阈值,自适应阈值是图像的不同区域使用不同的阈值,而这个阈值是对整个区域计算出来的。在Emgu中也是调用函数AdaptiveThreshold()来实现的。
public static AdaptiveThreshold(IInputArray src,IOutputArray dst,double maxValue,AdaptiveThresholdType adativeType,ThresholdType thresholdType,int blockSize,double param1)
AdaptiveThresholdType adativeType:自适应阈值计算方法:MeanC和GaussianC
ThresholdType thresholdType:必须为二值化阈值化或者是反二值化阈值化(Binary/BinaryInv)
int blockSize:计算使用的区域矩阵大小:3,5,7,9
来看代码实现:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using Emgu.CV;using Emgu.CV.Structure;using Emgu.Util;using Emgu.CV.CvEnum;namespace 全局阈值{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Image<Bgr, Byte> image = new Image<Bgr, Byte>(Properties.Resources._2); pictureBox1.Image = image.ToBitmap(); } private void button1_Click(object sender, EventArgs e) { using (var image = new Image<Bgr, Byte>(Properties.Resources._2)) { var grayImage = image.Convert<Gray, Byte>(); pictureBox1.Image = grayImage.ToBitmap(); } } private void button2_Click(object sender, EventArgs e) { Image<Bgr, Byte> image = new Image<Bgr, Byte>(Properties.Resources._2); var grayImage = image.Convert<Gray, Byte>(); var threshImage = grayImage.CopyBlank(); CvInvoke.Threshold(grayImage, threshImage, 150, 255, ThresholdType.Binary); pictureBox2.Image = threshImage.ToBitmap(); } private void button3_Click(object sender, EventArgs e) { var grayImage = new Image<Gray, Byte>(Properties.Resources._2); var threshImage = grayImage.ThresholdAdaptive(new Gray(255), AdaptiveThresholdType.MeanC, ThresholdType.Binary, 9, new Gray(5)); pictureBox3.Image = threshImage.ToBitmap(); } private void button4_Click(object sender, EventArgs e) { var grayImage = new Image<Gray, Byte>(Properties.Resources._2); var threshImge = grayImage.CopyBlank(); CvInvoke.Threshold(grayImage, threshImge, 0, 255, ThresholdType.Otsu); pictureBox4.Image = threshImge.ToBitmap(); } }}
效果图:
0 0
- Emgu 学习笔记(二)---图像二值化,自适应阈值化,Otsu二值化
- opencv学习笔记(十九)单通道固定阈值cvThreshold()以及自适应阈值化 OTSU算法
- OTSU方法计算图像二值化的自适应阈值
- OTSU方法计算图像二值化的自适应阈值
- OTSU方法计算图像二值化的自适应阈值
- 图像otsu阈值化
- otsu自动阈值对图像二值化程序
- 图像处理之基于Otsu阈值二值化
- 图像处理------基于Otsu阈值二值化
- 图像处理之基于OTSU阈值二值化
- 图像的二值化模块(固定阈值法和Otsu阈值法)
- Otsu自适应阈值算法
- opencv学习笔记(二十)自适应阈值cvAdaptiveThreshold ()
- 大津法(otsu),中间像素统计法,kittler全局阈值图像二值化
- 基于Otsu算法的图像自适应阈值分割
- 【OpenCV3图像处理】阈值化操作得到二值图像(附Otsu算法和三角法原理与源码)
- 用otsu算法进行图像阈值化
- 自己实现图像阈值化(OTSU)
- hdu 2017
- iOS UITextFielddelegate委托方法注释
- 评率控论文“Lambda Domain Optimal Bit Allocation Algorithm for High Efficiency Video Coding“
- 封装jquery的$方法
- Cannot create oci environment (Navicat链接数据库时报错解决)
- Emgu 学习笔记(二)---图像二值化,自适应阈值化,Otsu二值化
- 面试总结(1):HandlerThread
- oracle 之where子句和having子句
- 1,2,3,4,5,6,7,8,9,10;2,4,7,11…;3,7,14,25…;4,11,25,50 显示10列
- MyBatis--关联关系查询--多对多--多表连接查询
- hdu 2018
- Spring 实现数据库读写分离
- 运动跟踪
- Intel提供的面向机器学习和深度学习的优化工具和框架