Tile stock · Image sampler
Tile Stock Image Sampler
by Harrison Hildebrandt
Reuse starts with knowing what is in the pile. This small Python tool takes a photo of tiles, finds every tile-shaped region, names its colour and writes one CSV row per tile. The result is a rough stock count you can feed into a tiling design.
- 01Cluster coloursK-means on a downscaled copy, then every full-size pixel joins its nearest cluster.
- 02Cut on groutCanny edges are dilated into a barrier so neighbouring tiles do not merge.
- 03Find regionsConnected components per colour, filtered by minimum area, size and rectangularity.
- 04Name and exportEach region's mean colour snaps to a small palette and is written to CSV.
Results
Full results table
| id | colour | x | y | w | h | area px | mean RGB |
|---|
Files and how to run it
tile-stock-sampler.zipEverything below in one archive
tile_counter.pySettings for large tiles in a photo
tile_counter2.pySettings for many small tiles
tile_counts.csvResults for sample 1
tile_counts2.csvResults for sample 2
source_image.jpgFull-resolution photo for sample 1
# Python 3 with OpenCV, NumPy and pandas pip install opencv-python numpy pandas # Writes tile_results/tile_counts.csv and prints a count per colour python tile_counter.py source_image.jpg