In a previous post we saw the differences between K-means and K-NN. Here is step by step on how to compute K-nearest neighbors KNN algorithm. Determine parameter K = number of nearest neighbors Calculate the distance between the query-instance and all the training samples Sort the distance and determine nearest neighbors based on the K-th minimum distance Gather the category of the nearest neighbors Use simple majority of the category of nearest neighbors as the prediction…

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 unsupervised learning clustering algorithms (it takes a bunch of unlabeled…

1. What is ICA ? Independent Component Analysis is a technique of separating signals from their linear mixes. We could assume two signals $ x_1(t) $ and $ x_2(t) $ that are a linear combination of two signals source $ s_1(t) $ and $ s_2(t) $, the relationships of $ x_n $ and $ s_n $ are shown in the following system of linear equations where $ a_{11} $, $ a_{12} $, $ a_{21} $ and…

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 : https://en.wikipedia.org/wiki/Perceptron

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.

TiIf a program requires measuring elapsed time, you will need an individual timer that will be independent even if the user changes the time on the system clock. In Linux there are several different implementations for different cases (https://linux.die.net/man/3/clock_gettime): CLOCK_REALTIME System-wide realtime clock. Setting this clock requires appropriate privileges. CLOCK_MONOTONIC Clock that cannot be set and represents monotonic time since some unspecified starting point. CLOCK_PROCESS_CPUTIME_ID High-resolution per-process timer from the CPU. CLOCK_THREAD_CPUTIME_ID Thread-specific CPU-time clock.…

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:…

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:

Step 1 – Initialize the dataset, 6 vectors of 32 sample data

Step 2 – Subtract the mean from each of the data dimensions. The mean subtracted is the average across each dimension. [math]Y= X – (O * Mean(X)) [/math], where [math]O…

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 etc…

Constructors

Operators overloading

Other Methods

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.

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.

This project is a memory allocation scheme that provides efficient dynamic memory allocation for small embedded systems lacking a Memory Management Unit (MMU). The proposed Simple Memory Management Scheme (SMM) maintains a balance between performance and efficiency, with the objective to increase the amount of usable memory in MMU-less embedded systems with a bounded and acceptable timing behavior. This implementation does not require a hardware MMU, and does requires a few or no manual changes…