MATLAB: Difficulty with imwarp function

3d single view metrology

I am writing a code in order to generate a 3d view of a painting from a single image of the painting. For that, i have to generate the 3d views of all the planes present in the image using projective homography transformations. I am using imwarp in order to warp the image. But after warping the output image size is [295,524569] while the input image is only[892,1152]. Can anybody please tell me where am i going wrong?

Best Answer

You probably used something like
[numrows, numcols] = size(YourImage)
when YourImage was an RGB image. RGB images are 3 dimensional, and when you use size() with only two outputs for a 3D matrix, the second output is set to the product of the number of columns and the length of the third dimension. For example,
[numrows, numcols] = size(zeros(25, 31, 3))
would return numrows of 25 and numcols of 31*3
When you take size() of a 3D matrix, either only use one output or else use at least 3 outputs.