How To Identify Shapes Using Affine Transform?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
This is the problem I have: Given 4 images ('AllThreeShapes.jpeg','circle.jpeg','square.jpeg','triangle.jpeg'), I need to apply an affine transformation on those images to identify each of the shapes in 'AllThreeShapes.jpeg'. Basically, I just need to confirm in my coding that the left image is a circle, middle image is a triangle, and the right image is a square.
I figured that if I considered the pose of the objects with respect to a few reference points for each of the objects, then I could successfully identify the shapes in 'AllThreeShapes.jpeg' correctly.
I've attached the 4 images.
And the coding I have which reads in the 4 images is below:
if true
% code
end
clc
InputImage='AllThreeShapes.jpeg';
[img,map]=imread(InputImage);
figure
imshow(img,map);
title('Original Image of 3 Objects');
%Read the other images of the 3 seperate objects.
%(circle.jpeg,square.jpeg,& triangle.jpeg)
%and display them.
CircleImage='circle.jpeg';
[img,map]=imread(CircleImage);
figure
imshow(img,map);
title('Circle Object');
SquareImage = 'square.jpeg';
[img,map]=imread(SquareImage);
figure
imshow(img,map);
title('Square Object');
TriangleImage = 'triangle.jpeg';
[img,map]=imread(TriangleImage);
figure
imshow(img,map);
title('Triangle Object');
The problem I have is that I'm not too sure how to apply an affine transformation to the 'circle.jpeg','square.jpeg', and 'triangle.jpeg' images to identify those 3 objects correctly in 'AllThreeShapes.jpeg'.
Any help would be greatly appreciated.
0 commentaires
Réponses (2)
Image Analyst
le 12 Nov 2013
I'm not sure why you want to apply an affine transform and what you think that will get you. Why don't you just use regionprops to calculate the area and perimeter and calculate the circularities, which will be different for each shape
circularities = perimeters .^ 2 / (4*pi*Areas);
Or else use bwboundaries to get the perimeter coordinates and then use this http://matlab.wikia.com/wiki/FAQ#How_do_I_find_.22kinks.22_in_a_curve.3F to find out how many kinks there are in the coordinates.
2 commentaires
Image Analyst
le 12 Nov 2013
You need to tweak your circularity numbers to get the proper range for each shape. But, yes, this is basically it. Please mark the answer as Accepted. Thanks.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!