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. linux系统下nginx/mysql/php启动、停止、重启命令

    /usr/local/nginx/sbin/nginx /etc/init.d/mysql start /usr/local/php/sbin/php-fpm start   #nginx命令     ...

  2. ThinkPHP系统常量

    _ROOT__ : 网站根目录地址 __APP__ : 当前项目(入口文件)地址 __URL__ : 当前模块地址 __ACTION__ : 当前操作地址 __SELF__ : 当前 URL 地址 _ ...

  3. hdu 5753

    Permutation Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  4. RTS打卡计划第四周

    Algorithms: https://leetcode-cn.com/problems/subarray-sum-equals-k/comments/ 此问题开始考虑空间换时间,结果完全不用空间,不 ...

  5. python 购物车+用户认证程序

    创建文件a.txt,b.txt.c.txt用于存放应该持续保存的信息 a.txt :用户密码输入错误3次就锁定 b.txt :购物时的活动,每个用户只能参与一次 c:txt :购物完后的发票在这里查看 ...

  6. PHP AJAX 返回JSON 数据

    例子:利用AJAX返回JSON数据,间接访问数据库,查出Nation 表,并用下拉列表显示 造一个外部下拉列表框 </select> JQurey代码 $(document).ready( ...

  7. 理解MVC/MVP/MVVM的区别

    转载至[http://www.ruanyifeng.com/blog/2015/02/mvcmvp_mvvm.html] MVC 所有的通信都是单向的. M(Model)V(View)C(Contro ...

  8. Linux - 加密打包

    tar 加密打包 压缩 tar -czvf /path/to/file.tar.gz file 解压 tar -xzvf /path/to/file.tar.gz /path/to 加密压缩 tar ...

  9. java初级之数组详解

    一,数组的概念: 数组是为了存储同一种数据多个元素的集合,也可以看成是一个容器,数组既可以存储基本数据类型,也可以存储引用数据类型,数组是为了存储同种数据类型的多个值. 1.1.1,一维数组重点: 数 ...

  10. log4j日志配置文件

    log4j.properties: ### 设置### log4j.rootLogger = debug,stdout,D,E ### 输出信息到控制抬 ### log4j.appender.stdo ...