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()

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

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式