Android基于opencv实现多通道分离与合并

Android基于opencv实现多通道分离与合并

目录

          多通道分离

          API

          public static void split(Mat m, List<Mat> mv)

          操作

          override fun onCreate(savedInstanceState: Bundle?) {
              super.onCreate(savedInstanceState)
              mBinding = DataBindingUtil.setContentView(this, R.layout.activity_channel_split_merge)
              mBgr = Utils.loadResource(this, R.drawable.test)
              val imgList = mutableListOf<Mat>()
              Core.split(mBgr, imgList)
              mChannelB = imgList[0]
              mChannelG = imgList[1]
              mChannelR = imgList[2]
          }

          通道合并

          API

          public static void merge(List<Mat> mv, Mat dst)

          操作

          private fun showBGZero() {
              val zero = Mat.zeros(mBgr.rows(), mBgr.cols(), CvType.CV_8UC1)
              val list = mutableListOf<Mat>()
              list.add(zero)
              list.add(zero)
              list.add(mChannelR)
              val result = Mat()
              Core.merge(list, result)
              showMat(result)
              result.release()
          }
          
          private fun showBRZero() {
              val zero = Mat.zeros(mBgr.rows(), mBgr.cols(), CvType.CV_8UC1)
              val list = mutableListOf<Mat>()
              list.add(zero)
              list.add(mChannelG)
              list.add(zero)
              val result = Mat()
              Core.merge(list, result)
              showMat(result)
              result.release()
          }
          
          private fun showGRZero() {
              val zero = Mat.zeros(mBgr.rows(), mBgr.cols(), CvType.CV_8UC1)
              val list = mutableListOf<Mat>()
              list.add(mChannelB)
              list.add(zero)
              list.add(zero)
              val result = Mat()
              Core.merge(list, result)
              showMat(result)
              result.release()
          }
          
          private fun showSwitchBR() {
              val zero = Mat.zeros(mBgr.rows(), mBgr.cols(), CvType.CV_8UC1)
              val list = mutableListOf<Mat>()
              list.add(mChannelR)
              list.add(mChannelG)
              list.add(mChannelB)
              val result = Mat()
              Core.merge(list, result)
              showMat(result)
              result.release()
          }

          结果

          源码

          github.com/onlyloveyd/…

          以上就是Android基于opencv实现多通道分离与合并的详细内容,更多关于Android opencv实现多通道分离与合并的资料请关注趣讯吧其它相关文章!

          发布于 2021-06-19 06:11:40
          收藏
          分享
          海报
          0 条评论
          173
          上一篇:教你如何使用Python实现二叉树结构及三种遍历 下一篇:Android开发实现简单计算器功能
          目录

            推荐阅读

            0 条评论

            本站已关闭游客评论,请登录或者注册后再评论吧~

            忘记密码?

            图形验证码