Hierarchical image clustering using a KD-Tree, served via a simple Node/Express UI.
- Windows 10/11
- Node.js (LTS 18+ recommended) and npm
- Optional: MinGW‑w64 g++ if you want to rebuild the C++ binaries
Prebuilt executables project.exe and histogram.exe are already present in Project/.
- Open PowerShell and go to the server folder:
cd "C:\Users\HP\Desktop\KDTreeImageClustering\Project"- Install dependencies:
npm install- Start the server:
npm start- Open your browser at:
- In the web UI:
- Upload an image (stored in
Project/Images/). - Enter the number of results and click Search. Results render below.
Only if you modify sources or your environment requires it. From Project/:
# Build project.exe (KD-Tree clustering)
g++ -std=gnu++17 -O2 -Wall project.cpp -o project.exe
# Build histogram.exe (histogram generator)
# If filesystem linking fails on old GCC, try adding -lstdc++fs
g++ -std=gnu++17 -O2 -Wall histogram.cpp -o histogram.exeAlternatively, if you have mingw32-make installed:
mingw32-make.exe allhistogram.exescansProject/Images/and writes color histograms tooutput.json.project.exereadsoutput.jsonandinput.json(fields:target,num), clusters via KD‑Tree, and writes thenumbersarray toinput.json.server.jswires it together and serves the static UI inpublic/.
- Run npm from
Project/(not repo root). Thepackage.jsonis inProject/. - g++: unrecognized
-std=c++20- Use
-std=gnu++17(already set in the makefile and commands above).
- Use
- g++:
KdTree.cpp: No such file or directory- There is no
KdTree.cpp; onlyKdTree.hpp. Buildproject.cppdirectly.
- There is no
- Filesystem linker errors with very old MinGW
- Rebuild
histogram.exewith:-lstdc++fs.
- Rebuild
- Port 8000 busy
- Edit
const PORT = 8000;inserver.jsand restart.
- Edit
Project/
histogram.cpp, project.cpp, KdTree.hpp, json.hpp, stb_image.h
histogram.exe, project.exe
output.json, input.json
public/ (index.html, index.js)
Images/
server.js, package.json, makefile