Astronomy Python - Creating Histogram of the Asteroid
Histogram of Image help us to understand distribution of color values in the image. In the below images, left image is of asteroid Bennu and right image is of Histogram. Below is the Python code used to create Histogram. **************************************************************************** from PIL import Image import numpy as np import matplotlib.pyplot as plt # Open the image file img = Image.open("E:\\astronomy_related\\image_to_histogram\\asteroid_bennu.jpg") # Convert the image to grayscale img = img.convert("L") # Convert the image data to a numpy array data = np.array(img) # Plot the histogram plt.hist(data.ravel(), bins=256, range=(0, 256), fc='k', ec='k') plt.show() ***************************************************************************** Credits and Information- Code Credit-(Some modification is done in original code as per the need) https://chat.openai.com Image Cedit and Information https://www.nasa.gov/image-feature/osiris-re...