Set certain pixels black, leave others alone

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
Posts: 1
Joined: 2017-09-04T13:55:31-07:00
Authentication code: 1151

Set certain pixels black, leave others alone

Post by sizzzzlerz » 2017-09-04T14:06:16-07:00

From the recent eclipse, I have some images of the partially eclipsed sun showing up in orange on an almost black background. What I'd like to do is set the almost black pixels to fully black while leaving the orange image of the sun unchanged. Basically, if all RGB channels of a pixel have a value between 0 and N, I want that pixel to be set to (0,0,0). If any channel has a value greater than N, the pixel should remain unmodified. I need to experiment to determine a good value of N. I've played with -channel and -threshold a bit but haven't found the correct recipe. Is there one which will do what I want?

User avatar
Posts: 22105
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Set certain pixels black, leave others alone

Post by fmw42 » 2017-09-04T15:04:11-07:00

You could try -black-threshold. See ... -threshold. You may have to do it channel by channel using -channel. Also it uses either percent or pixel values in the range 0 to quantumrange for your compile of ImageMagick. (Q8 is 0 to 255, Q16 is 0 to 65535)

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

http:// ... essing.php

Post Reply