1.完整项目描述和程序获取
>面包多安全交易平台:https://mbd.pub/o/bread/Y56TlJdx
>如果链接失效,可以直接打开本站店铺搜索相关店铺:
>如果链接失效,程序调试报错或者项目合作也可以加微信或者QQ联系。
2.部分仿真图预览
3.算法概述
SIFT 是一种从图像中提取独特不变特征的方法,其特点为基于图像的一些局部特征,而与图像整体的大小和旋转无关。并且该方法对于光照、噪声、仿射变换具有一定鲁棒性,同时能生成大量的特征点。SIFT (Scale-invariant feature transform), 尺度不变特征转换,是一种图像局部特征提取算法,它通过在不同的尺度空间中寻找极值点(特征点,关键点)的精确定位和主方向,构建关键点描述符来提取特征。
4.部分源码
.............................................................
%车标的初步定位
BW0 = bwareaopen(Img3,400);
[rows,cols] = size(BW0);
[L,n] = bwlabel(BW0);
for i=1 : n
[r,c]=find(L==i);
a1(i)=max(r);
a2(i)=min(r);
b1(i)=max(c);
b2(i)=min(c);
w(i)=b1(i)-b2(i);
h(i)=a1(i)-a2(i);
square = w(i)*h(i);
if square > 1000
Yc = (a1(i) + a2(i))/2;
Xc = (b1(i) + b2(i))/2;
end
end
Xc2 = Xc;
Yc2 = Yc-75;
xl = Yc2-40;
xr = Yc2+40;
yl = Xc2-50;
yr = Xc2+50;
CB = Img2(xl:Yc2+40,Xc2-50:Xc2+50,:);
figure(1);
imshow(Img2);
hold on
plot([b2:b1],a1*ones(size([b2:b1])),'r','linewidth',2);
hold on
plot([b2:b1],a2*ones(size([b2:b1])),'r','linewidth',2);
hold on
plot(b1*ones(size([a2:a1])),[a2:a1],'r','linewidth',2);
hold on
plot(b2*ones(size([a2:a1])),[a2:a1],'r','linewidth',2);
hold on
plot([yl:yr],xl*ones(size([yl:yr])),'g','linewidth',2);
hold on
plot([yl:yr],xr*ones(size([yl:yr])),'g','linewidth',2);
hold on
plot(yr*ones(size([xl:xr])),[xl:xr],'g','linewidth',2);
hold on
plot(yl*ones(size([xl:xr])),[xl:xr],'g','linewidth',2);
hold on
title('车标初步定位');
im1 = Img1;
im2 = rgb2gray(CB);
%基于SIFT的定位
gray1=(im1);
gray2=(im2);
[des1,loc1]=func_sift(gray1);
[des2,loc2]=func_sift(gray2);
figure(2);
func_drawPoints(im1,loc1,im2,loc2);
Num=2;Thresh=0.85;
match=func_BidirectionalMatch(des1,des2,Num,Thresh);
clear des1 des2
if isempty(match) == 0
loc1=loc1(match(:,1),:);
loc2=loc2(match(:,2),:);
figure(3);
func_linePoints(im1,loc1,im2,loc2);
Lens(kk) = length(match);
else
Lens(kk) = 0;
end
pause(0.0000000001);
end
[V,I] = max(Lens);
for kk = I
if kk == 1
Img1 = I1;
end
if kk == 2
Img1 = I2;
end
if kk == 3
Img1 = I3;
end
if kk == 4
Img1 = I4;
end
%将图片大小进行统一
Img2 = imresize(Img2,[480,640]);
%%
%车牌的定位
[R,C,K] = size(Img2);
Img3 = zeros(R,C);
for i = 1:R
for j = 1:C
%候选区域的确定
if (Img2(i,j,1)<20) & (Img2(i,j,2)<20) & (Img2(i,j,3)>100)
Img3(i,j) = 1;
end
end
end
%%
%车标的初步定位
BW0 = bwareaopen(Img3,400);
[rows,cols] = size(BW0);
[L,n] = bwlabel(BW0);
for i=1 : n
[r,c]=find(L==i);
a1(i)=max(r);
a2(i)=min(r);
b1(i)=max(c);
b2(i)=min(c);
w(i)=b1(i)-b2(i);
h(i)=a1(i)-a2(i);
square = w(i)*h(i);
if square > 1000
Yc = (a1(i) + a2(i))/2;
Xc = (b1(i) + b2(i))/2;
end
end
Xc2 = Xc;
Yc2 = Yc-75;
xl = Yc2-40;
xr = Yc2+40;
yl = Xc2-50;
yr = Xc2+50;
CB = Img2(xl:Yc2+40,Xc2-50:Xc2+50,:);
figure(1);
imshow(Img2);
hold on
plot([b2:b1],a1*ones(size([b2:b1])),'r','linewidth',2);
hold on
plot([b2:b1],a2*ones(size([b2:b1])),'r','linewidth',2);
hold on
plot(b1*ones(size([a2:a1])),[a2:a1],'r','linewidth',2);
hold on
plot(b2*ones(size([a2:a1])),[a2:a1],'r','linewidth',2);
hold on
plot([yl:yr],xl*ones(size([yl:yr])),'g','linewidth',2);
hold on
plot([yl:yr],xr*ones(size([yl:yr])),'g','linewidth',2);
hold on
plot(yr*ones(size([xl:xr])),[xl:xr],'g','linewidth',2);
hold on
plot(yl*ones(size([xl:xr])),[xl:xr],'g','linewidth',2);
hold on
title('车标初步定位');
im1 = Img1;
im2 = rgb2gray(CB);
%基于SIFT的定位
gray1=(im1);
gray2=(im2);
[des1,loc1]=func_sift(gray1);
[des2,loc2]=func_sift(gray2);
figure(2);
func_drawPoints(im1,loc1,im2,loc2);
Num=2;Thresh=0.85;
match=func_BidirectionalMatch(des1,des2,Num,Thresh);
clear des1 des2
if isempty(match) == 0
loc1=loc1(match(:,1),:);
loc2=loc2(match(:,2),:);
figure(3);
func_linePoints(im1,loc1,im2,loc2);
Lens(kk) = length(match);
else
Lens(kk) = 0;
end
pause(0.0000000001);
end
05_046_m