[ad_1]
Yes. Algorithms that do that exist. You need to use kernel or mask on an image in order to transform it: http://en.wikipedia.org/wiki/Kernel_%28image_processing%29
Many libraries have that built in, for example openCV.
[ad_2]
solved algorithms to detect lines in an image?