Long story short, I have finally managed to bring necessary code pieces together to build a macro that makes the job. The macro works in Fiji (ImageJ) environment and requires an additional plugin installed.
I consider myself as hobbyist-grade programmer so please don't expect perfectly written code, failsafes, etc etc, just a piece of semi-sloppy code. It does the job and thats all.
If you would like to try it, please use it on a backup set of images then manually copy the outputs. The macro is open to public and feel free to modify it for your needs. I appreciate if you keep my name, in case you decide to publish an updated version of it.
The macro is "as is" and I take no responsibility from any kind of damage it may directly or indirectly cause.
Please see the video below for installation and operation process.
I hope someone finds this macro useful.
https://alpslabel.wordpress.com/
info video:
https://www.youtube.com/watch?v=G6ib950iDvQ