mathcad_ median filtering in two dimensionGRAPHING AND VISUALIZATIONMedian Filtering in Two DimensionsThis QuickSheet illustrates smoothing of a 2D image using 3 x 3 or 5 x 5 median filtering. S := READBMP( "cross" ) g( x) := if( rnd( 1) < 0.1 , 255 , x) → S := g( S) First example Adds noiseM := READBMP( "mona" ) K := submatrixM ( , 60 , 160 , 50 , 150) → K := g( K) Second exampleInput parameter k is 3 or 5 or 7. . . medflt ( M , k) := I0 ← J0 ← k12k12I1 ← rows ( M) J1 ← cols ( M) for i ∈ I0 .. I1 for j ∈ J0 .. J1k+12k+12for r ∈ 0 .. k 1 for s ∈ 0 .. k 1 Ar , s ← Mi+ r k12, j+sk 12Ni , j ← median ( A) N T := medflt ( S , 5) Noisy image Smoothed imageSTL := medflt ( K , 3)KL……
猜您喜欢
评论