bitwise_and()를 사용하여 두 이미지 간의 비트 연결을 계산할 수 있습니다. org.opencv.core.Core 메소드 수업.
이 방법은 세 개의 매트 원본, 대상 및 결과 행렬을 나타내는 개체는 원본 행렬의 각 요소에 대한 비트 연결을 계산하고 결과를 대상 행렬에 저장합니다.
예시
다음 Java 예제에서는 이미지를 이진 및 회색조로 변환하고 결과의 비트 결합을 계산합니다.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class BitwiseAndExample {
public static void main(String args[]) throws Exception {
//Loading the OpenCV core library
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
//Reading the Image
String file ="D://images//elephant.jpg";
Mat src = Imgcodecs.imread(file, Imgcodecs.IMREAD_GRAYSCALE );
HighGui.imshow("Grayscale Image", src);
//Creating an empty matrix to store the results
Mat dst = new Mat(src.rows(), src.cols(), src.type());
Mat threshold = new Mat(src.rows(), src.cols(), src.type());
Mat gray = new Mat(src.rows(), src.cols(), src.type());
//Converting the gray scale image to binary image
Imgproc.threshold(src, threshold, 100, 255, Imgproc.THRESH_BINARY_INV);
HighGui.imshow("Binary Image", threshold);
//Applying bitwise and operation
Core.bitwise_and(src, threshold, dst);
HighGui.imshow("Bitwise And operation", dst);
HighGui.waitKey();
}
} 입력 이미지

출력
실행 시 위의 프로그램은 다음과 같은 창을 생성합니다. -
회색조 이미지 -

이진 이미지 -

비트 및 -
