📄 matlab检测直线交点.txt
字号:
一个用matlab检测直线交点的源程序2008年05月11日 星期日 12:49function [n]=CountWhi(f,i,j,window);
n=0;
[h,w]=size(window);
if(i-(h-1)/2>0&j-(w-1)/2>0&j+(w-1)/2<size(f,2)&i+(h-1)/2<size(f,1))
window=f((i-(h-1)/2):(i+(h-1)/2),(j-(w-1)/2):(j+(w-1)/2));
n=sum(sum(window));
else
n=0;
end[f,map]=imread('****.bmp');
%函数实现了图像中单象素宽白色相交直线交点的检测
%利用的是最简单的邻域中计算白点的个数的算法,当
%一个象素的window邻域中有四个邻域为白色的时候,该
%点即为交点。
%f:image that read in with map stored with the image's colormap
%window determines the nabor which you can change according to
%the lines;CountWhi.m counts the number of white point in the nabor
%given by the window.it returns the number of the whi p
%速度慢,比较笨了,可以分两步来作,第一次循环时步长可以大一些:)
[h,w]=size(f);
sign=0;
window=zeros(3);;
x=0;
% y=0;
% n=0;
for i=0:h
if sign~=0
break;
end
for j=0:w
n=CountWhi(f,i,j,window);
if n==4
sign=1;
break;
else
continue;
end
end
end
image(f),colormap(map);
hold on,plot(j,i,'+r');
[n]=CountWhi(f,i,j,window);
n=0;
[h,w]=size(window);
if(i-(h-1)/2>0&j-(w-1)/2>0&j+(w-1)/2<size(f,2)&i+(h-1)/2<size(f,1))
window=f((i-(h-1)/2):(i+(h-1)/2),(j-(w-1)/2):(j+(w-1)/2));
n=sum(sum(window));
else
n=0;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -