Learn R Programming

Rvision (version 0.4.2)

warpPerspective: Perspective Transformation

Description

warpPerspective applies a perspective transformation to an image.

Usage

warpPerspective(
  image,
  warp_matrix,
  output_size = dim(image)[1:2],
  interp_mode = "linear",
  inverse_map = TRUE,
  border_type = "constant",
  border_color = "black"
)

Arguments

image

An Image object.

warp_matrix

A 3x3 numeric matrix.

output_size

A 2-elements vector indicating the number of rows and columns of the output image (defaults to the dimensions of image).

interp_mode

A character string indicating the interpolation method to be used. It can be any of the following:

  • "nearest":nearest neighbor interpolation.

  • "linear" (the default):bilinear interpolation.

  • "cubic":bicubic interpolation.

  • "area":resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moir<U+00E9>-free results, but when the image is zoomed, it is similar to the nearest neighbor method.

  • "lanczos4":Lanczos interpolation over 8x8 neighborhood.

  • "linear_exact":bit exact bilinear interpolation.

inverse_map

A logical. TRUE if warp_matrix represents an inverse transformation. If FALSE, warp_matrix will be inverted.

border_type

A character string indicating the extrapolation method to use when filling empty pixels created during the transformation. It can be any of the following:

  • "constant" (the default):iiiiii|abcdefgh|iiiiii with i specified by border_value.

  • "replicate":aaaaaa|abcdefgh|hhhhhh.

  • "reflect":fedcba|abcdefgh|hgfedc.

  • "wrap":cdefgh|abcdefgh|abcdef.

  • "reflect_101":gfedcb|abcdefgh|gfedcb.

  • "transparent":uvwxyz|abcdefgh|ijklmn.

border_color

A value or vector of any kind of R color specification compatible with col2bgr representing the color of the border (default: "black").

Value

An Image object.

See Also

warpPerspective, findTransformECC

Examples

Run this code
# NOT RUN {
file1 <- system.file("sample_img/balloon1.png", package = "Rvision")
file2 <- system.file("sample_img/balloon2.png", package = "Rvision")
balloon1 <- changeColorSpace(image(file1), "GRAY")
balloon2 <- changeColorSpace(image(file2), "GRAY")
ecc <- findTransformECC(balloon1, balloon2)
balloon2_transformed <- warpAffine(balloon2, ecc)

# }

Run the code above in your browser using DataLab