There is a good tutorial on the Sobel algorithm at: [[1]]. He also wrote source code to read a bmp file as well as the actual code performing the Sobel algotihm [[2]]. Be sure to site him if you are using his code.