“ matplotlib.image”加载的图像与使用“ fl_image”从视频提取的图像之间的差异

时间:2019-06-05 15:53:03

标签: python computer-vision

我正在使用Python cv2包处理视频帧(mp4)。对于图像处理,我使用的是moviepy.editor.VideoFileClip的方法fl_image。但是,当我将提取的帧保存为jpg格式,然后使用matplotlib.image重新打开时,在加载的图像中会出现小的差异。可以通过在两种方法中简单地取所加载图像的均值来看出。

我想知道为什么两个加载的图像略有不同。这在逐帧处理视频剪辑时引起了一些问题。

sampleImage = mpimg.imread("sample-01.jpg")
print("sampleImage", np.mean(sampleImage))

# sampleImage is extracted from the video, say the last frame of the subClip1, and already saved using method imsave

# result
# sampleImage 115.64719075520833

# using the other method 

def processFrameImage(image):
    print("sampleImage", np.mean(image))

    result = extractFeatures(image)

    return result 

clip1 = VideoFileClip("sample-video.mp4")
subClip1 = clip1.subclip(t_start=0.0, t_end=0.1)
whiteClip = subClip1.fl_image(processFrameImage)

# result 
# sampleImage 115.64437065972223

请注意如上所述的打印结果之间的差异

0 个答案:

没有答案