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();
}

效果如下

最新文章

  1. Ajax方式上传文件
  2. .NET平台开源项目速览(3)小巧轻量级NoSQL文件数据库LiteDB
  3. php时间戳之间相互转换
  4. Sublime 3114 + 转换GBK方法
  5. 深入研究Clang(三) libclang
  6. KindEditor图片上传到七牛云
  7. POJ 1135 Domino Effect(Dijkstra)
  8. Delphi实现无标题有边框的窗体
  9. 关于C函数的参数个数的问题
  10. Java-老夫对泛型的理解。。
  11. Servlet3.0新特性使用详解
  12. (工具类)double类型数据运算
  13. 【codeforces 698C】LRU
  14. NodeJs操作MongoDB之分页功能与常见问题
  15. 根据不同访问设备跳转到PC页面或手机页面
  16. Latex常用软件
  17. Java设计模式学习记录-外观模式
  18. java的数组和arraylist
  19. Trove系列(八)——Trove的配置管理相关的功能介绍
  20. IOS微信后台运行时候倒计时暂停问题

热门文章

  1. jpa多对一映射
  2. Vue 工程化最佳实践
  3. windows驱动开发详解学习笔记
  4. sh_21_遍历字典的列表
  5. TensorFlow使用记录 (六): 优化器
  6. Count the Buildings
  7. PHP-过滤器-连接数据库-解析XML
  8. mysql统计前24小时数据没有补0
  9. iOS真机调试之免费预配(Free provisioning)
  10. R语言:读入txt文件中文文本出现乱码解决方案