Curved road image example

Load in sample image

Be sure that the directory points to the image to be loaded in.

Timing[g = Import["curved_road_bw.jpg", "JPEG"] ;]

RowBox[{{, RowBox[{RowBox[{0.07,  , Second}], ,, Null}], }}]

Show sample image

Show[g] ;

[Graphics:../HTMLFiles/index_37.gif]

Subsample trapezoidal region

m = g[[1, 1]] ; tst = subSampleImage[m, {48, 118}, {110, 236}, 50] ; Show[Graphics[Raster[Reverse[tst/255]]], AspectRatioAutomatic, ImageSize {300, 300}] ;

[Graphics:../HTMLFiles/index_39.gif]

Test different straight line hypotheses

f[a_] := measure[rectify[tst, curveCurv[#, a] &]] ; result = Table[{-Log[-i], f[i]}, {i, - ... 1/4}] ; ListPlot[result, PlotJoinedTrue, FrameTrue, GridLinesAutomatic] ;

[Graphics:../HTMLFiles/index_41.gif]

Best result

RowBox[{bestResult,  , =,  , RowBox[{-, RowBox[{Exp, [, 0.7, ]}]}]}]

RowBox[{-, 2.01375}]

Best circle curvature hypothesis (reflected)

PlotCurveCurv[bestResult] ;

[Graphics:../HTMLFiles/index_45.gif]

Illustrate corresponding shifted image

tst2 = rectify[tst, curveCurv[#, bestResult] &] ; Show[Graphics[Raster[Reverse[tst2/255]]], AspectRatioAutomatic, ImageSize {300, 300}] ;

[Graphics:../HTMLFiles/index_47.gif]

Compare to original image

Show[Graphics[Raster[Reverse[tst/255]]], AspectRatioAutomatic, ImageSize {300, 300}] ;

[Graphics:../HTMLFiles/index_49.gif]

Show scan line function for best curvature hypothesis

bestScanLine = scanLines[tst2] ; g1 = ListPlot[bestScanLine, PlotJoinedTrue, FrameTrue, PlotRangeAll, PlotStyle {RGBColor[1, 0, 0]}] ;

[Graphics:../HTMLFiles/index_51.gif]

Compare to baseline straight-line, zero-orientation hypothesis

originalScanLine = scanLines[tst] ; g2 = ListPlot[originalScanLine, PlotJoinedTrue, Fr ... 754;All, PlotStyle {RGBColor[0, 0, 1]}, DisplayFunctionIdentity] ; Show[g1, g2] ;

[Graphics:../HTMLFiles/index_53.gif]


Created by Mathematica  (September 29, 2003)