Removing All Shades of Grey from an Image

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?".
User avatar
fmw42
Posts: 25751
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing All Shades of Grey from an Image

Post by fmw42 » 2019-05-22T13:24:56-07:00

You cannot post https URLs as images on this forum. It does not support that. You will need to change them to links. I have edited your post above.

User avatar
fmw42
Posts: 25751
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing All Shades of Grey from an Image

Post by fmw42 » 2019-05-22T13:27:50-07:00

Which part of your command do you want to change? The input image or the mask you create. Please clarify where you need the change.

User avatar
GeeMack
Posts: 727
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Removing All Shades of Grey from an Image

Post by GeeMack » 2019-05-22T19:29:25-07:00

OmahaWxMan wrote:
2019-05-22T10:51:32-07:00
After more testing I realized that I can't entirely drop the black channel from the CYMK separation. [...] To my novice eyes, adding a second +clone line and fuzzing the K-channel to a few percentage points of #000000 would work, but I'm not sure how to pull that off and then combine both into the intended results.
There are a few ways to isolate all the white inside another set of parentheses, then composite it over the result you have so far. Here is an example command showing one idea...

Code: Select all

convert input.png \
   \( -clone 0 -colorspace CMYK -channel CMY -separate -evaluate-sequence add \) \
   \( -clone 0,1 -alpha off -compose copyopacity -composite \) \
   \( -clone 0 -fuzz 50% +transparent white -blur 0x0.5 \) \
   -delete 0,1 -compose over -composite result.png
The command starts by reading in the input image.

Then it removes the black from CMYK to make a mask inside the first parentheses.

Next it applies that mask to the input image to more or less get rid of the grayscale and keep all the colors.

The input image is cloned again inside the next set of parentheses, and everything is made transparent except white. A fuzz value determines how pure the white must be to keep it. A little blur is applied to the result.

Then it deletes the original input image and the mask because they're no longer needed. It finishes by compositing the white layer over the color layer and writing the output result.

OmahaWxMan
Posts: 8
Joined: 2019-05-17T08:38:25-07:00
Authentication code: 1152

Re: Removing All Shades of Grey from an Image

Post by OmahaWxMan » 2019-05-23T07:26:33-07:00

Thanks for editing my above post, I'm a bit confused though, I've only submitted HTTPS images and they seem to be showing up fine. However, it may be due to my permissions in Google Photos, I moved the two photos to a different album and they should be OK now.

Thank you, GeeMack, for the new convert command and the explanation, that's exactly what I was trying to do on my own and reading the documentation but didn't quite get.

Here's one more image using the updated convert command.

Image

User avatar
fmw42
Posts: 25751
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing All Shades of Grey from an Image

Post by fmw42 » 2019-05-23T07:50:45-07:00

fmw42 wrote:
2019-05-22T13:24:56-07:00
You cannot post https URLs as images on this forum. It does not support that. You will need to change them to links. I have edited your post above.
I could be wrong about this. I have seen this issue numerous times and assumed it was the https, since it was always those link. But you could be write that it is just permissions.

OmahaWxMan
Posts: 8
Joined: 2019-05-17T08:38:25-07:00
Authentication code: 1152

Re: Removing All Shades of Grey from an Image

Post by OmahaWxMan » 2019-05-23T11:01:10-07:00

I just updated the previous image's URL with the one from my shared Google Album and it's working now.

Thanks again for all the help!

Post Reply