李宏毅机器学习-作业/HW0
import numpy as np matrixA = [] for i in open("D:\\matrixA.txt"): row = [int(x) for x in i.split(",")] matrixA.append(row) matrixB = [] for j in open("D:\\matrixB.txt"): row = [int(x) for x in j.split(",")] matrixB.append(row) matrixA = np.array(matrixA) matrixB = np.array(matrixB) ans = matrixA.dot(matrixB) ans.sort(axis=1) np.savetxt("D:\\Q1_ans.txt", ans, fmt="%d", delimiter="\r\n")
from PIL import Image lena = Image.open("D:\\lena.png") lena_modified = Image.open("D:\\lena_modified.png") w, h = lena.size for j in range(h): for i in range(w): if lena.getpixel((i, j)) == lena_modified.getpixel((i, j)): lena_modified.putpixel((i, j), 255) lena_modified.show() lena_modified.save("D:\\ans_two.png")