09 สิงหาคม 2553

โค๊ดตัวอย่างการ warp case 2

โค๊ดตัวอย่างการ warp case 2
มีการใช้ Go Wrap Matlab Library ดาวน์โหลดที่นี่
keyword :warping Quadrilateral to Unit Square 
input : จุดมุมในสีเหลี่ยมใดๆปลายทาง 4 จุด คือ (s0,t0), (s1,t1), (s2,t2), (s3,t3)
output : Transformation matrix และการทดสอบwarp จุด
% Unit Square to Quadrilateral
% By Nemin Suksen
% Master Degree FIBO, KMUTT, Thailand
% Reference:  pages 17-21 of Fundamentals of Texture Mapping and Image Warping, Paul Heckbert,
% Master’s thesis, UCB/CSD 89/516, CS Division, U.C. Berkeley, June 1989,
% URL=http://www.cs.cmu.edu/?ph.
% Thank Nung Navakun Sebang for paper sample data and suggestion
clc; clear all; close all;

%% Source Quadrilateral
% 4 Point of Quadrilateral = (x0,y0), (x1,y1), (x2,y2), (x3,y3)
s0 = 7;
t0 = 171;
s1 = 294;
t1 = 168;
s2 = 307;
t2 = 2;
s3 = 1;
t3 = 2;

%% Destination Quadrilateral
% 4 Point of unit squre = (u0,v0), (u1,v1), (u2,v2), (u3,v3)
u0 = 0;
v0 = 1;
u1 = 1;
v1 = 0;
u2 = 1;
v2 = 1;
u3 = 0;
v3 = 1;


%% Forward wrap
T = warps2q(s0, t0, s1, t1, s2, t2, s3, t3);

%% invert wrap
iT = iwarp(T);

%% testing wrap
s = 154;
t = 154;
point = iwarp(T)*[s t 1]';
point = point./point(3)



ไม่มีความคิดเห็น: