Detail-preserving switching algorithm for the removal of random-valued impulse noise