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