[英]Detect correct number of CORNER coordinates from a Polygon image in MATLAB
I have a number of polygon images like a hexagon, a pentagon, any quadrilateral etc.. i need to generalize the detection technique to detect the RIGHT number of Corner coordinates.. no extra coordinates should be generated. 我有许多多边形图像,例如六边形,五边形,任何四边形等。我需要推广检测角点坐标的正确数量的检测技术。不应生成任何额外的坐标。
for eg:- the code should detect only 4 for a quadrilateral, 3 for triangle, 5 for pentagon and so on.. 例如:-代码应仅检测四边形为4,三角形为3,五边形为5,依此类推。
I used HARRIS corner detection to detect right corners by specifying the number of corners value but i cant use the same code for an image with different number of edges. 我使用HARRIS拐角检测通过指定拐角数值来检测右拐角,但是我不能对具有不同边缘数的图像使用相同的代码。
Reason for using the same code is i am trying to bulk process image -> Detect corners and print them... i cant change the code for each image. 使用相同代码的原因是我正在尝试批量处理图像->检测角并打印它们...我无法更改每个图像的代码。
Sample Images:- 样本图片:-
Octagon: 八边形:
Pentagon: 五角大楼:
There is a function called corner that works very well given the right input parameters. 给定正确的输入参数,有一个称为corner的功能可以很好地工作。
For instance setting an appropriate QualityLevel
give accurate results: 例如,设置适当的
QualityLevel
得到准确的结果:
clear
clc
A = imread('Octagon.jpg');
A_gray = rgb2gray(A);
figure;
Ca = corner(A_gray,'QualityLevel',.2)
The coordinates ar stored in Ca
as a N x 2 matrix. 坐标ar作为N x 2矩阵存储在
Ca
中。 Here N = 8. 这里N = 8。
imshow(A)
hold on
scatter(Ca(:,1),Ca(:,2),80,'filled','k')
hold off
B = imread('Pentagon.jpg');
B_gray = rgb2gray(B);
figure;
Cb = corner(B_gray,'QualityLevel',.2)
imshow(B)
hold on
scatter(Cb(:,1),Cb(:,2),80,'filled','k')
hold off
Outputs: 输出:
and 和
Yay! 好极了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.