Reputation: 5023
I want to implement GPUImage Framework filter in Opencv API.I knew GPUImage sketchfilter in IOS.But I want to implement GPUImage filter in windows platform using Opencv API.
My input image below
Here I want to get below output image
How will I get above output image.?
Is there any opencv API to get the result image.?
please help and give any suggestions.?
Upvotes: 0
Views: 1006
Reputation: 3988
That looks like Sobel edge detection. Since you want to do it in GPU with OpenCV, here is the relevant function.
Upvotes: 0
Reputation: 36487
What you're looking for is an edge detector, like the Canny Detector.
This will return edges as dark lines, the harder the contrast, the darker the edge.
If you're not satisfied with provided detectors (there should be more than just Canny, but to be honest I haven't used OpenCV in years), you can just implement your own edge detection:
output[y * stride + x] = std::abs(input[y * stride + x] - input[y * stride + x + 1]);
This example will find all vertical edges without using any thresholds.
The horizontal version would be similar:
output[y * stride + x] = std::abs(input[y * stride + x] - input[(y + 1) * stride + x]);
Or both in one:
output[y * stride + x] = ((std::abs(input[y * stride + x] - input[y * stride + x + 1]) + std::abs(input[y * stride + x] - input[(y + 1) * stride + x]))) / 2;
However, it's more common to simply use some kernel and use that to implement many different filters (blur, edge detection, etc.)
More details can be found under Image Filtering (Filter2D).
A simple edge detector could use a kernel like this:
| 0 -1 0 |
K = | -1 0 1 |
| 0 1 0 |
Upvotes: 2