how to compute intersection of union for two polygons?
Show older comments
I have two polygons (mat files attached), how to compute their IOU (Intersection of union)? here is the code I'm using, but it gives me a wrong values.
T1 = importdata('T1.mat');
T2 = importdata('T2.mat');
polygon1= [T1(:,1),T1(:,2)];
polygon2= [T2(:,1),T2(:,2)];
poly1 = polyshape(polygon1(:,1),polygon1(:,2));
%plot(poly1)
poly2 = polyshape(polygon2(:,1),polygon2(:,2));
hold on
%plot(poly2)
ply_inter = intersect(poly1, poly2);
area_inter = area(ply_inter);
% plot(ply_inter)
ply_union = union(poly1,poly2);
area_union = area(ply_union);
% plot(ply_union)
IoU = area_inter/area_union
2 Comments
Steven Lord
on 18 Jun 2023
At first glance that looks right. What value are you getting for IoU and what value do you expect to get?
Accepted Answer
More Answers (0)
Categories
Find more on Polygonal Shapes 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!
