How To Identify Shapes Using Affine Transform?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Image Analyst
2013 年 11 月 12 日
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 件のコメント
Image Analyst
2013 年 11 月 12 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!