Case study #3: find the people...

Load a foreground and background image of a hallway

img1 = ReadImage["outdoor1.ppm"] ; img2 = ReadImage["outdoor2.ppm"] ; scale = 1 ;

Display images

g1 = ShowImage[img1, scale, 200, 0, DisplayFunctionIdentity] ; g2 = ShowImage[img2, sc ... 4;Identity] ; Show[GraphicsArray[{g1, g2}], ImageSizeDimensions[img1][[2]] * scale * 2] ;

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

Example processing steps #1

Smooth both images (Gaussian filtering)

RowBox[{RowBox[{gf, =, RowBox[{RowBox[{GaussianFilter, [, RowBox[{11, ,, 1.25}], ]}],  , //,   ... 4;Identity] ; Show[GraphicsArray[{g1, g2}], ImageSizeDimensions[img1][[2]] * scale * 2] ;

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

Subtract background from foreground image

ShowImage[diff = Abs[s2 - s1], scale, 100] ;

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

Threshold difference image

Threshold image

RowBox[{RowBox[{threshold, =, 20.}], ;}]

th = ThresholdImage[diff, threshold] ; ShowImage[th, scale] ;

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

Blob finding on unprocessed threshold image

tmp = BlobFind[th] ; ShowImage[BlobImage[tmp], scale] ; BlobCount[tmp]

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

19

Manipulate binary threshold image

Closing operator

th2 = Closing[th, Table[1, {5}, {5}]] ; ShowImage[th2, scale] ;

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

Blob finding on processed threshold image

blb = BlobFind[th2] ; ShowImage[BlobImage[blb], scale] ; BlobCount[blb]

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

9

Superimpose original image with cleaned-up threshold image

ShowImage[BitAnd[th2, img2], scale, 200] ;

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

Example processing steps #2

Subtract background from foreground image

ShowImage[diff = Abs[img2 - img1], scale, 100] ;

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

Threshold difference image

Threshold image

RowBox[{RowBox[{threshold, =, 20.}], ;}]

th = ThresholdImage[diff, threshold] ; ShowImage[th, scale] ;

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

Blob finding on unprocessed threshold image

tmp = BlobFind[th] ; ShowImage[BlobImage[tmp], scale] ; BlobCount[tmp]

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

77

Manipulate binary threshold image

Median filter

th2 = MedianFilter[th, 3] ; ShowImage[th2, scale] ;

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

Closing operator

th3 = Closing[th2, Table[1, {5}, {5}]] ; ShowImage[th3, scale] ;

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

Blob finding on processed threshold image

blb = BlobFind[th3] ; ShowImage[BlobImage[blb], scale] ; BlobCount[blb]

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

8

Superimpose original image with cleaned-up threshold image

ShowImage[BitAnd[th3, img2], scale, 100] ;

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


Created by Mathematica  (February 5, 2004)