Google's John Mueller said on Twitter that text within an image's alt attribute is generally seen as text "as a part of the page where the image is embedded." If that text is within an H1 tag, then Google will also see it as part of the H1.
It is a bit of a confusing response, here it is within the context:
We tend to see text in image alt attributes as a part of the page where the image is embedded (as well as context for the image); if that's an image within a "h1", then that would be a part of the "h1".
— 🍌 John 🍌 (@JohnMu) February 14, 2020
Just a little tidbit for you.
Forum discussion at Twitter.