資源簡介
mathwork上的有關廣義霍夫變換學習的代碼,其中的輸入變量需要自己更改。
代碼片段和文件信息
function?[score??y?x?]?=?Generalized_hough_transform(IsItm)?
%Find?template/shape?Itm?in?greyscale?image?Is?using?generalize?hough?trasform
%Use?generalized?hough?transform?to?find?Template/shape?binary?image?given?in?binary?image?Itm?in?grayscale?image?Is?(greyscale?image)
%Is?is?greyscale??picture?were?the?template?Itm?should?be?found?
%Itm?is?bool?edge?image?of?the?template?with?edges?markedd?ones
%Return?the?xy?location??cordniates??which?gave?the?best?match?
%Also?return?the?score?of?each?this?point?(number?of?point?matching)
%The?xy?are?the?cordinates?in?image?Is?in?which?the??the?top?left?edge?of?image?Itm?(11)?should?be?positioned?in?order?to?give?the?best?match
%Is=imread(‘‘);
%Itm=imread(‘‘);
%if?nargin<3?thresh=1;end;
%--------------------------create?edge?and?system?edge?images------------------------------------------------------------------------------------------------------------------------
%Is=rgb2gray(Is);
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
%-------------------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(MaxAngelsBinsMaxPointsPerangel2);?%?assume?maximum?of?100?points?per?angle?with?MaxAngelsBins?angles?bins?between?zero?and?pi?and?xy?for?the?vector?to?the?center?of?each?point
%?the?third?adimension?are?vector?from?the?point?to?the?center?of?the?vessel
%------------------fill?the??angel?bins?with?points?in?the?Rtable---------------------------------------------------------
for?f=1:1:nvs(1)
????bin=round((GradientMap(y(f)?x(f))/pi)*(MaxAngelsBins-1))+1;?%?transform?from?continues?gradient?angles?to?discrete?angle?bins?and?
????PointCounter(bin)=PointCounter
- 上一篇:matlab輪廓匹配的物體識別系統
- 下一篇:乘同余法產生M序列的matlab源程序
評論
共有 條評論