这个小工具把原帖和临写分解成多列对照的形式。
输入原帖图片,
和输入临写图片,
生成对照图片。
运行compare.py文件,输入参数为:原帖图片文件名,临写图片文件名,列数。
python3 compare.py
好吧,严格点,应该说核心代码就第13行到23行十来行代码。
from skimage import io
from skimage import transform
from skimage.color import rgb2gray
import numpy as np
import matplotlib.pyplot as plt
import sys
import os.path
def main(modelname, copiedname, colnum):
copied = io.imread(copiedname)
copied = rgb2gray(copied) * 255
model = io.imread(modelname)
model = rgb2gray(model)
model = transform.resize(model, copied.shape) * 255
r = np.zeros((copied.shape[0], copied.shape[1]*2), np.uint8)
width = copied.shape[1] // colnum
for i in range(colnum):
r[:, 2*i*width:(2*i+1)*width] = model[:, i*width:(i+1)*width]
r[:, (2*i+1)*width:(2*i+2)*width] = copied[:, i*width:(i+1)*width]
name, ext = os.path.splitext(copiedname)
name += "_cmp.jpg"
io.imsave(name, r)
#name = os.path.join(os.path.dirname(copiedname), "comparison.jpg")
plt.figure()
plt.imshow(r, cmap=plt.cm.gray)
plt.show()
if __name__ == "__main__":
if len(sys.argv) == 4:
modelname = sys.argv[1]
copiedname = sys.argv[2]
colnum = int(sys.argv[3])
else:
print("usage: python3 compare.py ")
sys.exit()
main(modelname, copiedname, colnum)
页面更新:2024-04-15
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号