Straight road image example

Load in sample image

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

SetDirectory["/Users/nechyba/public_html/eel5840/neural_networks/data"] ;

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

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

Show sample image

Show[g] ;

[Graphics:../HTMLFiles/index_18.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_20.gif]

Test different straight line hypotheses

f[a_] := measure[rectify[tst, lineCurv[#, a] &]] ; result = Table[{i, f[i]}, {i, 0, 1, 1/2 ... x[{GridLines, , RowBox[{{, RowBox[{RowBox[{{, 0.5, }}], ,, Automatic}], }}]}]}], ]}], ;}]

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

Best result

RowBox[{RowBox[{bestResult,  , =,  , 0.45}], ;}]

Best straight line hypothesis

PlotLineCurv[1 - bestResult] ;

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

Illustrate corresponding shifted image

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

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

Compare to original

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

[Graphics:../HTMLFiles/index_29.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_31.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_33.gif]


Created by Mathematica  (September 29, 2003)