Especially I want to translate this answer in matlab to PHP,
is it viable?
No. This tool not exists.
But you can do this simple by hand using some for
statements. With using GD and some code to Image Processing.
More information how to implement Image Processing you can find at http://php.net/manual/en/book.image.php