This project has moved and is read-only. For the latest updates, please go here.

Image Overlay

Aug 14, 2013 at 10:09 PM
Edited Aug 14, 2013 at 10:12 PM

I recently installed the Magick.NET library for an application I am developing for high throughput image screening.
one of the requirements is to be able to overlay multiple images (no more than 3). The original images are scanned in gray-scale 16bits channel so the first thing I do is convert them to 8bits, RGB mode image. Then each image needs to be colorized (either red, green or blue).
The last step is to overlay them (order is not important). However, I've been unsuccessful in doing so and I am hoping someone can help me.

This is what I tried so far:
MagickImage img1 = new MagickImage(filename1)
MagicImage img2 = new MagickImage(filename2);

//first attempt
MagickImageCollection col = new MagickImageCollection() {img1, img2};
col.Merge(); // caused the result image to be fully colorized 

// second attempt
MagickImageCollection col = new MagickImageCollection() {img1, img2};
col.Combine(); // the RGB colors were combined into the resulting color.

// third attempt
img1.Composite(img2, Gravirt.Center); // generated a mesh of RGB colors
I don't really have much image processing experience so I apologize in advance for not being able to use proper terminology. But what I am really trying to achieve here is to overlay the pixels of one image with the pixels of the other image.

I tried to upload images to show you what I mean by overlaying pixels but it doesn't seem to work.

I hope you can help me.
Aug 15, 2013 at 9:47 PM
Your third attempt was almost right. With the images you emailed me I was able to produce the expected result:
using (MagickImage first = new MagickImage("Source_img1.tif"))
  MagickImage second = new MagickImage("Source_img2.tif");
  first.Composite(second, 0, 0, CompositeOperator.Plus);
You should specify the CompositeOperator. I think 'Plus' is the one you need but feel free to try the other composite operators.
Aug 16, 2013 at 3:27 PM
Hi Again,

Thank you so much. It worked beautifully :)