Existence result and approximation of an optimal control problem for the Perona–Malik equation