Matlab function for poly_2d which is a PV-Wave function

12 次查看(过去 30 天)
Dear Forum,
I am looking for an equivalent function in Matlab for the PV-Wave function poly_2D. It appears that I could write one but I would like to ask to see if something similar exist in Matlab. Thank you. See imagebelow for PV-Wave function.

回答(1 个)

Anjaneyulu Bairi
Anjaneyulu Bairi 2025-7-1
Hey,
There is no direct built-in implementation of PV-Wave’s "POLY_2D" function in MATLAB. However, you can write your own MATLAB function to perform polynomial geometric operations, similar to what "POLY_2D" does.
  1 个评论
Chad
Chad 2025-10-21,0:21
I have attempted to write my own code that is supposed to perform the image warp. However, it appears to works but the correction seems too much. Can you spot an errors in my code below?
function test_ploy_2D
% poly2D_transform applies a 2D polynomial mapping:
% xp = a(x,y) = Σ_i=0^n Σ_j=0^n coeffx(i+1,j+1) * x^j * y^i
% yp = b(x,y) = Σ_i=0^n Σ_j=0^n coeffy(i+1,j+1) * x^j * y^i
% INPUTS:
% x, y - coordinates (scalars, vectors, or matrices of same size)
% coeffx - coefficient matrix for x'
% coeffy - coefficient matrix for y'
%
% OUTPUTS:
% xp, yp - transformed coordinates
coeffx = [0 1 0; 0 0.5 0.2; 0 0 0.1];
coeffy = [0 0.8 0; 0 0.1 0.4; 0 0 0.05];
img = imread('cameraman.tif'); % example grayscale image
figure(1)
imagesc(img)
[x,y]=meshgrid(1:size(img,2), 1:size(img,1));
[nx, ny] = size(coeffx);
n = nx - 1; % polynomial degree
xp = zeros(size(x));
yp = zeros(size(y));
for i = 0:n
for j = 0:n
xp = xp + coeffx(i+1,j+1).*(x.^j).*(y.^i);
yp = yp + coeffy(i+1,j+1).*(x.^j).*(y.^i);
end
end
img_warp = interp2(x, y, double(img), xp, yp, 'linear', 0);
figure(2)
imagesc(uint8(img_warp));
title('Warped Image (2D Polynomial Transform)')

请先登录,再进行评论。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by