You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A set of naive implementations of popular CV algorithms implemented in C++ using the OpenCV library. The examples below contain code snippets showcasing example use of algorithms.
// Convert the image to grayscale
Mat gray(original.rows, original.cols, CV_8UC1, Scalar(0));
CVAlg::grayscale(original, gray);
//Binarize image
Mat binary = CVAlg::threshold(gray, 125);
Image Transformations
Scaling
Original
Scaled
// Convert the image to grayscale
Mat gray(original.rows, original.cols, CV_8UC1, Scalar(0));
CVAlg::grayscale(original, gray);
// Scale the image
Mat scale = CVAlg::scaleMat(2.0, 2.0);
Mat result = CVAlg::backwardMapping(gray, scale, 2, 2);
Rotation about Z axis
Original
Rotated
// Convert the image to grayscale
Mat gray(original.rows, original.cols, CV_8UC1, Scalar(0));
CVAlg::grayscale(original, gray);
// Rotate the image
Mat rot = CVAlg::rotationMat(150.0);
Mat trans = CVAlg::translateMat(500.0, 0.0);
Mat combined = trans * rot;
Mat result = CVAlg::backwardMapping(gray, combined, 2, 2);
Shearing
Original
Sheared
// Convert the image to grayscale
Mat gray(original.rows, original.cols, CV_8UC1, Scalar(0));
CVAlg::grayscale(original, gray);
// Perform Shearing
Mat shear = CVAlg::shearMat(0.0, 1.1);
Mat sheared = CVAlg::backwardMapping(gray, shear, 1, 2.5);
// Resize image
Mat result;
cv::resize(sheared, result, cv::Size(), 0.5, 0.5);
Gaussian Blurring
Original
Blurred
// Convert the image to grayscale
Mat gray(original.rows, original.cols, CV_8UC1, Scalar(0));
CVAlg::grayscale(original, gray);
// Blur the image
Mat blurred = CVAlg::gausBlur(gray, 7, 2.0);
Sobel edge detection
Original
Edges
// Convert the image to grayscale
Mat gray(original.rows, original.cols, CV_8UC1, Scalar(0));
CVAlg::grayscale(original, gray);
// Extract edges
Mat edges = CVAlg::sobelEdge(gray);
Features
Harris Corners Detector
// Convert the image to grayscale
Mat gray = CVAlg::grayscale(original);
// Extract corners
Mat corners = CVAlg::harrisCorners(gray, 7, 0.04);
// Draw cornersCVAlg::drawCorners(corners, original, 0.5, cv::Scalar(0, 0, 255), cv::MARKER_DIAMOND);
Shi-Tomasi Corners Detector
// Convert the image to grayscale
Mat gray = CVAlg::grayscale(original);
// Extract corners
Mat corners = CVAlg::shiTomasiCorners(gray, 5);
// Draw cornersCVAlg::drawCorners(corners, original, 0.65, cv::Scalar(0, 0, 255));