Finding edges in images 和 decomposing images into geometry and texture

Finding edges 是 image processing 成熟的理论

pic.jpg

MATLAB自带edge函数

% MATLAB自带的edge函数
pic = imread('pic.jpg');
tmp = size(pic);
N = tmp(1); M = tmp(2);
pic_ = rgb2gray(pic);
pic2 = edge(pic_,'canny');
for x = 1:N
	for y = 1:M
		if pic2(x,y) == true
			pic2(x,y) = false;
		elseif pic2(x,y) == false
			pic2(x,y) = true;
		end
	end
end
imwrite(pic2,'pic_canny.jpg');

Canny方法提取edges噪声过高
Canny方法提取edges的噪声过高,于是我们想是否可以ROF模型分离噪声之后再使用Canny方法。

ROF方法其实是变分法转化为偏微分方程数值解。

% ROF.m
% Decomposing images into geometry and texture using ROF models
% 方法是数值解Euler-Lagrange equations
function [u,v] = ROF(pic)
	% 论文中参数lambda取0.1
	lambda = 0.1;
	
	tmp = size(pic);
	N = tmp(1); M = tmp(2);
	f = rgb2gray(pic);
	u = double(f);
	v = uint8(zeros(N,M));
	% u的梯度
	Dx_u = zeros(N,M);
	Dy_u = zeros(N,M);
	Dx_u_ = zeros(N,M);
	Dy_u_ = zeros(N,M);
	% 定义偏微分方程迭代次数
	n_loop = 300;
	for n = 1:n_loop
		% 首先求解 u 的梯度 (Dx_u, Dy_u)
		for x = 2:N
			for y = 2:M
				Dx_u(x,y) = u(x,y) - u(x-1,y);
				Dy_u(x,y) = u(x,y) - u(x,y-1);
			end
		end
		% Dx_u_ = Dx_u / module(Du)
		for x = 2:N
			for y = 2:M
				Dx_u_(x,y) = Dx_u(x,y) / ((Dx_u(x,y)^2+Dy_u(x,y)^2)^0.5+0.01);
				Dy_u_(x,y) = Dy_u(x,y) / ((Dx_u(x,y)^2+Dy_u(x,y)^2)^0.5+0.01);
			end
		end
		% Euler-Lagrange Equations
		for x = 2:N
			for y = 2:M
				div = Dx_u_(x,y) - Dx_u_(x-1,y) + Dy_u_(x,y) - Dy_u_(x,y-1);
				u(x,y) = f(x,y) + 0.5 / lambda * div;
			end
		end
	end
	u = uint8(u);
	%imwrite(u,'pic_ROF_u.jpg');
	for x = 1:N
		for y = 1:M
			v(x,y) = 127 + uint8(f(x,y)-u(x,y));
			if v(x,y) > 255
				v(x,y) = 255;
			elseif v(x,y) < 0
				v(x,y) = 0;
			end
		end
	end
	%imwrite(v,'pic_ROF_v.jpg');
end

这是提取出的texture
提取出的纹理
提取纹理之后的edge detecting效果
注意到提取texture之后再提取edges效果微好一点点,但仍然不理想

论文Modeling Textures with Total Variation Minimization and
Oscillating Patterns in Image Processing BY Vese and Osher 较ROF更好的提取纹理的方法

或许效果能更好

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值