Home > Enterprise >  Combine MRI image with an heatmap plot
Combine MRI image with an heatmap plot

Time:01-06

I have a jpg photo of the brain with a shape of (430,355) and a heatmap image (5x5 shape) relating to the different brain parts. I want to combine these two in a way that shows which part of the brain is more active.

enter image description here and enter image description here

what I want is:

enter image description here

CodePudding user response:

The easiest solution can be to add the second images with a weight, with OpenCv, after resizing the second one so that it matches the size of the original one:

heatmap = cv2.resize(heatmap, (brain.shape[1], brain.shape[0]))
combined = cv2.addWeighted(brain, 1, heatmap, 0.7, 1)

This is the output:

Output

Modifying the parameters you can have the result that best fits your use case.

addWeighted is a function that calculates the weighted sum of two arrays.

Here you can find the documentation: https://docs.opencv.org/3.4/d2/de8/group__core__array.html#gafafb2513349db3bcff51f54ee5592a19

Is not exactly like the one in your question, but it is a fast and effective approach.

  • Related