how to enter the weights in bilinear interpolation

2 visualizaciones (últimos 30 días)
Eric Hun
Eric Hun el 6 de Nov. de 2015
Comentada: Image Analyst el 7 de Nov. de 2015
here is the required code for wrapping an image using bilinear interpolation.how to calculate weights. Please help
function Iout=deform(Iin,T) % function Iout=deform(Iin,T) % Bilinear Interpolation Operation on 2D image I using Deformation Field T % Inputs: % Iin is of size nx x ny % T is of size nx x ny x 2 % T(:,:,1)=Bx, deformation along x/rows % T(:,:,2)=By, deformation along y/columns % Output: % Iout is of size nx x ny
% x,y indices nx=size(Iin,1); ny=size(Iin,2);
% Regular output grid [xout,yout]=ndgrid(1:nx,1:ny);
% Corresponding input pixels xin=xout+T(:,:,1); yin=yout+T(:,:,2);
% Nearest grid points xin0=floor(xin); yin0=floor(yin); xin1=xin0+1; yin1=yin0+1;
% check_xin0=(xin0<1)|(xin0>nx); check_yin0=(yin0<1)|(yin0>ny); check_xin1=(xin1<1)|(xin1>nx); check_yin1=(yin1<1)|(yin1>ny);
% Bilinear interpolation weights (fractions) tx=xin-xin0; ty=yin-yin0; w00=?; w01=?; w10=?; w11=?;
xin0=min(max(xin0,1),nx); yin0=min(max(yin0,1),ny); xin1=min(max(xin1,1),nx); yin1=min(max(yin1,1),ny);
% Interpolate I00=Iin(xin0+(yin0-1)*nx); I01=Iin(xin0+(yin1-1)*nx); I10=Iin(xin1+(yin0-1)*nx); I11=Iin(xin1+(yin1-1)*nx);
w00(check_xin0|check_yin0)=0; w01(check_xin0|check_yin1)=0; w10(check_xin1|check_yin0)=0; w11(check_xin1|check_yin1)=0;
Iout=$;

Respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by