Local definitions

Segment loaded image

SegmentObject[img_, thresh_:245, color_:replacementColor] := Module[{img2}, im ... eplacementColor, #] & , img[[1, 1]], {2}] ; ReplacePart[img, img2, {1, 1}] ] ;

Segment file image

ConvertImage[outFile_, inFile_, type_, thresh_:245, color_:replacementColor] := Module ... = SegmentObject[img, thresh, color] ; Export[outFile, img2, "PPM"] ; ] ;

Extract RGB data from segmented images

ExtractRGB[img_, color_:replacementColor] := Module[{rgb}, rgb = Partition[Flatten[img[[1, 1]]], 3] ; DeleteCases[rgb, color] ] ;

Get representative sample of data

RepresentativeSample[dat_, n_] := Module[{d2, m}, m = Ceiling[Length[dat]/n] ; d2 = First /@ Partition[dat, m]] ;

Data plotting routines

Plot representative sample data (columns a and b from dat ) from a larger data set in 2d

PlotRepresentativeSample2D[dat_, n_, {a_, b_}, opt___] := Module[{d2, m, rgblabel}, &# ... [[a]], rgblabel[[b]]}, DisplayFunctionIdentity, PlotRange {{0, 255}, {0, 255}}]] ;

Plot representative sample data  from a larger data set in 3d

PlotRepresentativeSample3D[dat_, n_, opt___] := Module[{d2, m}, m = Ceiling[Le ... , Point/@ d2]], DisplayFunctionIdentity, PlotRange-> {{0, 255}, {0, 255}, {0, 255}}]] ;

RowBox[{data2pixel[{r_, g_, b_, x_, y_}], :=, RowBox[{{, RowBox[{RowBox[{RGBColor, [, RowBox[{ ... [{g, /, 255.}], ,, RowBox[{b, /, 255.}]}], ]}], ,,  , Rectangle[{x, -y - 1}, {x + 1, -y}]}], }}]}]

Plot multiple results for mixture model

EMAllPlot[{μ_, Σ_, priors_}, gin_] := Module[{pr, g2, g4, g5}, pr =  ... nS, AxesNone] ; Show[GraphicsArray[{{g2, gin}, {g4, g5}}], yS, imSize] ] ;

Classify image (2d)

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

Classify image (3d)

ClassifyImage3DAugmented[im_, lpdf1_, lpdf2_, scale_:1] := Module[{class, colors, lpdf ...  N}) > 0, gr, bl]] &, im[[1, 1]], {2}] ; ReplacePart[im, class, {1, 1}] ] ;

Count pixels in classified images

CountPixels[classim_, color1_: (List @@ (pointStyle1 // First)) * 255, color2_: (List @@ (poin ... olor] // Flatten // First, 1]] ;  {100 * n1/(n1 + n2), 100 * n2/(n1 + n2)} // N] ;

Normalized log-likelihood for each object (2d)

RowBox[{RowBox[{AggregateLogLikelihood2D[data1_, data2_, which_], :=, , RowBox[{Module ... ureDataSet[d2, gauss2]/Length[d2], ;, , {{a11, a12}, {a21, a22}}}]}], , ]}]}], ;}]

Normalized log-likelihood for each object (2d) (mixture model)

AggregateLogLikelihood2DEM[data1_, data2_, model1_, model2_, which_] := Module[{d1, d2 ... LogLikelihoodMixtureDataSet[d2, model2]/Length[d2] ;  {{a11, a12}, {a21, a22}} ] ;

Normalized log-likelihood for each object (3d)

RowBox[{RowBox[{AggregateLogLikelihood3D[data1_, data2_], :=, , RowBox[{Module, [, Row ... ureDataSet[d2, gauss2]/Length[d2], ;, , {{a11, a12}, {a21, a22}}}]}], , ]}]}], ;}]

Normalized log-likelihood for each object (3d) (mixture model)

AggregateLogLikelihood3DEM[data1_, data2_, model1_, model2_] := Module[{d1, d2, a11, a ... LogLikelihoodMixtureDataSet[d2, model2]/Length[d2] ;  {{a11, a12}, {a21, a22}} ] ;

3d EM initialization function

Scalar covariance initialization 3d

EMInitializationScalar3D[x_, k_] := Module[{n, rl, μ, σ, priors, sm, del2}, <br />&n ... riors = Table[1/k, {k}] // N ; <br />     {μ, σ, priors} ] ;

Full covariance initialization 3d

EMInitializationFull3D[x_, k_] := Module[{μ, σ, priors, dim},  {_ ... th[First[μ]] ;  {μ, (# IdentityMatrix[dim]) & /@ σ, priors} ] ;


Created by Mathematica  (October 9, 2003)