李宏毅机器学习-作业/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")

  李宏毅机器学习-作业/HW0_第1张图片李宏毅机器学习-作业/HW0_第2张图片

  

转载于:https://www.cnblogs.com/tangjiansheng/p/11219368.html

你可能感兴趣的:(人工智能,python)