Intensity-based classification (1D)

Read in image files

brick = ReadWholeImage[BrickFile] ;  brickIm = brick ; wood = ReadWholeImage[WoodFile] ; woodIm = wood ;

d1 = brick[[1, 1]] // Flatten ; d2 = wood[[1, 1]] // Flatten ;

Show image files

Show[GraphicsArray[{{brick, wood}}], ImageSize400] ;

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

Compute one-dimensional pdfs and corresponding error on 1d color channels

p1 = ComputePDF1D[d1] ; p2 = ComputePDF1D[d2] ;

pl1 = ShowTwoGaussianPDFs1D[p1, p2, {0, 255}, x, FrameTicksNone, nS] ;

error = ExpectedError1D[p1, p2, x] ;

Show one-dimensional pdfs

Show[pl1, yS, ImageSize400] ; error

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

89.4881

Classify training and test image

c1 = ClassifyImage1D[brick, ComputeDecisionBoundary1D[p1, p2, x]] ; c2 = ClassifyImage1D[wood, ComputeDecisionBoundary1D[p1, p2, x]] ;

Show classification results

Show[GraphicsArray[{{brick, c1}, {wood, c2}}], ImageSize400, GraphicsSpacing.02] ;

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

Compute classification error

brickStats = First /@ Frequencies[Partition[Flatten[c1[[1, 1]]], 3]] ; woodStats = First /@&nb ... ]]], 3]] ; bar1 = {brickStats/(Plus @@ brickStats), woodStats/(Plus @@ woodStats)} // Transpose ;

Show classification error

BarChart[bar1[[1]], bar1[[2]], BarStyle {Blue, Orange}, FrameTrue, BarLabels {"Brick", "Wood"}, imSize] ;

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


Created by Mathematica  (October 9, 2003)