I am using Opencv to posterize a picture with the function pyrMeanShiftFiltering, but i don't know how to posterize it to the exact 32 colors i need. I don't even know how to tell it that i need exactly 32 colors.
This is my code so far.
public void run(Mat image, double windowSize, double colorValue){
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Imgproc.pyrMeanShiftFiltering(image,image,windowSize,colorValue,2,new TermCriteria(TermCriteria.MAX_ITER|TermCriteria.EPS, 50, 0.001));
String filename = "<MYPATH>/Posterized_"+ (int)windowSize +"."+ (int)colorValue + ".jpg";
System.out.println(String.format("Done. Writing %s", filename));
Imgcodecs.imwrite(filename, image);
}
public static void main (String[] args)
{
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat image = Imgcodecs.imread("<MYPATH>/Soccer.jpg");
posterize po = new posterize();
po.run(image,10,10);
}
Any suggestions?
Thank you in advance.