Threshold

代码如下

        static void Main(String[] args)
{
Mat img = CvInvoke.Imread(@"C:\Users\dell\Pictures\facesGray.png", ImreadModes.Grayscale);
Mat dst = new Mat();
double thresholdValue = ;
double max = ;
CvInvoke.Threshold(img, dst, thresholdValue, max, ThresholdType.Binary);
CvInvoke.Imshow("src", img);
CvInvoke.Imshow("Binary", dst);
CvInvoke.Threshold(img, dst, thresholdValue, max, ThresholdType.BinaryInv);
CvInvoke.Imshow("BinaryInv", dst);
CvInvoke.Threshold(img, dst, thresholdValue, max, ThresholdType.Otsu);
CvInvoke.Imshow("Otsu", dst); CvInvoke.Threshold(img, dst, thresholdValue, max, ThresholdType.ToZero);
CvInvoke.Imshow("ToZero", dst); CvInvoke.Threshold(img, dst, thresholdValue, max, ThresholdType.ToZeroInv);
CvInvoke.Imshow("ToZeroInv", dst); CvInvoke.Threshold(img, dst, thresholdValue, max, ThresholdType.Trunc);
CvInvoke.Imshow("Trunc", dst);
CvInvoke.WaitKey();
}

例子

    class Program
{
static void Main(String[] args)
{
Mat img = CvInvoke.Imread(@"C:\Users\dell\Pictures\faces.png");
Mat dst = new Mat();
Mat weighted = new Mat();
weighted = sum_rgb(img, dst).Clone();
CvInvoke.Imshow("src", img);
CvInvoke.Imshow("weighted", weighted);
CvInvoke.Imshow("dst", dst);
CvInvoke.WaitKey();
}
static Mat sum_rgb(Mat src,Mat dst)
{
int ch = src.NumberOfChannels;
VectorOfMat vMat = new VectorOfMat(ch);
CvInvoke.Split(src, vMat);
Mat b = vMat[];
Mat g = vMat[];
Mat r= vMat[];
Mat s = new Mat();
CvInvoke.AddWeighted(r, 1.0 / , g, 1.0 / , 0.0,s);
CvInvoke.AddWeighted(s, 1.0, b, 1.0 / , 0.0, s);
CvInvoke.Threshold(s, dst, , , ThresholdType.Trunc);
return s;
}
}

自适应Threshold

代码

        static void Main(String[] args)
{
Mat img = CvInvoke.Imread(@"C:\Users\dell\Pictures\faces.png",);
Mat Gaussian = new Mat();
Mat Mean = new Mat();
CvInvoke.AdaptiveThreshold(img, Gaussian, , AdaptiveThresholdType.GaussianC, ThresholdType.Binary, , );
CvInvoke.AdaptiveThreshold(img, Mean, , AdaptiveThresholdType.MeanC, ThresholdType.Binary, , );
CvInvoke.Imshow("src", img);
CvInvoke.Imshow("Gaussian", Gaussian);
CvInvoke.Imshow("Mean", Mean);
CvInvoke.WaitKey();
}

代码

        static void Main(String[] args)
{
Mat img = CvInvoke.Imread(@"C:\Users\dell\Pictures\faces.png"); Mat dst = new Mat();
CvInvoke.BoxFilter(img, dst, DepthType.Default, new Size(, ), new Point(-, -));
CvInvoke.Imshow("src", img);
CvInvoke.Imshow("boxFilter", dst);
CvInvoke.Blur(img, dst, new Size(, ), new Point(-, -));
CvInvoke.Imshow("blur", dst);
CvInvoke.GaussianBlur(img, dst, new Size(, ), );
CvInvoke.Imshow("Gaussian", dst);
CvInvoke.MedianBlur(img, dst, );
CvInvoke.Imshow("median", dst);
CvInvoke.BilateralFilter(img, dst, , 30.0, 2.0);
CvInvoke.Imshow("Bilateral", dst);
CvInvoke.WaitKey();
}

效果如下

Emgu 学习(7)threshold ,图像过滤的更多相关文章

  1. Emgu学习之(四)——图像阈值

    http://www.cnblogs.com/CoverCat/p/5043833.html Visual Studio Community 2015 工程和代码:http://pan.baidu.c ...

  2. Emgu学习之(二)——图像读取、显示、保存

    visual Studio Community 2015 工程和源代码:http://pan.baidu.com/s/1o6u5Fdw 内容 在这篇文章中将提到以下内容: 从文件中读取图像 Image ...

  3. Emgu学习之(三)——操作图像数据

    Visual Studio Community 2015 工程和代码:http://pan.baidu.com/s/1jHmlQeE 内容 在这篇文章中将提到以下内容: 修改像素值 图像ROI 图像加 ...

  4. Emgu学习手册

    作为opencv的c#封装库.emgu可以满足基本的图像处理功能,经过测试,效果还可以,主要用于windows窗体应用程序的开发,或者wpf,你可以用来做ocr,也可以用来做人脸识别或者可以用来做定位 ...

  5. B1066 图像过滤 (15分)

    B1066 图像过滤 (15分) 图像过滤是把图像中不重要的像素都染成背景色,使得重要部分被凸显出来.现给定一幅黑白图像,要求你将灰度值位于某指定区间内的所有像素颜色都用一种指定的颜色替换. 输入格式 ...

  6. PAT 1066 图像过滤

    https://pintia.cn/problem-sets/994805260223102976/problems/994805266514558976 图像过滤是把图像中不重要的像素都染成背景色, ...

  7. openCV学习——一、图像读取、显示、输出

    openCV学习——一.图像读取.显示.输出   一.Mat imread(const string& filename,int flags=1),用于读取图片 1.参数介绍 filename ...

  8. PAT 乙级 1066. 图像过滤(15)

    图像过滤是把图像中不重要的像素都染成背景色,使得重要部分被凸显出来.现给定一幅黑白图像,要求你将灰度值位于某指定区间内的所有像素颜色都用一种指定的颜色替换. 输入格式: 输入在第一行给出一幅图像的分辨 ...

  9. PAT 乙级 1066 图像过滤(15) C++版

    1066. 图像过滤(15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 图像过滤是把图像中不重要的像素都染成 ...

随机推荐

  1. 直接插入排序java代码

    //直接插入排序(无哨兵) 通过测试 public class InsertSortTest{ public static void insertSort(int[] arr) { for (int ...

  2. SQL Prompt 5 功能按键说明

    1. Refresh suggestions                 未知,按了没反映 2.Format sql                               标准化SQL代码书 ...

  3. 【51nod 1038】X^A Mod P

    题目描述 X^A mod P = B,其中P为质数.给出P和A B,求< P的所有X. 例如:P = 11,A = 3,B = 5. 3^3 Mod 11 = 5 所有数据中,解的数量不超过Sq ...

  4. javascript中的正确错误处理------------引用

    JavaScript的事件驱动机制让JavaScript更加丰富,浏览器好比就是一个事件驱动的机器,错误也是一种事件.当一个错误发生时,一个事件就在某个点抛出. 解释起来就是,当发生错误时,JavaS ...

  5. nodejs (下)(设置响应参数)

         响应: 可以自定义设置状态码(状态码范围内的):res.statusCode =  404; 修改响应头信息: res.setHeader('content-type','text/html ...

  6. bootstrap列表组的使用

    <ul class="list-group"> <li class="list-group-item"> <div class=& ...

  7. Android 内存 - 获取单个应用内存限制

    方法一: adb shell getprop | grep dalvik.vm.heapgrowthlimit [dalvik.vm.heapgrowthlimit]: [64m] 方法二: Acti ...

  8. 使用wait/notify实现生产消费模型

    public class A { private Deque<Integer> list = new LinkedList<>(); private int max = 10; ...

  9. 25.Python逻辑运算符及其用法

    逻辑运算符是对真和假两种布尔值进行运算(操作 bool 类型的变量.常量或表达式),逻辑运算的返回值也是 bool 类型值. Python 中的逻辑运算符主要包括 and(逻辑与).or(逻辑或)以及 ...

  10. template模板循环嵌套循环

    template嵌套循环写法:在第一次循环里面需要循环的地方再写个循环,把要循环的数据对象改为第一层的循环对象别名 //template模板循环嵌套循环 <script id="ban ...