top of page

KMeans3D

Project is a part of my master thesis. The aim is to achieve 3D visualization of k-means clusterization algorithm. Base of the project is a image color cloud presented in 3D space. Whole image colors data is loaded into k-means solver that calculates clusters centers until they stabilize. Each color on the histogram represents one cluster. By clicking "step" button user can see how clusterized histogram and image change after one iteration of the algorithm.

Technical stack

To render graphics I used my little 3D library based on OpenGL (link here). Images are loaded with use of OpenCV, which can be used in the future to compare algorithms results or process clusterized data.

GUI, however, is created with use of Qt library and its layout designer.

Solutions

Clusterized image

OpenCV's cv::Mat object is converted to ProEngine3D's Texture object and rendered as a simple quad. Clusterized image is achieved by applying shader that sets color based on the closest centroid (of the k-means solver). Using fragment shader for simple image processing is a good idea for achieving  GPU support. 

Rendering colors cloud.

Colors cloud is rendered as a set of colored points (one vertex per point). Graphics cards can easily handle even huge number of vertices if shaders are simple. To achieve best performance, I have applied the simplest shader which only sets vertex color. Data is updated on the CPU and transfered to GPU only when position of centroids have changed. That means, when user rotates or zooms cube, only simple colored points are renderered. This is important to make the application smooth looking even on slower machines.

bottom of page