如何在Matlab中找到这个“正方形”中四个角的坐标?我试过corner,regionprops('Extrema')和detectMinEigenFeatures,但没有运气。问题是蓝色方块不是一个完美的正方形,所以我需要某种锐化的边缘技术或者更“智能”的找角算法来找到它们。

发布于 2017-01-04 16:04:39
因为我是个好人,所以我把Tasos的解释翻译成代码,查看评论:
%Open your image
I = imread('square.png');
I = im2bw(I(:,:,3));
%Compute the centroid
centroid = round(size(I)/2);
%Find the pixels that create the square
[x,y] = find(I);
%Change the origin
X = [y,x]-centroid;
%Sort the data
X = sortrows(X,[1 2]);
%Cartesian to polar coordinates
[theta,rho] = cart2pol(X(:,1),X(:,2));
%sort the polar coordinate according to the angle.
[POL,index] = sortrows([theta,rho],1);
%Smoothing, using a convolution
len = 15 %the smoothing factor
POL(:,2) = conv(POL(:,2),ones(len ,1),'same')./conv(ones(length(POL(:,2)),1),ones(len ,1),'same');
%Find the peaks
pfind = POL(:,2);
pfind(pfind<mean(pfind)) = 0;
[~,pos] = findpeaks(pfind);
%Change (again) the origin
X = X+centroid;
%Plot the result
plot(POL(:,1),POL(:,2))
hold on
plot(POL(pos,1),POL(pos,2),'ro')
figure
imshow(I)
hold on
plot(X(index(pos),1),X(index(pos),2),'ro')结果:
距离(y轴)与角度(x轴)图:

最后发现:

发布于 2017-01-04 11:25:48
假设你是在“图像”模式下做这件事,而不是解析的,计算出从质心到形状上每个像素的距离,然后把它绘制成角度的函数(就好像你从质心和一条水平线开始,然后旋转这条线,并在每个角度上注意到‘半径’的长度)。你的图形应该是一条有4个局部峰的曲线,然后你可以分离并追溯到它们的坐标。
或者,如果假设角点相对保证接近图像角,则通过从图像角点执行上述步骤并求出最小值,限制自己在各自的图像象限中找到形状角,然后重复这4次(即每个角)。
https://stackoverflow.com/questions/41462091
复制相似问题