I have a problem with a matrix logical operation. I want to use bitwise_andwith image A and image B to get the result of image C.
bitwise_and
The image data type is everything Mat, image A was processed after some functions, and it was a binary image with three channels. Image B was also a binary image after some processing, but with only 1 channel.
Mat
Since the channel numbers are different, I get an error when bitwise_and.
How can I do to combine a channel or any other methods to solve this problem?
Here is a picture of A, B, C:
A B , . cvtColor 3 1 . , C:
A
B
cvtColor
C
Mat A; // CV_8UC3 Mat B; // CV_8UC1
, C 3 :
cvtColor(B, B, COLOR_GRAY2BGR); Mat C; bitwise_and(A,B,C); // C will be 3 channel, CV_8UC3
else, , C 1 :
cvtColor(A, A, COLOR_BGR2GRAY); Mat C; bitwise_and(A,B,C); // C will be 1 channel, CV_8UC1
, , :
Mat C = A & B;
Java.
1. webcam_image 3.
OPENCV 3.0
// convert 3 channel Imgproc.cvtColor(thresholded, thresholded, Imgproc.COLOR_GRAY2BGR); Core.bitwise_and(thresholded, webcam_image, webcam_image);
, .
" " :
vector<Mat> channels(3); // split img: split(imageA, channels); bitwise_and(channels[0], imageB, channels[0]); bitwise_and(channels[1], imageB, channels[1]); bitwise_and(channels[2], imageB, channels[2]);
, 3- Mat:
merge(channels, imageC);
Source: https://habr.com/ru/post/1613020/More articles:плагин phonegap onload = false не влияет - cordovaSpring Social with Simple OpenID - springAdd space as line break using Java 8 (lambdas) thread - javaShow webView in Cordoba before loading API - androidWhat is the difference in expanding and adding to Hybris - hybrishttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1613021/spring-data-jpa-custom-sort-in-jparepository&usg=ALkJrhgW1uKI5SJLCVIqpODa3ovQsY15HQC ++: why does the regex pattern "[+ - / *]" match the string "."? - c ++Failed to create parent directory for itmtransporter - iosAsync N1QL couchbase query using Twisted API for Python SDK - pythonPolymorphic instruction in Free Monad in Purescript - free-monadAll Articles