⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hough.m

📁 dip函数 hough houghpeaks
💻 M
字号:
function [h] = Hough(image)
%Function to perform Hough Transform on an image
%Inputs:  image
%Returns: h
%
%image:  It is the input image.
%h:      It is the accumulator array
%
%Example:
%       h = Hough(image);
%       This call takes image as input and returns accumulator array

siz = size(image);
rl = ceil(sqrt(siz(1)^2+siz(2)^2));

h = zeros(rl,360);
theta = 360;

%Building up the accumulator array
for x = 1:siz(1)
    for y = 1:siz(2)
        if image(x,y)==1
            for theta = 1:360
                r = round(x*cos(theta*pi/180) + y*sin(theta*pi/180));
                if r<1
                    r = 1;
                    h(r,theta) = h(r,theta);
                else
                    h(r,theta) = h(r,theta) + 1;
                end
            end
        end
    end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -