How to separate image into different shades of grey?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
alasdairdf
Posts: 53
Joined: 2012-05-15T04:56:50-07:00
Authentication code: 13

How to separate image into different shades of grey?

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Change every pixel lighter than x% to white
Change every pixel equal to or darker than x% to black
-threshold x%
snibgo's IM pages: im.snibgo.com
Post Reply