Astronomy Python - Chatgpt based- Stich Images Horizontally
Often there will be need to put images one beside another for analyzing .
For example we have 3 images (shown below)and we want to align it in one single image one beside another.
Individual Images are taken from below website
https://asd.gsfc.nasa.gov/archive/mwmw/mmw_sci.html
Python code below
*******************************************************************
from PIL import Image
# Open the images
image1 = Image.open("E:\\astronomy_related\\imageoverlay\\image1.jpg")
image2 = Image.open("E:\\astronomy_related\\imageoverlay\\image2.jpg")
image3 = Image.open("E:\\astronomy_related\\imageoverlay\\image3.jpg")
# Create a list of images
images = [image1, image2, image3]
# Determine the width and height of the final image
widths, heights = zip(*(i.size for i in images))
total_width = sum(widths)
max_height = max(heights)
# Create a new image the size of the final image
result = Image.new("RGB", (total_width, max_height))
# Paste the images together
x_offset = 0
for im in images:
result.paste(im, (x_offset,0))
x_offset += im.size[0]
# Save the result
result.save("E:\\astronomy_related\\imageoverlay\\result_horizontal.jpg")
credit -
For images- https://asd.gsfc.nasa.gov/archive/mwmw/mmw_sci.html
For python code-https://chat.openai.com
Comments
Post a Comment