2
$\begingroup$

How can I overlap/merge two density plot (in attach) using Mathematica. One image is in red scale and the other is in green scale.

enter image description here

In theses two images the lowest value is white (background) and the highest values are represented by pure red [ RGB (255,0,0) ] and green [ RGB (0,255,0) ] scale.

How do I to overlap these two images such that intersections are a combination of red and green to give a yellow intensity [ RGB (255,255,0) ] dependent on the "red" and "green" values. In summary I need that resultant image had red, green and yellow colors.

I already tried these examples:

and the function Blend[{ Image1 , Image2 }], but I didn't get a good result.

This is the closest example that I get using Blend[{imag1,imag2}].

enter image description here

But this is not 100 % correct a time that if you combine two pure colors, pure red and green, I was expecting that the combination of these two pure colors result a image that had red, green and yellow colors, but not in the dark tone of these color.

$\endgroup$
  • 3
    $\begingroup$ Could you show the code you used to create the above images in Mathematica? Or are they imported from somewhere else? In other words are you wanting to treat external data (like fluorescence microscopy images) or are you wanting to do everything inside Mathematica (also the creation of the images)? $\endgroup$ – Dunlop Nov 14 '16 at 11:42
  • $\begingroup$ This images are from a external data. I would like to treat this images using Mathematica. $\endgroup$ – G. Candiotto Nov 14 '16 at 11:53
  • $\begingroup$ ImageCompose[img, {img2, 0.5}] is, I think, the way to go but it doesn't necessarily result in a "nice" scale of yellow colors. $\endgroup$ – C. E. Nov 14 '16 at 12:02
  • $\begingroup$ When you use this function ImageCompose[img, {img2, 0.5}] you obtain the same result of Blend[img , img2] this result is like a average of interpolation of the two images. The image that result from these two function ImageCompose[img, {img2, 0.5}] and Blend[img,img2] has a color tone /2 from the pure yellow $\endgroup$ – G. Candiotto Nov 14 '16 at 12:08
  • $\begingroup$ @G.Candiotto . Hard to say but it looks from a first glance that the intensities are identical. If you combine both "red" and "green" images and then use ColorSeparate[] you end up with only the blue channel having less than a full intensity (except where the black lines are). Do you know where you are expecting the images not to match up, or have an example of what the output should be like? $\endgroup$ – Dunlop Nov 14 '16 at 13:35
4
$\begingroup$

Assuming the images are aligned and the same size, you can apply Max (or any other function) to each pixel color component like this:

imgs = Import /@ {"https://i.stack.imgur.com/aFlhC.png", 
    "https://i.stack.imgur.com/ez2ql.png"};

Image[MapThread[Max, ImageData /@ imgs, 3]]

enter image description here

$\endgroup$
  • $\begingroup$ Hello nikie, first thanks for your attention. Your example is pretty good, but is necessary appears de colors red and green in the resultant image, a time that intersection region isn't 100% equal in the two images. The result that you plot in your example has the same result of function ImageAdd[ img1 , Img2 ]. $\endgroup$ – G. Candiotto Nov 14 '16 at 13:22
  • $\begingroup$ @G.Candiotto: You can use any function instead of Max. But you'll have to come up with a function yourself - I have no idea what kind of mapping you have in mind. $\endgroup$ – Niki Estner Nov 14 '16 at 13:50
0
$\begingroup$

Here is a result that might be useful to you. I cannot think of a simple way to restore the white background but perhaps I will come back to it later.

imgs = Import /@ {"https://i.stack.imgur.com/aFlhC.png", 
                  "https://i.stack.imgur.com/ez2ql.png"};

ImageApply[1 - {#[[2]], #2[[1]], #[[1]]} &, imgs]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.