hough transform to small

1 回表示 (過去 30 日間)
James Robinson
James Robinson 2022 年 12 月 8 日
回答済み: Kush 2023 年 7 月 11 日
i am running a program that cand find and plot lines. after masking the image with color thresholder and using canny edge detect, when i run the hough transform, the image comes out to small.
  1 件のコメント
Varun
Varun 2023 年 3 月 23 日
Hello!
Can you please elaborate on exactly what's going wrong with your code and what you are trying to achieve?

サインインしてコメントする。

回答 (1 件)

Kush
Kush 2023 年 7 月 11 日
According to your given picture and question, I assume you're trying to do lane detection using canny edge detection and hough transform to overlay lines on that lane. Try altering your threshold values for color thresholding, Here is a result that I tried to get using some thresholding techniques and hough transform via this code.
image = imread('out1.jpeg');
hls = rgb2hsv(image);
s_channel = hls(:,:,2)*255;
s_binary = zeros(size(s_channel));
s_binary((s_channel > 130) & (s_channel <= 255)) = 1;
hsv = rgb2hsv(image);
v_channel = hsv(:,:,3)*255;
v_binary = zeros(size(v_channel));
v_binary((v_channel > 220) & (v_channel <= 250)) = 1;
output = zeros(size(s_channel));
output((s_binary == 1) | (v_binary == 1)) = 1;
output = logical(output);
convolvedImage = imboxfilt(double(output), [7,7]); %Choose a window size for blurring
% Perform Hough transform
[H,theta,rho] = hough(convolvedImage);
% Find peaks in the Hough transform
peaks = houghpeaks(H, 10); % Adjust the number of peaks as needed
% Retrieve the lines from the Hough transform
lines = houghlines(convolvedImage, theta, rho, peaks);
% Display the original image
figure;
subplot(1, 2, 1);
imshow(image);
title('Original Image');
% Display the Canny edges
subplot(1, 2, 2);
imshow(convolvedImage);
hold on;
% Plot the detected lines on the Canny edges
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:, 1), xy(:, 2), 'LineWidth', 2, 'Color', 'r');
end
%imwrite(convolvedImage,"edgeDetectionImage.jpg","jpg");
%saveas(gcf, 'plot.png');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by