你试过MSER 算法吗?它对我来说总是很好。
---标准答案结束,只有在您有时间并喜欢玩图像处理时才继续---
此外,在搜索面积相对较小的模板时,我开发了一种方法来使用模板的稳定极值区域 (SER) 来映射扫描区域,以获得另一种更强大/资源密集型的算法。这种方法非常容易实施,并且在我的上一个项目中创造了奇迹。如果您有兴趣,实现如下(MatLab 代码,但没有花哨的函数或矢量化):
尝试使用以下程序确定徽标的唯一稳定性区间 (MinT-MaxT):
TestImage=imread('Leaves.jpg');
TestImage=rgb2gray(TestImage); %Transform RGB to grayscale
NewSER=zeros(size(TestImage)); %initialise stuff
OldSER=zeros(size(TestImage));
SpinSER=zeros(size(TestImage));
Hot=zeros(size(TestImage)); %your stability map
MaxT=255; %your interval, unlike MSER you don't use the whole bit-depth
MinT=1; %try something like 40-150 if you have high contrast in your logo
for k=MaxT:-1:MinT
TestImage1=im2bw(TestImage,k/256);
imshow(abs(Hot/Interval))
colormap(hot)
hold on
text(20,30,['Treshold: ',num2str(k)],'Color','k','FontWeight','bold','FontSize',16,'BackgroundColor','r')
hold off
OldSER=NewSER;
NewSER=TestImage1;
for i=1:size(TestImage,1);
for j=1:size(TestImage,2)
if OldSER(i,j)==NewSER(i,j) && SpinSER(i,j)==0 % Do the extremal regions remain the same/ are they stable over both thresholds?
Hot(i,j)=Hot(i,j)+1;
else
Hot(i,j)=Hot(i,j)-1;
SpinSER(i,j)=1;
end
end
end
shg
pause(0.1)
end
一旦您确定了适合您所在区域的时间间隔,就会生成一张地图以区分图像的其余部分,并在地图上搜索感兴趣的区域。
MaxT=120;
MinT=40;
Map=zeros(x,y); %Create a map for the SER-filtering
% TestImageMinT=im2bw(Image,MinT/256); %Set the range of the extremal region stability.
% TestImageMaxT=im2bw(Image,MaxT/256);
%
% for i=1:x
% for j=1:y
%
% Map(i,j)=TestImageMaxT(i,j)==TestImageMinT(i,j) ; %Map the pixels that remain stable over the interval
%
% end
% end
Map=abs(Image-(MaxT-MinT)/(2*MaxT))*2*MaxT/(MaxT-MinT); %More or less equivalent to the loop comented above but >10x faster...
Map=Map>0.5; %...
并将您想要的任何检测器应用于该区域或 ¬(该区域)
Corners = CornerSusanMapped(ImageBW,Map,17);
希望对您有所帮助并玩得开心!