dongzhidian3538 2019-06-12 01:08
浏览 771
已采纳

在gocv中是否有类似python中的np.where()的类似功能?

Is there any similar function in Gocv like np.where() in Python? I want to specify some specific pixel values to 0, and others to 255. As follows, in Python I can do:

        img = cv2.imread("test.png", cv2.IMREAD_GRAYSCALE)
        img_ = np.where(img == 144 , img*0, np.where(img == 170 , img*0, np.where(img == 178 , img*0, np.where(img == 187 , img*0, 255))))

the pixel values which are 187, 178, 170, 144 will be set to 0, and others to 255. How can I do this job in Golang with Gocv?

  • 写回答

1条回答 默认 最新

  • dongziduo9762 2019-06-21 23:06
    关注

    I just found out that there is nothing like np.where() in gocv. All I have to do is: 1. get []byte using Mat.ToBytes() 2. writing a for loop to check each pixel in []byte and changing it if meet the condition. 3. get Mat from gocv.NewMatFromBytes()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部