Page 1 of 1

How to separate image into different shades of grey?

Posted: 2014-02-28T00:39:43-07:00
by alasdairdf
Hello,

I'm trying to build a vectorizer for greyscale images. What I need to do with IM is to separate each image into 32 shades of grey, starting from very light grey all the way to black. For each shade a copy is made of the original where any pixels lighter than this shade are changes to white, and any pixels of this shade or darker are changed to black. (Then I can vectorize each image, change its color, and combine them all back into one image.)

It's actually very simple, the formula would be:
Change every pixel lighter than x% to white
Change every pixel equal to or darker than x% to black

How to do that with IM? I've looked through the docs but I can't find anything. I tried playing with levels but couldn't figure out how to get it to do what I need.

Thanks!

Re: How to separate image into different shades of grey?

Posted: 2014-02-28T03:22:24-07:00
by snibgo
Change every pixel lighter than x% to white
Change every pixel equal to or darker than x% to black
-threshold x%