Home > Back-end >  Matlab equivalent for cv2.warpPerspective?
Matlab equivalent for cv2.warpPerspective?

Time:02-01

Is there a Matlab image function which does something similar as cv2.warpPerspective? I would like to implement the following python line into Matlab:

image_OUT=cv2.warpPerspective(image_IN, matrix, (row, col), cv2.INTER_NEAREST)

My matrix is 3x3.

I tried with imwarp but get the following error(in Matlab):

Error using imwarp>parseInputsDisplacementFieldSyntax (line 303)
The value of 'DisplacementField' is invalid. Displacement field D must be of size MxNx2 or MxNxPx3.

Error in imwarp (line 172)
    [parsedInputs,catConverter,isInputCategorical] = parseInputsDisplacementFieldSyntax(varargin{:});

CodePudding user response:

out = imwarp(image_IN,projective2d(matrix'),'nearest');

Note that the transform convention in MATLAB is transposed from that of OpenCV.

  •  Tags:  
  • Related