【问题标题】:Implementation of ripple transformation in matlabmatlab中波纹变换的实现
【发布时间】:2018-04-15 22:21:29
【问题描述】:

波纹变换是一种非线性图像扭曲,在照片中给出了公式: 我的实现如下:

function y = rippleTransform(I, t1, t2, t3, t4)

[m,n] = size(I);

for i=1:m
    for j=1:n
        if round(i+t3*sin((2*pi*j)/t1)) > 0 && round(j+t4*sin((2*pi*i/t2))) > 0
            T(round(i+t3*sin((2*pi*j)/t1)), round(j+t4*sin((2*pi*i)/t2))) = I(i,j);
        end
    end
end
y = T;
end

但结果并不如预期。任何想法为什么?

【问题讨论】:

    标签: matlab image-processing transform


    【解决方案1】:

    当您对图像执行几何变换时,您想要进行反向映射。实际上,您希望遍历输出图像中的像素并从源图像中采样正确的位置。这就是为什么赋值给出的是逆变换而不是正向变换。

    您需要考虑的一件事是源图像中的采样坐标可能不是整数值,因此我们执行插值以估计“像素之间”的图像强度。

    function T = rippleTransform(I, tx, ty, ax, ay)
        [x,y] = meshgrid(1:size(I,2),1:size(I,1));
        u = x + ax*sin(2*pi*y/tx);
        v = y + ay*sin(2*pi*x/ty);
        T = cast(interp2(x,y,double(I),u,v),class(I));
    end
    

    示例

    >> I = imread('rice.png');
    >> T = rippleTransform(I, 120, 250, 10, 15);
    

    【讨论】:

      猜你喜欢
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-12
      • 2013-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多