Giter VIP home page Giter VIP logo

cvalgorithms's Introduction

CV Algorithms

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.

Table of contents

Image thresholding

Original Binary
sudoku 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);

Image Transformations

Scaling

Original Scaled
butterfly Enlarged
    // 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
chicky_512 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
fruits 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
messi5 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
board Edge
    // 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

Corners

    // 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);

Shi-Tomasi Corners Detector

Corners

    // 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));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.