Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use opencv of Android to realize multi-channel separation and merge

Shulou Source: shulou.com Published: 2022-05-31 21:44:55 10月02日 Update

In this article Xiaobian for you to introduce in detail "how to use Android's opencv to achieve multi-channel separation and merge", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to use Android's opencv to achieve multi-channel separation and merger" can help you solve your doubts.

Multichannel separation

APIpublic static void split (Mat m, List mv)

Parameter one: M, the multi-channel image to be separated

Parameter 2: mv, the separated single-channel image

Operate 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 () Core.split (mBgr, imgList) mChannelB = imgList [0] mChannelG = imgList [1] mChannelR = imgList [2]} Channel merge

APIpublic static void merge (List mv, Mat dst)

Parameter 1: mv, an array of images to be merged, where each image must have the same size and data type

Parameter 2: dst, the merged output image has the same size and data type as mv [0], and the number of channels is equal to the sum of the channels of all input images.

Operation private fun showBGZero () {val zero = Mat.zeros (mBgr.rows (), mBgr.cols (), CvType.CV_8UC1) val list = mutableListOf () 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 () 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 () 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 () list.add (mChannelR) list.add (mChannelG) list.add (mChannelB) val result = Mat () Core.merge (list, result) showMat (result) result.release ()} result

Read here, this "how to use Android opencv to achieve multi-channel separation and merger" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow the industry information channel.

Tags: Channels images parameters articles same content dimensions data types appropriateness ideas summation arrays new knowledge more steps knowledge knowledge points articles details Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno Docker NVidia MariaDB