An optimized version using VTK and openCV