Matlab function for poly_2d which is a PV-Wave function

조회 수: 13 (최근 30일)
Chad
Chad 2025년 6월 26일
댓글: Chad 2025년 10월 21일 0:21
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