Multichannel separation
API
public static void split(Mat m, List<Mat> mv)
Copy the code
- Parameter 1: m, multi-channel image to be separated
- Parameter 2: MV, single channel image after separation
operation
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]
}
Copy the code
Channel merging
API
public static void merge(List<Mat> mv, Mat dst)
Copy the code
- 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 image output after merging has the same size and data type as MV [0], and the number of channels is equal to the sum of the number of channels of all input images
operation
private fun showBGZero(a) {
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(a) {
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(a) {
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(a) {
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()
}
Copy the code
The results of
The source code
Github.com/onlyloveyd/…
This article is formatted using MDNICE