我需要一段用Pascal/Delphi/Lazarus编写的逆透视变换。见下图:
我认为我需要遍历目标像素,然后计算出对应的源图像位置(以避免由于舍入误差等问题而产生错误)。
function redraw_3d_to_2d(sourcebitmap:tbitmap, sourceaspect:extended, point_a, point_b, point_c, point_d:tpoint, megapixelcount:integer):tbitmap;
var
destinationbitmap:tbitmap;
x,y,sx,sy:integer;
begin
destinationbitmap:=tbitmap.create;
destinationbitmap.width=megapixelcount*sourceaspect*???; // I dont how to calculate this
destinationbitmap.height=megapixelcount*sourceaspect*???; // I dont how to calculate this
for x:=0 to destinationbitmap.width-1 do
for y:=0 to destinationbitmap.height-1 do
begin
sx:=??;
sy:=??;
destinationbitmap.canvas.pixels[x,y]=sourcebitmap.canvas.pixels[sx,sy];
end;
result:=destinationbitmap;
end;
我需要真正的公式...因此OpenGL解决方案并不理想...
megapixelcount
比输入照片小得多,那么有机会,但我同意通常情况下,重建图像的保真度会受到影响。一些形式的混叠可能会通过超采样等技术来对抗,但这不会恢复在过程中丢失的信息,只是使它们的缺乏不那么明显。 - MvG