Tôi tìm thấy một thực hiện các biến đổi Hough trong MATLAB tại Rosetta Code, nhưng tôi đang gặp khó khăn khi hiểu nó. Ngoài ra tôi muốn sửa đổi nó để hiển thị hình ảnh gốc và các đường được xây dựng lại (de-Houghing).Hough biến đổi trong MATLAB mà không sử dụng chức năng hough
Bất kỳ trợ giúp nào trong việc hiểu nó và khử Houghing đều được đánh giá cao. Cảm ơn
Tại sao hình ảnh bị lật?
theImage = flipud(theImage);
Tôi không thể quấn quanh đầu tôi các chức năng tiêu chuẩn. Mục đích của nó là gì, và nó có thể tránh được không?
EDIT: tiêu chỉ là một từ đồng nghĩa với khoảng cách Euclide: sqrt (chiều rộng^2 + chiều cao^2)
rhoLimit = norm([width height]);
Ai đó có thể cung cấp một lời giải thích như thế nào/tại sao rho, theta, và houghSpace được tính?
rho = (-rhoLimit:1:rhoLimit); theta = (0:thetaSampleFrequency:pi); numThetas = numel(theta); houghSpace = zeros(numel(rho),numThetas);
Làm cách nào để loại bỏ không gian Hough để tạo lại đường kẻ?
Gọi chức năng sử dụng một hình ảnh 10x10 của một đường chéo tạo ra bằng cách sử dụng danh tính (mắt) chức năng
theImage = eye(10)
thetaSampleFrequency = 0.1
[rho,theta,houghSpace] = houghTransform(theImage,thetaSampleFrequency)
Chức năng thực tế
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
Câu hỏi hay hơn về [DSP.SE] (http://dsp.stackexchange.com/). – Phonon
@Phonon Tại sao? Đây là câu hỏi về chi tiết triển khai của một thuật toán cụ thể. –