Slope Detection of line in a image
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Can I use this method of finding slope to this image
Ymin,Ymax,xmin and Xmax are coordinates of the line
slope=(Ymax-Ymin/Xmax-Xmin);
Because it is not a perfect straight line.So using this will be correct?
0 Kommentare
Antworten (2)
Image Analyst
am 7 Nov. 2011
I wouldn't do it that way at all. That's just the slope between the endpoints. What you probably want is to use polyfit() to get the slope and offset so that you use all the points along the line. Write back if you can't figure out how to use polyfit.
3 Kommentare
Image Analyst
am 7 Nov. 2011
I don't know what that means. Your coeff variable has the offset and the slope so I don't know what you're asking. However it looks like you're really struggling and could benefit from a full blown demo. See my answer below.
Image Analyst
am 7 Nov. 2011
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 16;
xcoord = 0:42;
% Create a line with close 2 and offset 10;
ycoord = 2.0 * xcoord + 10;
subplot(3, 1, 1);
plot(xcoord, ycoord, 'rd-', 'LineWidth', 3);
grid on;
title('Perfect Y', 'FontSize', fontSize);
ylabel('Perfect Y', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1])
% Now add noise.
noisy_y = ycoord + 10*rand(1, length(xcoord));
subplot(3, 1, 2);
plot(xcoord, noisy_y, 'bd-', 'MarkerSize', 10);
grid on;
title('Noisy Y', 'FontSize', fontSize);
ylabel('Noisy Y', 'FontSize', fontSize);
% Now do the fit.
coeff = polyfit(xcoord, noisy_y,1)
fitted_y = polyval(coeff, xcoord);
subplot(3, 1, 3);
plot(xcoord, noisy_y, 'bd', 'MarkerSize', 10);
hold on;
plot(xcoord, fitted_y, 'r-', 'LineWidth', 3);
grid on;
title('Fitted Y', 'FontSize', fontSize);
ylabel('Fitted Y', 'FontSize', fontSize);
message = sprintf('The slope = %.3f\nThe intercept is %.3f',...
coeff(1), coeff(2));
uiwait(msgbox(message));
2 Kommentare
Image Analyst
am 10 Nov. 2011
So just do it on the xcoords and ycoords that you have for each frame - you already know how to do that because you did it already for the first frame. Just do it like you did for the first frame.
Siehe auch
Kategorien
Mehr zu Basic Display finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!