2

I want to apply homography to the satellite images. I found this post quite helpful. So I decided to use the same Matlab code.

 im = imread('cameraman.tif');
 n = [0;0;-1];
 d = Inf

       theta = 60*pi/180;

       R = [ 1     0           0 ;
           0  cos(theta) -sin(theta);
           0  sin(theta)  cos(theta)];

       t = [0;0;0];

      K=[300 0    0;
            0    300 0;
            0    0    1];

      H=K*R/K-1/d*K*t*n'*K;

     img=imagehomog(im,H','c');
     figure;imshow(img)

but the output is just the small box. I am using MATLAB 2015b enter image description here

EDIT Homography using imtransform and maketform

n = [0;0;-1];
d = Inf;

im = imread('cameraman.tif');

   theta = 60*pi/180;

   R = [ 1     0           0 ;
       0  cos(theta) -sin(theta);
       0  sin(theta)  cos(theta)];

   t = [0;0;0];

  K=[300 0    0;
        0    300 0;
        0    0    1];

  H=K*R/K-1/d*K*t*n'*K;

  tform = maketform('projective',H');
  imT = imtransform(im,tform);

  imshow(imT)

Output enter image description here

How can I do it from the center. Something like this enter image description here

Community
  • 1
  • 1
Addee
  • 663
  • 10
  • 21
  • That code does not run, its full of bugs. `imagehomog` is not a MATLAB fucntion – Ander Biguri Feb 16 '17 at 08:07
  • Yes its not a matlab function. I used the code as it is mentioned in the post. If it is full bugs then how he showed an output in the answer? – Addee Feb 16 '17 at 09:23
  • I have no idea, because your `for` loop has no `end`, so MATLAB can not run that code. Can you please link the documentation of `imagehomog`? – Ander Biguri Feb 16 '17 at 09:29
  • Sorry I have corrected that code, that `for` shouldn't be there. here is the [code](https://github.com/covarep/covarep/blob/master/external/voicebox/imagehomog.m) of `imagehomg`. Full [description](http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/doc/voicebox/imagehomog.html) – Addee Feb 16 '17 at 09:40
  • Oh, so **its not** a function inside MATLAB. I suggest you have a look at [imtransform](https://uk.mathworks.com/help/images/ref/imtransform.html) and the multiple possibilities that [maketform](https://uk.mathworks.com/help/images/ref/maketform.html) gives you. I can not comment in code you found randomly on the internet. – Ander Biguri Feb 16 '17 at 09:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/135906/discussion-between-addee-and-ander-biguri). – Addee Feb 17 '17 at 00:04

0 Answers0