Unverified Commit 10686238 authored by Maximilian Schmidt's avatar Maximilian Schmidt
Browse files

Fix some stuff

parent f9fe172c
......@@ -39,4 +39,4 @@ img_clean = im2uint8(img_clean);
end
%by NAME
%by Philip Ansari, Sahra Naser, Maximilian Schmidt
......@@ -39,5 +39,4 @@ imshow(peppers_clean);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%by NAME
%by Philip Ansari, Sahra Naser, Maximilian Schmidt
......@@ -12,26 +12,19 @@ skyline_right_dist = imread("skyline_right_dist.png");
movingPoints = [196, 6; 177, 31; 166, 31; 77, 127; 65, 137; 82, 137; 148, 49; 78, 128; 123, 140];
fixedPoints = [400, 6; 405, 31; 394, 31; 363, 127; 354, 137; 370, 137; 390, 49; 363, 128; 412, 140];
combined = zeros(size(skyline_left, 1), size(skyline_left, 2) + size(skyline_right_dist, 2) - 150);
combined(:, 1:size(skyline_left, 2)) = skyline_left;
% regression
ft = fittype( 'poly21' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Lower = [-Inf -Inf 1 -Inf 0];
opts.Upper = [Inf Inf 1 Inf 0];
% find transformation of x coordinates
A = ones(size(fixedPoints, 1), 3);
A(:, 1) = fixedPoints(:, 2).^2;
A(:, 2) = fixedPoints(:, 2);
abc = A \ (movingPoints(:, 1) - fixedPoints(:, 1));
% Fit model to data.
[fitresult, gof] = fit([fixedPoints(:, 2), fixedPoints(:, 1)], movingPoints(:, 1), ft, opts );
a = fitresult.p20;
b = fitresult.p10;
c = fitresult.p00;
forwardfn_x = @(yx, a, b, c) a * yx(1).^2 + b * yx(1) + c + yx(2);
combined = zeros(size(skyline_left, 1), size(skyline_left, 2) + size(skyline_right_dist, 2) - 150);
combined(:, 1:size(skyline_left, 2)) = skyline_left;
for y = 1:size(skyline_left, 1)
for x = size(skyline_left, 2)+1:size(combined, 2)
y_fw = y;
x_fw = forwardfn_x([y, x], a, b, c);
x_fw = abc(1) * y^2 + abc(2) * y + abc(3) + x;
x_fw = min(max(x_fw, 1), size(skyline_right_dist, 2));
x_fw = floor(x_fw + 0.5);
combined(y, x) = skyline_right_dist(y_fw, x_fw);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment