Extract common part of images with Opencv

前端 未结 1 1074
醉话见心
醉话见心 2021-01-22 15:40

I\'m writing a program that find differences between images. For now, I\'m finding features with AKAZE, so I\'ve the common point of the 2 images. The problem is that these 2 im

相关标签:
1条回答
  • 2021-01-22 16:23

    You should warp the first image onto the second. You can use findHomography and perspectiveTransform functions given by the correspondence of your keypoints. You can find most of the code you need here.

    Update


    Incidentally, I had to do basically the same stuff today. It's tested on gray images (Mat1b), but should require only minor changes to apply to rgb images (Mat3b). Here the relevant parts of the code:

    Mat1b A = imread("...");
    Mat1b B = imread("...");
    
    vector<Point2f> ptsA; 
    vector<Point2f> ptsB;
    
    // Fill ptsA, ptsB with the points given by the match of your descriptors.
    
    Mat H = findHomography(ptsA, ptsB, CV_RANSAC); // With ransac is more robust to outliers
    
    Mat1b warpedA;
    warpPerspective(A, warpedA, H, B.size());
    
    // Now compute diff
    Mat1b res;
    absdiff(warpedA, B, res);
    
    // res is what you are looking for!
    
    0 讨论(0)
提交回复
热议问题