Created
October 28, 2018 23:27
-
-
Save wonrobot/f658842b0f2cf829161a4a511f003173 to your computer and use it in GitHub Desktop.
Converts Hubble Images into Sound
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from statistics import median | |
import numpy as np | |
import cv2 | |
import skimage.measure | |
import matplotlib.pyplot as plt | |
import winsound | |
finalnotes = [] | |
im = cv2.imread(r'C:\Users\vikas\OneDrive\Desktop\Back ground\pillars.jpg', 0) # Can be many different formats. | |
x=cv2.resize(im, (1500, 1000)) | |
x = skimage.measure.block_reduce(x, (3,3), np.max) | |
x = skimage.measure.block_reduce(x, (4,4), np.mean) | |
nim = skimage.measure.block_reduce(x, (4,4), np.mean) | |
notes = np.ndarray.flatten(nim) | |
notes=list(notes) | |
for item in notes: | |
if item < 30: | |
finalnotes.append(item*10) | |
elif item < 50: | |
finalnotes.append(item*4) | |
elif item < 150: | |
finalnotes.append(item*5) | |
elif item>150: | |
finalnotes.append(item*15) | |
plt.imshow(nim) | |
for n in range(0,672): | |
winsound.Beep(int(finalnotes[n]), 350) | |
print(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment