Detecting edges
In this recipe, we will demonstrate how to use edge detection function, which is one of the image processing functions implemented directly in Cinder.
Getting ready
Make sure you have Xcode up and running with an empty Cinder project opened. We will need a sample image to proceed, so save it in your assets folder as image.png
.
How to do it…
We will process the sample image with the edge detection function. Perform the following steps to do so:
Include necessary headers:
#include "cinder/gl/Texture.h" #include "cinder/Surface.h" #include "cinder/ImageIo.h" #include "cinder/ip/EdgeDetect.h" #include "cinder/ip/Grayscale.h"
Add two properties to your main class:
Surface8u mImageOutput;
Load the source image and set up
Surface
for processed images inside thesetup
method:mImage = loadImage( loadAsset("image.png") ); mImageOutput = Surface8u(mImage.getWidth(), mImage.getHeight(), false);
Use image processing functions:
ip::grayscale(mImage, &mImage); ip::edgeDetectSobel(mImage, &...