How to convert a targeting code in python to kotlin?

前端 未结 2 855
北恋
北恋 2021-01-16 10:45

I am developing an image segmentation application that will use watersheds. For that, I found a code that I will need to use in python. However, I\'m having a hard time conv

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-16 11:18

    numpy.zeros_like basically creates an array the same shape as the input with all zeros in it.

    https://numpy.org/doc/stable/reference/generated/numpy.zeros_like.html

    In this case, you have a simple 2d array so you could roll your own just by indexing through the whole array (all dimensions) and setting everything to zero.

    var marker = Array(srcOriginal.rows()) {Array(srcOriginal.cols()) {0} }
    

提交回复
热议问题