91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

通過canny算子提取棋盤格圖像邊緣,然后使用Hough算法提取邊緣圖中直線,利用直線交點對全圖角點檢測結果進行過濾,最終達到自動可靠準確地提取出所有圖像中棋盤格的角點坐標,可用于相機或投影儀的標定。

資源截圖

代碼片段和文件信息

clc
clear
close?all
%結果數據是CC
%?rootFolder?=?fullfile(‘D:\Data\2016.5.18棋盤格‘);
rootFolder?=?fullfile(‘D:\程序\總‘);

imgSets?=?imageSet(rootFolder);
count=imgSets.Count(11);
row=7;%棋盤格的行數
col=10;%棋盤格的列數
rho=12;%ρ為圖像中角點彌散斑直徑。
bianchang=160;%棋盤格的邊長
theta=0.2;%角度步進
jd=cell(1count);
for?img=1:count
????I=read(imgSetsimg);%讀取第i幅圖
????I=rgb2gray(I);
????%做標準差為3的高斯濾波,然后以0.08為低門檻,0.2為高門檻,進行canny邊緣檢測
????%考慮到棋盤格信息對比度明顯,選擇較高的灰度梯度門檻值進行邊緣檢測
????%可以考慮使用OTSU算法對棋盤格圖像進行預處理
????[BWthresh]=edge(I‘canny‘[0.2*0.40.2]3);%BW為二值化的邊緣圖像
%?????figure;imshow(I[]);
%?????figure;imshow(BW[]);
????%%
????%hough變換檢測豎線
????[HTR]=hough(BW‘RhoResolution‘rho‘Theta‘-10:theta:10);
????P=houghpeaks(Hcol+3‘threshold‘ceil(0.2*max(H(:))));%預留4個裕量
????lines=houghlines(BWTRP‘FillGap‘bianchang*1.5‘MinLength‘bianchang*3);
%?????h2=figure;
%?????imshow(I‘InitialMagnification‘30);
%?????title(‘霍夫變換直線檢測‘);
%?????grid?on;
%?????axis?on;
%?????hold?on;
????shu=[];
????ps=[];
????for?k=1:length(lines)
????????xy=[lines(k).point1;lines(k).point2];
????????dis=(xy(11)+xy(21))/2;
????????shu=[shudis];
????????sign=0;
????????if?length(shu)>1
????????????for?i=1:length(shu)-1
????????????????if?abs(dis-shu(i))????????????????????shu(end)=[];%刪除重復直線
????????????????????sign=1;
????????????????????break
????????????????end
????????????end
????????end
????????if?sign
????????????continue
????????end
????????t=lines(k).theta;
????????r=lines(k).rho;
????????%寫成x=p1*y+p2的形式避免斜率為無窮
????????p=[-tan(t*pi/180)r/cos(t*pi/180)];
????????ps=[ps;p];
%?????????y=1:max(size(I));
%?????????x=polyval(py);
%?????????plot(xy‘LineWidth‘2‘Color‘‘green‘);
????end
????%刪除可能存在的棋盤格邊緣線
????%限制條件:棋盤格必須位于圖像正中,偏差不能超過一個棋盤格
????%這里是偷懶了、、湊合用
????switch?length(shu)
????????case?col+1
????????????for?u=1:2
????????????????[m1index1]=max(shu);
????????????????m1=size(I2)-m1;
????????????????[m2index2]=min(shu);
????????????????if?m1????????????????????ps(index1:)=[];
????????????????????shu(index1)=[];
????????????????else
????????????????????ps(index2:)=[];
????????????????????shu(index2)=[];
????????????????end
????????????end
????????case?col
????????????[m1index1]=max(shu);
????????????m1=size(I2)-m1;
????????????[m2index2]=min(shu);
????????????if?m1????????????????ps(index1:)=[];
????????????????shu(index1)=[];
????????????else
????????????????ps(index2:)=[];
????????????????shu(index2)=[];
????????????end
????end
????if?length(shu)????????disp(strcat(‘第‘num2str(img)‘張棋盤格豎線漏檢‘));
????end
????????
????%%
????%hough變換檢測橫線
????[HTR]=hough(BW‘RhoResolution‘rho‘Theta‘[-90:theta:-8080:theta:90-theta]);
????P=houghpeaks(Hrow+3‘threshold‘ceil(0.2*max(H(:))));
????lines=houghlines(BWTRP‘FillGap‘bianchang*1.5‘MinLength‘bianchang*3);
????heng=[];
????ph=[];
????for?k=1:length

評論

共有 條評論