Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Overlaying images on python

I have these three pictures from a SEM Microscope. One is the actual picture whilst the other two just indicated the presence of specific elements (Aluminium and Silicon) on the sample.

I’d like to overlay them using Numpy and matplotlib so that I can then see where exactly the elements are, however not sure how to approach this on python, so far I’ve only gone as far as reading the picture files as np arrays:

image_SEM = np.asarray(Image.open('Project_SEI.JPG'))
image_Al = np.asarray(Image.open('Project_Al K.JPG'))
image_Si = np.asarray(Image.open('Project_Si K.JPG'))

Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here
enter image description here
enter image description here

>Solution :

You don’t need Numpy arrays at all for a simple overlay.

from PIL import Image

# Change to your file names, this is what mine downloaded as from your post
image_sem = Image.open('aZ8ED.jpg')
image_si = Image.open('HeiA7.jpg')
image_al = Image.open('HlcOR.jpg')

si_k = Image.blend(image_sem, image_si, 0.5)
si_k.show()

al_k = Image.blend(image_sem, image_al, 0.5)
al_k.show()

You’ll have to crop or work with the picture label in the lower right corner for your needs and perhaps the color scale on the left, but this should get you started. It worked for me.

enter image description here
enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading