A 19th Century portrait that lay in a cupboard in a Highland castle for more than 100 years has been restored and put on public display.