Separating white 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?".
Post Reply
liamcrayden
Posts: 2
Joined: 2019-02-12T07:46:39-07:00
Authentication code: 1152

Separating white from an image

Post by liamcrayden »

ImageMagick 7.0.8-26 Q16 x86_64 2019-02-09
(but happy to use any version)


Please see the example Butterfly image here (I have added both a RGB .png file and a CMYK .tif file):
https://www.dropbox.com/sh/lfhwwep2f29x ... Ncfua?dl=0

What I am trying to do is keep the white whilst preserving the transparency of the original image and removing everything else.

The actual end goal is:

1. Given an image, separate out so that I have the greyscale versions of the C, the Y, the M, and the K as individual files (I think I have this already).
2. From the same file, separate out the white so that I have a greyscale version of it (this bit I can't do).
3. In external software, combine the C, M, Y, K and white into a file file for printing. The "white" file is basically a spot colour.

If you haven't already guessed, this is for printing on a CMYW printer (OKI Pro8432WT). The actual printer has C, M, Y and W toner - no black. So any blacks in the image must be a mix of the CMY channels only. The resulting image can have a K channel, but it will be ignored. The printer only prints white when it is designed as a spot colour.

I'm happy that I can figure out that actual printing side and sending the raw data to the printer, but I'm really struggling with separating out the white from the original butterfly image, especially whilst preserving the transparency.

The best I can come up with so far is also in that dropbox folder (the files named C.tif, M.tif, Y.tif and W.png). Essentially what I need is that W.png file, but with the alpha and the white reversed out so that white is where the transparent part is, and transparent is where the white is now. To achieve that I used this command:

convert ButterflyRGB.png -alpha off -channel A -transparent white -negate +channel W.png

.. but can't work out going the other way to invert the result.

To clarify: I'm not looking to produce a "CMYW image" (if such a thing even exists). I'm only looking to separate out so that I have 4 resulting files - C, M, Y and W (where W is the spot colour but could be anything). I will re-combine the images for printing myself.

Many thanks for any suggestions.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Separating white from an image

Post by snibgo »

For IM v7, I suggest you use "magick", not "convert".

I think you want to make W.png from ButterflyRGB.png. W.png should be opaque white where ButterflyRGB.png is opaque white, and fully transparent everywhere else. Is that right?

Code: Select all

magick ButterflyRGB.png +transparent White x.png
snibgo's IM pages: im.snibgo.com
liamcrayden
Posts: 2
Joined: 2019-02-12T07:46:39-07:00
Authentication code: 1152

Re: Separating white from an image

Post by liamcrayden »

That is literally the exact thing I was looking for - embarrassing that it was so simple!

Many thanks for your time.
Post Reply