My goal is to make aliasing in python but actually i have problem ValueError: assignment destination is read-only. This because of this line
numpy_new[:lines * k][:][:] = numpy_last
And I don't know how solve this.
import warnings
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.animation import ArtistAnimation, FuncAnimation
from PIL import Image
warnings.filterwarnings("ignore", category=DeprecationWarning)
N = 3
M = 64
PI = np.pi
x = np.linspace(1, 10, 1000)
y_ = np.sin((N * x + (1 * PI) / 10))
subplot_kw = {'projection': 'polar'}
fig, ax = plt.subplots()
lines = 16
sensor_img = []
for i in range(M):
k = i
if i == 0:
image = Image.open(f'proppler/myplot{i}.png')
sensor_img.append(image)
image.save(fr'Sensor/sensor{i}.png')
continue
last = sensor_img[k - 1]
numpy_last = np.asarray(last)[:lines * k][:][:]
new_image = Image.open(fr'proppler/myplot{i}.png')
numpy_new = np.asarray(new_image)
numpy_new[:lines * k][:][:] = numpy_last
result = Image.fromarray(numpy_new)
result.save(fr'Sensor/sensor{i}.png')
if k == 16:
k = 0
sensor_img.append(result)
ims = []
for i in range(M):
im_file = plt.imread(f'Sensor/sensor{i}.png')
im = ax.imshow(im_file)
ims.append([im])
if i == 64:
break
plt.grid(False)
plt.axis('off')
ani = ArtistAnimation(fig, ims, interval=100, blit=True, repeat_delay=0)
plt.show()
Thank you everyone for help.