【事件图像】RGB Image conversion to event Image

简介: 【事件图像】RGB Image conversion to event Image

前言


       有些时候我们需要使用事件图像来做实验,但是事件图像数据实在是太少了,冲浪几乎得不到想要的数据,我们不得不使用正常的图像转换为事件图像来保证数据来源。

image.png

 This repository contains code that implements video to events conversion as described in Gehrig et al. CVPR'20 and the used dataset. The paper can be found here


If you use this code in an academic context, please cite the following work:


Daniel Gehrig, Mathias Gehrig, Javier Hidalgo-Carrió, Davide Scaramuzza, "Video to Events: Recycling Video Datasets for Event Cameras", The Conference on Computer Vision and Pattern Recognition (CVPR), 2020


@InProceedings{Gehrig_2020_CVPR,
  author = {Daniel Gehrig and Mathias Gehrig and Javier Hidalgo-Carri\'o and Davide Scaramuzza},
  title = {Video to Events: Recycling Video Datasets for Event Cameras},
  booktitle = {{IEEE} Conf. Comput. Vis. Pattern Recog. (CVPR)},
  month = {June},
  year = {2020}


代码Code:


def RGB_to_EventImg(im):
    gray_img=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
    # 偏移方向 建议设置区间[-5,5]
    xshift = 3
    yshift = -3
    xlong = gray_img.shape[1]-2*abs(xshift)
    ylong = gray_img.shape[0]-2*abs(yshift)
    pic_shape = [ylong,xlong,3]
    img = np.full(pic_shape, 0, dtype=np.uint8)
    # 如果图像相素偏移量>10那么记录该像素点
    for i in range(abs(yshift),ylong):
        for j in range(abs(xshift),xlong):
            if int(gray_img[i+yshift][j+xshift])-int(gray_img[i][j])>10:
                img[i][j]=[0,255,0]
            if int(gray_img[i+yshift][j+xshift])-int(gray_img[i][j])<-10:
                img[i][j]=[0,0,255]
    return img
if __name__ == '__main__':
    img = cv2.imread('test.png')
    cv2.imshow('frame', RGB_toEventImg(img))
    cv2.waitKey(0)


演示:


转化前:


1dc618a0ed9580ce8bfa6facb208c08f.png


转换后:


       不得不说,居然还有点好看~


5d4c6812c8535adbb050f4ddf2e1bce8.png


完毕!


是不是超级简单呢?如果觉得有用的话欢迎点赞+关注哦!  


相关文章
|
4月前
|
Python
已解决:_tkinter.TcLError: couldn’t recognize data in image file “Image/nakamuraan.gif”
已解决:_tkinter.TcLError: couldn’t recognize data in image file “Image/nakamuraan.gif”
149 1
|
6月前
|
计算机视觉
halcon系列基础之Scale_image_range
halcon系列基础之Scale_image_range
306 0
|
11月前
|
JavaScript
image-conversion
image-conversion
211 0
|
人工智能 自然语言处理 BI
CLIP-Event: Connecting Text and Images with Event Structures 论文解读
视觉-语言(V+L)预训练模型通过理解图像和文本之间的对齐关系,在支持多媒体应用方面取得了巨大的成功。
128 0
|
计算机视觉
图像拼接遇到module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
图像拼接遇到module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘
131 0
|
缓存 前端开发 JavaScript
浅析data:image/png;base64的应用
浅析data:image/png;base64的应用
901 0
浅析data:image/png;base64的应用
错误及原因:Empty JPEG image (DNL not supported)
错误及原因:Empty JPEG image (DNL not supported)
150 0
|
机器学习/深度学习 编解码 机器人
Paper:《First Order Motion Model for Image Animation》翻译与解读
Paper:《First Order Motion Model for Image Animation》翻译与解读
Paper:《First Order Motion Model for Image Animation》翻译与解读
成功解决AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;CV_CAP_PROP_FPS&#39;和 &#39;CV_CAP_PROP_FRAME_WIDTH&#39;
成功解决AttributeError: module &#39;cv2.cv2&#39; has no attribute &#39;CV_CAP_PROP_FPS&#39;和 &#39;CV_CAP_PROP_FRAME_WIDTH&#39;
|
编解码 机器人 测试技术
Paper:《First Order Motion Model for Image Animation》翻译与解读(二)
Paper:《First Order Motion Model for Image Animation》翻译与解读