0% found this document useful (0 votes)
6 views4 pages

Hogh Transform

The document outlines a series of image processing tasks using Matlab/Python/C++. It includes importing images, applying Canny edge detection, and performing Hough transforms to detect lines and circles in the images. Specific code snippets are provided for each task, demonstrating the implementation of these techniques.

Uploaded by

pawruu2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Hogh Transform

The document outlines a series of image processing tasks using Matlab/Python/C++. It includes importing images, applying Canny edge detection, and performing Hough transforms to detect lines and circles in the images. Specific code snippets are provided for each task, demonstrating the implementation of these techniques.

Uploaded by

pawruu2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Họ tên:Trương Minh Thành

MSSV:22151145
Question 1:
1.1.Import an image to Matlab/python/C++
I = imread("art2.png");
imshow(I);title('Original image');

1.2.Extract the edge using Canny method


I_gray = rgb2gray(I);
I_edges = edge(I_gray, 'Canny');
figure;
imshow(I_edges), title('Canny Edge Detection');

1.3.Hough transform:
*Find the straight line in the edge image
*Show the response of rho and theta value
[H, theta, rho] = hough(I_edges);
peaks = houghpeaks(H, 10);
lines = houghlines(I_edges, theta, rho, peaks);
figure;
subplot(2,1,1), imshow(I), hold on, title('Detected Lines');
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1), xy(:,2), 'LineWidth', 2, 'Color', 'green');
plot(xy(1,1), xy(1,2), 'x', 'LineWidth', 2, 'Color', 'yellow');
plot(xy(2,1), xy(2,2), 'x', 'LineWidth', 2, 'Color', 'red');
end
subplot(2,1,2);
imshow(imadjust(rescale(H)), 'XData', theta, 'YData', rho, ...
'InitialMagnification', 'fit');
xlabel('\theta (degrees)'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(gca,hot);
title('Hough Transform');

Question 2:
2.1.Import an image to Matlab/python/C++
I1 = imread('coins.png');
figure;
imshow(I1);title("Original Image");
2.2.Extract the edge using Canny method
I_edges1 = edge(I1, 'Canny');
figure;
imshow(I_edges1), title('Canny Edge Detection');

2.3.Hough transform:
*Select the radius range of circles
*Find the circles in the edge image
radius_range = [20 50];
[centers, radii] = imfindcircles(I_edges1, radius_range, 'ObjectPolarity', 'bright', 'Sensitivity', 0.9);
figure, imshow(I1), title('Detected Circles');
hold on;
viscircles(centers, radii, 'EdgeColor', 'b');
hold off

You might also like