Is there a way to label figures which are placed inside a grid?

This might be related, but a little more complex starting point.