Page 1 of 1

Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-16T05:42:20-07:00
by pablobhz
Hello Everyone.

Lemme explain my scenario.
I have an old software, that takes 4 tiff images (grayscale), and combine them into a final CMYK colored image.

I already know that each one of those images, corresponds to one color channel
ex:
image 1 - foo(c).TIFF
image 2 - foo(m).TIFF

and so goes on.

I would like to know if, can MagickNET do this kind of merging to create a final file ?
There's no documentation or anything in the old source code.

Here's my tought:
Loop into each image pixel, store and later combine in a final image (something like that) ?

Thanks in advance for any input\help.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-16T06:05:19-07:00
by dlemstra
You could use the Combine method of the MagickImageCollection for this. Only have a phone atm so I cannot easily create an example for you.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-16T07:12:22-07:00
by snibgo
At the command line, you can do this:

Code: Select all

convert foo(c).TIFF foo(m).TIFF foo(y).TIFF foo(k).TIFF -set colorspace CMYK -combine +write info: out.tiff
Sorry, I don't know Magick.NET.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-18T20:12:51-07:00
by pablobhz
dlemstra wrote: 2017-03-16T06:05:19-07:00 You could use the Combine method of the MagickImageCollection for this. Only have a phone atm so I cannot easily create an example for you.
This method works for RGB output only, as i could see. It has no mentions to a CMYK combining.
The input is 4 files, output will be one file. Unless there's some way to convert from CMYK to RGB and then combine, it won't work.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-20T18:29:41-07:00
by dlemstra
What happens when you set the ColorSpace of the image to CMYK afterwards?

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T20:09:40-07:00
by pablobhz
Here's the tests i've done.

Using MagickCollection (MagickNET)

Code: Select all

using (MagickImageCollection images = new MagickImageCollection())
            {
                // Add the first image
                MagickImage first = new MagickImage(@"C:\DI_PLOT\Bitmaps\8FILES_IMPOSED_4UP_BACK.PDF (C)00.TIF");
                images.Add(first);

                // Add the first image
                MagickImage second = new MagickImage(@"C:\DI_PLOT\Bitmaps\8FILES_IMPOSED_4UP_BACK.PDF (M)00.TIF");
                images.Add(second);

                // Add the first image
                MagickImage third = new MagickImage(@"C:\DI_PLOT\Bitmaps\8FILES_IMPOSED_4UP_BACK.PDF (Y)00.TIF");
                images.Add(third);

                // Add the first image
                MagickImage fourth = new MagickImage(@"C:\DI_PLOT\Bitmaps\8FILES_IMPOSED_4UP_BACK.PDF (C)00.TIF");
                images.Add(fourth);

                images.Combine();
                images.Write(@"C:\DI_PLOT\finalmerge.png");
                /*
                // Create a mosaic from both images
                using (MagickImage result = images.Mosaic())
                {
                    // Save the result
                    result.Write(@"C:\DI_PLOT\finalmerge.png");
                }
                */
            }
Neither the combine or mosaic worked. They all created a grayscale output anyway (and i need a colored output).
Using the command-line version, gives a few errors but create a weird output. I've uploaded the correct sample and the output i got.
Correct:
http://imgur.com/fyZEMLW

My current output:
http://imgur.com/WLh4KQc

If i set the colorspace to CMYK or RGB (while doing convert), here's the output:
http://imgur.com/8qsmEJr

Any help is appreciated. Kinda lost on this, since i'm new to image processing.
Thanks in advance.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T20:22:03-07:00
by fmw42
It does not look like you changed the colorspace to CMYK per dlemstra's suggestion. I do not use Magick.NET, but as a quick test, try negating the image (command line equivalent is -negate). If that is close then you need to do what dlemstra suggests.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T20:42:50-07:00
by pablobhz
fmw42 wrote: 2017-03-21T20:22:03-07:00 It does not look like you changed the colorspace to CMYK per dlemstra's suggestion. I do not use Magick.NET, but as a quick test, try negating the image (command line equivalent is -negate). If that is close then you need to do what dlemstra suggests.
But i did
The entire command is:
convert c.tif m.tif y.tif k.tif -set colorspace CMYK -combine + write output.tif

For now i'm using command line to achieve this result. When i get command line working, i'll think on how can i implement it using MagickNET

Edit: got this version right now.
http://imgur.com/qPDXgmQ

And using negate:
http://imgur.com/vC0tFgn

Seems like the image is missing "brightness" or something (since i can see RGB colors on the left)

With negate i got really vivid colors but it still seems i'm missing some kind of brightness .

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T21:00:37-07:00
by fmw42
Sorry, your code was Magick.NET. So I only thought you were asking about that. I think the proper command line would be

Code: Select all

convert c.tif m.tif y.tif k.tif -set colorspace sRGB -combine -colorspace CMYK output.tif

You do not need the +write (which should not have any spaces)

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T21:07:57-07:00
by pablobhz
Got it done.
I was looking this thread:

viewtopic.php?t=21159

Then i saw an sample command:
convert imgC imgM imgY imgK -set colorspace CMYK -negate -combine output_image

Should've set the colorspace to CMYK and negate also. Output is fine now.
However, now i'll check how to add some spot colors to this CMYK image.

And later, how to convert all of this to MagickNET (if possible).
The suggestion a guy gave eariler (MagickCollection) didn't worked (produced an black output). I believe i'll try to do a few more things.

Thanks !!!

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T21:15:20-07:00
by fmw42
IM does not support spot colors as far as I know.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-21T21:33:48-07:00
by pablobhz
fmw42 wrote: 2017-03-21T21:15:20-07:00 IM does not support spot colors as far as I know.
And if i add it as a new color ?
Ex: i have color X
It is composed by:
0% cyan
10% magenta
60% yellow
0% black

How would i combine an image with this color composition (and a white background) into my existant CMYK image ?

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-22T08:47:59-07:00
by snibgo
A "spot color" means a colour in used in a product that isn't made by combining CMYK inks. Instead, another plate is used with an ink of that colour.

IM can't add spot colors, but I don't think you want to add a spot colour.

Re: Combine 4 grayscale images into a final CMYK image

Posted: 2017-03-22T08:59:32-07:00
by pablobhz
Okay. So i got it wrong.
The color i want to add, is composed by this amount on each channel.

Like i mentioned before:
0% cyan
10% magenta
60% yellow
0% black

The image color is Grayscale and when combining it to a CMYK image, this is the color the image should have.

I supposed it would be like convert the image to CMYK assigning these channels (amount of each one), and then combine with the final CMYK image ?