1) Understanding Hough Transform
Show older comments
- Implement Hough Transform (sample code is given at the lecture notes.) by using your own Canny Edge Detect code and execute it for different images given. - Learn Matlab’s embedded Hough Tranform function. Explain its parameters with outputs of your own selfie. - Compare results with your own code and explain if there is any differences.
sample code
clear % Creating a simple image im = Get your selfie and use given images. figure imshow(im) %% Initializing other parameters theta = ((-90:90)./180) .* pi; D = sqrt(size(im,1).^2 + size(im,2).^2); HS = zeros(ceil(2.*D),numel(theta)); [y,x] = find(im); y = y - 1; x = x - 1; figure rho = cell(1,numel(x)); %% Calculating the Hough Transform for i = 1: numel(x) rho{i} = x(i).*cos(theta) + y(i).*sin(theta); % [-sqrt(2),sqrt(2)]*D rho interval plot(theta,-rho{i}) hold on end %% Creating the Hough Space as an Image
for i = 1:numel(x) rho{i} = rho{i} + D; % mapping rho from 0 to 2*sqrt(2) rho{i} = floor(rho{i}) + 1; for j = 1:numel(rho{i}) HS(rho{i}(j),j) = HS(rho{i}(j),j) + 1; end end figure imshow(HS)
Answers (0)
Categories
Find more on Hough Transform in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!