我编写了一段代码来旋转图像并保存它们。所以我使用OpenCv来保存旋转图像。保存旋转后的图像后,图像上会变成蓝色。
操作系统:Ubuntu 16.04
这是代码:
from scipy.ndimage import rotate
from scipy.misc import imread, imshow
import cv2
count = 0
while True:
if count<230:
filename = 'frame'+str(count)+'.jpg'
print(filename)
img = imread(filename)
rotate_img = rotate(img, 90)
cv2.imwrite(filename,rotate_img)
count = count + 1
continue
else :
break
为什么颜色会这样变化?我需要做什么?
任何帮助,将不胜感激!谢谢您的高级!
图片(保存前):
图片(保存后):
我可以解决这个问题。我必须将图像的颜色转换为 RGB 颜色。
cv2.cvtColor(rotate_img, cv2.COLOR_BGR2RGB)
这是代码:
from scipy.ndimage import rotate
from scipy.misc import imread, imshow
import cv2
count = 0
while True:
if count<230:
filename = 'frame'+str(count)+'.jpg'
print(filename)
img = imread(filename)
rotate_img = rotate(img, 90)
#convert color of image before saving
rgbImg = cv2.cvtColor(rotate_img, cv2.COLOR_BGR2RGB)
cv2.imwrite(filename,rgbImg)
count = count + 1
continue
else :
break
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)