Thank you for your suggestions. I didn't really find a suitable terrain database generation or terrain query tool for plain vanilla Matlab and Simulink.
So, I put a simple approach together and posted it here:
Your first idea for image analysis is good and included in the terrain processing script, process_track.m.
This is one part of achieving a lap time simulation.