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

前言

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

论文链接http://file///C:/Users/86137/Documents/temp/Gehrig_Video_to_Events_Recycling_Video_Datasets_for_Event_Cameras_CVPR_2020_paper.pdf        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 GehrigMathias GehrigJavier 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}
}

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

代码Code:

演示:

转化前: 

转换后: 


代码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)

演示:

转化前: 

转换后: 

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

完毕!

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

  • 7
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大气层煮月亮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值