2D convolution: image smoothing

Mean-filtering: gray-scale image example

Load gray-scale image

img = ReadImage["cat256x256.ppm"] ; RowBox[{RowBox[{scale,  , =,  , 1.5}], ;}]

Display image

ShowImage[img, scale] ;

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

Mean filtering

5 × 5mean filter

n = 5 ; tmp = Mask[img, MeanFilter[n]] ; ShowImage[tmp, scale] ;

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

11 × 11mean filter

n = 11 ; tmp = Mask[img, MeanFilter[n]] ; ShowImage[tmp, scale] ;

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

21 × 21mean filter

n = 21 ; tmp = Mask[img, MeanFilter[n]] ; ShowImage[tmp, scale] ;

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

Mean-filtering: color image example

Load color image

img = ReadImage["flowers256x256.ppm"] ; RowBox[{RowBox[{scale,  , =,  , 1.5}], ;}]

Display image

ShowImage[img, scale] ;

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

Mean filtering

5 × 5mean filter

n = 5 ; tmp = Mask[img, MeanFilter[n]] ; ShowImage[tmp, scale] ;

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

11 × 11mean filter

n = 11 ; tmp = Mask[img, MeanFilter[n]] ; ShowImage[tmp, scale] ;

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

21 × 21mean filter

n = 21 ; tmp = Mask[img, MeanFilter[n]] ; ShowImage[tmp, scale] ;

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

Gaussian filtering: gray-scale image example

Load gray-scale image

img = ReadImage["cat256x256.ppm"] ; RowBox[{RowBox[{scale,  , =,  , 1.5}], ;}]

Display image

ShowImage[img, scale] ;

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

Gaussian filtering

5 × 5Gaussian filter

n = 5 ; RowBox[{RowBox[{gf, =, RowBox[{GaussianFilter, [, RowBox[{n, ,, RowBox[{(n - 1), /, 4. ... se, ImageSize5 * n, PlotRangeAll] ; tmp = Mask[img, gf] ; ShowImage[tmp, scale] ;

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

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

11 × 11Gaussian filter

n = 11 ; RowBox[{RowBox[{gf, =, RowBox[{GaussianFilter, [, RowBox[{n, ,, RowBox[{(n - 1), /, 4 ... se, ImageSize5 * n, PlotRangeAll] ; tmp = Mask[img, gf] ; ShowImage[tmp, scale] ;

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

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

21 × 21Gaussian filter

n = 21 ; RowBox[{RowBox[{gf, =, RowBox[{GaussianFilter, [, RowBox[{n, ,, RowBox[{(n - 1), /, 4 ... se, ImageSize5 * n, PlotRangeAll] ; tmp = Mask[img, gf] ; ShowImage[tmp, scale] ;

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

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

Gaussian filtering: color image example

Load color image

img = ReadImage["flowers256x256.ppm"] ; RowBox[{RowBox[{scale,  , =,  , 1.5}], ;}]

Display image

ShowImage[img, scale] ;

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

Gaussian filtering

5 × 5Gaussian filter

n = 5 ; RowBox[{RowBox[{gf, =, RowBox[{GaussianFilter, [, RowBox[{n, ,, RowBox[{(n - 1), /, 4. ... se, ImageSize5 * n, PlotRangeAll] ; tmp = Mask[img, gf] ; ShowImage[tmp, scale] ;

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

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

11 × 11Gaussian filter

n = 11 ; RowBox[{RowBox[{gf, =, RowBox[{GaussianFilter, [, RowBox[{n, ,, RowBox[{(n - 1), /, 4 ... se, ImageSize5 * n, PlotRangeAll] ; tmp = Mask[img, gf] ; ShowImage[tmp, scale] ;

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

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

21 × 21Gaussian filter

n = 21 ; RowBox[{RowBox[{gf, =, RowBox[{GaussianFilter, [, RowBox[{n, ,, RowBox[{(n - 1), /, 4 ... se, ImageSize5 * n, PlotRangeAll] ; tmp = Mask[img, gf] ; ShowImage[tmp, scale] ;

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

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


Created by Mathematica  (February 5, 2004)