我已经计算出单应性,取出了透视变换.我能够在一个窗口中显示两个图像,但无法合并它们.这是我的示例图像 - >


我正在使用此代码的代码 - >
cv::warpPerspective(image2,warpresult2,homography,cv::Size(2*image2.cols,image2.rows));
Mat imgResult(image1.rows,2*image1.cols,image1.type());
Mat roiImgResult_Left = imgResult(Rect(0,0,image1.cols,image1.rows));
Mat roiImgResult_Right = imgResult(Rect(image1.cols,0,image2.cols,image2.rows));
Mat roiImg1 = image1(Rect(0,0,image1.cols,image1.rows));
Mat roiImg2 = warpresult2(Rect(0,0,image2.cols,image2.rows));
roiImg1.copyTo(roiImgResult_Left); //Img1 will be on the left of imgResult
roiImg2.copyTo(roiImgResult_Right); //Img2 will be on the right of imgResult
imshow("Finalimg",imgResult);
imwrite("C:\\OpenCv_Projects\\outputimage.jpg",imgResult);
cvWaitKey(0);
Run Code Online (Sandbox Code Playgroud)
我认为问题出在我给予roiImgResult_right的坐标中.
输出图像是 - >
如你所见,图像没有正确合并,右侧有黑色区域.如何删除它?
opencv image-processing computer-vision visual-c++ image-stitching
我有一个图像和圆形区域。我需要模糊所有,除了圆形区域。另外我需要使圆的边界平滑。
输入:

输出(在带有掩码的图像编辑器中制作,但我认为 opencv 仅使用位图掩码):

现在我在 python 中有代码,它不会模糊圆圈的边界。
def blur_image(cv_image, radius, center, gaussian_core, sigma_x):
blurred = cv.GaussianBlur(cv_image, gaussian_core, sigma_x)
h, w, d = cv_image.shape
# masks
circle_mask = np.ones((h, w), cv_image.dtype)
cv.circle(circle_mask, center, radius, (0, 0, 0), -1)
circle_not_mask = np.zeros((h, w), cv_image.dtype)
cv.circle(circle_not_mask, center, radius, (2, 2, 2), -1)
# Computing
blur_around = cv.bitwise_and(blurred, blurred, mask=circle_mask)
image_in_circle = cv.bitwise_and(cv_image, cv_image, mask=circle_not_mask)
res = cv.bitwise_or(blur_around, image_in_circle)
return res
Run Code Online (Sandbox Code Playgroud)
当前版本:
如何模糊圆圈的边界?在输出示例中,我在程序中使用了渐变掩码。opencv 中有类似的东西吗?
更新 04.03
所以,我已经尝试过这个回答主题的公式以及我所拥有的:

代码:
def blend_with_mask_matrix(src1, src2, …Run Code Online (Sandbox Code Playgroud)