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!
