I made this algorithm while in college for the Digital Image Processing class, though back then the code was in PHP and it was very rough and dirty. You can read about the algorithm here (in Spanish)(https://www.unocero.com/ciencia/como-se-hace-un-filtro-artistico/) or here (in English).
The effect of the algorithm gives results like this: