Skip to content

kobejean/tf-image-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tf-image-kit

alt

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:

  • filepath - The file path of the image to apply the k-means effect.
  • k - The number of means/clusters.
  • wx - A weight on the x values. Higher values will make it cluster along the x-axis.
  • wy - A weight on the y values. Higher values will make it cluster along the y-axis.
  • outdir - The file path to the output directory.

Example 1

video

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

Example 2

video

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

Example 3

video

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

Example 4

video

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

Example 5

video

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

Example 6

video

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