Lane detection and tracking using B-snake? I am truly sorry if my question sounds little bit stupid, but I am getting stuck at this part for a long time. I am currently working for my final year project of lane detection for curved road using B-snake. I am using Matlab software, and I have done the image pre processing part by converting the RGB value to grayscale. After the converting I simply use the Canny edge detection but it seems that there is too many noise.



This is the first part that I obtained :



Then, I tried the region props function for which the Matlab code I obtained from this website. The noise has reduced a little bit.



The only region that I want is the road region. But I don't manage to get the ROI that I need. So I just proceed to Hough Transform to obtain the straight line. I try to run the coding of Hough Transform that I found on the internet, but the result is so confusing. I don't know how to change the code so that my result will turn out better.

The image after Hough Transform is applied :



This is my full code:

I=imread('C:\Users\LENOVO\Documents\MATLAB\PSM2\road\draw\test1.jpg'); %         Input image file here
dim = size(I); % Get size of the image and store in an array called 'dim'.%size array matrix; 1 is height, 2 is width

I2 = rgb2gray(I); % Convert to grayscale
BW = edge(I2,'canny',[]); % Edge detection using Canny
cc = bwconncomp(BW);
I4 = labelmatrix(cc);

a_rp = regionprops(cc,'Area','MajorAxisLength','MinorAxislength','Orientation','PixelList','Eccentricity');
idx = ([a_rp.Eccentricity] &gt; 0.99 &amp; [a_rp.Area] &gt; 100 &amp; [a_rp.Orientation] &lt; 60 &amp; [a_rp.Orientation] &gt; -90);

BW2 = ismember(I4,find(idx));
[H,T,R] = hough(BW2);

%  figure, imshow(H,[], 'XData', T, 'YData', R, 'InitialMagnification', 'fit');
%  xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P  = houghpeaks(H,50,'threshold',ceil(0.1*max(H(:))));

% Set houghpeaks parameters, threshold unsure
x = T(P(:,2));
y = R(P(:,1));
plot(x,y,'s','color','white');

% Apply median filtering
I3 = medfilt2(I2);

% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',20,'MinLength',10);
figure, imshow(I3),imagesc(I3), hold on
max_len = 0;

for k = 1:length(lines)
    xy = [lines(k).point1; lines(k).point2];
    plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');

    % plot beginnings and ends of lines
    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

showlines = struct(lines);
cellData = struct2cell(showlines);

% X-coordinates are for width
% Y-coordinates are for height
%point1(x y) etc

for i = 1:280
    % 'A' stores all 'x' coordinates of point 1
    A([i,i+1])= [cellData{1,i}];
    % 'B' stores all 'x' coordinates of point 2
    B([i,i+1])= [cellData{2,i}];
    % 'C' stores all 'y' coordinates of point 1
    C([i,i])= [cellData{1,i}];
    % 'D' stores all 'y' coordinates of point 2
    D([i,i])= [cellData{2,i}];
end


I do really hope someone can help me. At least general idea for me to proceed to the next step is enough. Thank you in advance.
Following my comment I suggest you a "dumb" heuristic you could try : Consider your images row-wise. Extract a few features from each row, these could be average RGB value, RGB covariance matrix, entropy etc ... Use a simple clustering algorithm to separate your image into 2 parts : the upper one and the lower one. Let's assume the heuristic has been successful and the lower part is mostly composed of road. We'll just consider this part and run a clustering algorithm on the RGB values. We keep the number of cluster low and we want to take the cluster which is the closest from grey as the road cluster. Once you have a not too bad road segmentation, play around a bit with edge detection to extract only the white marking.