Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Matlab中求角点坐标?_Matlab_Edge Detection - Fatal编程技术网

如何在Matlab中求角点坐标?

如何在Matlab中求角点坐标?,matlab,edge-detection,Matlab,Edge Detection,如何在Matlab中找到这个“正方形”中四个角的坐标?我尝试了corner、regionprops('Extrema')和detectMinEigenFeatures,但没有成功。问题是蓝色正方形不是一个完美的正方形,所以我需要一些锐化边缘的技术或者一个更“智能”的找到角点的算法来找到它们 假设您是在“图像”模式下进行此操作,而不是通过分析计算,计算从质心到形状上每个像素的距离,然后将其作为角度的函数进行绘制(即,假设您从质心和水平线开始,然后旋转该线,并注意每个角度的“半径”长度)。您的图形应

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


假设您是在“图像”模式下进行此操作,而不是通过分析计算,计算从质心到形状上每个像素的距离,然后将其作为角度的函数进行绘制(即,假设您从质心和水平线开始,然后旋转该线,并注意每个角度的“半径”长度)。您的图形应该是一条具有4个局部峰值的曲线,然后您可以将其隔离并追溯到它们的坐标


或者,如果假设角点相对保证接近图像角点,则通过从图像角点执行上述步骤并找到最小值,限制自己在相应的图像象限中找到形状角点,然后重复4次(即每个角点)

假设您是在“图像”模式下进行此操作,而不是通过分析计算,计算从质心到形状上每个像素的距离,然后将其作为角度的函数进行绘制(即,假设您从质心和水平线开始,然后旋转该线,并注意每个角度的“半径”长度)。您的图形应该是一条具有4个局部峰值的曲线,然后您可以将其隔离并追溯到它们的坐标


或者,如果假设角点相对保证接近图像角点,则通过从图像角点执行上述步骤并找到最小值,限制自己在相应的图像象限中找到形状角点,然后重复4次(即每个角点)

,因为我是个好人,我已经将塔索斯的解释翻译成代码,请查看注释:

%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')
%打开您的图像
I=imread('square.png');
I=im2bw(I(:,:,3));
%计算质心
质心=圆形(尺寸(I)/2);
%找到创建正方形的像素
[x,y]=找到(I);
%改变原点
X=[y,X]-质心;
%对数据进行排序
X=sortrows(X[12]);
%笛卡尔坐标到极坐标
[theta,rho]=cart2pol(X(:,1),X(:,2));
%根据角度对极坐标进行排序。
[POL,index]=sortrows([theta,rho],1);
%平滑,使用卷积
len=平滑因子的15%
POL(:,2)=conv(POL(:,2),one(len,1),‘相同’。/conv(one(length)(POL(:,2)),1),one(len,1),‘相同’;
%找到山峰
pfind=POL(:,2);

pfind(pfind因为我是个好人,我已经把塔索的解释翻译成了代码,请查看评论:

%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')
%打开您的图像
I=imread('square.png');
I=im2bw(I(:,:,3));
%计算质心
质心=圆形(尺寸(I)/2);
%找到创建正方形的像素
[x,y]=找到(I);
%改变原点
X=[y,X]-质心;
%对数据进行排序
X=sortrows(X[12]);
%笛卡尔坐标到极坐标
[theta,rho]=cart2pol(X(:,1),X(:,2));
%根据角度对极坐标进行排序。
[POL,index]=sortrows([theta,rho],1);
%平滑,使用卷积
len=平滑因子的15%
POL(:,2)=conv(POL(:,2),one(len,1),‘相同’。/conv(one(length)(POL(:,2)),1),one(len,1),‘相同’;
%找到山峰
pfind=POL(:,2);

pfind(pfind take it用鼠标点击它们不是选项?不是选项,不允许用户输入。“允许”还是仅仅“不切实际”?这是一个一次性的问题,还是你有成千上万的类似图像要处理?任务不允许(也是不合法的,因为我有很多类似的图像要处理)。我认为用鼠标点击他们不是一个选项?不是一个选项,不允许用户输入。“允许”或仅仅是“不可行”?这是一个一次性问题,还是你有成千上万的类似图像要处理?分配不允许(而且也不合法,因为我有许多类似的图像要处理)这是一个很棒的建议,你能给我一些代码作为例子吗?这是一个很棒的建议,你能给我一些代码作为例子吗?很好:)我完全赞同这个代码:pNice:)我完全赞同这个代码:p