Theory

K means clustering: Image Difference

K means clustering algorithm can been used to cluster the pixel values for the given input image. In this question, the algorithm has been used to detect the changes between two images. The main purpose is to obtain whether there is a big difference between two pixel values at the same pixel coordinate or not.

Given below images A and B

Image A

Image B

Calculations

There are two steps to detect the changes between two images:

Step 1

Subtract two images to obtain difference image. Difference = |A-B| for each pixel coordinate in the images (|...| is shown as absolute value of the value).

Step 2

Apply K means clustering algorithm to the difference image to obtain the changed pixels as 1 and unchanged pixels as 0.

Press 'Step manually' button to perform step wise calculations of the clusters. Press 'Converge' to directly calculate the clusters (automatically perform all iterations). The result will be presented in below plot.