Simple Edge Detection

Let’s make a picture that looks like a pencil sketch.
Here is a simple technique that can help you to achieve the above said results.

  • Find an area of high contrast between a pixel and the pixel below it
  • if contrast is high we can make pixel black otherwise white

Question here is how to find high or low contrast pixels? Follow the steps below :

  • Average the RGB of current pixel and the pixel below it
  • Find the difference between both average values
  • If the resultant value is higher than a given amount, set current pixel to black, otherwise white

Here is an example program. Have a look on it and add it in to your MyPicture class used in our tutorial.

Watch Video Tutorial

No Responses