Curve fitting for 2d Array
26 views (last 30 days)
Show older comments
Hi,
I have to find slope by using curve fitting in this figure. There are 7 wavefronts in this image. What method should I apply? I have tried different techniques like I manually selected 2 points and find slope but that is not appropriate way. I have to utilize all the data points and fit curve to all 7 wavefronts. Sample image is attached here
0 Comments
Answers (2)
yanqi liu
on 16 Feb 2022
yes,sir,may be choose the target line by color and fit them,such as
im = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/896015/image.png');
jm = rgb2hsv(im);
v = mat2gray(jm(:,:,3));
bw = ~im2bw(v,0.9);
bw2 = imopen(bw, strel('line', 20, 0));
bw3 = logical(bw-bw2);
bw3 = imopen(imclose(bw3, strel('disk', 5)), strel('square', 3));
bw3 = bwareafilt(bw3, 2);
[r,c] = find(bw3);
p = polyfit(c,r,3);
xc = linspace(min(c),max(c));
yc = polyval(p,xc);
figure; imshow(im)
hold on; plot(xc,yc,'r--','LineWidth',2);
2 Comments
See Also
Categories
Find more on Wavelet Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!