clc
clear all
close all
%% parametry kamery
f=4.21;         %ohniskova vzdalenost mm
h=5.5e1;        %vzdalenost kamery od osy z mm
a=26.5*pi/180;  %viditelny uhel
uhel=0*pi/180;  %uhel opticke osy ud osy z x=0 
uhel2=9.*pi/180; %uhel opticke osy ud horyzontu
l=0;
d=0;
k=1;        % mm

%% nacteni obrazu a priprava dat
img=imread('..\img\vlcsnap-2010-10-10-21h09m35s62.png');

im_orig=img;
figure (1)
imshow(img);
[horx hor]=ginput(1);
img(hor,:,:)=255;
x=edge(rgb2gray(img),'canny');
edge_org=x;

img=im_orig;
pause(0.1);
[m,n,nn]=size(img);

sm=ceil(m/2);
sn=ceil(n/2);

%% výpočet
imgout=uint8(zeros(500,900,3));
for i=hor:.1:m
    for j=1:.1:n
        
            x=+ceil((h*cos((uhel-a)+(j)*2*a/(n-1)))/(tan((uhel2-a)+((i)*2*a)/(m-1)))+l);
            y=2500+ceil((h*sin((uhel-a)+(j)*2*a/(n-1)))/(tan((uhel2-a)+((i)*2*a)/(m-1)))+d);
            
            if((x>0) && (y>0) && (x<9000) && (y<5000))
            imgout(ceil(x/10),ceil(y/10),:)=img(ceil(i),ceil(j),:);

            end
    end
end

figure (2)
imshow(imgout(:,:,:),[])
