日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Shi-Tomasi算子的运用 ,用于检测角点

發布時間:2025/4/16 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Shi-Tomasi算子的运用 ,用于检测角点 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

角點檢測

當一個窗口在圖像上移動,在平滑區域如圖(a),窗口在各個方向上沒有變化。在邊緣上如圖(b),窗口在邊緣的方向上沒有變化。在角點處如圖(c),窗口在各個方向上具有變化。Harris角點檢測正是利用了這個直觀的物理現象,通過窗口在各個方向上的變化程度,決定是否為角點。

將圖像窗口平移[u,v]產生灰度變化E(u,v)

由:, 得到:

對于局部微小的移動量 [u,v],近似表達為:

其中M是 2*2 矩陣,可由圖像的導數求得:

E(u,v)的橢圓形式如下圖:

?

定義角點響應函數?R?為:

Harris角點檢測算法就是對角點響應函數R進行閾值處理:R > threshold,即提取R的局部極大值。

?

Shi--Tomasi角點檢測法,如果像素點的最小特征值大于周圍像素的特征值,則該點是角點。


代碼:

<span style="font-size:18px;"><strong>im=imread('lena.jpg'); tau=100; im=double(im); keyXs=[]; keyYs=[]; win=3; [height,width] = size(im); result = zeros(height,width); %Then I will get the gradients of the image along the x and y axises. sobel_x=1/4*[-1 0 1;-2 0 2;-1 0 1]; sobel_y=1/4*[-1 0 1;-2 0 2;-1 0 1]'; diffx=imfilter(im,sobel_x); %對圖像x方向進行梯度 diffy=imfilter(im,sobel_y); %對圖像y方向的梯度進行計算 %For smoothing the differentiation of the image along the x and y %direction, the gauss filter of the diffx and diffy is must. gauss_win=win; sigma=1; [x,y]=meshgrid(-gauss_win:gauss_win,-gauss_win:gauss_win); gauss2D=exp(-(x.^2+y.^2)/(2*sigma.^2)); %產生高斯算子 gauss2D=gauss2D/(sum(sum(gauss2D))); %對高斯算子進行歸一化 %Then calculate the M matrix. A=imfilter(diffx.*diffx,gauss2D); %二階x方向梯度進行高斯濾波 B=imfilter(diffy.*diffy,gauss2D); %二階y方向梯度進行高斯濾波 C=imfilter(diffx.*diffy,gauss2D); %對圖像x y方向的梯度進行高斯濾波 supress_win=2;threshold=100;points_count=0;bigger=zeros(height,width);smaller=zeros(height,width);for x=1:widthfor y=1:heightM=[A(y,x) C(y,x);C(y,x) B(y,x)];%It is too time-consuming.%eigenvalue=eig(M);%bigger(y,x)=max(eigenvalue);%smaller(y,x)=min(eigenvalue);temp1=M(1,1)+M(2,2);temp2=sqrt((M(1,1)-M(2,2))^2+4*M(1,2)^2);bigger(y,x)=(temp1+temp2)/2;smaller(y,x)=(temp1-temp2)/2;endendfor x=supress_win+1:width-supress_winfor y=supress_win+1:height-supress_win temp=smaller(y,x);if(temp>threshold)%Then I will make the non-maximumu suppression to the%samller matrix after the threholding.flag=0;for i=-supress_win:supress_winfor j=-supress_win:supress_winif(temp>=smaller(y+j,x+i))flag=flag+1;endendendif(flag==((2*supress_win+1)*(2*supress_win+1)))result(y,x)=1;points_count=points_count+1;keyXs(points_count)=x;keyYs(points_count)=y;endendendend end </strong></span>

總結

以上是生活随笔為你收集整理的Shi-Tomasi算子的运用 ,用于检测角点的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。