Optimization of angular and frequency compounding in ultrasonic