在MATLAB中从多边形图像中检测正确数量的CORNER坐标 [英] Detect correct number of CORNER coordinates from a Polygon image in MATLAB
问题描述
我有许多多边形图像,如六边形,五边形,任何四边形等。我需要概括检测技术来检测角坐标的RIGHT数。不应生成额外的坐标。
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.
例如: - 代码应该只检测四边形为4,三角形为3,五边形为5等等。
for eg:- the code should detect only 4 for a quadrilateral, 3 for triangle, 5 for pentagon and so on..
我使用HARRIS角点检测来通过指定角点数来检测右角,但我不能对具有不同边数的图像使用相同的代码。
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.
原因使用相同的代码是我试图批量处理图像 - >检测角落并打印它们...我无法更改每个图像的代码。
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.
示例图片:
八角形
五角大楼:
推荐答案
有一个名为角落,如果输入参数正确,效果非常好。
There is a function called corner that works very well given the right input parameters.
例如设置一个合适的 QualityLevel
给出准确的结果:
For instance setting an appropriate QualityLevel
give accurate results:
clear
clc
A = imread('Octagon.jpg');
A_gray = rgb2gray(A);
figure;
Ca = corner(A_gray,'QualityLevel',.2)
存储的坐标在 Ca
中作为N x 2矩阵。这里N = 8。
The coordinates ar stored in Ca
as a N x 2 matrix. Here 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
输出:
和
是的!
这篇关于在MATLAB中从多边形图像中检测正确数量的CORNER坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!