?? 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 + -