栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

用于校正FishEye透镜的镜筒畸变校正算法-无法用Java实现

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用于校正FishEye透镜的镜筒畸变校正算法-无法用Java实现

您遇到的主要错误是该算法指定r_corr和r_src以min((xDim-1)/ 2,(yDim-1)/
2)为单位。需要执行此操作以标准化计算,以便参数值不依赖于源图像的大小。有了代码,您将需要为paramB使用更小的值,例如,对于paramB =0.00000002(对于尺寸为2272 x 1704的图像),它对我来说可以正常工作。

在计算与中心的差异时,还存在一个错误,该错误会导致生成的图像与源图像相比旋转180度。

修复这两个错误应会为您提供以下信息:

protected static int[] correction2(int[] pixels, int width, int height) {    int[] pixelsCopy = pixels.clone();    // parameters for correction    double paramA = -0.007715; // affects only the outermost pixels of the image    double paramB = 0.026731; // most cases only require b optimization    double paramC = 0.0; // most uniform correction    double paramD = 1.0 - paramA - paramB - paramC; // describes the linear scaling of the image    for (int x = 0; x < width; x++) {        for (int y = 0; y < height; y++) { int d = Math.min(width, height) / 2;    // radius of the circle // center of dst image double centerX = (width - 1) / 2.0; double centerY = (height - 1) / 2.0; // cartesian coordinates of the destination point (relative to the centre of the image) double deltaX = (x - centerX) / d; double deltaY = (y - centerY) / d; // distance or radius of dst image double dstR = Math.sqrt(deltaX * deltaX + deltaY * deltaY); // distance or radius of src image (with formula) double srcR = (paramA * dstR * dstR * dstR + paramB * dstR * dstR + paramC * dstR + paramD) * dstR; // comparing old and new distance to get factor double factor = Math.abs(dstR / srcR); // coordinates in source image double srcXd = centerX + (deltaX * factor * d); double srcYd = centerY + (deltaY * factor * d); // no interpolation yet (just nearest point) int srcX = (int) srcXd; int srcY = (int) srcYd; if (srcX >= 0 && srcY >= 0 && srcX < width && srcY < height) {     int dstPos = y * width + x;     pixels[dstPos] = pixelsCopy[srcY * width + srcX]; }        }    }    return pixels;}

使用此版本,您可以使用现有镜头数据库(例如LensFun)中的参数值(尽管您需要翻转每个参数的符号)。现在可以在http://mipav.cit.nih.gov/pubwiki/index.php/Barrel_Distortion_Correction中找到描述算法的页面



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/469315.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号