Selective Color Adjustment tool like in Photoshop possible?

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
tavtav
Posts: 4
Joined: 2016-10-27T12:35:48-07:00
Authentication code: 1151

Selective Color Adjustment tool like in Photoshop possible?

Post by tavtav »

I've been trying for a few hours now to get a selective color adjustment tool working similar to the one that exists in Photoshop.

I am translating this tutorial (http://gomedia.com/zine/tutorials/easy- ... photoshop/) step by step to ImageMagick and haven't had any issues until "step 5 emulating the 'color profile' of film". I want to be able to select a certain color channel in the source image and edit it's specific CMYK values.

Here is the source image that I wish to edit: https://i.imgur.com/8F6LQHg.jpg

Using the photoshop selective color tool: https://i.imgur.com/wC5203b.png

Image after using the Selective Color tool in Photoshop to change the Magenta and Yellow values of the Yellow colors in the image (following the tutorial): https://i.imgur.com/OXEnArw.jpg

My attempt at doing the same thing in ImageMagick: https://i.imgur.com/A0JqWUo.jpg

My idea was to try to separate the different CMYK and RGB channels into their own files, editing each one's color channels then combining them back together. I want to do this for the Yellow, Green, Blue, and Black channels, but I am just focusing on one to get it working for now. Here is my code:

Code: Select all

convert source.jpg -colorspace CMYK -separate separate_CMYK_%d.jpg

#I'm assuming separate_CMYK_2.jpg is the Yellow spectrum
convert separate_CMYK_2.jpg -colorspace CMYK -channel M -evaluate set 75% +channel -channel Y -evaluate set 25% +channel separate_CMYK_2.jpg

convert separate_CMYK_0.jpg separate_CMYK_1.jpg separate_CMYK_2.jpg separate_CMYK_3.jpg -set colorspace CMYK -combine -colorspace RGB combine.jpg

Code: Select all

Version: ImageMagick 6.9.6-2 Q16 x86_64 2016-10-11 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
I am definitely doing something wrong here. I have read up on the following documentation:

https://www.imagemagick.org/Usage/color_basics
http://www.imagemagick.org/script/comma ... hp#channel
http://www.imagemagick.org/script/comma ... p#evaluate
http://www.imagemagick.org/script/comma ... colorspace

I just can't figure this out. I have also tried searching on the forums and came across this post:

https://www.imagemagick.org/discourse-s ... =1&t=28646

The user there asks how to change the CMYK values on only the Black channel, and I assume they figured out how to do it as they never asked about it again. Unfortunately, a solution was never posted. Some people responded and said to convert the colorspace to CMYK and edit from there, but that would effect the whole 'spectrum' and all channels. I want to specifically target certain colors and edit only their CMYK values.

Anyways, any help with this would be appreciated. Thank you!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by snibgo »

You're not far off. Your files separate_CMYK_2.jpg etc are grayscale, one grayscale file per colour channel. That particular one is from the yellow channel. If you want to set the yellow channel in all pixels to 25%, then:

Code: Select all

convert separate_CMYK_2.jpg -evaluate set 25% separate_CMYK_2.jpg
BUT don't ever use jpg as an intermediate format because it is lossy. Use MIFF or MPC or PNG or TIFF.
snibgo's IM pages: im.snibgo.com
tavtav
Posts: 4
Joined: 2016-10-27T12:35:48-07:00
Authentication code: 1151

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by tavtav »

So, I understand your code, but I'm still confused. In the tutorial, they edit the CMYK values of the color, in this example, the Magenta and Yellow values of the Yellow "spectrum" as so: http://s3.gomedia.us/wp-content/uploads ... tments.png

But in your code, I would only be editing the value of the yellow in the yellow channel (seprate_CMYK_2.jpg) to 25%? How do I edit the Magenta value in the same file?

Would I edit spectrum_CMYK_1.jpg and set it to 75% for magenta? And then do I make another group of separate CMYK files to edit each color (like I said earlier, Yellow Green Blue and Black?)? Then do I layer each group on top of each other "over" or "blend" them with -compose and -composite? The tutorial link I posted earlier may actually explain this better...

http://gomedia.com/zine/tutorials/easy- ... photoshop/
under step 5

Still confused as how I can do this.

EDIT: I've made the changes as stated above and now my image is completely magenta: https://i.imgur.com/epNCJYU.jpg

Code that ran to make this output:

Code: Select all

convert source.jpg -colorspace CMYK -separate separate_CMYK_%d.jpg
convert separate_CMYK_1.jpg -evaluate set 75% separate_CMYK_1.jpg
convert separate_CMYK_2.jpg -evaluate set 25% separate_CMYK_2.jpg
convert separate_CMYK_0.jpg separate_CMYK_1.jpg separate_CMYK_2.jpg separate_CMYK_3.jpg -set colorspace CMYK -combine -colorspace RGB combine.jpg
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by snibgo »

I don't use PS so can't be sure but I think the web page you link to adds values to channels, rather than setting values to channels.
snibgo's IM pages: im.snibgo.com
tavtav
Posts: 4
Joined: 2016-10-27T12:35:48-07:00
Authentication code: 1151

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by tavtav »

I've changed -evaluate set to -evaluate add and it still isn't right. I'm trying to find more information about how this tool works and I've stumbled upon the following links:

https://www.psdbox.com/tutorials/how-se ... olor-works
https://fstoppers.com/post-production/s ... phers-7954

I'll keep trying different ways to get this to work.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by snibgo »

From the second link:
What Relative does is it takes the value of the color tone in the image, and then changes it by a percentage of the total. So if your image is 50% red tones, adding 10% to the red slider is actually going to add 50% of the 10%....bringing the total to 55%.
So, in ImageMagick terms, "adding 10%" means multiplying by 1.1. Similarly, "adding 75%" would mean multiplying by 1.75.
snibgo's IM pages: im.snibgo.com
tavtav
Posts: 4
Joined: 2016-10-27T12:35:48-07:00
Authentication code: 1151

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by tavtav »

Unfortunately, I can't figure this out. I might not know enough about color theory to figure this out. I just want to edit the CMYK values of a specific color channel but it seems like it is something that isn't possible to do. I'm now trying to do this with HSL and -modulate but I can't wrap my head around it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Selective Color Adjustment tool like in Photoshop possible?

Post by snibgo »

tavtav wrote:I just want to edit the CMYK values of a specific color channel but it seems like it is something that isn't possible to do.
It is possible. The problem is that you first have to define what you mean by "edit".

But I do suggest you play with IM, and other tools. I like Gimp. Playing with the color-curves tool, and seeing the effect on the image, helps us to understand the theory.
snibgo's IM pages: im.snibgo.com
Post Reply