Re: kleine Mathe-Spielereien
Verfasst: Freitag 8. Dezember 2023, 10:29
8.12.2023
Ich habe erkannt, dass ich in Python nicht viel weiter
kommen werde, wenn ich mich nicht endlich
v i e l intensiver mit NUMPY beschäftigen werde.
Ich glaube, es lohnt sich.
Hier gleich ein schönes Beispiel.
Gute Zeit OSWALD
Ich habe erkannt, dass ich in Python nicht viel weiter
kommen werde, wenn ich mich nicht endlich
v i e l intensiver mit NUMPY beschäftigen werde.
Ich glaube, es lohnt sich.
Hier gleich ein schönes Beispiel.
Gute Zeit OSWALD
Code: Alles auswählen
mport numpy as np
import matplotlib.pyplot as plt
# let img1 be an image with no features
bild1 = np.array([np.array([400, 200]), np.array([255, 145])])
bild2 = np.array([np.array([400, 255]), np.array([400,255])])
bild3 = np.array([np.array([7, 3]), np.array([8, 9])])
kernel_horizontal = np.array([np.array([0, 3]), np.array([-3, 4])])
print(kernel_horizontal, 'is a kernel for detecting horizontal edges')
kernel_vertical = np.array([np.array([0,-1]), np.array([7, -1])])
print(kernel_vertical, 'is a kernel for detecting vertical edges')
# We will apply the kernels on the images by
def apply_kernel(bild1, kernel):
return np.sum(np.multiply(bild1, kernel))
# bild1 plotten
plt.imshow(bild1)
plt.axis('off')
plt.title('bild1- Leiste erlaubt Veränderung der Daten ')
plt.show()
print('Horizontales Kanten-Konfidenzintervall:', apply_kernel(bild1,
kernel_horizontal))
print('Vertikales Kanten-Kconfidenzintervall:', apply_kernel(bild1,
kernel_vertical))
# bild2 plotten
plt.imshow(bild2)
plt.axis('off')
plt.title('bild2')
plt.show()
print('Horizontales Kanten-Konfidenzintervall :', apply_kernel(bild2,
kernel_horizontal))
print('Vertikales Kanten-Konfidenzintervall:', apply_kernel(bild2,
kernel_vertical))
# bild3 plotten
plt.imshow(bild3)
plt.axis('off')
plt.title('bild3')
plt.show()
print('Horizontales Kanten-Kconfidenzintervall:', apply_kernel(bild3,
kernel_horizontal))
print('Vertical edge confidence score:', apply_kernel(bild3,
kernel_vertical))