【问题标题】:Convert Fisheye Video into regular Video将鱼眼视频转换为普通视频
【发布时间】:2019-08-05 13:05:45
【问题描述】:

我有一个来自 180 度鱼眼摄像头的视频流。我想做一些图像处理以将鱼眼视图转换为普通视图。

经过一些研究和大量阅读文章,我找到了this paper

他们描述了解决这个问题的算法(和一些公式)。

我曾经尝试在 Matlab 中实现此方法。不幸的是,它不起作用,我没能使它起作用。 “校正”图像看起来与原始照片完全一样,并且没有任何失真消除,其次我只收到图像的左上角,而不是完整的图像,但是将“K”的值更改为 1.9 给出了整个图像的 mw ,但它的图像完全相同。

输入图片:

结果:

When the value of K is 1.15 as mentioned in the article

When the value of K is 1.9

这是我的代码:

image = imread('image2.png');
[Cx, Cy, channel] = size(image);

k = 1.5;
f = (Cx * Cy)/3;
opw = fix(f * tan(asin(sin(atan((Cx/2)/f)) * k)));
oph = fix(f * tan(asin(sin(atan((Cy/2)/f)) * k)));
image_new  = zeros(opw, oph,channel);

for i = 1: opw    
    for j = 1: oph        
        [theta,rho] = cart2pol(i,j);        
        R = f * tan(asin(sin(atan(rho/f)) * k));        
        r = f * tan(asin(sin(atan(R/f))/k));        
        X = ceil(r * cos(theta));        
        Y = ceil(r * sin(theta));

        for k = 1: 3            
            image_new(i,j,k) = image(X,Y,k);            
        end
    end
end

image_new = uint8(image_new);
warning('off', 'Images:initSize:adjustingMag');
imshow(image_new);

【问题讨论】:

    标签: matlab image-processing fisheye


    【解决方案1】:

    这就是解决我的问题的方法。

    输入: 作为浮点数的强度 >= 0。0 = 没有变化,高数字等于更强的修正。 缩放为浮点 >= 1。(1 = 缩放不变)

    算法:

    set halfWidth = imageWidth / 2
    set halfHeight = imageHeight / 2
    
    if strength = 0 then strength = 0.00001
    set correctionRadius = squareroot(imageWidth ^ 2 + imageHeight ^ 2) / strength
    
    for each pixel (x,y) in destinationImage
        set newX = x - halfWidth
        set newY = y - halfHeight
    
        set distance = squareroot(newX ^ 2 + newY ^ 2)
        set r = distance / correctionRadius
    
        if r = 0 then
            set theta = 1
        else
            set theta = arctangent(r) / r
    
        set sourceX = halfWidth + theta * newX * zoom
        set sourceY = halfHeight + theta * newY * zoom
    
        set color of pixel (x, y) to color of source image pixel at (sourceX, sourceY)
    

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 2020-08-04
      • 2022-01-13
      • 2018-08-20
      • 2016-01-31
      • 2014-04-04
      • 2023-04-02
      • 1970-01-01
      • 2020-12-25
      相关资源
      最近更新 更多