资源简介
matlab开发-使用与旋转匹配的模板查找目标图像。使用与旋转匹配的模板在图像中查找对象
代码片段和文件信息
function [score y x ] = Generalized_hough_transform(IsItm)
%Find template/shape Itm in greyscale image Is using generalize hough trasform
%show the image with the template marked on it
%Use generalized hough transform to find Template/shape binary image given in binary image Itm inimage Is (greyscale image)
%Return the xy location cordniates which gave the best match
%Also return the score of the match (number of point matching)
%INPUT
%Is is greyscale picture were the template Itm should be found
%Itm is binary edge image of the template with edges marked 1 and the rest 0
% OUTPUT
%Score of the best match
%xy location of template Itm in image Is (Location the edge (point [11]) of the template Itm in Is)
%%%%%%%%%%%%%%%%%%%%%%%%Reads images if this were not input%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (nargin<2) %if no image was given as input read images from file
Itm=imread(‘itm.tif‘);
Is=imread(‘Is.tif‘);
%Is=rgb2gray(Is);
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------create edge and system edge images------------------------------------------------------------------------------------------------------------------------
Iedg=edge(Is‘canny‘); % Take canny edge images of Is with automatic threshold
%}
%--------------------------------------------------------------------------------------------------------------------------------------
[y x]=find(Itm>0); % find all yx cordinates of all points equal 1 inbinary template image Itm
nvs=size(x);% number of points in the template image
if (nvs<1) disp(‘error no points find in in template in generalize hought transform teriminating‘); quit() ; end
%-------------------Define Yc and Xc ----------------------------------------------
Cy=1;%round(mean(y));% find object y center note that any reference point will do so the origin of axis hence 1 could be used just as well
Cx=1;%round(mean(x));% find object z center note that any reference point will do so the origin of axis hence 1 could be used just as well
%------------------------------create gradient map of Itm distrobotion between zero to pi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GradientMap = gradient_direction( Itm );
%%%%%%%%%%%%%%%%%%%%%%%Create an R-Table of Itm gradients to parameter space in parameter space.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%---------------------------create template descriptor array------------------------------------
MaxAngelsBins=30;% devide the angel space to MaxAngelsBins uniformed space bins
MaxPointsPerangel=nvs(1);% maximal amount of points corresponding to specific angel
PointCounter=zeros(MaxAngelsBins);% counter for the amount of edge points associate with each angel gradient
Rtable=zeros(MaxAngelsBinsMaxPoint
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 409435 2015-03-30 05:01 ReadMe.pdf
文件 196635 2015-03-30 05:04 ReadMe.docx
文件 8129 2015-03-30 06:14 MAIN_find_ob
文件 1104 2013-08-21 01:40 Itm.tif
文件 12975 2015-03-29 06:13 Is.JPG
文件 658 2013-08-28 03:39 gradient_size.m
文件 1006 2013-09-05 22:11 gradient_direction.m
文件 6990 2014-06-11 00:55 Generalized_hough_transform.m
文件 6721 2015-03-28 08:47 Template_match.m
文件 288 2013-07-01 00:35 set2.m
文件 4648 2015-03-29 06:00 Rotate_binary_edge_image.m
文件 1310 2015-03-29 19:50 license.txt
评论
共有 条评论