Definitions

Turn off annoying warnings

Off[Plot :: "plnr"] ;

Extract trapezoidal region

extractTrapezoid[m_, {ymin_, dmin_}, {ymax_, dmax_}] := Module[{m2, xsize, tbl}, ɯ ... min)/2}]}], {i, 1, Length[m]}], Null] ; Take[m2[[#[[1]]]], #[[2]]] & /@ tbl] ;

Subsample a line of an image

subSampleLine[zl_, n_] := Module[{len, di}, len = Length[zl] ; di = (len - 1)/(n - 1) ; Table[zl[[Round[i]]], {i, 1, len, di}] ] ;

Subsample an extracted trapezoidal region

subSampleTrapezoid[z_, n_] := Module[{z1}, z1 = subSampleLine[#, n] & /@ z ; subSampleLine[z1, n] ] ;

Subsample a trapezoidal region from an image

subSampleImage[m_, {ymin_, dmin_}, {ymax_, dmax_}, n_] := Module[{z1, z2}, z1  ... tractTrapezoid[m, {ymin, dmin}, {ymax, dmax}] ; z2 = subSampleTrapezoid[z1, n] ] ;

Rectify one processed line

rectifyOne[l_] := Module[{a, b},  {a, b} = l ; Drop[RotateRight[PadLeft[b, Abs[a] + Length[b], -1], a], Abs[a]] ] ;

Rectify an image based on a given curvature

The function curv[y] is expected to return an x value for y values between 0 and 1 that corresponds to that lines shift. A value of 0.5 corresponds to no shift; negative values correspond to left shift, positive values correspond to right shift.

rectify[mat_, curv_] := Module[{n, m, tbl},  {n, m} = Dimensions[mat] ; ᡝ ... , mat[[n - i * (n - 1)]]}, {i, 0, 1, 1/(n - 1)}] ;  Reverse[rectifyOne /@ tbl] ] ;

Compute vertical scan line summations

scanLines[mat_] := Module[{m2}, m2 = DeleteCases[#, -1] & /@ Transpose[mat] ;  ((Plus @@ #)/Length[#]) & /@ m2] ;

Compute measure

measure[mat_] := Plus @@ (Abs[#[[1]] - #[[2]]] & /@ Partition[scanLines[mat], 2, 1]) // N ;

Sloped line curvature

RowBox[{lineCurv[y_, a_], :=,  , RowBox[{0.5,  , +,  , RowBox[{RowBox[{(, RowBox[{a, -, 0.5}], )}], y}]}]}]

PlotLineCurv[a_] := Module[{x, y, res}, res = y /. (Solve[x  lineCurv[ ... ot[res, {x, 0, 1}, PlotRange {{0, 1}, {0, 1}}, AspectRatio1, FrameTrue]] ;

Circle curvature

RowBox[{curveCurv[y_, a_], :=, RowBox[{RowBox[{Sqrt, [, RowBox[{RowBox[{RowBox[{(, RowBox[{a, -, 0.5}], )}], ^, 2}],  , -,  , y^2}], ]}], +, a}]}]

PlotCurveCurv[a_] := Module[{x, y, res}, res = y /. (Solve[x  curveCur ... x, 0, 1}, PlotRange {{0, 1}, {0, 1}}, AspectRatio1, FrameTrue] ] ;


Created by Mathematica  (September 29, 2003)