[python]image(reshape,overlay)
来源:互联网 发布:涂子沛 数据之巅 编辑:程序博客网 时间:2024/05/17 23:09
import sysimport numpy as np#import scipy.miscfrom scipy import ndimage, miscfrom PIL import Imageimgpath="demo_img1.jpg"#1.generate Attention Map#files=["word.txt","phrase.txt","question.txt"]files=["question.txt"]for filename in files: print filename f=open(filename,'r') nums=f.read() f.close() atten=np.zeros(196) img=np.ones((448,448)) for i in range(0,196): atten[i]=nums.split(' ')[i] atten=(atten-min(atten))/(max(atten)-min(atten)) atten=np.floor(atten*255) #atten=atten.reshape(14,14) #print max(atten),min(atten) for i in range(0,14): r=i*32 for j in range(0,14): c=j*32 mul=atten[i*14+j] for ri in range(r,r+31): for cj in range(c,c+31): img[ri][cj]=img[ri][cj]*mul misc.toimage(img, cmin=0.0, cmax=255.0).save(filename+'.jpg') #sys.exit()#2.reshape the original image img = Image.open(imgpath) # image extension *.png,*.jpg new_width = 448 new_height = 448 img = img.resize((new_width, new_height), Image.ANTIALIAS) img.save('test448.jpg')#3.overlay two images background = Image.open("test448.jpg") overlay = Image.open(filename+".jpg") background = background.convert("RGBA") overlay = overlay.convert("RGBA") new_img = Image.blend(background, overlay, 0.5) new_img.save("new.png","PNG")
0 0
- [python]image(reshape,overlay)
- python reshape用法
- python reshape -1
- MATLAB 与python reshape 比较
- Python numpy函数:reshape()
- python--leetcode566. Reshape the Matrix
- python中的reshape()和matlab中的reshape()区别
- reshape
- reshape
- reshape
- Overlay
- .overlay
- overlay
- overlay
- OVERLAY
- Overlay
- Overlay
- Overlay
- qrencode-3.4.4.tar.gz在arm上的移植
- Android中更新UI的几种方式
- VTK“静态编译”与“动态编译”的区别:
- HDU ACM 11 2031 进制转换
- sql select * ,select 1, select count(*) ,select count(1)的区别
- [python]image(reshape,overlay)
- 网站建设流程_网站建设流程介绍
- Picasso粗糙分析
- CSDN-markdown编辑器 使用方法
- [leetcode]Implement strStr()
- 工厂方法模式
- Android Service浅析(下)
- DeepID人脸识别算法之三代
- Joysticks