您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – skimage调整大小给出奇怪的输出

5b51 2022/1/14 8:22:06 python 字数 3054 阅读 536 来源 www.jb51.cc/python

我正在使用skimage.transform.resize调整图像大小,但我得到了一个非常奇怪的输出,我无法弄清楚为什么.有人可以帮忙吗?这是我的代码:import matplotlib.pyplot as plt import skimage.transform plt.imshow(y) h,w,c = y.shape x = skimage.trans

概述

我正在使用skimage.transform.resize调整图像大小,但我得到了一个非常奇怪的输出,我无法弄清楚为什么.有人可以帮忙吗?

这是我的代码

import matplotlib.pyplot as plt
import skimage.transform
plt.imshow(y)
h,w,c = y.shape
x = skimage.transform.resize(y,(256,(w*256)/h),preserve_range=True)
plt.imshow(x)

这是我的输入图像y(240,320,3):

enter image description here

这是我的输出图像x(256,341,3):

enter image description here

编辑:
好吧,如果我改变preserve_range = False似乎工作正常.但为什么它不允许我保持目前的范围?

编辑:
我正在使用OpenCV从视频中随机抽样帧.这是从我传递给它的视频路径返回帧的函数.

def read_random_frames(vid_file):

   vid = cv2.VideoCapture(vid_file)
   # get the number of frames    
   num_frames = vid.get(cv2.CAP_PROP_FRAME_COUNT)
   # randomly select frame
   p_frame = random.randint(0,(num_frames-1))
   # get frame
   vid.set(cv2.CAP_PROP_POS_FRAMES,p_frame)
   ret,frame = vid.read()
   # convert from BGR to RGB
   frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)

   return frame

我有一个视频路径列表,我使用map函数检索帧然后我将输出列表转换为numpy数组:

 batch_frames = map(lambda vid: read_random_frames(vid),train_vids_batch)
 frame_tensor = np.asarray(batch_frames)
 y = frame_tensor[0]

总结

以上是编程之家为你收集整理的python – skimage调整大小给出奇怪的输出全部内容,希望文章能够帮你解决python – skimage调整大小给出奇怪的输出所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶