Question

MATLAB QUESTION Implement Least squares fitting for linear line detection in MATLAB. Using Any input image,...

MATLAB QUESTION

Implement Least squares fitting for linear line detection in MATLAB. Using Any input image, After detection you need to plot output line on the input image used (you can use MATLAB functions for this purpose)

Hint: find an appropriate input image and apply edge detection first. Then use MATLAB edge detector function and Implement Sobel edge detector.

Write a report about it (written codes need to be included as a text as well).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

A series of numbers are taken in 1D matrix x and corresponding functions in matrix y. They are plotted .Then the least square fitting method are used to find a approximate plot for the series based on the values of x,y matrices .The fitted curve is plotted which approximately follows the x,y matrix values.

%%------------------ MATLAB CODE ----------------------%%

%least square regression
x=[2 5 6 8 9 13 15];
y=[7 8 10 11 12 14 15];
plot(x,y,'k*')
xlabel('x');ylabel('y')
title('data points')
grid on
hold on
%% p=polyfit(X_R,Y_R,1)

Y_R=y';
X_R=x';
H=[];
%N=5 is used for best fit
N=5;
for idx=0:N
H=[H,X_R.^idx];
end
Astar=inv(H' *H)*H'*Y_R;
Ytilde=H*Astar;
R=sum((Y_R-Ytilde).^2);
plot(X_R,Ytilde,'r-','LineWidth',2)

%%------------------------ END -------------------------------%%

plot:

N.B: Please copy the code and save it in a mfile and simulate using MATLAB tool to have the best result.

Add a comment
Know the answer?
Add Answer to:
MATLAB QUESTION Implement Least squares fitting for linear line detection in MATLAB. Using Any input image,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT