My journey into computer vision began with Mathematics 155: a UCLA course on Mathematical Imaging/ Image Processing. My professor introduced the subject as the mathematics behind Photoshop – and I was hooked.

We studied a breadth of topics ranging from Fourier Transform Analysis, Convolution/Edge Detection, Interpolation, Image Reconstruction techniques, to Mathematical Morphology. With this technical understanding as a foundation, I thought it would be interesting to apply some of these techniques with an artistic motivation.

—

Image segmentation is the process of partitioning an image into multiple segments, based on similarities in color, texture, brightness, etc. These new segments are more meaningful and easier to analyze, especially in the fields of medical imaging and object tracking.

I decided to implement the K-Means Clustering Algorithm to segment images based on HSV and RGB channels.

The first step is to determine the channel that you want to segment, and number of segments.

If we notice a large range of red in our image, we might chose to segment the Red channel. The Red channel values in an image range from 0 to 255. What the K-means Clustering Algorithm does is find the K number of values that best represent the range in an image, and essentially map each value in the image to its closest centroid. The Red values in the image will no longer span the range 0-255, but instead come from the set [r_1, r_2, r_3 .. r_k].

There is a lot of artistic flexibility with this process, as you can chose any number of segments and combination of channels. A lower K value will give stronger posterization, whereas a higher K value may maintain the original structure of the image. Similarly, segmenting two channels will also give stronger posterization.

I found that segmenting the Value channel in an HSV image gives really awesome and contrasted results, since Value represents the brightness/shadows in the image. Based on the color profile of the image, experimenting with different RGB channel combinations can also produce beautiful and alternative color posterizing.

Below are a few examples of some of the effects achieved, check out the pdf/source code attached for more detailed analysis!

and of course, had to try the algorithm on this cutie < 3

source code:

https://github.com/sneha-belkhale/KMeans-ImageSegmentation

image pdf :

colorSegmentation

### Like this:

Like Loading...

*Related*