image = | kMeansPosterizeImg (inImg,classImg,clustersCenters) |
image = | kMeansPosterizeImg (inImg,classImg,maskImg,clustersCenters) |
Posterize an image using the results from k-means algorithm.
Fills the output image (that must have the same geometry as the input one), by replacing each pixel value of the input image ( ) with the value of the center of the cluster which it belongs to. Values of clusters centers are defined by
attribute, and input image clustering is defined by
attribute. These 2 attributes are usually initialized using K-means algorithm.
Here is an example of posterization algorithm applied to Lena RGB image and to results of K-Means algorithm application (4 clusters expected):
It is also possible to provide a mask image. In this case, the posterized image will have a value of 0 where the mask equals False. Here is an example of masked posterization: