Opening is somewhat like erosion in that it tends to remove some of the foreground (bright) pixels from the edge of regions of foreground pixels. However it is less destructive than erosion in general. The effect of the operator is to preserve foreground regions that have a similar shape to the structuring element, or that can completely contain the structuring element, while eliminating all other regions of foreground pixels. Opening is the dual of closing.
An opening is defined as an erosion followed by a dilation using the same structuring element for both operations. Sometimes multiple erosions are used followed by the same number of dilations.
It is very common to use a 3x3 square structuring element. Although a 5x5 is equivalent to using 3x3 twice, the former has 5*5=25 pixels to consider while the latter is more computationally efficient at 2*3*3=18 pixels.
After the opening has been carried out, the new boundaries of foreground regions will be such that the structuring element fits inside them, and so farther openings with the same element have no effect. This property is known as idempotence. Opening can be used to remove salt noise.
See example 2.5.2.