# matlab

## RANSAC Algorithm parameter explained

In this tutorial I explain the RANSAC algorithm, their corresponding parameters and how to choose the number of samples: N = number of samples e = probability that a point is an outlier s = number of points in a sample p = desired probability that we get a good sample N =log(1-p) /log(1- (1- […]

## Finding Homography Matrix using Singular-value Decomposition and RANSAC in OpenCV and Matlab

Solving a Homography problem leads to solving a set of homogeneous linear equations such below: \left( \begin{array}{ccccccccc} -x1 & -y1 & -1 & 0 & 0 & 0 & x1*xp1 & y1*xp1 & xp1\\ 0 & 0 & 0 & -x1 & -y1 & -1 & x1*yp1 & y1*yp1 &  yp1\\ -x2 & -y2 &

## Finding Affine Transform with Linear Least Squares

linear least squares is a method of fitting a model to data in which the relation between data and unknown paramere can be expressed in a linear form. $$Ax=b$$ $$X^{*}= \underset{x}{\mathrm{argmin}}= \|Ax-b\|^{2} =(A^{T}A)^{-1}A^{T}b$$

And testing the code:

## Examples of Dynamic Programming with C++ and Matlab

In this tutorial, I will give you examples of using dynamic programming for solving the following problems: 1)Minimum number of coins for summing X.

2)The most (least) costly path on a grid (dynamic time warping).

3)Levenshtein edit distance.

4)Seam Carving. I have written a tutorial on that

## Peak Signal-to-Noise Ratio (PSNR) in Image using OpenCV and Matlab

Peak signal-to-noise ratio (PSNR) shows the ratio between the maximum possible power of a signal and the power of the same image with noise. PSNR is usually expressed in logarithmic decibel scale. $$MSE =1/m*n \sum_{i=0}^{m-1} \sum_{j=0}^{n-1} [ Image( i,j) -NoisyImage( i,j) ] ^2$$ $$PSNR =10* \log_{10} \Bigg(MAXI^2/MSE\Bigg)$$ MSE is Mean Square Error and MAXI is

## Stitching image using SIFT and Homography

This Matlab tutorial I use SIFT, RANSAC, and homography to find corresponding points between two images. Here I have used vlfeat to find SIFT features. Full code is available at my GitHub repository Major steps are: 0.Adding vlfeat to your Matlab workspace:

1.Detect key points and extract descriptors. In the image below you can see some SIFT key

## Lucas–Kanade method optical flow with MATLAB

In this tutorial, I will show you how to estimate optical flow based on Lucas–Kanade method.  This project has the following scripts: Optical_flow_estimation, myFlow, myWarp, computeColor, flowToColor. The myFlow does the main job, it gets two images and a window length (patch length) and a threshold for accepting the optical flow.  In the following, you see the myFlow.  You can uncomment figure function calls

## Displaying Adjusted Frequencies of signal with Fast Fourier transform

In this tutorial, I will show you how to get Fast Fourier transform of a signal and then correctly display the signal. Link to the code in my Github repository.

Getting Fourier transform of the signal: