tf-image-kit

k-means

Here we are using k-means clustering to cluster (x,y,r,g,b) values. This creates an image segmentation effect.

image image image

|

v

gif gif gif

Usage:

from kmeans import *
kmeans(filepath, k, wx = 1.0, wy = 1.0, outdir = None)

Arguments:


Example 1

from kmeans import *
# read from input/nagano_train_960x720.jpeg
kmeans(readpath, 5, 0.5, 0.5, outpath)

Example 2

from kmeans import *
# read from input/kurohime_bike_1920x1080.jpeg
kmeans(readpath, 50, 3.0, 1.0, outpath)

Example 3

from kmeans import *
# read from input/flower_1856x1392.jpeg
kmeans(readpath, 16, 5.0, 5.0, outpath)

Example 4

from kmeans import *
# read from input/kurohime_bike_1920x1080.jpeg
kmeans(readpath, 50, 3.0, 3.0, outpath)

Example 5

from kmeans import *
# read from input/nagano_train_960x720.jpeg
kmeans(readpath, 100, 4.0, 4.0, outpath)

Example 6

from kmeans import *
# read from input/kurohime_bike_960x540.jpeg
kmeans(readpath, 100, 4.0, 4.0, outpath)