Curve fitting for 2d Array
显示 更早的评论
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

回答(2 个)
KSSV
2022-2-16
If (x,y) are the points of your curve...
m = gradient(y)./gradient(x) ; % diff(y)./diff(x)
7 个评论
Leostar90
2022-2-16
KSSV
2022-2-16
In the plot you have a legend, fitted curve. What's that?
Leostar90
2022-2-16
KSSV
2022-2-16
Wavefront has 2D data right? On this use polyfit. Read about polyfit.
Leostar90
2022-2-16
KSSV
2022-2-16
Yes, for the pixel values the positions are (x,y). You need to seek those positions and fit a curve.
Leostar90
2022-2-16
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);
类别
在 帮助中心 和 File Exchange 中查找有关 Fit Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
