# ORIGINAL SINE WAVE
%pylab inline
import numpy as np
import matplotlib.pyplot as plt
#creating x-variables and labelling it time
time = np.arange(0,4*np.pi,0.05)
amplitude = np.sin(time)
# we want to plot the sinwave using amplitude and time.
plt.plot(time,amplitude)
# labelling the graph, x-axis and the y-axis
plt.title("SINE WAVE")
plt.xlabel('Time')
plt.ylabel('Amplitude')
#let's try plotting what we have so far
plt.grid(True)
plt.axhline(y=0, color='red')
plt.show()
noise = np.random.normal(0,0.4,len(time))
amplitude_new = amplitude + noise
plt.plot(time,amplitude_new)
plt.show()
noise = np.random.normal(0,0.6,len(time))
amplitude_new = amplitude + noise
plt.plot(time,amplitude_new)
plt.show()
noise = np.random.normal(0,0.8,len(time))
amplitude_new = amplitude + noise
plt.plot(time,amplitude_new)
plt.show()
noise = np.random.normal(0,10,len(time))
amplitude_new = amplitude + noise
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE ONE
noise1 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise1
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE TWO
noise2 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise2
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE THREE
noise3 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise3
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE FOUR
noise4 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise4
plt.plot(time,amplitude_new)
plt.show()
# NOISY WAVE FIVE
noise5 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise5
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE SIX
noise6 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise6
plt.plot(time,amplitude_new)
plt.show()
### NOISY WAVE SEVEN
noise7 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise7
plt.plot(time,amplitude_new)
plt.show()
### NOISY WAVE EIGHT
noise8 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise8
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE NINE
#noise 9
noise9 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise9
plt.plot(time,amplitude_new)
plt.show()
#NOISY WAVE TEN
#noise 10
noise10 = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise10
plt.plot(time,amplitude_new)
plt.show()
noise = np.random.normal(0,0.2,len(time))
amplitude_new = amplitude + noise
plt.plot(time,amplitude_new)
from statsmodels.nonparametric.smoothers_lowess import lowess
filtered=lowess(amplitude_new,time,frac=0.2)
#filtered
plt.plot(filtered[: ,0],filtered[: ,1],'black',linewidth=3)
plt.show()
averaged_noise =(noise1 +noise2+noise3+noise4+noise5+noise6+noise7+noise8+noise9+noise10)/10
averaged_amplitude = averaged_noise + amplitude
plt.ylabel('Amplitude')
#let's try plotting what we have so far
plt.grid(True)
plt.axhline(y=0, color='red')
plt.plot(time,averaged_amplitude)
#ylim = (-1,1)
plt.show()
n = 5000
final_sig = 0
for i in range(n):
noise = np.random.normal(0,0.2,len(time))
noisy_sig = amplitude+noise
final_sig += noisy_sig
final_sig /= n
plt.plot(time,final_sig)
ylim = (-1,1)
import matplotlib.pyplot as plt
img1 = plt.imread("/work/sample_images/im0.png",)
plt.imshow(img1)
img2 = plt.imread("/work/sample_images/im6.png",)
plt.imshow(img2)
img3 = plt.imread("/work/sample_images/im12.png",)
plt.imshow(img3)
img4 = plt.imread("/work/sample_images/im18.png",)
plt.imshow(img4)
img5 = plt.imread("/work/sample_images/im24.png",)
plt.imshow(img5)
img6 = plt.imread("/work/sample_images/im30.png",)
plt.imshow(img6)
img7 = plt.imread("/work/sample_images/im36.png",)
plt.imshow(img7)
img8 = plt.imread("/work/sample_images/im42.png",)
plt.imshow(img8)
img13 = plt.imread("/work/sample_images/im72.png",)
plt.imshow(img13)
img12 = plt.imread("/work/sample_images/im66.png",)
plt.imshow(img12)
img11 = plt.imread("/work/sample_images/im60.png",)
plt.imshow(img11)
img10 = plt.imread("/work/sample_images/im54.png",)
plt.imshow(img10)
#plt.show()
img9 = plt.imread("/work/sample_images/im48.png",)
plt.imshow(img9)
#plt.show()
img_tot =(img1+img2+img3+img4+img5+img6+img7+img8+img9+img10+img11+img12+img13)/13
plt.imshow(img_tot)
plt.show()
c=abs(img_tot - img2)
plt.imshow(c)
plt.show()
#!apt update && apt install ffmpeg libsm6 libxext6 -y up
img9 = plt.imread("/work/sample_images/im0.png",)
im = img9.astype(float)
im/=255
im=im.mean(axis=2)
plt.imshow(im,cmap="gray")
plt.show()
import glob
import matplotlib.pyplot as plt
from matplotlib.image import imread
filepath = "/work/sample_images/*.png"
image=0
fin_image=0
counter = 0
for i in glob.iglob(filepath):
image = imread(i)
img = image.astype(float)
img/=255
img=img.mean(axis=2)
fin_image+=img
counter+=1
fin_image/=counter
b=plt.imshow(fin_image,cmap = "gray")
plt.show()
plt.imshow(img,cmap="gray")
plt.show()
import matplotlib.pyplot as plt
## subtracting a random image from the averaged image.
plt.imshow(abs(fin_image - img)>0.0005, cmap='gray')
plt.show()