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.
Original |
Binary |
---|---|
![]() |
![]() |
// 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);
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);
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);
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);
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);
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);
// Convert the image to grayscale
Mat gray = CVAlg::grayscale(original);
// Extract corners
Mat corners = CVAlg::harrisCorners(gray, 7, 0.04);
// Draw corners
CVAlg::drawCorners(corners, original, 0.5, cv::Scalar(0, 0, 255), cv::MARKER_DIAMOND);
// Convert the image to grayscale
Mat gray = CVAlg::grayscale(original);
// Extract corners
Mat corners = CVAlg::shiTomasiCorners(gray, 5);
// Draw corners
CVAlg::drawCorners(corners, original, 0.65, cv::Scalar(0, 0, 255));