Astronomy Python - Chatgpt based- Stich Images Vertically

 Often there will be need to put images one below another for analyzing . 

For example we have 3 images (shown below)and we want to align it in one single image one below another.


Below is the python script,  Special Thanks and all credit goes to "Chatgpt", who has generated the code, which will align the image one below another. Below is the output.


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))

max_width = max(widths)

total_height = sum(heights)


# Create a new image the size of the final image

result = Image.new("RGB", (max_width, total_height))


# Paste the images together

y_offset = 0

for im in images:

    result.paste(im, (0, y_offset))

    y_offset += im.size[1]


# Save the result

result.save("E:\\astronomy_related\\imageoverlay\\result_vertical.jpg")


***********************************************************

credit -

For images- https://asd.gsfc.nasa.gov/archive/mwmw/mmw_sci.html

For python code-https://chat.openai.com


Comments

Popular posts from this blog

Astronomy Python - Webb's First Deep Field - Marking the Edges of the Galaxies

Online Observatory for Meteor Scatter Detection - Radio Astronomy.

Astronomy Python - Mars Planet Surface - Creating Sharpen Image from Blur Image