Ask Your Question


asked 2013-03-14 16:21:05 -0500

christinasc gravatar image

updated 2013-03-14 17:36:37 -0500

Hi So I have been testing out the method binarizeFromPalette and have been noticing some odd behaviors:

What I really want to do is to getPalette from Image #1 and use all the colors from this image to binarize image #2. This way I can see what parts of the image #2 do not contain the palette colors in image #1

It works, however two things happen:

1) There are colors that appear in the binary image that are not just white/black.

2) The result is inconsistent. I'm assuming this has something to do with the algorithm which generates the palette and some other random variable. Sometimes I get a completely different pattern when I run the same code. The only thing I notice that is different between the runs is that the the colors in the palette are different every time I run the code. Is this to be expected?

>>> img1 = Image("lenna")
>>> img2 = Image("lenna2")
>>> p = img1.getPalette()
>>> b = img2.binarizeFromPalette( p )

Finally, I am wondering if a better approach would be to use a color model and threshold that instead.

Example :

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-14 17:47:29 -0500

kscottz gravatar image

The suite of palette functions do not do what you are looking for. The palette functions essentially do a k-means analysis of the colors in your image. The color model is what you want to use.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-03-14 16:21:05 -0500

Seen: 151 times

Last updated: Mar 14 '13