首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利用java和opencv对灰度图像进行图像融合得到了奇怪的结果。

利用java和opencv对灰度图像进行图像融合得到了奇怪的结果。
EN

Stack Overflow用户
提问于 2018-03-27 09:43:48
回答 1查看 125关注 0票数 1

我目前正在尝试使用java和OpenCV包装融合放射性灰度图像。我编写了一些代码,以便在数据库中找到相似的图像并将它们融合。融合部分是我所在的地方,struggling.This是我正在努力解决的方法:

代码语言:javascript
复制
public BufferedImage registerImages(BufferedImage source, BufferedImage target) 
throws RegistrationException{

    LinkedList<DMatch> goodMatches = getGoodMatches(source, target);
    if(goodMatches.size() >= 7){
         List<KeyPoint> sourceKeypoints = sourceKeyPointsMat.toList();
        List<KeyPoint> targetKeypoints = targetKeyPointsMat.toList();

        LinkedList<Point> sourcePoints = new LinkedList<>();
        LinkedList<Point> targetPoints = new LinkedList<>();

        for(int i = 0; i < goodMatches.size(); i++) {
            sourcePoints.addLast(sourceKeypoints.get(goodMatches.get(i).queryIdx).pt);
            targetPoints.addLast(targetKeypoints.get(goodMatches.get(i).trainIdx).pt);
        }

        MatOfPoint2f sourceMatOfPoint2f = new MatOfPoint2f();
        sourceMatOfPoint2f.fromList(sourcePoints);
        MatOfPoint2f targetMatOfPoint2f = new MatOfPoint2f();
        targetMatOfPoint2f.fromList(targetPoints);

        Mat homography = Calib3d.findHomography(sourceMatOfPoint2f, targetMatOfPoint2f);            
        Mat transformationResult = new Mat(sourceImageMat.rows(), sourceImageMat.cols(), sourceImageMat.type());                
        Imgproc.warpPerspective(sourceImageMat, transformationResult, homography, transformationResult.size());

        Mat resultImage = new Mat();
        Core.add(transformationResult, targetImageMat, resultImage);

        return mat2BufferedImage(resultImage);
    }
    else{
        throw new RegistrationException();
    }
}

mat2BufferedImage()getGoodMatches()都经过了测试,似乎都是有效的。findHomography()warpPerspective()似乎有问题,因为这是当我查看转换(而不是融合)图像时的结果:https://i.imgur.com/8JRQwtG.png

有人知道出了什么问题吗?提前谢谢你!

编辑:因此在深入研究之后,发现转换矩阵具有极强的透视图转换(值从400-700)。由于图像非常相同/差别很小,我不明白为什么这是findHomography()的结果。这种方法有替代办法吗?

EN

回答 1

Stack Overflow用户

发布于 2018-03-28 05:14:31

我会使用drawMatches()来验证goodMatches中没有异常值。离群点会完全破坏计算机的同调。如果得到异常值,则需要使用findHomography()的健壮变体。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49509502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档