【问题标题】:How do I get the function of the curve in an image?如何获得图像中曲线的功能?
【发布时间】:2017-03-30 18:40:46
【问题描述】:

我需要得到曲线的函数,因为我需要计算得到长度曲线。 首先我尝试从曲线中获取函数

[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
   grayImage = grayImage(:, :, 2); % Take green channel.
end
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off') 
binaryImage = grayImage < 100;
subplot(2, 2, 2);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);
axis on;
[rows, columns] = find(binaryImage);
coefficients = polyfit(columns, rows, 3); 
fittedX = linspace(min(columns), max(columns), 500);
fittedY = polyval(coefficients, fittedX);
subplot(2,2,3:4);

plot(fittedX, fittedY, 'b-', 'linewidth', 4);
grid on;
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
hold on;
plot(columns, rows, 'r+', 'LineWidth', 2, 'MarkerSize', 10);

测试图像是下一条曲线

【问题讨论】:

    标签: matlab function curve


    【解决方案1】:

    弧长(s)的公式是

      s = Integral Sqrt[1 + (dy/dx)^2] dx,
    

    其中两个 x 端点处的积分极限。对于大多数曲线来说,这不是很容易处理,因此您必须求助于将小的线性部分相加。

    【讨论】:

    • 我尝试使用代码,但是当我尝试对我的函数进行整数运算时出现错误... formula = poly2sym([coefficients(1),coefficients(2),coefficients(3)]) ;公式D = vpa(公式) df=@(x)diff(公式(x)); df = df^2 f= @(x)sqrt(1+(df)^2); i = 积分(f,0,Inf);我得到这个错误 Error using sym>tomupad (line 1135) Conversion to 'sym' from 'function_handle' 是不可能的。 sym 错误(第 151 行) S.s = tomupad(x); sym/int 错误(第 63 行) f = sym(f);
    • 我只使用int而不是integral
    猜你喜欢
    • 2011-02-01
    • 2019-06-21
    • 1970-01-01
    • 2020-05-16
    • 1970-01-01
    • 2013-09-03
    相关资源
    最近更新 更多