addWeighted() 를 사용하여 OpenCV에서 두 이미지를 혼합할 수 있습니다. 핵심 의 방법 수업.
이 메소드는 두 개의 Mat 객체(소스 및 대상 매트릭스를 나타냄)와 이미지 알파, 감마의 원하는 가중치를 나타내는 두 개의 이중 값을 허용하고 이들의 가중치 합을 계산합니다.
예시
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
public class AddingTwoImages {
public static void main( String[] args ) {
//Loading the OpenCV core library
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
//Reading the input images
Mat src1 = Imgcodecs.imread("D://images//a1.jpg");
Mat src2 = Imgcodecs.imread("D://images//a2.jpg");
//Creating an empty matrix to store the result
Mat dst = new Mat();
//Adding two images
Core.addWeighted(src1, 0.4, src2, 0.8, 0, dst);
HighGui.imshow("Adding two images", dst);
HighGui.waitKey(0);
}
} 이미지1 입력
<강한>
이미지 2 입력
출력