Hough变换的实现
2012-05-09 19:51
141 查看
function [rho,theta,houghSpace] = houghTransform(theImage,thetaSampleFrequency) %Define the hough space theImage = flipud(theImage); [width,height] = size(theImage); rhoLimit = norm([width height]); rho = (-rhoLimit:1:rhoLimit); theta = (0:thetaSampleFrequency:pi); numThetas = numel(theta); houghSpace = zeros(numel(rho),numThetas); %Find the "edge" pixels [xIndicies,yIndicies] = find(theImage); %Preallocate space for the accumulator array numEdgePixels = numel(xIndicies); accumulator = zeros(numEdgePixels,numThetas); %Preallocate cosine and sine calculations to increase speed. In %addition to precallculating sine and cosine we are also multiplying %them by the proper pixel weights such that the rows will be indexed by %the pixel number and the columns will be indexed by the thetas. %Example: cosine(3,:) is 2*cosine(0 to pi) % cosine(:,1) is (0 to width of image)*cosine(0) cosine = (0:width-1)'*cos(theta); %Matrix Outerproduct sine = (0:height-1)'*sin(theta); %Matrix Outerproduct accumulator((1:numEdgePixels),:) = cosine(xIndicies,:) + sine(yIndicies,:); %Scan over the thetas and bin the rhos for i = (1:numThetas) houghSpace(:,i) = hist(accumulator(:,i),rho); end pcolor(theta,rho,houghSpace); shading flat; title('Hough Transform'); xlabel('Theta (radians)'); ylabel('Rho (pixels)'); colormap('gray'); end
来源:http://stackoverflow.com/questions/9916253/hough-transform-in-matlab-without-using-hough-function
相关文章推荐
- DSP实现快速Hough变换圆检测算法
- Hough变换的C实现
- Hough变换以及C实现
- 基于Hough 变换的直线检测(Matlab实现)
- OpenCV2马拉松第22圈——Hough变换直线检测原理与实现
- 【转】利用Hough变换实现直线检测的代码
- Hough变换——直线检测(投票方法实现)
- 直线hough变换原理及实现
- MATLAB 实现Hough变换
- opencv+vs2008实现canny边缘检测与hough变换检测直线并用红线在原图标出直线
- OpenCV2马拉松第22圈——Hough变换直线检測原理与实现
- OpenCV实现Hough变换检测圆形
- Hough变换直线检测的MATLAB实现
- 图像进行Sobel算子、Hough变换检测圆的matlab实现
- hough变换 正在的c代码风格实现
- C实现hough变换拟合直线
- Hough变换检测直线的Java实现
- Hough变换 直线检测原理及其Matlab实现
- 利用Hough变换实现直线检测的代码
- 标准hough变换的具体实现