Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

undistortFisheyeImage

Correct fisheye image for lens distortion

Syntax

J = undistortFisheyeImage(I,intrinsics)
[J,camIntrinsics] = undistortFisheyeImage(I,intrinsics)
[___] = undistortFisheyeImage(___,interp)
[___] = undistortFisheyeImage(___,Name,Value)

Description

example

J = undistortFisheyeImage(I,intrinsics) removes lens distortion for image I and returns the result as image J.

[J,camIntrinsics] = undistortFisheyeImage(I,intrinsics) also returns a cameraIntrinsics object, which corresponds to a virtual perspective camera that produces image J.

[___] = undistortFisheyeImage(___,interp) specifies the interpolation method, interp, using the preceding syntaxes.

example

[___] = undistortFisheyeImage(___,Name,Value) specifies one or more Name,Value pair arguments. Unspecified properties have their default values.

Examples

collapse all

Remove lens distortion from a fisheye image by detecting a checkboard calibration pattern and calibrating the camera. Then, display the results.

Gather a set of checkerboard calibration images.

images = imageDatastore(fullfile(toolboxdir('vision'),'visiondata', ...
    'calibration','gopro'));

Detect the calibration pattern from the images.

[imagePoints,boardSize] = detectCheckerboardPoints(images.Files);

Generate world coordinates for the corners of the checkerboard squares.

squareSize = 29; % millimeters
worldPoints = generateCheckerboardPoints(boardSize,squareSize);

Estimate the fisheye camera calibration parameters based on the image and world points. Use the first image to get the image size.

I = readimage(images,1);
imageSize = [size(I,1) size(I,2)];
params = estimateFisheyeParameters(imagePoints,worldPoints,imageSize);

Remove lens distortion from the first image I and display the results.

J1 = undistortFisheyeImage(I,params.Intrinsics);
figure
imshowpair(I,J1,'montage')
title('Original Image (left) vs. Corrected Image (right)')

J2 = undistortFisheyeImage(I,params.Intrinsics,'OutputView','full');
figure
imshow(J2)
title('Full Output View')

Input Arguments

collapse all

Input image, specified as an M-by-N-by-3 truecolor or M-by-N 2-D grayscale image. The input image must be real and nonsparse.

Data Types: single | double | int16 | uint8 | uint16 | logical

Fisheye intrinsic camera parameters, specified as a fisheyeIntrinsics object.

Interpolation method to use on the input image, specified as 'bilinear', 'nearest' , or 'cubic'.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'ScaleFactor',2 sets the scale factor to increase the zoom in the camera view.

collapse all

Scale factor for the focal length of a virtual camera perspective, in pixels, specified as a scalar or an [sx sy] vector. Specify a vector to scale the x and y axes individually. Increase the scale to zoom in the perspective of the camera view.

collapse all

Output pixel fill values, specified as the comma-separated pair consisting of 'FillValues' and scalar or 3-element vector. When the corresponding inverse-transformed location in the input image lies completely outside the input image boundaries, you use the fill values for output pixels. When you use a 2-D grayscale input image, FillValues must be a scalar. When you use a truecolor image, FillValues can be a scalar or a 3-element vector of RGB values.

Output Arguments

collapse all

Undistorted image, returned as an M-by-N-by-3 truecolor or M-by-N 2-D grayscale image.

Data Types: single | double | int16 | uint8 | uint16 | logical

Undistorted intrinsics of a virtual camera, returned as a cameraIntrinsics object. These intrinsics are for a camera that has a perspective that produces the undistorted image.

Introduced in R2017b