how to find convex hull and the area of intersection
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I want to find the convex hull of this two triangle and then find the intersection area of them.to find convex hull i tried convhull(A,B) but it did not work. Is there anybody to explain how can i use convhull function for the code below.
P(1,:) = [0.9 2.1]; P(2,:) = [2.8 5.2]; P(3,:) = [5.7 2.3];
Q(:,:) = ... [2.7 1.1 5.6 4.1 8.0 1.8];
X = [P(:,1) P(1,1)];
Y = [P(:,2) P(1,2)];
line(X,Y)
A = [Q(:,1)
Q(1,1)];
B = [Q(:,2) Q(1,2)];
line(A,B)
0 commentaires
Réponse acceptée
Image Analyst
le 23 Déc 2011
Sum the intersection image to find the area. Try this code:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
P(1,:) = [0.9 2.1];
P(2,:) = [2.8 5.2];
P(3,:) = [5.7 2.3];
windowSize = 30;
image1 = poly2mask(P(:,1), P(:,2), windowSize, windowSize);
subplot(2, 2,1);
imshow(image1);
title('P', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
Q = [2.7 1.1; 5.6 4.1; 8.0 1.8];
image2 = poly2mask(Q(:,1), Q(:,2), windowSize, windowSize);
subplot(2, 2, 2);
imshow(image2);
title('Q', 'FontSize', fontSize);
intersectionImage = image1 | image2;
subplot(2, 2, 3);
imshow(intersectionImage);
title('Intersection Image', 'FontSize', fontSize);
intersectionCoords = [P;Q];
convexHullIndex = convhull(intersectionCoords)
convexHullImage = poly2mask(intersectionCoords(convexHullIndex,1), intersectionCoords(convexHullIndex,2), windowSize, windowSize);
subplot(2, 2, 4);
imshow(convexHullImage);
title('Convex Hull Image', 'FontSize', fontSize);
2 commentaires
Image Analyst
le 23 Déc 2011
If you don't want to do it quantized (via digital arrays/images) then you're going to have to figure it out analytically using formulas for the 6 lines to find intersection points and the overlap area. Maybe the Symbolic Toolbox could help you - I don't know because I don't have that toolbox.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Point Cloud Processing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!