dongzhidian3538 2019-06-12 09:08
浏览 769
已采纳

在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-22 07: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()

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

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决