I suspect that there is a way to do it with XPATH, but you could just use search and replace:
Search:
Code:
(?P<hopen><h2[^>]*)><img alt="(?P<title>.*?)"
Replace:
Code:
\g<hopen> title="\g<title>"><img
After that just open it in Sigil and it will create a TOC, save and your done.