function [lines] = lane_detection_houghlines(inputImage)%#codegen

%  Copyright 2019 The MathWorks, Inc.
coder.gpu.kernelfun;

% Convert RGB image to grayscale image.
if size(inputImage,3)==3
    grayImage = rgb2gray(inputImage);
else
    grayImage = inputImage;
end

% Edge detection using ordfilt2.
input = grayImage(240:end,1:end);
dom = ones(2);
minOrder = 1;
maxOrder = 4;
padopt = 'zeros';

MinImg = ordfilt2(input,minOrder,dom,padopt);
MaxImg = ordfilt2(input,maxOrder,dom,padopt);

% Edge detected output.
outImage = MaxImg - MinImg;
BW = imbinarize(outImage);

[H,T,R] = hough(BW);
P  = houghpeaks(H,20,'threshold',1);
lines = houghlines(BW,T,R,P,'FillGap',200,'MinLength',150);

