Local definitions

Turn off integration warning message

Off[NIntegrate :: ncvb] ; Off[NIntegrate :: slwcon] ;

Read whole image

ReadWholeImage[file_, dir_:"."] := Module[{im, d}, im = Import[dir<>"/"<>file<>".ppm", "PPM"] ; im] ;

Read in split images

ReadSplitImages[file_, dir_:"."] := Module[{im1, im2, raw1, raw2, d1, d2}, & ... eleteCases[Partition[Flatten[raw2], 3], {255, 255, 255}] ;  {d1, d2, im1, im2} ] ;

Compute 1D pdfs

ComputePDF1D[data_, which_:Red] := Module[{colors, pos, d2}, colors = {Red, Gr ... ;/@data] ; stats = {Mean[d2], StandardDeviation[d2]} ; pdf1D[stats, x] ] ;

One-dimensional decision boundary

ComputeDecisionBoundary1D[pdf1_, pdf2_, x_:x] := Module[{sol, lpdf1, lpdf2}, l ... 2371;If[sol[[1]] ≥0 && sol[[1]] ≤ 255, sol // First, sol // Last]] ] ;

Expected error (1d)

ExpectedError1D[pdf1_, pdf2_, x_:x] := NIntegrate[Min[pdf1, pdf2], {x, 0, 255}] * 100 ;

Expected error (2d)

ExpectedError2D[pdf1_, pdf2_, x_:x, y_:y] := NIntegrate[Min[pdf1, pdf2], {x, 0, 255}, {y, 0, 255}] * 100 ;

Classify image (1d)

ClassifyImage1D[im_, db_, which_:Red] := Module[{class, colors, pos, gr, bl},  ... pos]] <db, gr, bl] &, im[[1, 1]], {2}] ; ReplacePart[im, class, {1, 1}] ] ;

Classify image (2d)

ClassifyImage2D[im_, pdf1_, pdf2_, which_: {Red, Green}] := Module[{class, colors, pos ... 2]]}) > 0, gr, bl] &, im[[1, 1]], {2}] ; ReplacePart[im, class, {1, 1}] ] ;

Colors representing two classes

Data colors

data1Color = Green ; data2Color = Blue ;

style1 = {data1Color, PointSize[.02]} ; style2 = {data2Color, PointSize[.02]} ;

Classification region colors

class1Color = RGBColor[1, 1, .5] ; class2Color = RGBColor[.5, 1, 1] ;

classColors = {class1Color, class2Color} ;

Default plot range

pr = {{0, 255}, {0, 255}} ;


Created by Mathematica  (September 8, 2003)