DNN has some modules that do this which you might be able to plug in with ML/DNN. Otherwise you would need to code this, I wouldn't expect it to be monumental.

- Dan