Cape Code
Cape Code

Reputation: 3574

How to define 'interp' when using imwarp

I'm using imwarp to modify an image like this:

WarpedImage=imwarp(Image, tform, 'OutputView', imref2dObject);

I would like to define the interpolation parameter called 'interp' listed in the manual:

But this:

Interp='nearest';
WarpedImage=imwarp(Image, tform, 'OutputView', imref2dObject, 'Interp', Interp);

gives the error:

Error using imwarp>parseInputs (line 329)
Argument 'Interp' did not match any valid parameter of the parser.

and that:

WarpedImage=imwarp(Image, tform, 'OutputView', imref2dObject, Interp);

gives:

Error using imwarp>parseInputs (line 329)
Parameter 'nearest' does not have a value.

What is the correct way of defining this parameter?

Upvotes: 2

Views: 1047

Answers (2)

Dima
Dima

Reputation: 39419

A typical MATLAB function may have 3 kinds of parameters: required, optional, and name-value pairs. Required parameters come first, then optional parameters, and then the name-value pairs. In the case of imwarp, Image and tform are required, and interp is optional, so it has to come before the name-value pairs:

WarpedImage=imwarp(Image, tform, Interp, 'OutputView', imref2dObject);

Upvotes: 3

Shai
Shai

Reputation: 114866

Try put Interp before the other options (e.g., 'OutputView'...)

>> WarpedImage=imwarp(Image, tform, Interp, 'OutputView', imref2dObject);

Upvotes: 3

Related Questions