图像分割 1.基于阈值的算法


   

  

http://blog.csdn.net/xw20084898/article/details/17564957            主要取自这里,修改为Mat类。

    单阈值图像分割算法,有手动阀值,自适应阈值,最大熵法,基本全局阈值法,OTSU阈值。

#include<opencv2/opencv.hpp>
#include<opencv2/imgproc.hpp>
#include<opencv2/highgui.hpp>
#include<vector>
using namespace cv;
using namespace std;

void maxEntroy(Mat src,int&Threshold);
int BasicGlobalThreshold(int *pg, int x, int y);
int ThresholdOtsu(Mat src);


int main() {
	Mat src,gray,dst1,dst2,dst3,dst4, dst5,dst6;
	src = imread("trees.png");
	
	cvtColor(src, gray, CV_BGR2GRAY);
	imshow("原图", src);
	imshow("灰度图", gray);
	///手动设置阈值
	threshold(gray, dst1,100, 255, CV_THRESH_BINARY);
	namedWindow("手动阈值",CV_WINDOW_AUTOSIZE);
	imshow("手动阈值", dst1);

	///自适应阈值计算图像领域平均灰度
	double max_value = 255;
    int adpative_m
  • 3
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值