Combining TIFs to 48bit RGB-TIF

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
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Combining TIFs to 48bit RGB-TIF

Post by Jossie »

Hello,

being new to imagemagick I have a most likely simple question:

I have three 16bit-TIF Images, corresponding to the R, G and B channel of a color image. How do I combine these into a single one-page 48bit-TIF color image?

Many thanks in advance for any hints.

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Combining TIFs to 48bit RGB-TIF

Post by snibgo »

I don't know what you mean by 16-bit and 48-bit, but how about:

Code: Select all

convert a.tif b.tif c.tif +append out.tif
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Combining TIFs to 48bit RGB-TIF

Post by Jossie »

Hi,

thanks for your reply. Perhaps I should give some more details.

I have an image being the raw data from a slide scanner. The raw image consists of pixels, each of which is a 16bit number for the R, G, B and IR channel. I have used imageJ to extract from this raw image 4 separate images as 16bit (single color) TIF-files corresponding to the 4 channels. Now I want to combine three of them, corresponding to R,G and B into a single TIF-File (not a multi-page TIF) which is then an RGB-image with 48bit / pixel, 16bit for each color).

You can phrase it differently: I want to eliminate the fourth channel (IR) from the raw data file (TIF), so each pixel is just R,G and B with 16bits/pixel/color (and not R,G,B,IR).

I have tried various things. I can do this with imageJ ("image -- color -- stack to RGB" in imageJ) but this produces 24bits/pixel TIFs, not 48bit TIFs. I have tried imagemagick but without success thus far.

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Combining TIFs to 48bit RGB-TIF

Post by snibgo »

Ah, okay. You have 3 input files. Each is grayscale, but represents one of R, G and B.

The answer is in your title: use "-combine". See http://www.imagemagick.org/script/comma ... hp#combine

Code: Select all

convert a.tif b.tif c.tif -combine out.tif
If that doesn't work, then posting sample images would help. Put them somewhere like dropbox.com and paste the links here.
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Combining TIFs to 48bit RGB-TIF

Post by Jossie »

Great, that worked perfectly!

As I mentioned, I used imageJ to get the grayscale Images, to begin with. In the end I would, of course, like to do this in one go over many files in imagemagick.

So the first question would be, if it is possible to convert the 4x16bit/pixel TIF image into a 3x16bit/pixel image, which would be the RGB image, in imagemagick directly.

If the answer is "YES", then the second question is, how to do this in batch mode, say for all TIF-files in a folder named image_001.tif, image_002.tif, and so on, resulting in the RGB-TIFs image_001_RGB.tif, image_0002_RGB.tif etc.

Many thanks for your help!

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Combining TIFs to 48bit RGB-TIF

Post by snibgo »

I don't know if IM can read your 4x16bit/pixel TIF files. With luck, it can, treating the 4th channel as alpha. You can then ignore the alpha.

Code: Select all

convert in.tif -alpha off out.tif
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Combining TIFs to 48bit RGB-TIF

Post by Jossie »

Thanks a lot for your reply.

Unfortunately the trick with the alpha channel did not work. So I will set up a macro for imageJ and split the pixels there.

If I have then a series of images in a folder, with the RGB channels named image_001_R.tif, image_001_G.tif, image_001_B.tif, image_002_R.tif etc. and I want to run a macro to create the RGB Images, how would the macro look like to create the output files image_001_RGB.tif, image_002_RGB.tif etc.?

Best wishes

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Combining TIFs to 48bit RGB-TIF

Post by snibgo »

Jossie wrote:If I have then a series of images in a folder, ...
You would write a script. See tutorials or references for the script language of your choice.
snibgo's IM pages: im.snibgo.com
Post Reply