新闻  |   论坛  |   博客  |   在线研讨会
Python 读取照片(灰度)并将像素写入txt
tanry111 | 2018-07-12 13:51:27    阅读:2939   发布文章

import cv2

import numpy as np

import os

img_file_name="Video_File_1.bmp"

img = cv2.imread(img_file_name,0)

width,height=img.shape

txt_file_name="77.txt"

try:

    os.remove(txt_file_name)

except Exception,e:

    print e

txt=open(txt_file_name,"w")

for i in range(height):

    for j in range(width):

        txt.write(str(img[j,i]))

        txt.write("\r")

txt.close()


*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客