There’s a script available for Aseprite that does something like this:
It’s not AI driven, but it does a pretty good job.