Matlab插值:actif轮廓检测器

时间:2013-12-07 11:34:09

标签: matlab interpolation

我尝试在matlab下编码蛇形轮廓检测器。到目前为止,这是我的代码:

function contour_actif (Image, nombre_point)

[M N]=size(Image);
Image=rgb2gray(Image);

imshow(Image);
hold on;
[x,y] = ginput(nombre_point);

t = linspace(0,1,nombre_point);
ti = linspace(0,1,10*nombre_point);
x = spline(t,x,ti);
y = spline(t,y,ti);

alpha = 5;
beta = 0.5;
gamma = 1;
iterations = 50;

N = length(x);
a = gamma*(2*alpha+6*beta)+1;
b = gamma*(-alpha-4*beta);
c = gamma*beta;
P = diag(repmat(a,1,N));
P = P + diag(repmat(b,1,N-1), 1) + diag(   b, -N+1);
P = P + diag(repmat(b,1,N-1),-1) + diag(   b,  N-1);
P = P + diag(repmat(c,1,N-2), 2) + diag([c,c],-N+2);
P = P + diag(repmat(c,1,N-2),-2) + diag([c,c], N-2);
P = inv(P);

Image = double(Image);
[Gx,Gy] = gradient(Image);
f = sqrt(Gx.^2+Gy.^2);
[Gxx Gyy]= gradient(f);

for i = 1:iterations
    coords = [x,y];    
    fex = griddedInterpolant(Gxx , 'linear')
    fey = griddedInterpolant(Gyy , 'linear')
    x = P*(x*gamma+fex);
    y = P*(y*gamma+fey);
end
plot([x;x(1)],[y;y(1)],'r')

hold off;

end

当我尝试在渐变图像和图像之间进行插值时出现错误。 coords = [x,y];
        fex = griddedInterpolant(Gxx,'linear')         fey = griddedInterpolant(Gyy,'linear')         x = P *(x * gamma + fex);         y = P *(y * gamma + fey);

请帮助。

0 个答案:

没有答案