大佬教程收集整理的这篇文章主要介绍了OpenCV Python显示原始图像,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
OpenCV不支持.RAW文件,请参阅imread,@H_772_3@
但是该文件可以用Python打开并用Numpy解析@H_772_3@
import numpy as np
fd = open('flight0000.raw', 'rb')
rows = 480
cols = 640
f = np.fromfile(fd, dtype=np.uint8,count=rows*cols)
im = f.reshape((rows, cols)) #notice row, column format
fd.close()
这使得可以由OpenCV直接操纵的numpy数组@H_772_3@
import cv2
cv2.imshow('', im)
cv2.waitKey()
cv2.destroyAllwindows()
我不知道如何显示包含640x480像素信息(每个像素8位)的原始图像。(灰色图像)@H_772_3@
我需要从np数组转换为Mat格式才能显示图像。@H_772_3@
#!/usr/bin/python
import numpy as np
import cv2
import sys
# Load image as String from file/database
fd = open('flight0000.raw')
img_str = fd.read()
fd.close()
img_array = np.asarray(bytearray(img_str),dtype=np.uint8)
img = ... Conversion to Mat graycolor
cv2.imshow('rawgrayimage',img)
cv2.waitKey(0)
它与cv2令人困惑。我已经尝试了一段时间,但找不到解决方案。@H_772_3@
以上是大佬教程为你收集整理的OpenCV Python显示原始图像全部内容,希望文章能够帮你解决OpenCV Python显示原始图像所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。