I need to project one image into the door window of another image.
This is Home work problem. And I've tried solving it using linear equations. Door image window coordinates :
Top left corner = (188,155)
Top Right corner = (343,177)
Bottom left corner = (186,462)
Bottom right corner = (343,432)
Image that I want to project coordinates :
Top left corner = (0,0)
Top Right corner = (499,0)
Bottom left corner = (0,507)
Bottom right corner = (499,507)
I made equations as :
matrix(3*3)[a b c;d e f;g h 1]*[0 0 1]=[188 155 1] etc
And I get the transformation matrix as
[0.311 -0.003 188;0.044 0.605 155;0 0 1]
tm=[0.311 -0.003 188;0.044 0.605 155;0 0 1]
tff = projective2d(tm)
I=imread('a1.jpg');
output=imwarp(I,tff);
imshow(output);
When run I get a dot only but it is not supposed to be that
It seems that you derived the Homography Matrix correctly. But you have vague idea about the values in that matrix.
The values 188 and 155 are translating your image to 188 points right and 155 points down. That is why the output is empty. Because the image is shifted to an area that is invisible in the output window.
You derived your transformation matrix with respect to a bigger image that made these shifting values large. Make them 0.
In order to make the transformed image visible, you need to make your transformation matrix this:
tm=[0.311 -0.003 0;0.044 0.605 0;0 0 1]
This would solve your issue I suppose.