Latest stories

Difference between K-means and K-nearest neighbor algorithm

In short, the algorithms are trying to accomplish different goals. K-nearest neighbor is a subset of supervised learning classification (or regression) algorithms (it takes a bunch of labeled points and uses them to learn how to label other points). It is supervised because you are trying to classify a point based on the known classification of other points. In contrast, K-means is a subset of...

An overview of Independent Component Analysis

1. What is ICA ? Independent Component Analysis is a technique of separating signals from their linear mixes. We could assume two signals and that are a linear combination of two signals source and , the relationships of and are shown in the following system of linear equations where , , and are the parameters determining the mixing of the signals. These parameters( ) are not known, so the...

Perceptron Neural Network using Matlab

Perceptron is one of the simplest forms of a neural network model. The following code snippet is a simple version of such a neural network using Matlab. Before using it please read some background information at wikipedia :  clc; clear all; close all; % Data inputs=[1 0 0; 1 0 1;1 1 0;1 1 1]; % Desired Output desiredOutput=[1 1 1 0]; % Learning Rate learningRate=0.1; % HardLimit threshold...

Separation of Image Mixture using FastICA

Image separation of mixed and overlapped images is a frequent problem in computer vision (image processing). The following Matlab source code is a demonstration of image separation using FastICA algorithm based on kurtosis. clc;clear all;close all; original_image1=imread ('input1.jpg'); original_image2=imread ('input2.jpg'); figure() subplot(3,3,1),imshow(original_image1),title('Original Source...

Find the Elapsed Time using Monotonic Clocks in Linux

When a linux program requires measuring elapsed time, you need an individual timer to perform this task. This timer should be independent even if the user changes the time on the system clock. In Linux there are several different implementations for different cases (): CLOCK_REALTIMESystem-wide realtime clock. Setting this clock requires appropriate privileges.CLOCK_MONOTONICClock that cannot be...

Edge detection with a given direction using Matlab

The aim of this article is to detect the edges with a given direction in an image. To that end create a function [ E ] = oriented_edges( I, thr, a, da ) that takes as input a double grayscale image Ι, a threshold value thr, a direction a, and an angle da. The output of the function is a binary image Ε where the pixels that meet the following requirements should have the value 1: The pixel...

Principal Component Analysis using Matlab

PCA is a way of identifying patterns in data, and expressing the data in such a way as to highlight their similarities and differences. Below are the steps of the algorithm: close all; % clear all; clc; % data = load('Data/eeg.mat'); % data = data.data{1,2}; Step 1 – Initialize the dataset, 6 vectors of 32 sample data % % Step 1 - Initialize the dataset, 6 vectors of 32 sample data % X =...

C++ Template Class for Linear Algebra Matrix

It seems that many projects come upon a need to perform some linear algebra maths. However, the a large number of the available libraries usually are huge with many unnecessary or system dependent functionalities or …they are not free. The following template class provides some basic linear algebra matrix operations such as +,-,* as well as find the determinant, the covariance matrix...

CRC16 Simple Algorithm for C

The following code snippet is about CRC16 hash function. Usually in embedded systems there is an already built-in function for CRC8-16-32 etc. However in case there is not, here is a simple approach for it. If you are looking for CRC8 Algorithm please go to the following post here. /* CRC_H_ */ #ifndef CRC_H_ #define CRC_H_ #ifdef __cplusplus extern "C" { #endif #include <string.h> #include...

Improved circular list /array (ring buffer) in C++

This is a new version of the ring buffer. Using function templates the FIFO ring buffer is able to handle almost any type of data. template<typename T> struct cbuffer_t { T * data; T * first; T * next; int max; }; template<typename T> extern cbuffer_t<T> * cBufferInit(int); template<typename T> extern int cBufferPush(cbuffer_t<T> *, T ); template<typename T> extern int...

Categories