I see the issue is happening because the class is not added to the IMG tag, so Smush can’t target it.
Couldn’t you enhance this feature so that it targets child elements?
For example:
<div id="header-element">
<img src="/wp-content/themes/mycooltheme/assets/img/headerimage.png><img>
<h1>This is my awesome header!</h1>
</div>
And then exclude #header-element
This would be for example very helpful for themes with a widget area at the top of the page.