hough transform to small
1 次查看(过去 30 天)
显示 更早的评论
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
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
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');
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!