导入cv2
import numpy as np
导入操作系统
img_file_name='IMG_2271.jpg '
img=cv2.imread(img_file_name )。
width,height,dep=img.shape
k=浮动(宽度/浮动(高度) ) ) )。
img=cv2.resize(img,(400,int ) k*400 )、interpolation=cv2.INTER_CUBIC ) )。
width,height,dep=img.shape
txt_file_name='77.txt '
try:
操作系统. remove (txt _ file _ name ) )。
except Exception,e:
打印e
txt=open(txt_file_name,' w ' ) )。
txt.write(str ) width ) ' ' str (height ) )
txt.write () (r ) )。
foriinrange (高) :
forjinrange(width ) :
TXT.write(str(img[j,I,0] ) ' str (img [ j,I,1] ) ' str (j,I,2] ) )
txt.write () (r ) )。
txt.close (
博客内容是网友的个人帖子,只表达了博客的个人见解。 有侵害的情况请联系工作人员删除。