图像分割

用光模式移除背景进行分割

方法一:R = L - I
方法二:R = 255*( 1 - (I/L) )

光模式L :没有对象,只有背景
图像I
结果 R

在这里插入图片描述
在这里插入图片描述

Mat removeLight(Mat img, Mat pattern, int method)
{
	Mat aux;
	// if method is normalization
	if(method == 1)
	{
		// Reequire change out image to 32 float for divison
		Mat img32, pattern32;
		img.converTo(img32, CV__32F);
		pattern.convertTo(pattern32, CV_32F);
		
		// Divide the image by the pattern
		aux = 1 - (img32/pattern32);
	}
	else
	{
		// Convert 8 bits format and scale
		aux = pattern - img;
	}
	return aux;
}

光模式的获取

大内核尺寸的模糊技术,常用于光学字符识别。
在这里插入图片描述
左为近似,右7为真实。

Mat calculateLightPattern(Mat img)
{
	Mat pattern;
	// Basic and effective way to calculate the light pattern from one image 
	blur(img, pattern, Size(img.cols/3, img.cols/3));
	return pattern;
}

阈值化

固定阈值操作

double threshold();

自适应阈值操作

void adaptiveThreshold();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值