polynomial curve fitting on image
Afficher commentaires plus anciens
Hello all, below is one of the images i am working on

I would like to perform third degree polynomial curve fitting on the green and red boundary segments and find their intersection points.Further using that intersection point i would like to segment the image into right and left parts. But I am not getting the right fitting, what am i doing wrong, can anyone please help? I have attactched the code and the original image. Any help is deeply appreciated, thank you in advance.
clc;
clear;
close all;
a=rgb2gray(imread('FLIR0179.jpg'));
a=a(500:800,50:1080);
en= imsharpen(a,'Radius',4,'Amount',2);
ed=edge(en,'canny',0.2,0.5);
bw1=bwareaopen(ed,20);
se = strel('disk',4);
bw=imdilate(bw1,se);
col1 = 422;
row1 = min(find(bw(:,col1)));
boundary1 = bwtraceboundary(bw,[row1, col1],'N');
col2 = 629;
row2 = min(find(bw(:,col2)));
boundary2 = bwtraceboundary(bw,[row2, col2],'N');
figure;
imshow(bw);
hold on;
plot(boundary1(:,2),boundary1(:,1),'g','LineWidth',3);
plot(boundary2(:,2),boundary2(:,1),'r','LineWidth',3);
hold off
x1 = boundary1(:, 2);y1 = boundary1(:, 1);
x2 = boundary1(:, 2);y2 = boundary1(:, 1);
P1=polyfit(y1,x1,3);
P2=polyfit(y2,x2,3);
yy = linspace( 1, size(bw,1));
p1=polyval( P1, yy);
p2=polyval( P2, yy);
figure;
imshow(a, 'border', 'tight' );
hold on
plot(p1,yy);
plot(p2,yy);
hold off
Réponses (0)
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!