Source code for wolfhece.image.image2mnt

from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from math import sqrt

[docs] def main(): logo = Image.open('Logo HECE grand.png') logo_np = np.array(logo)/255. mnt = np.zeros((logo_np.shape[0], logo_np.shape[1])) mnt[:,:] = logo_np[:,:,0] + logo_np[:,:,1]*2. + logo_np[:,:,2]*3. mnt[mnt>5.8] = 6. cx,cy = mnt.shape[0]//2, mnt.shape[1]//2 xy = np.where(mnt==mnt.max()) for x,y in zip(xy[0],xy[1]): mnt[x,y] += sqrt((x-cx)**2+(y-cy)**2)/sqrt(cx**2+cy**2)*2. mnt-=mnt.min() mnt/=mnt.max() mnt = np.array(mnt, dtype=np.float32) np.save('logo.npy', mnt) plt.imshow(mnt, cmap='gray') plt.show() print()
if __name__ == '__main__': main()