this is (𝑟𝑜𝑤, 𝑐𝑜𝑙) default way to find a pixel in the image.
Defaults:
Mask default size: 3x3
If you get more than 1 mode, get their average
Ignore edges technique is default
Salt and pepper noise:
1 2 1
16 16 16
Min filter → removes salt 2 4 2
Weighting average default: 16 16 16
Max filter → removes pepper 1 2 1
(16 16 16)
1 2 1
If the filter is a matrix, like this one: (2 4 2)
1 2 1
get the dot product and store the final value in the center point of the mask (this one) →
𝑎 𝑏 𝑐
(𝑑 ℎ𝑒𝑟𝑒 𝑒 )
𝑓 𝑔 ℎ
Low pass filter = averaging filter = smoothing filter
1⁄ 1⁄ 1⁄
9 9 9
1 1⁄ 1⁄ so basically, multiply each value in your mask by 1
This → ⁄9 9 9 𝑚𝑎𝑠𝑘 𝑠𝑖𝑧𝑒
1 1⁄ 1⁄
( ⁄9 9 9)
Suppose mena gives you a mask, and its size is (4,3) DON’T GET FOOLED, this size is in the
format (𝑤𝑖𝑑𝑡ℎ, ℎ𝑒𝑖𝑔ℎ𝑡) and it will be drawn like this: yes, this is a 3 × 4 matrix.
How to get the center of any mask (by default, if not given a center)?
Simple, suppose we have a mask size of (4,3)
Divide the points by 2 and take the floor, which will be: (𝑓𝑙𝑜𝑜𝑟(4⁄2), 𝑓𝑙𝑜𝑜𝑟(3⁄2)) → (2,1)
NOTE: 2,1 is in the format of 𝑤𝑖𝑑𝑡ℎ, ℎ𝑒𝑖𝑔ℎ𝑡 so to get the actual point in the matrix, swap it
→ (1,2)
So this is the center: 0 1 2 3
1 me
2
Rank → sort values, including the repeated values [13,13,13,17,18,18,20] for example, then, find
the nth position (counting from 1 NOT ZERO) example: rank 1 of this ^ example is 13, rank 4 is
17… you get it now.
Ignore edges:
Suppose the mask size is 3,2 and the center point is called me, with value of 10
Center? 1,0 (width, height) format
me 16 17 16
20 42 69 57
12 21 35 12
46 8 6 13
67
To solve this, simply ignore the imaginary edges, as they never existed and never count them in
your calculations, in the zero-padding method, replace the edges with zeros.
Like that:
0 me 16
0 20 42
And apply the desired mask.