Class RectifyImageOps


  • public class RectifyImageOps
    extends java.lang.Object

    Operations related to rectifying stereo image pairs. Provides functions for 1) creating rectification calculation algorithms, 2) rectification transforms, and 3) image distortion for rectification.

    Definition of transformed coordinate systems:

    Pixel
    Original image coordinates in pixels.
    Rect
    Rectified image coordinates in pixels. Lens distortion has been removed.
    RectNorm
    Rectified image coordinates in normalized coordinates.

    • Constructor Summary

      Constructors 
      Constructor Description
      RectifyImageOps()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void allInsideLeft​(int imageWidth, int imageHeight, org.ejml.data.DMatrixRMaj rectifyLeft, org.ejml.data.DMatrixRMaj rectifyRight)
      Adjust the rectification such that only pixels which overlap the original left image can be seen.
      static void allInsideLeft​(int imageWidth, int imageHeight, org.ejml.data.FMatrixRMaj rectifyLeft, org.ejml.data.FMatrixRMaj rectifyRight)
      Adjust the rectification such that only pixels which overlap the original left image can be seen.
      static void allInsideLeft​(CameraPinholeBrown paramLeft, org.ejml.data.DMatrixRMaj rectifyLeft, org.ejml.data.DMatrixRMaj rectifyRight, org.ejml.data.DMatrixRMaj rectifyK, boofcv.struct.image.ImageDimension rectifiedSize)
      Adjust the rectification such that only pixels which overlap the original left image can be seen.
      static void allInsideLeft​(CameraPinholeBrown paramLeft, org.ejml.data.FMatrixRMaj rectifyLeft, org.ejml.data.FMatrixRMaj rectifyRight, org.ejml.data.FMatrixRMaj rectifyK, boofcv.struct.image.ImageDimension rectifiedSize)
      Adjust the rectification such that only pixels which overlap the original left image can be seen.
      static void applyMask​(boofcv.struct.image.GrayF32 disparity, boofcv.struct.image.GrayU8 mask, int radius)
      Applies a mask which indicates which pixels had mappings to the unrectified image.
      static void applyMask​(boofcv.struct.image.GrayU8 disparity, boofcv.struct.image.GrayU8 mask, int radius)
      Applies a mask which indicates which pixels had mappings to the unrectified image.
      static RectifyCalibrated createCalibrated()
      Rectification for calibrated stereo pairs.
      static RectifyFundamental createUncalibrated()
      Rectification for uncalibrated stereo pairs using the fundamental matrix.
      static void fullViewLeft​(int imageWidth, int imageHeight, org.ejml.data.DMatrixRMaj rectifyLeft, org.ejml.data.DMatrixRMaj rectifyRight)
      Adjust the rectification such that the entire original left image can be seen.
      static void fullViewLeft​(int imageWidth, int imageHeight, org.ejml.data.FMatrixRMaj rectifyLeft, org.ejml.data.FMatrixRMaj rectifyRight)
      Adjust the rectification such that the entire original left image can be seen.
      static void fullViewLeft​(CameraPinholeBrown paramLeft, org.ejml.data.DMatrixRMaj rectifyLeft, org.ejml.data.DMatrixRMaj rectifyRight, org.ejml.data.DMatrixRMaj rectifyK, boofcv.struct.image.ImageDimension rectifiedSize)
      Adjust the rectification such that the entire original left image can be seen and adjusts the shape of the rectified image to maximize it's area.
      static void fullViewLeft​(CameraPinholeBrown paramLeft, org.ejml.data.FMatrixRMaj rectifyLeft, org.ejml.data.FMatrixRMaj rectifyRight, org.ejml.data.FMatrixRMaj rectifyK, boofcv.struct.image.ImageDimension rectifiedSize)
      Adjust the rectification such that the entire original left image can be seen.
      static <T extends boofcv.struct.image.ImageBase<T>>
      boofcv.alg.distort.ImageDistort<T,​T>
      rectifyImage​(CameraPinholeBrown param, org.ejml.data.FMatrixRMaj rectify, boofcv.struct.border.BorderType borderType, boofcv.struct.image.ImageType<T> imageType)
      Creates an ImageDistort for rectifying an image given its radial distortion and rectification matrix.
      static <T extends boofcv.struct.image.ImageGray<T>>
      boofcv.alg.distort.ImageDistort<T,​T>
      rectifyImage​(org.ejml.data.FMatrixRMaj rectify, boofcv.struct.border.BorderType borderType, java.lang.Class<T> imageType)
      Creates an ImageDistort for rectifying an image given its rectification matrix.
      static boofcv.struct.distort.Point2Transform2_F64 transformPixelToRect​(CameraPinholeBrown param, org.ejml.data.DMatrixRMaj rectify)
      Creates a transform that applies rectification to unrectified distorted pixels.
      static boofcv.struct.distort.Point2Transform2_F32 transformPixelToRect​(CameraPinholeBrown param, org.ejml.data.FMatrixRMaj rectify)
      Creates a transform that applies rectification to unrectified distorted pixels.
      static boofcv.struct.distort.Point2Transform2_F64 transformPixelToRectNorm​(CameraPinholeBrown param, org.ejml.data.DMatrixRMaj rectify, org.ejml.data.DMatrixRMaj rectifyK)
      Creates a transform that applies rectification to unrectified distorted pixels and outputs normalized pixel coordinates.
      static boofcv.struct.distort.Point2Transform2_F32 transformPixelToRectNorm​(CameraPinholeBrown param, org.ejml.data.FMatrixRMaj rectify, org.ejml.data.FMatrixRMaj rectifyK)
      Creates a transform that applies rectification to unrectified distorted pixels and outputs normalized pixel coordinates.
      static boofcv.struct.distort.Point2Transform2_F64 transformRectToPixel​(CameraPinholeBrown param, org.ejml.data.DMatrixRMaj rectify)
      Creates a transform that goes from rectified to original distorted pixel coordinates.
      static boofcv.struct.distort.Point2Transform2_F32 transformRectToPixel​(CameraPinholeBrown param, org.ejml.data.FMatrixRMaj rectify)
      Creates a transform that goes from rectified to original distorted pixel coordinates.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RectifyImageOps

        public RectifyImageOps()
    • Method Detail

      • createCalibrated

        public static RectifyCalibrated createCalibrated()

        Rectification for calibrated stereo pairs. Two stereo camera care considered calibrated if their baseline is known.

        After the rectification has been found it might still need to be adjusted for maximum viewing area. See fullViewLeft and allInsideLeft for adjusting the rectification.

        Returns:
        RectifyCalibrated
      • fullViewLeft

        public static void fullViewLeft​(CameraPinholeBrown paramLeft,
                                        org.ejml.data.DMatrixRMaj rectifyLeft,
                                        org.ejml.data.DMatrixRMaj rectifyRight,
                                        org.ejml.data.DMatrixRMaj rectifyK,
                                        @Nullable
                                        boofcv.struct.image.ImageDimension rectifiedSize)

        Adjust the rectification such that the entire original left image can be seen and adjusts the shape of the rectified image to maximize it's area. For use with calibrated stereo images having a known baseline. Due to lens distortions it is possible for large parts of the rectified image to have no overlap with the original and will appear to be black. This can cause issues when processing the image

        WARNING: There are pathological conditions where this will fail. If the new rotated image view and a pixel are parallel it will require infinite area.

        Parameters:
        paramLeft - Intrinsic parameters for left camera. Not modified.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
        rectifyK - Rectification calibration matrix. Input and Output. Modified.
        rectifiedSize - (Optional) Size that the rectified images should be changed to. Modified.
      • fullViewLeft

        public static void fullViewLeft​(CameraPinholeBrown paramLeft,
                                        org.ejml.data.FMatrixRMaj rectifyLeft,
                                        org.ejml.data.FMatrixRMaj rectifyRight,
                                        org.ejml.data.FMatrixRMaj rectifyK,
                                        @Nullable
                                        boofcv.struct.image.ImageDimension rectifiedSize)

        Adjust the rectification such that the entire original left image can be seen. For use with calibrated stereo images having a known baseline. Due to lens distortions it is possible for large parts of the rectified image to have no overlap with the original and will appear to be black. This can cause issues when processing the image

        WARNING: There are pathological conditions where this will fail. If the new rotated image view and a pixel are parallel it will require infinite area.

        Parameters:
        paramLeft - Intrinsic parameters for left camera. Not modified.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
        rectifyK - Rectification calibration matrix. Input and Output. Modified.
        rectifiedSize - (Optional) Size that the rectified images should be changed to. Modified.
      • fullViewLeft

        public static void fullViewLeft​(int imageWidth,
                                        int imageHeight,
                                        org.ejml.data.DMatrixRMaj rectifyLeft,
                                        org.ejml.data.DMatrixRMaj rectifyRight)

        Adjust the rectification such that the entire original left image can be seen. For use with uncalibrated stereo images with unknown baseline.

        Input rectification matrices are overwritten with adjusted values on output.

        Parameters:
        imageWidth - Width of left image.
        imageHeight - Height of left image.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
      • fullViewLeft

        public static void fullViewLeft​(int imageWidth,
                                        int imageHeight,
                                        org.ejml.data.FMatrixRMaj rectifyLeft,
                                        org.ejml.data.FMatrixRMaj rectifyRight)

        Adjust the rectification such that the entire original left image can be seen. For use with uncalibrated stereo images with unknown baseline.

        Input rectification matrices are overwritten with adjusted values on output.

        Parameters:
        imageWidth - Width of left image.
        imageHeight - Height of left image.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
      • allInsideLeft

        public static void allInsideLeft​(CameraPinholeBrown paramLeft,
                                         org.ejml.data.DMatrixRMaj rectifyLeft,
                                         org.ejml.data.DMatrixRMaj rectifyRight,
                                         org.ejml.data.DMatrixRMaj rectifyK,
                                         @Nullable
                                         boofcv.struct.image.ImageDimension rectifiedSize)

        Adjust the rectification such that only pixels which overlap the original left image can be seen. For use with calibrated stereo images having a known baseline. Image processing is easier since only the "true" image pixels are visible, but information along the image border has been discarded. The rectification matrices are overwritten with adjusted values on output.

        Parameters:
        paramLeft - Intrinsic parameters for left camera. Not modified.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
        rectifyK - Rectification calibration matrix. Input and Output. Modified.
        rectifiedSize - (Optional) Size that the rectified images should be changed to. Modified.
      • allInsideLeft

        public static void allInsideLeft​(CameraPinholeBrown paramLeft,
                                         org.ejml.data.FMatrixRMaj rectifyLeft,
                                         org.ejml.data.FMatrixRMaj rectifyRight,
                                         org.ejml.data.FMatrixRMaj rectifyK,
                                         @Nullable
                                         boofcv.struct.image.ImageDimension rectifiedSize)

        Adjust the rectification such that only pixels which overlap the original left image can be seen. For use with calibrated stereo images having a known baseline. Image processing is easier since only the "true" image pixels are visible, but information along the image border has been discarded. The rectification matrices are overwritten with adjusted values on output.

        Parameters:
        paramLeft - Intrinsic parameters for left camera. Not modified.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
        rectifyK - Rectification calibration matrix. Input and Output. Modified.
      • allInsideLeft

        public static void allInsideLeft​(int imageWidth,
                                         int imageHeight,
                                         org.ejml.data.DMatrixRMaj rectifyLeft,
                                         org.ejml.data.DMatrixRMaj rectifyRight)

        Adjust the rectification such that only pixels which overlap the original left image can be seen. For use with uncalibrated images with unknown baselines. Image processing is easier since only the "true" image pixels are visible, but information along the image border has been discarded. The rectification matrices are overwritten with adjusted values on output.

        Parameters:
        imageWidth - Width of left image.
        imageHeight - Height of left image.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
      • allInsideLeft

        public static void allInsideLeft​(int imageWidth,
                                         int imageHeight,
                                         org.ejml.data.FMatrixRMaj rectifyLeft,
                                         org.ejml.data.FMatrixRMaj rectifyRight)

        Adjust the rectification such that only pixels which overlap the original left image can be seen. For use with uncalibrated images with unknown baselines. Image processing is easier since only the "true" image pixels are visible, but information along the image border has been discarded. The rectification matrices are overwritten with adjusted values on output.

        Parameters:
        imageWidth - Width of left image.
        imageHeight - Height of left image.
        rectifyLeft - Rectification matrix for left image. Input and Output. Modified.
        rectifyRight - Rectification matrix for right image. Input and Output. Modified.
      • transformRectToPixel

        public static boofcv.struct.distort.Point2Transform2_F64 transformRectToPixel​(CameraPinholeBrown param,
                                                                                      org.ejml.data.DMatrixRMaj rectify)

        Creates a transform that goes from rectified to original distorted pixel coordinates. Rectification includes removal of lens distortion. Used for rendering rectified images.

        Parameters:
        param - Intrinsic parameters.
        rectify - Transform for rectifying the image.
        Returns:
        Transform from rectified to unrectified pixels
      • transformRectToPixel

        public static boofcv.struct.distort.Point2Transform2_F32 transformRectToPixel​(CameraPinholeBrown param,
                                                                                      org.ejml.data.FMatrixRMaj rectify)

        Creates a transform that goes from rectified to original distorted pixel coordinates. Rectification includes removal of lens distortion. Used for rendering rectified images.

        Parameters:
        param - Intrinsic parameters.
        rectify - Transform for rectifying the image.
        Returns:
        Transform from rectified to unrectified pixels
      • transformPixelToRect

        public static boofcv.struct.distort.Point2Transform2_F64 transformPixelToRect​(CameraPinholeBrown param,
                                                                                      org.ejml.data.DMatrixRMaj rectify)

        Creates a transform that applies rectification to unrectified distorted pixels.

        Parameters:
        param - Intrinsic parameters. Not modified.
        rectify - Transform for rectifying the image. Not modified.
        Returns:
        Transform from distorted pixel to rectified pixels
      • transformPixelToRect

        public static boofcv.struct.distort.Point2Transform2_F32 transformPixelToRect​(CameraPinholeBrown param,
                                                                                      org.ejml.data.FMatrixRMaj rectify)

        Creates a transform that applies rectification to unrectified distorted pixels.

        Parameters:
        param - Intrinsic parameters. Not modified.
        rectify - Transform for rectifying the image. Not modified.
        Returns:
        Transform from distorted pixel to rectified pixels
      • transformPixelToRectNorm

        public static boofcv.struct.distort.Point2Transform2_F64 transformPixelToRectNorm​(CameraPinholeBrown param,
                                                                                          org.ejml.data.DMatrixRMaj rectify,
                                                                                          org.ejml.data.DMatrixRMaj rectifyK)

        Creates a transform that applies rectification to unrectified distorted pixels and outputs normalized pixel coordinates.

        Parameters:
        param - Intrinsic parameters.
        rectify - Transform for rectifying the image.
        rectifyK - Camera calibration matrix after rectification
        Returns:
        Transform from unrectified to rectified normalized pixels
      • transformPixelToRectNorm

        public static boofcv.struct.distort.Point2Transform2_F32 transformPixelToRectNorm​(CameraPinholeBrown param,
                                                                                          org.ejml.data.FMatrixRMaj rectify,
                                                                                          org.ejml.data.FMatrixRMaj rectifyK)

        Creates a transform that applies rectification to unrectified distorted pixels and outputs normalized pixel coordinates.

        Parameters:
        param - Intrinsic parameters.
        rectify - Transform for rectifying the image.
        rectifyK - Camera calibration matrix after rectification
        Returns:
        Transform from unrectified to rectified normalized pixels
      • rectifyImage

        public static <T extends boofcv.struct.image.ImageGray<T>> boofcv.alg.distort.ImageDistort<T,​T> rectifyImage​(org.ejml.data.FMatrixRMaj rectify,
                                                                                                                           boofcv.struct.border.BorderType borderType,
                                                                                                                           java.lang.Class<T> imageType)
        Creates an ImageDistort for rectifying an image given its rectification matrix. Lens distortion is assumed to have been previously removed.
        Parameters:
        rectify - Transform for rectifying the image.
        imageType - Type of single band image the transform is to be applied to.
        Returns:
        ImageDistort for rectifying the image.
      • rectifyImage

        public static <T extends boofcv.struct.image.ImageBase<T>> boofcv.alg.distort.ImageDistort<T,​T> rectifyImage​(CameraPinholeBrown param,
                                                                                                                           org.ejml.data.FMatrixRMaj rectify,
                                                                                                                           boofcv.struct.border.BorderType borderType,
                                                                                                                           boofcv.struct.image.ImageType<T> imageType)
        Creates an ImageDistort for rectifying an image given its radial distortion and rectification matrix.
        Parameters:
        param - Intrinsic parameters.
        rectify - Transform for rectifying the image.
        imageType - Type of single band image the transform is to be applied to.
        Returns:
        ImageDistort for rectifying the image.
      • applyMask

        public static void applyMask​(boofcv.struct.image.GrayF32 disparity,
                                     boofcv.struct.image.GrayU8 mask,
                                     int radius)
        Applies a mask which indicates which pixels had mappings to the unrectified image. Pixels which were outside of the original image will be set to 255. The border is extended because the sharp edge in the rectified image can cause in incorrect match between image features.
        Parameters:
        disparity - (Input) disparity
        mask - (Input) mask. 1 = mapping to unrectified. 0 = no mapping
        radius - How much the border is extended by
      • applyMask

        public static void applyMask​(boofcv.struct.image.GrayU8 disparity,
                                     boofcv.struct.image.GrayU8 mask,
                                     int radius)
        Applies a mask which indicates which pixels had mappings to the unrectified image. Pixels which were outside of the original image will be set to 255. The border is extended because the sharp edge can confuse disparity algorithms.
        Parameters:
        disparity - (Input) disparity
        mask - (Input) mask. 1 = mapping to unrectified. 0 = no mapping
        radius - How much the border is extended by