Sobel derivative in OpenCV

This code snippet is to demonstrate how to compute Sobel 3×3 derivatives convolving the image with Sobel kernels. You can easily extend to different kernel sizes giving the kernel radius as input to my_sobel, and creating the appropriate kernel. #include <opencv2\opencv.hpp> #include <iostream> using namespace std; using namespace cv; void my_sobel(const Mat1b& src, Mat1s& dst, … Read more

Inverse fourier transformation in OpenCV

Actually, you don’t have to swap the different quadrants, it’s needed only if you’re a human and want a more natural looking visualization of the FFT result (i.e. with the 0 frequency in the middle, negative frequencies left/bottom and positive frequencies up/right). To invert the FFT, you need to pass the result of the forward … Read more

Calculating convexityDefects using OpenCV 2.4 in c++

From openCV wiki : Finds the convexity defects of a contour. So you should include it in your loop. std::vector<Vec4i> defects; vector<cv::vector<int> >hull( contours.size() ); for (int i = 0; i < contours.size(); i++) { convexHull( contours[i], hull[i], false ); convexityDefects(contours[i], hull[i], defects[i]); } Also, as you mentioned, in wiki is said: hull – Output … Read more