Curve fitting for 2d Array
Afficher commentaires plus anciens
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

Réponses (2)
KSSV
le 16 Fév 2022
If (x,y) are the points of your curve...
m = gradient(y)./gradient(x) ; % diff(y)./diff(x)
7 commentaires
Leostar90
le 16 Fév 2022
KSSV
le 16 Fév 2022
In the plot you have a legend, fitted curve. What's that?
Leostar90
le 16 Fév 2022
KSSV
le 16 Fév 2022
Wavefront has 2D data right? On this use polyfit. Read about polyfit.
Leostar90
le 16 Fév 2022
KSSV
le 16 Fév 2022
Yes, for the pixel values the positions are (x,y). You need to seek those positions and fit a curve.
Leostar90
le 16 Fév 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);
Catégories
En savoir plus sur Fit Postprocessing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
