From 72cacda0daedab04fa74f1b95fe530a617f9e4ef Mon Sep 17 00:00:00 2001 From: gkj1g12 <g.jankee@soton.ac.uk> Date: Thu, 27 Feb 2020 16:50:25 +0000 Subject: [PATCH] Upload New File --- Synthetic Image Generator/volume_gen2.m | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Synthetic Image Generator/volume_gen2.m diff --git a/Synthetic Image Generator/volume_gen2.m b/Synthetic Image Generator/volume_gen2.m new file mode 100644 index 0000000..8c67e5e --- /dev/null +++ b/Synthetic Image Generator/volume_gen2.m @@ -0,0 +1,37 @@ +function [disp,Cam2]= volume_gen2(disp,Transform,Calib_type) + +if Calib_type == 1 + + % Apply the transformation matrix to the generated points + % Left camera + [Cam2.L.X2,Cam2.L.Y2] = apply_poly(disp,Transform.Leftcam); + + % Right camera + [Cam2.R.X2,Cam2.R.Y2] = apply_poly(disp,Transform.Rightcam); + +else + % Count rows and columns in the original image + [num_rows, num_cols,depth] = size(disp.X1); + + % Apply the transformation matrix to the shifted points + % Left camera + Trans.Left = Transform.Leftcam * [(disp.X1(:))'; (disp.Y1(:))'; (disp.Z1(:))'; ones(1,numel(disp.X1))]; + + % Right camera + Trans.Right = Transform.Rightcam * [(disp.X1(:))'; (disp.Y1(:))'; (disp.Z1(:))'; ones(1,numel(disp.X1))]; + + % Find the scaling factor + Lambda.L = reshape(Trans.Left(3, :),[num_rows, num_cols, depth]); + Lambda.R = reshape(Trans.Right(3, :),[num_rows, num_cols, depth]); + + % Compute corresponding coordinates in image plane + % X-coordinate + Cam2.L.X2 = reshape(Trans.Left(1, :),[num_rows, num_cols, depth])./Lambda.L; + Cam2.R.X2 = reshape(Trans.Right(1, :),[num_rows, num_cols, depth])./Lambda.R; + + % Y coordinate + Cam2.L.Y2 = reshape(Trans.Left(2, :),[num_rows, num_cols, depth])./Lambda.L; + Cam2.R.Y2 = reshape(Trans.Right(2, :),[num_rows, num_cols, depth])./Lambda.R; +end + + -- GitLab