我希望使用Python中的CV2获得IMG1和IMG2之间的区别,以此可以重新申请与IMG1的区别。
本质上:差异= img2 -img1
的格式,我以后可以声明:
img2 = img1 +差异
我很清楚CV2功能脓肿,减去和添加。但是,我尚未设法以允许以后添加的格式提取差异。
任何帮助都非常感谢。
PS如果有人想知道为什么?差异将通过插座发送,并重新应用于IMG1,该IMG1先前发送或构造。
I am looking to get the difference between img1 and img2 using cv2 in python, in a way that I can reapply the difference to img1.
Essentially: Difference = img2 - img1
In a format where I can later declare:
img2 = img1 + difference
I am well aware of the cv2 functions absdiff, subtract and add. However I have not managed to extract the diff in a format that would allow addition later on.
Any help is much appreciated.
P.S. In case anybody is wondering why? The difference would be sent over socket and reapplied to img1 which was sent or constructed prior.
发布评论
评论(1)
原始图像使用dtype
uint8
带有值0..255
,但是当您提取时,您可以获得value-255..255..255..255
(( 0-255)..(255-0)
,并且需要转换为int16
back
给出正确的图像,但diff
给出灰色图像(因为它具有值-255 ... 255,它在显示时将其转换为0..255
),因此显示它是没有用的。但是,现在您必须使用
int16
发送数组diff
,因此它可能需要发送更多字节然后使用原始图像,并且发送原始图像可能会更快。图像 lenna 来自wikipedia
lenna.png
https://i.sstatic.net/hwdhx.png
” href =“ https://i.sstatic.net/wnuwg.png” rel =“ nofollow noreferrer”>
Original image uses dtype
uint8
with values0..255
but when you substract then you can get values-255..255
(0-255)..(255-0)
and it needs to convert toint16
back
gives correct image butdiff
gives gray image (because it has values -255...255 which it converts to0..255
when it displays) so it is useless to display it.But now you have to send array
diff
withint16
so it may need to send more bytes then using original image and maybe it would be faster to send original image.Image Lenna from Wikipedia
lenna.png
lenna_flip.png