OpenCV 2.4.6

org.opencv.imgproc
Class Imgproc

java.lang.Object
  extended by org.opencv.imgproc.Imgproc

public class Imgproc
extends java.lang.Object


Field Summary
static int ADAPTIVE_THRESH_GAUSSIAN_C
           
static int ADAPTIVE_THRESH_MEAN_C
           
static int BORDER_CONSTANT
           
static int BORDER_DEFAULT
           
static int BORDER_ISOLATED
           
static int BORDER_REFLECT
           
static int BORDER_REFLECT_101
           
static int BORDER_REFLECT101
           
static int BORDER_REPLICATE
           
static int BORDER_TRANSPARENT
           
static int BORDER_WRAP
           
static int CHAIN_APPROX_NONE
           
static int CHAIN_APPROX_SIMPLE
           
static int CHAIN_APPROX_TC89_KCOS
           
static int CHAIN_APPROX_TC89_L1
           
static int COLOR_BayerBG2BGR
           
static int COLOR_BayerBG2BGR_VNG
           
static int COLOR_BayerBG2GRAY
           
static int COLOR_BayerBG2RGB
           
static int COLOR_BayerBG2RGB_VNG
           
static int COLOR_BayerGB2BGR
           
static int COLOR_BayerGB2BGR_VNG
           
static int COLOR_BayerGB2GRAY
           
static int COLOR_BayerGB2RGB
           
static int COLOR_BayerGB2RGB_VNG
           
static int COLOR_BayerGR2BGR
           
static int COLOR_BayerGR2BGR_VNG
           
static int COLOR_BayerGR2GRAY
           
static int COLOR_BayerGR2RGB
           
static int COLOR_BayerGR2RGB_VNG
           
static int COLOR_BayerRG2BGR
           
static int COLOR_BayerRG2BGR_VNG
           
static int COLOR_BayerRG2GRAY
           
static int COLOR_BayerRG2RGB
           
static int COLOR_BayerRG2RGB_VNG
           
static int COLOR_BGR2BGR555
           
static int COLOR_BGR2BGR565
           
static int COLOR_BGR2BGRA
           
static int COLOR_BGR2GRAY
           
static int COLOR_BGR2HLS
           
static int COLOR_BGR2HLS_FULL
           
static int COLOR_BGR2HSV
           
static int COLOR_BGR2HSV_FULL
           
static int COLOR_BGR2Lab
           
static int COLOR_BGR2Luv
           
static int COLOR_BGR2RGB
           
static int COLOR_BGR2RGBA
           
static int COLOR_BGR2XYZ
           
static int COLOR_BGR2YCrCb
           
static int COLOR_BGR2YUV
           
static int COLOR_BGR2YUV_I420
           
static int COLOR_BGR2YUV_IYUV
           
static int COLOR_BGR2YUV_YV12
           
static int COLOR_BGR5552BGR
           
static int COLOR_BGR5552BGRA
           
static int COLOR_BGR5552GRAY
           
static int COLOR_BGR5552RGB
           
static int COLOR_BGR5552RGBA
           
static int COLOR_BGR5652BGR
           
static int COLOR_BGR5652BGRA
           
static int COLOR_BGR5652GRAY
           
static int COLOR_BGR5652RGB
           
static int COLOR_BGR5652RGBA
           
static int COLOR_BGRA2BGR
           
static int COLOR_BGRA2BGR555
           
static int COLOR_BGRA2BGR565
           
static int COLOR_BGRA2GRAY
           
static int COLOR_BGRA2RGB
           
static int COLOR_BGRA2RGBA
           
static int COLOR_BGRA2YUV_I420
           
static int COLOR_BGRA2YUV_IYUV
           
static int COLOR_BGRA2YUV_YV12
           
static int COLOR_COLORCVT_MAX
           
static int COLOR_GRAY2BGR
           
static int COLOR_GRAY2BGR555
           
static int COLOR_GRAY2BGR565
           
static int COLOR_GRAY2BGRA
           
static int COLOR_GRAY2RGB
           
static int COLOR_GRAY2RGBA
           
static int COLOR_HLS2BGR
           
static int COLOR_HLS2BGR_FULL
           
static int COLOR_HLS2RGB
           
static int COLOR_HLS2RGB_FULL
           
static int COLOR_HSV2BGR
           
static int COLOR_HSV2BGR_FULL
           
static int COLOR_HSV2RGB
           
static int COLOR_HSV2RGB_FULL
           
static int COLOR_Lab2BGR
           
static int COLOR_Lab2LBGR
           
static int COLOR_Lab2LRGB
           
static int COLOR_Lab2RGB
           
static int COLOR_LBGR2Lab
           
static int COLOR_LBGR2Luv
           
static int COLOR_LRGB2Lab
           
static int COLOR_LRGB2Luv
           
static int COLOR_Luv2BGR
           
static int COLOR_Luv2LBGR
           
static int COLOR_Luv2LRGB
           
static int COLOR_Luv2RGB
           
static int COLOR_mRGBA2RGBA
           
static int COLOR_RGB2BGR
           
static int COLOR_RGB2BGR555
           
static int COLOR_RGB2BGR565
           
static int COLOR_RGB2BGRA
           
static int COLOR_RGB2GRAY
           
static int COLOR_RGB2HLS
           
static int COLOR_RGB2HLS_FULL
           
static int COLOR_RGB2HSV
           
static int COLOR_RGB2HSV_FULL
           
static int COLOR_RGB2Lab
           
static int COLOR_RGB2Luv
           
static int COLOR_RGB2RGBA
           
static int COLOR_RGB2XYZ
           
static int COLOR_RGB2YCrCb
           
static int COLOR_RGB2YUV
           
static int COLOR_RGB2YUV_I420
           
static int COLOR_RGB2YUV_IYUV
           
static int COLOR_RGB2YUV_YV12
           
static int COLOR_RGBA2BGR
           
static int COLOR_RGBA2BGR555
           
static int COLOR_RGBA2BGR565
           
static int COLOR_RGBA2BGRA
           
static int COLOR_RGBA2GRAY
           
static int COLOR_RGBA2mRGBA
           
static int COLOR_RGBA2RGB
           
static int COLOR_RGBA2YUV_I420
           
static int COLOR_RGBA2YUV_IYUV
           
static int COLOR_RGBA2YUV_YV12
           
static int COLOR_XYZ2BGR
           
static int COLOR_XYZ2RGB
           
static int COLOR_YCrCb2BGR
           
static int COLOR_YCrCb2RGB
           
static int COLOR_YUV2BGR
           
static int COLOR_YUV2BGR_I420
           
static int COLOR_YUV2BGR_IYUV
           
static int COLOR_YUV2BGR_NV12
           
static int COLOR_YUV2BGR_NV21
           
static int COLOR_YUV2BGR_UYNV
           
static int COLOR_YUV2BGR_UYVY
           
static int COLOR_YUV2BGR_Y422
           
static int COLOR_YUV2BGR_YUNV
           
static int COLOR_YUV2BGR_YUY2
           
static int COLOR_YUV2BGR_YUYV
           
static int COLOR_YUV2BGR_YV12
           
static int COLOR_YUV2BGR_YVYU
           
static int COLOR_YUV2BGRA_I420
           
static int COLOR_YUV2BGRA_IYUV
           
static int COLOR_YUV2BGRA_NV12
           
static int COLOR_YUV2BGRA_NV21
           
static int COLOR_YUV2BGRA_UYNV
           
static int COLOR_YUV2BGRA_UYVY
           
static int COLOR_YUV2BGRA_Y422
           
static int COLOR_YUV2BGRA_YUNV
           
static int COLOR_YUV2BGRA_YUY2
           
static int COLOR_YUV2BGRA_YUYV
           
static int COLOR_YUV2BGRA_YV12
           
static int COLOR_YUV2BGRA_YVYU
           
static int COLOR_YUV2GRAY_420
           
static int COLOR_YUV2GRAY_I420
           
static int COLOR_YUV2GRAY_IYUV
           
static int COLOR_YUV2GRAY_NV12
           
static int COLOR_YUV2GRAY_NV21
           
static int COLOR_YUV2GRAY_UYNV
           
static int COLOR_YUV2GRAY_UYVY
           
static int COLOR_YUV2GRAY_Y422
           
static int COLOR_YUV2GRAY_YUNV
           
static int COLOR_YUV2GRAY_YUY2
           
static int COLOR_YUV2GRAY_YUYV
           
static int COLOR_YUV2GRAY_YV12
           
static int COLOR_YUV2GRAY_YVYU
           
static int COLOR_YUV2RGB
           
static int COLOR_YUV2RGB_I420
           
static int COLOR_YUV2RGB_IYUV
           
static int COLOR_YUV2RGB_NV12
           
static int COLOR_YUV2RGB_NV21
           
static int COLOR_YUV2RGB_UYNV
           
static int COLOR_YUV2RGB_UYVY
           
static int COLOR_YUV2RGB_Y422
           
static int COLOR_YUV2RGB_YUNV
           
static int COLOR_YUV2RGB_YUY2
           
static int COLOR_YUV2RGB_YUYV
           
static int COLOR_YUV2RGB_YV12
           
static int COLOR_YUV2RGB_YVYU
           
static int COLOR_YUV2RGBA_I420
           
static int COLOR_YUV2RGBA_IYUV
           
static int COLOR_YUV2RGBA_NV12
           
static int COLOR_YUV2RGBA_NV21
           
static int COLOR_YUV2RGBA_UYNV
           
static int COLOR_YUV2RGBA_UYVY
           
static int COLOR_YUV2RGBA_Y422
           
static int COLOR_YUV2RGBA_YUNV
           
static int COLOR_YUV2RGBA_YUY2
           
static int COLOR_YUV2RGBA_YUYV
           
static int COLOR_YUV2RGBA_YV12
           
static int COLOR_YUV2RGBA_YVYU
           
static int COLOR_YUV420p2BGR
           
static int COLOR_YUV420p2BGRA
           
static int COLOR_YUV420p2GRAY
           
static int COLOR_YUV420p2RGB
           
static int COLOR_YUV420p2RGBA
           
static int COLOR_YUV420sp2BGR
           
static int COLOR_YUV420sp2BGRA
           
static int COLOR_YUV420sp2GRAY
           
static int COLOR_YUV420sp2RGB
           
static int COLOR_YUV420sp2RGBA
           
static int CV_BILATERAL
           
static int CV_BLUR
           
static int CV_BLUR_NO_SCALE
           
static int CV_CANNY_L2_GRADIENT
           
static int CV_CHAIN_CODE
           
static int CV_CLOCKWISE
           
static int CV_COMP_BHATTACHARYYA
           
static int CV_COMP_CHISQR
           
static int CV_COMP_CORREL
           
static int CV_COMP_HELLINGER
           
static int CV_COMP_INTERSECT
           
static int CV_CONTOURS_MATCH_I1
           
static int CV_CONTOURS_MATCH_I2
           
static int CV_CONTOURS_MATCH_I3
           
static int CV_COUNTER_CLOCKWISE
           
static int CV_DIST_C
           
static int CV_DIST_FAIR
           
static int CV_DIST_HUBER
           
static int CV_DIST_L1
           
static int CV_DIST_L12
           
static int CV_DIST_L2
           
static int CV_DIST_LABEL_CCOMP
           
static int CV_DIST_LABEL_PIXEL
           
static int CV_DIST_MASK_3
           
static int CV_DIST_MASK_5
           
static int CV_DIST_MASK_PRECISE
           
static int CV_DIST_USER
           
static int CV_DIST_WELSCH
           
static int CV_GAUSSIAN
           
static int CV_GAUSSIAN_5x5
           
static int CV_HOUGH_GRADIENT
           
static int CV_HOUGH_MULTI_SCALE
           
static int CV_HOUGH_PROBABILISTIC
           
static int CV_HOUGH_STANDARD
           
static int CV_LINK_RUNS
           
static int CV_MAX_SOBEL_KSIZE
           
static int CV_MEDIAN
           
static int CV_mRGBA2RGBA
           
static int CV_POLY_APPROX_DP
           
static int CV_RGBA2mRGBA
           
static int CV_SCHARR
           
static int CV_SHAPE_CROSS
           
static int CV_SHAPE_CUSTOM
           
static int CV_SHAPE_ELLIPSE
           
static int CV_SHAPE_RECT
           
static int CV_WARP_FILL_OUTLIERS
           
static int CV_WARP_INVERSE_MAP
           
static int DIST_LABEL_CCOMP
           
static int DIST_LABEL_PIXEL
           
static int FLOODFILL_FIXED_RANGE
           
static int FLOODFILL_MASK_ONLY
           
static int GC_BGD
           
static int GC_EVAL
           
static int GC_FGD
           
static int GC_INIT_WITH_MASK
           
static int GC_INIT_WITH_RECT
           
static int GC_PR_BGD
           
static int GC_PR_FGD
           
static int GHT_POSITION
           
static int GHT_ROTATION
           
static int GHT_SCALE
           
static int INTER_AREA
           
static int INTER_BITS
           
static int INTER_BITS2
           
static int INTER_CUBIC
           
static int INTER_LANCZOS4
           
static int INTER_LINEAR
           
static int INTER_MAX
           
static int INTER_NEAREST
           
static int INTER_TAB_SIZE
           
static int INTER_TAB_SIZE2
           
static int KERNEL_ASYMMETRICAL
           
static int KERNEL_GENERAL
           
static int KERNEL_INTEGER
           
static int KERNEL_SMOOTH
           
static int KERNEL_SYMMETRICAL
           
static int MORPH_BLACKHAT
           
static int MORPH_CLOSE
           
static int MORPH_CROSS
           
static int MORPH_DILATE
           
static int MORPH_ELLIPSE
           
static int MORPH_ERODE
           
static int MORPH_GRADIENT
           
static int MORPH_OPEN
           
static int MORPH_RECT
           
static int MORPH_TOPHAT
           
static int PROJ_SPHERICAL_EQRECT
           
static int PROJ_SPHERICAL_ORTHO
           
static int RETR_CCOMP
           
static int RETR_EXTERNAL
           
static int RETR_FLOODFILL
           
static int RETR_LIST
           
static int RETR_TREE
           
static int THRESH_BINARY
           
static int THRESH_BINARY_INV
           
static int THRESH_MASK
           
static int THRESH_OTSU
           
static int THRESH_TOZERO
           
static int THRESH_TOZERO_INV
           
static int THRESH_TRUNC
           
static int TM_CCOEFF
           
static int TM_CCOEFF_NORMED
           
static int TM_CCORR
           
static int TM_CCORR_NORMED
           
static int TM_SQDIFF
           
static int TM_SQDIFF_NORMED
           
static int WARP_INVERSE_MAP
           
 
Constructor Summary
Imgproc()
           
 
Method Summary
static void accumulate(Mat src, Mat dst)
          Adds an image to the accumulator.
static void accumulate(Mat src, Mat dst, Mat mask)
          Adds an image to the accumulator.
static void accumulateProduct(Mat src1, Mat src2, Mat dst)
          Adds the per-element product of two input images to the accumulator.
static void accumulateProduct(Mat src1, Mat src2, Mat dst, Mat mask)
          Adds the per-element product of two input images to the accumulator.
static void accumulateSquare(Mat src, Mat dst)
          Adds the square of a source image to the accumulator.
static void accumulateSquare(Mat src, Mat dst, Mat mask)
          Adds the square of a source image to the accumulator.
static void accumulateWeighted(Mat src, Mat dst, double alpha)
          Updates a running average.
static void accumulateWeighted(Mat src, Mat dst, double alpha, Mat mask)
          Updates a running average.
static void adaptiveThreshold(Mat src, Mat dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C)
          Applies an adaptive threshold to an array.
static void approxPolyDP(MatOfPoint2f curve, MatOfPoint2f approxCurve, double epsilon, boolean closed)
          Approximates a polygonal curve(s) with the specified precision.
static double arcLength(MatOfPoint2f curve, boolean closed)
          Calculates a contour perimeter or a curve length.
static void bilateralFilter(Mat src, Mat dst, int d, double sigmaColor, double sigmaSpace)
          Applies the bilateral filter to an image.
static void bilateralFilter(Mat src, Mat dst, int d, double sigmaColor, double sigmaSpace, int borderType)
          Applies the bilateral filter to an image.
static void blur(Mat src, Mat dst, Size ksize)
          Blurs an image using the normalized box filter.
static void blur(Mat src, Mat dst, Size ksize, Point anchor)
          Blurs an image using the normalized box filter.
static void blur(Mat src, Mat dst, Size ksize, Point anchor, int borderType)
          Blurs an image using the normalized box filter.
static int borderInterpolate(int p, int len, int borderType)
          Computes the source location of an extrapolated pixel.
static Rect boundingRect(MatOfPoint points)
          Calculates the up-right bounding rectangle of a point set.
static void boxFilter(Mat src, Mat dst, int ddepth, Size ksize)
          Blurs an image using the box filter.
static void boxFilter(Mat src, Mat dst, int ddepth, Size ksize, Point anchor, boolean normalize)
          Blurs an image using the box filter.
static void boxFilter(Mat src, Mat dst, int ddepth, Size ksize, Point anchor, boolean normalize, int borderType)
          Blurs an image using the box filter.
static void calcBackProject(java.util.List<Mat> images, MatOfInt channels, Mat hist, Mat dst, MatOfFloat ranges, double scale)
          Calculates the back projection of a histogram.
static void calcHist(java.util.List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges)
          Calculates a histogram of a set of arrays.
static void calcHist(java.util.List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges, boolean accumulate)
          Calculates a histogram of a set of arrays.
static void Canny(Mat image, Mat edges, double threshold1, double threshold2)
          Finds edges in an image using the [Canny86] algorithm.
static void Canny(Mat image, Mat edges, double threshold1, double threshold2, int apertureSize, boolean L2gradient)
          Finds edges in an image using the [Canny86] algorithm.
static double compareHist(Mat H1, Mat H2, int method)
          Compares two histograms.
static double contourArea(Mat contour)
          Calculates a contour area.
static double contourArea(Mat contour, boolean oriented)
          Calculates a contour area.
static void convertMaps(Mat map1, Mat map2, Mat dstmap1, Mat dstmap2, int dstmap1type)
          Converts image transformation maps from one representation to another.
static void convertMaps(Mat map1, Mat map2, Mat dstmap1, Mat dstmap2, int dstmap1type, boolean nninterpolation)
          Converts image transformation maps from one representation to another.
static void convexHull(MatOfPoint points, MatOfInt hull)
          Finds the convex hull of a point set.
static void convexHull(MatOfPoint points, MatOfInt hull, boolean clockwise)
          Finds the convex hull of a point set.
static void convexityDefects(MatOfPoint contour, MatOfInt convexhull, MatOfInt4 convexityDefects)
          Finds the convexity defects of a contour.
static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType)
          Forms a border around an image.
static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType, Scalar value)
          Forms a border around an image.
static void cornerEigenValsAndVecs(Mat src, Mat dst, int blockSize, int ksize)
          Calculates eigenvalues and eigenvectors of image blocks for corner detection.
static void cornerEigenValsAndVecs(Mat src, Mat dst, int blockSize, int ksize, int borderType)
          Calculates eigenvalues and eigenvectors of image blocks for corner detection.
static void cornerHarris(Mat src, Mat dst, int blockSize, int ksize, double k)
          Harris edge detector.
static void cornerHarris(Mat src, Mat dst, int blockSize, int ksize, double k, int borderType)
          Harris edge detector.
static void cornerMinEigenVal(Mat src, Mat dst, int blockSize)
          Calculates the minimal eigenvalue of gradient matrices for corner detection.
static void cornerMinEigenVal(Mat src, Mat dst, int blockSize, int ksize)
          Calculates the minimal eigenvalue of gradient matrices for corner detection.
static void cornerMinEigenVal(Mat src, Mat dst, int blockSize, int ksize, int borderType)
          Calculates the minimal eigenvalue of gradient matrices for corner detection.
static void cornerSubPix(Mat image, MatOfPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria)
          Refines the corner locations.
static void createHanningWindow(Mat dst, Size winSize, int type)
          This function computes a Hanning window coefficients in two dimensions.
static void cvtColor(Mat src, Mat dst, int code)
          Converts an image from one color space to another.
static void cvtColor(Mat src, Mat dst, int code, int dstCn)
          Converts an image from one color space to another.
static void dilate(Mat src, Mat dst, Mat kernel)
          Dilates an image by using a specific structuring element.
static void dilate(Mat src, Mat dst, Mat kernel, Point anchor, int iterations)
          Dilates an image by using a specific structuring element.
static void dilate(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
          Dilates an image by using a specific structuring element.
static void distanceTransform(Mat src, Mat dst, int distanceType, int maskSize)
          Calculates the distance to the closest zero pixel for each pixel of the source image.
static void distanceTransformWithLabels(Mat src, Mat dst, Mat labels, int distanceType, int maskSize)
          Calculates the distance to the closest zero pixel for each pixel of the source image.
static void distanceTransformWithLabels(Mat src, Mat dst, Mat labels, int distanceType, int maskSize, int labelType)
          Calculates the distance to the closest zero pixel for each pixel of the source image.
static void drawContours(Mat image, java.util.List<MatOfPoint> contours, int contourIdx, Scalar color)
          Draws contours outlines or filled contours.
static void drawContours(Mat image, java.util.List<MatOfPoint> contours, int contourIdx, Scalar color, int thickness)
          Draws contours outlines or filled contours.
static void drawContours(Mat image, java.util.List<MatOfPoint> contours, int contourIdx, Scalar color, int thickness, int lineType, Mat hierarchy, int maxLevel, Point offset)
          Draws contours outlines or filled contours.
static void equalizeHist(Mat src, Mat dst)
          Equalizes the histogram of a grayscale image.
static void erode(Mat src, Mat dst, Mat kernel)
          Erodes an image by using a specific structuring element.
static void erode(Mat src, Mat dst, Mat kernel, Point anchor, int iterations)
          Erodes an image by using a specific structuring element.
static void erode(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
          Erodes an image by using a specific structuring element.
static void filter2D(Mat src, Mat dst, int ddepth, Mat kernel)
          Convolves an image with the kernel.
static void filter2D(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta)
          Convolves an image with the kernel.
static void filter2D(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta, int borderType)
          Convolves an image with the kernel.
static void findContours(Mat image, java.util.List<MatOfPoint> contours, Mat hierarchy, int mode, int method)
          Finds contours in a binary image.
static void findContours(Mat image, java.util.List<MatOfPoint> contours, Mat hierarchy, int mode, int method, Point offset)
          Finds contours in a binary image.
static RotatedRect fitEllipse(MatOfPoint2f points)
          Fits an ellipse around a set of 2D points.
static void fitLine(Mat points, Mat line, int distType, double param, double reps, double aeps)
          Fits a line to a 2D or 3D point set.
static int floodFill(Mat image, Mat mask, Point seedPoint, Scalar newVal)
          Fills a connected component with the given color.
static int floodFill(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff, int flags)
          Fills a connected component with the given color.
static void GaussianBlur(Mat src, Mat dst, Size ksize, double sigmaX)
          Blurs an image using a Gaussian filter.
static void GaussianBlur(Mat src, Mat dst, Size ksize, double sigmaX, double sigmaY)
          Blurs an image using a Gaussian filter.
static void GaussianBlur(Mat src, Mat dst, Size ksize, double sigmaX, double sigmaY, int borderType)
          Blurs an image using a Gaussian filter.
static Mat getAffineTransform(MatOfPoint2f src, MatOfPoint2f dst)
          Calculates an affine transform from three pairs of the corresponding points.
static Mat getDefaultNewCameraMatrix(Mat cameraMatrix)
          Returns the default new camera matrix.
static Mat getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize, boolean centerPrincipalPoint)
          Returns the default new camera matrix.
static void getDerivKernels(Mat kx, Mat ky, int dx, int dy, int ksize)
          Returns filter coefficients for computing spatial image derivatives.
static void getDerivKernels(Mat kx, Mat ky, int dx, int dy, int ksize, boolean normalize, int ktype)
          Returns filter coefficients for computing spatial image derivatives.
static Mat getGaborKernel(Size ksize, double sigma, double theta, double lambd, double gamma)
           
static Mat getGaborKernel(Size ksize, double sigma, double theta, double lambd, double gamma, double psi, int ktype)
           
static Mat getGaussianKernel(int ksize, double sigma)
          Returns Gaussian filter coefficients.
static Mat getGaussianKernel(int ksize, double sigma, int ktype)
          Returns Gaussian filter coefficients.
static Mat getPerspectiveTransform(Mat src, Mat dst)
          Calculates a perspective transform from four pairs of the corresponding points.
static void getRectSubPix(Mat image, Size patchSize, Point center, Mat patch)
          Retrieves a pixel rectangle from an image with sub-pixel accuracy.
static void getRectSubPix(Mat image, Size patchSize, Point center, Mat patch, int patchType)
          Retrieves a pixel rectangle from an image with sub-pixel accuracy.
static Mat getRotationMatrix2D(Point center, double angle, double scale)
          Calculates an affine matrix of 2D rotation.
static Mat getStructuringElement(int shape, Size ksize)
          Returns a structuring element of the specified size and shape for morphological operations.
static Mat getStructuringElement(int shape, Size ksize, Point anchor)
          Returns a structuring element of the specified size and shape for morphological operations.
static void goodFeaturesToTrack(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance)
          Determines strong corners on an image.
static void goodFeaturesToTrack(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, boolean useHarrisDetector, double k)
          Determines strong corners on an image.
static void grabCut(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount)
          Runs the GrabCut algorithm.
static void grabCut(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount, int mode)
          Runs the GrabCut algorithm.
static void HoughCircles(Mat image, Mat circles, int method, double dp, double minDist)
          Finds circles in a grayscale image using the Hough transform.
static void HoughCircles(Mat image, Mat circles, int method, double dp, double minDist, double param1, double param2, int minRadius, int maxRadius)
          Finds circles in a grayscale image using the Hough transform.
static void HoughLines(Mat image, Mat lines, double rho, double theta, int threshold)
          Finds lines in a binary image using the standard Hough transform.
static void HoughLines(Mat image, Mat lines, double rho, double theta, int threshold, double srn, double stn)
          Finds lines in a binary image using the standard Hough transform.
static void HoughLinesP(Mat image, Mat lines, double rho, double theta, int threshold)
          Finds line segments in a binary image using the probabilistic Hough transform.
static void HoughLinesP(Mat image, Mat lines, double rho, double theta, int threshold, double minLineLength, double maxLineGap)
          Finds line segments in a binary image using the probabilistic Hough transform.
static void HuMoments(Moments m, Mat hu)
          Calculates seven Hu invariants.
static void initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat map1, Mat map2)
          Computes the undistortion and rectification transformation map.
static float initWideAngleProjMap(Mat cameraMatrix, Mat distCoeffs, Size imageSize, int destImageWidth, int m1type, Mat map1, Mat map2)
           
static float initWideAngleProjMap(Mat cameraMatrix, Mat distCoeffs, Size imageSize, int destImageWidth, int m1type, Mat map1, Mat map2, int projType, double alpha)
           
static void integral(Mat src, Mat sum)
          Calculates the integral of an image.
static void integral(Mat src, Mat sum, int sdepth)
          Calculates the integral of an image.
static void integral2(Mat src, Mat sum, Mat sqsum)
          Calculates the integral of an image.
static void integral2(Mat src, Mat sum, Mat sqsum, int sdepth)
          Calculates the integral of an image.
static void integral3(Mat src, Mat sum, Mat sqsum, Mat tilted)
          Calculates the integral of an image.
static void integral3(Mat src, Mat sum, Mat sqsum, Mat tilted, int sdepth)
          Calculates the integral of an image.
static float intersectConvexConvex(Mat _p1, Mat _p2, Mat _p12)
           
static float intersectConvexConvex(Mat _p1, Mat _p2, Mat _p12, boolean handleNested)
           
static void invertAffineTransform(Mat M, Mat iM)
          Inverts an affine transformation.
static boolean isContourConvex(MatOfPoint contour)
          Tests a contour convexity.
static void Laplacian(Mat src, Mat dst, int ddepth)
          Calculates the Laplacian of an image.
static void Laplacian(Mat src, Mat dst, int ddepth, int ksize, double scale, double delta)
          Calculates the Laplacian of an image.
static void Laplacian(Mat src, Mat dst, int ddepth, int ksize, double scale, double delta, int borderType)
          Calculates the Laplacian of an image.
static double matchShapes(Mat contour1, Mat contour2, int method, double parameter)
          Compares two shapes.
static void matchTemplate(Mat image, Mat templ, Mat result, int method)
          Compares a template against overlapped image regions.
static void medianBlur(Mat src, Mat dst, int ksize)
          Blurs an image using the median filter.
static RotatedRect minAreaRect(MatOfPoint2f points)
          Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
static void minEnclosingCircle(MatOfPoint2f points, Point center, float[] radius)
          Finds a circle of the minimum area enclosing a 2D point set.
static Moments moments(Mat array)
          Calculates all of the moments up to the third order of a polygon or rasterized shape.
static Moments moments(Mat array, boolean binaryImage)
          Calculates all of the moments up to the third order of a polygon or rasterized shape.
static void morphologyEx(Mat src, Mat dst, int op, Mat kernel)
          Performs advanced morphological transformations.
static void morphologyEx(Mat src, Mat dst, int op, Mat kernel, Point anchor, int iterations)
          Performs advanced morphological transformations.
static void morphologyEx(Mat src, Mat dst, int op, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
          Performs advanced morphological transformations.
static Point phaseCorrelate(Mat src1, Mat src2)
          The function is used to detect translational shifts that occur between two images.
static Point phaseCorrelate(Mat src1, Mat src2, Mat window)
          The function is used to detect translational shifts that occur between two images.
static Point phaseCorrelateRes(Mat src1, Mat src2, Mat window)
           
static Point phaseCorrelateRes(Mat src1, Mat src2, Mat window, double[] response)
           
static double pointPolygonTest(MatOfPoint2f contour, Point pt, boolean measureDist)
          Performs a point-in-contour test.
static void preCornerDetect(Mat src, Mat dst, int ksize)
          Calculates a feature map for corner detection.
static void preCornerDetect(Mat src, Mat dst, int ksize, int borderType)
          Calculates a feature map for corner detection.
static double PSNR(Mat src1, Mat src2)
           
static void pyrDown(Mat src, Mat dst)
          Blurs an image and downsamples it.
static void pyrDown(Mat src, Mat dst, Size dstsize)
          Blurs an image and downsamples it.
static void pyrDown(Mat src, Mat dst, Size dstsize, int borderType)
          Blurs an image and downsamples it.
static void pyrMeanShiftFiltering(Mat src, Mat dst, double sp, double sr)
          Performs initial step of meanshift segmentation of an image.
static void pyrMeanShiftFiltering(Mat src, Mat dst, double sp, double sr, int maxLevel, TermCriteria termcrit)
          Performs initial step of meanshift segmentation of an image.
static void pyrUp(Mat src, Mat dst)
          Upsamples an image and then blurs it.
static void pyrUp(Mat src, Mat dst, Size dstsize)
          Upsamples an image and then blurs it.
static void pyrUp(Mat src, Mat dst, Size dstsize, int borderType)
          Upsamples an image and then blurs it.
static void remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation)
          Applies a generic geometrical transformation to an image.
static void remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, int borderMode, Scalar borderValue)
          Applies a generic geometrical transformation to an image.
static void resize(Mat src, Mat dst, Size dsize)
          Resizes an image.
static void resize(Mat src, Mat dst, Size dsize, double fx, double fy, int interpolation)
          Resizes an image.
static void Scharr(Mat src, Mat dst, int ddepth, int dx, int dy)
          Calculates the first x- or y- image derivative using Scharr operator.
static void Scharr(Mat src, Mat dst, int ddepth, int dx, int dy, double scale, double delta)
          Calculates the first x- or y- image derivative using Scharr operator.
static void Scharr(Mat src, Mat dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
          Calculates the first x- or y- image derivative using Scharr operator.
static void sepFilter2D(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY)
          Applies a separable linear filter to an image.
static void sepFilter2D(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta)
          Applies a separable linear filter to an image.
static void sepFilter2D(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta, int borderType)
          Applies a separable linear filter to an image.
static void Sobel(Mat src, Mat dst, int ddepth, int dx, int dy)
          Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
static void Sobel(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale, double delta)
          Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
static void Sobel(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
          Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
static double threshold(Mat src, Mat dst, double thresh, double maxval, int type)
          Applies a fixed-level threshold to each array element.
static void undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs)
          Transforms an image to compensate for lens distortion.
static void undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix)
          Transforms an image to compensate for lens distortion.
static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs)
          Computes the ideal point coordinates from the observed point coordinates.
static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P)
          Computes the ideal point coordinates from the observed point coordinates.
static void warpAffine(Mat src, Mat dst, Mat M, Size dsize)
          Applies an affine transformation to an image.
static void warpAffine(Mat src, Mat dst, Mat M, Size dsize, int flags)
          Applies an affine transformation to an image.
static void warpAffine(Mat src, Mat dst, Mat M, Size dsize, int flags, int borderMode, Scalar borderValue)
          Applies an affine transformation to an image.
static void warpPerspective(Mat src, Mat dst, Mat M, Size dsize)
          Applies a perspective transformation to an image.
static void warpPerspective(Mat src, Mat dst, Mat M, Size dsize, int flags)
          Applies a perspective transformation to an image.
static void warpPerspective(Mat src, Mat dst, Mat M, Size dsize, int flags, int borderMode, Scalar borderValue)
          Applies a perspective transformation to an image.
static void watershed(Mat image, Mat markers)
          Performs a marker-based image segmentation using the watershed algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADAPTIVE_THRESH_GAUSSIAN_C

public static final int ADAPTIVE_THRESH_GAUSSIAN_C
See Also:
Constant Field Values

ADAPTIVE_THRESH_MEAN_C

public static final int ADAPTIVE_THRESH_MEAN_C
See Also:
Constant Field Values

BORDER_CONSTANT

public static final int BORDER_CONSTANT
See Also:
Constant Field Values

BORDER_DEFAULT

public static final int BORDER_DEFAULT
See Also:
Constant Field Values

BORDER_ISOLATED

public static final int BORDER_ISOLATED
See Also:
Constant Field Values

BORDER_REFLECT

public static final int BORDER_REFLECT
See Also:
Constant Field Values

BORDER_REFLECT_101

public static final int BORDER_REFLECT_101
See Also:
Constant Field Values

BORDER_REFLECT101

public static final int BORDER_REFLECT101
See Also:
Constant Field Values

BORDER_REPLICATE

public static final int BORDER_REPLICATE
See Also:
Constant Field Values

BORDER_TRANSPARENT

public static final int BORDER_TRANSPARENT
See Also:
Constant Field Values

BORDER_WRAP

public static final int BORDER_WRAP
See Also:
Constant Field Values

CHAIN_APPROX_NONE

public static final int CHAIN_APPROX_NONE
See Also:
Constant Field Values

CHAIN_APPROX_SIMPLE

public static final int CHAIN_APPROX_SIMPLE
See Also:
Constant Field Values

CHAIN_APPROX_TC89_KCOS

public static final int CHAIN_APPROX_TC89_KCOS
See Also:
Constant Field Values

CHAIN_APPROX_TC89_L1

public static final int CHAIN_APPROX_TC89_L1
See Also:
Constant Field Values

COLOR_BayerBG2BGR

public static final int COLOR_BayerBG2BGR
See Also:
Constant Field Values

COLOR_BayerBG2BGR_VNG

public static final int COLOR_BayerBG2BGR_VNG
See Also:
Constant Field Values

COLOR_BayerBG2GRAY

public static final int COLOR_BayerBG2GRAY
See Also:
Constant Field Values

COLOR_BayerBG2RGB

public static final int COLOR_BayerBG2RGB
See Also:
Constant Field Values

COLOR_BayerBG2RGB_VNG

public static final int COLOR_BayerBG2RGB_VNG
See Also:
Constant Field Values

COLOR_BayerGB2BGR

public static final int COLOR_BayerGB2BGR
See Also:
Constant Field Values

COLOR_BayerGB2BGR_VNG

public static final int COLOR_BayerGB2BGR_VNG
See Also:
Constant Field Values

COLOR_BayerGB2GRAY

public static final int COLOR_BayerGB2GRAY
See Also:
Constant Field Values

COLOR_BayerGB2RGB

public static final int COLOR_BayerGB2RGB
See Also:
Constant Field Values

COLOR_BayerGB2RGB_VNG

public static final int COLOR_BayerGB2RGB_VNG
See Also:
Constant Field Values

COLOR_BayerGR2BGR

public static final int COLOR_BayerGR2BGR
See Also:
Constant Field Values

COLOR_BayerGR2BGR_VNG

public static final int COLOR_BayerGR2BGR_VNG
See Also:
Constant Field Values

COLOR_BayerGR2GRAY

public static final int COLOR_BayerGR2GRAY
See Also:
Constant Field Values

COLOR_BayerGR2RGB

public static final int COLOR_BayerGR2RGB
See Also:
Constant Field Values

COLOR_BayerGR2RGB_VNG

public static final int COLOR_BayerGR2RGB_VNG
See Also:
Constant Field Values

COLOR_BayerRG2BGR

public static final int COLOR_BayerRG2BGR
See Also:
Constant Field Values

COLOR_BayerRG2BGR_VNG

public static final int COLOR_BayerRG2BGR_VNG
See Also:
Constant Field Values

COLOR_BayerRG2GRAY

public static final int COLOR_BayerRG2GRAY
See Also:
Constant Field Values

COLOR_BayerRG2RGB

public static final int COLOR_BayerRG2RGB
See Also:
Constant Field Values

COLOR_BayerRG2RGB_VNG

public static final int COLOR_BayerRG2RGB_VNG
See Also:
Constant Field Values

COLOR_BGR2BGR555

public static final int COLOR_BGR2BGR555
See Also:
Constant Field Values

COLOR_BGR2BGR565

public static final int COLOR_BGR2BGR565
See Also:
Constant Field Values

COLOR_BGR2BGRA

public static final int COLOR_BGR2BGRA
See Also:
Constant Field Values

COLOR_BGR2GRAY

public static final int COLOR_BGR2GRAY
See Also:
Constant Field Values

COLOR_BGR2HLS

public static final int COLOR_BGR2HLS
See Also:
Constant Field Values

COLOR_BGR2HLS_FULL

public static final int COLOR_BGR2HLS_FULL
See Also:
Constant Field Values

COLOR_BGR2HSV

public static final int COLOR_BGR2HSV
See Also:
Constant Field Values

COLOR_BGR2HSV_FULL

public static final int COLOR_BGR2HSV_FULL
See Also:
Constant Field Values

COLOR_BGR2Lab

public static final int COLOR_BGR2Lab
See Also:
Constant Field Values

COLOR_BGR2Luv

public static final int COLOR_BGR2Luv
See Also:
Constant Field Values

COLOR_BGR2RGB

public static final int COLOR_BGR2RGB
See Also:
Constant Field Values

COLOR_BGR2RGBA

public static final int COLOR_BGR2RGBA
See Also:
Constant Field Values

COLOR_BGR2XYZ

public static final int COLOR_BGR2XYZ
See Also:
Constant Field Values

COLOR_BGR2YCrCb

public static final int COLOR_BGR2YCrCb
See Also:
Constant Field Values

COLOR_BGR2YUV

public static final int COLOR_BGR2YUV
See Also:
Constant Field Values

COLOR_BGR2YUV_I420

public static final int COLOR_BGR2YUV_I420
See Also:
Constant Field Values

COLOR_BGR2YUV_IYUV

public static final int COLOR_BGR2YUV_IYUV
See Also:
Constant Field Values

COLOR_BGR2YUV_YV12

public static final int COLOR_BGR2YUV_YV12
See Also:
Constant Field Values

COLOR_BGR5552BGR

public static final int COLOR_BGR5552BGR
See Also:
Constant Field Values

COLOR_BGR5552BGRA

public static final int COLOR_BGR5552BGRA
See Also:
Constant Field Values

COLOR_BGR5552GRAY

public static final int COLOR_BGR5552GRAY
See Also:
Constant Field Values

COLOR_BGR5552RGB

public static final int COLOR_BGR5552RGB
See Also:
Constant Field Values

COLOR_BGR5552RGBA

public static final int COLOR_BGR5552RGBA
See Also:
Constant Field Values

COLOR_BGR5652BGR

public static final int COLOR_BGR5652BGR
See Also:
Constant Field Values

COLOR_BGR5652BGRA

public static final int COLOR_BGR5652BGRA
See Also:
Constant Field Values

COLOR_BGR5652GRAY

public static final int COLOR_BGR5652GRAY
See Also:
Constant Field Values

COLOR_BGR5652RGB

public static final int COLOR_BGR5652RGB
See Also:
Constant Field Values

COLOR_BGR5652RGBA

public static final int COLOR_BGR5652RGBA
See Also:
Constant Field Values

COLOR_BGRA2BGR

public static final int COLOR_BGRA2BGR
See Also:
Constant Field Values

COLOR_BGRA2BGR555

public static final int COLOR_BGRA2BGR555
See Also:
Constant Field Values

COLOR_BGRA2BGR565

public static final int COLOR_BGRA2BGR565
See Also:
Constant Field Values

COLOR_BGRA2GRAY

public static final int COLOR_BGRA2GRAY
See Also:
Constant Field Values

COLOR_BGRA2RGB

public static final int COLOR_BGRA2RGB
See Also:
Constant Field Values

COLOR_BGRA2RGBA

public static final int COLOR_BGRA2RGBA
See Also:
Constant Field Values

COLOR_BGRA2YUV_I420

public static final int COLOR_BGRA2YUV_I420
See Also:
Constant Field Values

COLOR_BGRA2YUV_IYUV

public static final int COLOR_BGRA2YUV_IYUV
See Also:
Constant Field Values

COLOR_BGRA2YUV_YV12

public static final int COLOR_BGRA2YUV_YV12
See Also:
Constant Field Values

COLOR_COLORCVT_MAX

public static final int COLOR_COLORCVT_MAX
See Also:
Constant Field Values

COLOR_GRAY2BGR

public static final int COLOR_GRAY2BGR
See Also:
Constant Field Values

COLOR_GRAY2BGR555

public static final int COLOR_GRAY2BGR555
See Also:
Constant Field Values

COLOR_GRAY2BGR565

public static final int COLOR_GRAY2BGR565
See Also:
Constant Field Values

COLOR_GRAY2BGRA

public static final int COLOR_GRAY2BGRA
See Also:
Constant Field Values

COLOR_GRAY2RGB

public static final int COLOR_GRAY2RGB
See Also:
Constant Field Values

COLOR_GRAY2RGBA

public static final int COLOR_GRAY2RGBA
See Also:
Constant Field Values

COLOR_HLS2BGR

public static final int COLOR_HLS2BGR
See Also:
Constant Field Values

COLOR_HLS2BGR_FULL

public static final int COLOR_HLS2BGR_FULL
See Also:
Constant Field Values

COLOR_HLS2RGB

public static final int COLOR_HLS2RGB
See Also:
Constant Field Values

COLOR_HLS2RGB_FULL

public static final int COLOR_HLS2RGB_FULL
See Also:
Constant Field Values

COLOR_HSV2BGR

public static final int COLOR_HSV2BGR
See Also:
Constant Field Values

COLOR_HSV2BGR_FULL

public static final int COLOR_HSV2BGR_FULL
See Also:
Constant Field Values

COLOR_HSV2RGB

public static final int COLOR_HSV2RGB
See Also:
Constant Field Values

COLOR_HSV2RGB_FULL

public static final int COLOR_HSV2RGB_FULL
See Also:
Constant Field Values

COLOR_Lab2BGR

public static final int COLOR_Lab2BGR
See Also:
Constant Field Values

COLOR_Lab2LBGR

public static final int COLOR_Lab2LBGR
See Also:
Constant Field Values

COLOR_Lab2LRGB

public static final int COLOR_Lab2LRGB
See Also:
Constant Field Values

COLOR_Lab2RGB

public static final int COLOR_Lab2RGB
See Also:
Constant Field Values

COLOR_LBGR2Lab

public static final int COLOR_LBGR2Lab
See Also:
Constant Field Values

COLOR_LBGR2Luv

public static final int COLOR_LBGR2Luv
See Also:
Constant Field Values

COLOR_LRGB2Lab

public static final int COLOR_LRGB2Lab
See Also:
Constant Field Values

COLOR_LRGB2Luv

public static final int COLOR_LRGB2Luv
See Also:
Constant Field Values

COLOR_Luv2BGR

public static final int COLOR_Luv2BGR
See Also:
Constant Field Values

COLOR_Luv2LBGR

public static final int COLOR_Luv2LBGR
See Also:
Constant Field Values

COLOR_Luv2LRGB

public static final int COLOR_Luv2LRGB
See Also:
Constant Field Values

COLOR_Luv2RGB

public static final int COLOR_Luv2RGB
See Also:
Constant Field Values

COLOR_mRGBA2RGBA

public static final int COLOR_mRGBA2RGBA
See Also:
Constant Field Values

COLOR_RGB2BGR

public static final int COLOR_RGB2BGR
See Also:
Constant Field Values

COLOR_RGB2BGR555

public static final int COLOR_RGB2BGR555
See Also:
Constant Field Values

COLOR_RGB2BGR565

public static final int COLOR_RGB2BGR565
See Also:
Constant Field Values

COLOR_RGB2BGRA

public static final int COLOR_RGB2BGRA
See Also:
Constant Field Values

COLOR_RGB2GRAY

public static final int COLOR_RGB2GRAY
See Also:
Constant Field Values

COLOR_RGB2HLS

public static final int COLOR_RGB2HLS
See Also:
Constant Field Values

COLOR_RGB2HLS_FULL

public static final int COLOR_RGB2HLS_FULL
See Also:
Constant Field Values

COLOR_RGB2HSV

public static final int COLOR_RGB2HSV
See Also:
Constant Field Values

COLOR_RGB2HSV_FULL

public static final int COLOR_RGB2HSV_FULL
See Also:
Constant Field Values

COLOR_RGB2Lab

public static final int COLOR_RGB2Lab
See Also:
Constant Field Values

COLOR_RGB2Luv

public static final int COLOR_RGB2Luv
See Also:
Constant Field Values

COLOR_RGB2RGBA

public static final int COLOR_RGB2RGBA
See Also:
Constant Field Values

COLOR_RGB2XYZ

public static final int COLOR_RGB2XYZ
See Also:
Constant Field Values

COLOR_RGB2YCrCb

public static final int COLOR_RGB2YCrCb
See Also:
Constant Field Values

COLOR_RGB2YUV

public static final int COLOR_RGB2YUV
See Also:
Constant Field Values

COLOR_RGB2YUV_I420

public static final int COLOR_RGB2YUV_I420
See Also:
Constant Field Values

COLOR_RGB2YUV_IYUV

public static final int COLOR_RGB2YUV_IYUV
See Also:
Constant Field Values

COLOR_RGB2YUV_YV12

public static final int COLOR_RGB2YUV_YV12
See Also:
Constant Field Values

COLOR_RGBA2BGR

public static final int COLOR_RGBA2BGR
See Also:
Constant Field Values

COLOR_RGBA2BGR555

public static final int COLOR_RGBA2BGR555
See Also:
Constant Field Values

COLOR_RGBA2BGR565

public static final int COLOR_RGBA2BGR565
See Also:
Constant Field Values

COLOR_RGBA2BGRA

public static final int COLOR_RGBA2BGRA
See Also:
Constant Field Values

COLOR_RGBA2GRAY

public static final int COLOR_RGBA2GRAY
See Also:
Constant Field Values

COLOR_RGBA2mRGBA

public static final int COLOR_RGBA2mRGBA
See Also:
Constant Field Values

COLOR_RGBA2RGB

public static final int COLOR_RGBA2RGB
See Also:
Constant Field Values

COLOR_RGBA2YUV_I420

public static final int COLOR_RGBA2YUV_I420
See Also:
Constant Field Values

COLOR_RGBA2YUV_IYUV

public static final int COLOR_RGBA2YUV_IYUV
See Also:
Constant Field Values

COLOR_RGBA2YUV_YV12

public static final int COLOR_RGBA2YUV_YV12
See Also:
Constant Field Values

COLOR_XYZ2BGR

public static final int COLOR_XYZ2BGR
See Also:
Constant Field Values

COLOR_XYZ2RGB

public static final int COLOR_XYZ2RGB
See Also:
Constant Field Values

COLOR_YCrCb2BGR

public static final int COLOR_YCrCb2BGR
See Also:
Constant Field Values

COLOR_YCrCb2RGB

public static final int COLOR_YCrCb2RGB
See Also:
Constant Field Values

COLOR_YUV2BGR

public static final int COLOR_YUV2BGR
See Also:
Constant Field Values

COLOR_YUV2BGR_I420

public static final int COLOR_YUV2BGR_I420
See Also:
Constant Field Values

COLOR_YUV2BGR_IYUV

public static final int COLOR_YUV2BGR_IYUV
See Also:
Constant Field Values

COLOR_YUV2BGR_NV12

public static final int COLOR_YUV2BGR_NV12
See Also:
Constant Field Values

COLOR_YUV2BGR_NV21

public static final int COLOR_YUV2BGR_NV21
See Also:
Constant Field Values

COLOR_YUV2BGR_UYNV

public static final int COLOR_YUV2BGR_UYNV
See Also:
Constant Field Values

COLOR_YUV2BGR_UYVY

public static final int COLOR_YUV2BGR_UYVY
See Also:
Constant Field Values

COLOR_YUV2BGR_Y422

public static final int COLOR_YUV2BGR_Y422
See Also:
Constant Field Values

COLOR_YUV2BGR_YUNV

public static final int COLOR_YUV2BGR_YUNV
See Also:
Constant Field Values

COLOR_YUV2BGR_YUY2

public static final int COLOR_YUV2BGR_YUY2
See Also:
Constant Field Values

COLOR_YUV2BGR_YUYV

public static final int COLOR_YUV2BGR_YUYV
See Also:
Constant Field Values

COLOR_YUV2BGR_YV12

public static final int COLOR_YUV2BGR_YV12
See Also:
Constant Field Values

COLOR_YUV2BGR_YVYU

public static final int COLOR_YUV2BGR_YVYU
See Also:
Constant Field Values

COLOR_YUV2BGRA_I420

public static final int COLOR_YUV2BGRA_I420
See Also:
Constant Field Values

COLOR_YUV2BGRA_IYUV

public static final int COLOR_YUV2BGRA_IYUV
See Also:
Constant Field Values

COLOR_YUV2BGRA_NV12

public static final int COLOR_YUV2BGRA_NV12
See Also:
Constant Field Values

COLOR_YUV2BGRA_NV21

public static final int COLOR_YUV2BGRA_NV21
See Also:
Constant Field Values

COLOR_YUV2BGRA_UYNV

public static final int COLOR_YUV2BGRA_UYNV
See Also:
Constant Field Values

COLOR_YUV2BGRA_UYVY

public static final int COLOR_YUV2BGRA_UYVY
See Also:
Constant Field Values

COLOR_YUV2BGRA_Y422

public static final int COLOR_YUV2BGRA_Y422
See Also:
Constant Field Values

COLOR_YUV2BGRA_YUNV

public static final int COLOR_YUV2BGRA_YUNV
See Also:
Constant Field Values

COLOR_YUV2BGRA_YUY2

public static final int COLOR_YUV2BGRA_YUY2
See Also:
Constant Field Values

COLOR_YUV2BGRA_YUYV

public static final int COLOR_YUV2BGRA_YUYV
See Also:
Constant Field Values

COLOR_YUV2BGRA_YV12

public static final int COLOR_YUV2BGRA_YV12
See Also:
Constant Field Values

COLOR_YUV2BGRA_YVYU

public static final int COLOR_YUV2BGRA_YVYU
See Also:
Constant Field Values

COLOR_YUV2GRAY_420

public static final int COLOR_YUV2GRAY_420
See Also:
Constant Field Values

COLOR_YUV2GRAY_I420

public static final int COLOR_YUV2GRAY_I420
See Also:
Constant Field Values

COLOR_YUV2GRAY_IYUV

public static final int COLOR_YUV2GRAY_IYUV
See Also:
Constant Field Values

COLOR_YUV2GRAY_NV12

public static final int COLOR_YUV2GRAY_NV12
See Also:
Constant Field Values

COLOR_YUV2GRAY_NV21

public static final int COLOR_YUV2GRAY_NV21
See Also:
Constant Field Values

COLOR_YUV2GRAY_UYNV

public static final int COLOR_YUV2GRAY_UYNV
See Also:
Constant Field Values

COLOR_YUV2GRAY_UYVY

public static final int COLOR_YUV2GRAY_UYVY
See Also:
Constant Field Values

COLOR_YUV2GRAY_Y422

public static final int COLOR_YUV2GRAY_Y422
See Also:
Constant Field Values

COLOR_YUV2GRAY_YUNV

public static final int COLOR_YUV2GRAY_YUNV
See Also:
Constant Field Values

COLOR_YUV2GRAY_YUY2

public static final int COLOR_YUV2GRAY_YUY2
See Also:
Constant Field Values

COLOR_YUV2GRAY_YUYV

public static final int COLOR_YUV2GRAY_YUYV
See Also:
Constant Field Values

COLOR_YUV2GRAY_YV12

public static final int COLOR_YUV2GRAY_YV12
See Also:
Constant Field Values

COLOR_YUV2GRAY_YVYU

public static final int COLOR_YUV2GRAY_YVYU
See Also:
Constant Field Values

COLOR_YUV2RGB

public static final int COLOR_YUV2RGB
See Also:
Constant Field Values

COLOR_YUV2RGB_I420

public static final int COLOR_YUV2RGB_I420
See Also:
Constant Field Values

COLOR_YUV2RGB_IYUV

public static final int COLOR_YUV2RGB_IYUV
See Also:
Constant Field Values

COLOR_YUV2RGB_NV12

public static final int COLOR_YUV2RGB_NV12
See Also:
Constant Field Values

COLOR_YUV2RGB_NV21

public static final int COLOR_YUV2RGB_NV21
See Also:
Constant Field Values

COLOR_YUV2RGB_UYNV

public static final int COLOR_YUV2RGB_UYNV
See Also:
Constant Field Values

COLOR_YUV2RGB_UYVY

public static final int COLOR_YUV2RGB_UYVY
See Also:
Constant Field Values

COLOR_YUV2RGB_Y422

public static final int COLOR_YUV2RGB_Y422
See Also:
Constant Field Values

COLOR_YUV2RGB_YUNV

public static final int COLOR_YUV2RGB_YUNV
See Also:
Constant Field Values

COLOR_YUV2RGB_YUY2

public static final int COLOR_YUV2RGB_YUY2
See Also:
Constant Field Values

COLOR_YUV2RGB_YUYV

public static final int COLOR_YUV2RGB_YUYV
See Also:
Constant Field Values

COLOR_YUV2RGB_YV12

public static final int COLOR_YUV2RGB_YV12
See Also:
Constant Field Values

COLOR_YUV2RGB_YVYU

public static final int COLOR_YUV2RGB_YVYU
See Also:
Constant Field Values

COLOR_YUV2RGBA_I420

public static final int COLOR_YUV2RGBA_I420
See Also:
Constant Field Values

COLOR_YUV2RGBA_IYUV

public static final int COLOR_YUV2RGBA_IYUV
See Also:
Constant Field Values

COLOR_YUV2RGBA_NV12

public static final int COLOR_YUV2RGBA_NV12
See Also:
Constant Field Values

COLOR_YUV2RGBA_NV21

public static final int COLOR_YUV2RGBA_NV21
See Also:
Constant Field Values

COLOR_YUV2RGBA_UYNV

public static final int COLOR_YUV2RGBA_UYNV
See Also:
Constant Field Values

COLOR_YUV2RGBA_UYVY

public static final int COLOR_YUV2RGBA_UYVY
See Also:
Constant Field Values

COLOR_YUV2RGBA_Y422

public static final int COLOR_YUV2RGBA_Y422
See Also:
Constant Field Values

COLOR_YUV2RGBA_YUNV

public static final int COLOR_YUV2RGBA_YUNV
See Also:
Constant Field Values

COLOR_YUV2RGBA_YUY2

public static final int COLOR_YUV2RGBA_YUY2
See Also:
Constant Field Values

COLOR_YUV2RGBA_YUYV

public static final int COLOR_YUV2RGBA_YUYV
See Also:
Constant Field Values

COLOR_YUV2RGBA_YV12

public static final int COLOR_YUV2RGBA_YV12
See Also:
Constant Field Values

COLOR_YUV2RGBA_YVYU

public static final int COLOR_YUV2RGBA_YVYU
See Also:
Constant Field Values

COLOR_YUV420p2BGR

public static final int COLOR_YUV420p2BGR
See Also:
Constant Field Values

COLOR_YUV420p2BGRA

public static final int COLOR_YUV420p2BGRA
See Also:
Constant Field Values

COLOR_YUV420p2GRAY

public static final int COLOR_YUV420p2GRAY
See Also:
Constant Field Values

COLOR_YUV420p2RGB

public static final int COLOR_YUV420p2RGB
See Also:
Constant Field Values

COLOR_YUV420p2RGBA

public static final int COLOR_YUV420p2RGBA
See Also:
Constant Field Values

COLOR_YUV420sp2BGR

public static final int COLOR_YUV420sp2BGR
See Also:
Constant Field Values

COLOR_YUV420sp2BGRA

public static final int COLOR_YUV420sp2BGRA
See Also:
Constant Field Values

COLOR_YUV420sp2GRAY

public static final int COLOR_YUV420sp2GRAY
See Also:
Constant Field Values

COLOR_YUV420sp2RGB

public static final int COLOR_YUV420sp2RGB
See Also:
Constant Field Values

COLOR_YUV420sp2RGBA

public static final int COLOR_YUV420sp2RGBA
See Also:
Constant Field Values

CV_BILATERAL

public static final int CV_BILATERAL
See Also:
Constant Field Values

CV_BLUR

public static final int CV_BLUR
See Also:
Constant Field Values

CV_BLUR_NO_SCALE

public static final int CV_BLUR_NO_SCALE
See Also:
Constant Field Values

CV_CANNY_L2_GRADIENT

public static final int CV_CANNY_L2_GRADIENT
See Also:
Constant Field Values

CV_CHAIN_CODE

public static final int CV_CHAIN_CODE
See Also:
Constant Field Values

CV_CLOCKWISE

public static final int CV_CLOCKWISE
See Also:
Constant Field Values

CV_COMP_BHATTACHARYYA

public static final int CV_COMP_BHATTACHARYYA
See Also:
Constant Field Values

CV_COMP_CHISQR

public static final int CV_COMP_CHISQR
See Also:
Constant Field Values

CV_COMP_CORREL

public static final int CV_COMP_CORREL
See Also:
Constant Field Values

CV_COMP_HELLINGER

public static final int CV_COMP_HELLINGER
See Also:
Constant Field Values

CV_COMP_INTERSECT

public static final int CV_COMP_INTERSECT
See Also:
Constant Field Values

CV_CONTOURS_MATCH_I1

public static final int CV_CONTOURS_MATCH_I1
See Also:
Constant Field Values

CV_CONTOURS_MATCH_I2

public static final int CV_CONTOURS_MATCH_I2
See Also:
Constant Field Values

CV_CONTOURS_MATCH_I3

public static final int CV_CONTOURS_MATCH_I3
See Also:
Constant Field Values

CV_COUNTER_CLOCKWISE

public static final int CV_COUNTER_CLOCKWISE
See Also:
Constant Field Values

CV_DIST_C

public static final int CV_DIST_C
See Also:
Constant Field Values

CV_DIST_FAIR

public static final int CV_DIST_FAIR
See Also:
Constant Field Values

CV_DIST_HUBER

public static final int CV_DIST_HUBER
See Also:
Constant Field Values

CV_DIST_L1

public static final int CV_DIST_L1
See Also:
Constant Field Values

CV_DIST_L12

public static final int CV_DIST_L12
See Also:
Constant Field Values

CV_DIST_L2

public static final int CV_DIST_L2
See Also:
Constant Field Values

CV_DIST_LABEL_CCOMP

public static final int CV_DIST_LABEL_CCOMP
See Also:
Constant Field Values

CV_DIST_LABEL_PIXEL

public static final int CV_DIST_LABEL_PIXEL
See Also:
Constant Field Values

CV_DIST_MASK_3

public static final int CV_DIST_MASK_3
See Also:
Constant Field Values

CV_DIST_MASK_5

public static final int CV_DIST_MASK_5
See Also:
Constant Field Values

CV_DIST_MASK_PRECISE

public static final int CV_DIST_MASK_PRECISE
See Also:
Constant Field Values

CV_DIST_USER

public static final int CV_DIST_USER
See Also:
Constant Field Values

CV_DIST_WELSCH

public static final int CV_DIST_WELSCH
See Also:
Constant Field Values

CV_GAUSSIAN

public static final int CV_GAUSSIAN
See Also:
Constant Field Values

CV_GAUSSIAN_5x5

public static final int CV_GAUSSIAN_5x5
See Also:
Constant Field Values

CV_HOUGH_GRADIENT

public static final int CV_HOUGH_GRADIENT
See Also:
Constant Field Values

CV_HOUGH_MULTI_SCALE

public static final int CV_HOUGH_MULTI_SCALE
See Also:
Constant Field Values

CV_HOUGH_PROBABILISTIC

public static final int CV_HOUGH_PROBABILISTIC
See Also:
Constant Field Values

CV_HOUGH_STANDARD

public static final int CV_HOUGH_STANDARD
See Also:
Constant Field Values

CV_LINK_RUNS

public static final int CV_LINK_RUNS
See Also:
Constant Field Values

CV_MAX_SOBEL_KSIZE

public static final int CV_MAX_SOBEL_KSIZE
See Also:
Constant Field Values

CV_MEDIAN

public static final int CV_MEDIAN
See Also:
Constant Field Values

CV_mRGBA2RGBA

public static final int CV_mRGBA2RGBA
See Also:
Constant Field Values

CV_POLY_APPROX_DP

public static final int CV_POLY_APPROX_DP
See Also:
Constant Field Values

CV_RGBA2mRGBA

public static final int CV_RGBA2mRGBA
See Also:
Constant Field Values

CV_SCHARR

public static final int CV_SCHARR
See Also:
Constant Field Values

CV_SHAPE_CROSS

public static final int CV_SHAPE_CROSS
See Also:
Constant Field Values

CV_SHAPE_CUSTOM

public static final int CV_SHAPE_CUSTOM
See Also:
Constant Field Values

CV_SHAPE_ELLIPSE

public static final int CV_SHAPE_ELLIPSE
See Also:
Constant Field Values

CV_SHAPE_RECT

public static final int CV_SHAPE_RECT
See Also:
Constant Field Values

CV_WARP_FILL_OUTLIERS

public static final int CV_WARP_FILL_OUTLIERS
See Also:
Constant Field Values

CV_WARP_INVERSE_MAP

public static final int CV_WARP_INVERSE_MAP
See Also:
Constant Field Values

DIST_LABEL_CCOMP

public static final int DIST_LABEL_CCOMP
See Also:
Constant Field Values

DIST_LABEL_PIXEL

public static final int DIST_LABEL_PIXEL
See Also:
Constant Field Values

FLOODFILL_FIXED_RANGE

public static final int FLOODFILL_FIXED_RANGE
See Also:
Constant Field Values

FLOODFILL_MASK_ONLY

public static final int FLOODFILL_MASK_ONLY
See Also:
Constant Field Values

GC_BGD

public static final int GC_BGD
See Also:
Constant Field Values

GC_EVAL

public static final int GC_EVAL
See Also:
Constant Field Values

GC_FGD

public static final int GC_FGD
See Also:
Constant Field Values

GC_INIT_WITH_MASK

public static final int GC_INIT_WITH_MASK
See Also:
Constant Field Values

GC_INIT_WITH_RECT

public static final int GC_INIT_WITH_RECT
See Also:
Constant Field Values

GC_PR_BGD

public static final int GC_PR_BGD
See Also:
Constant Field Values

GC_PR_FGD

public static final int GC_PR_FGD
See Also:
Constant Field Values

GHT_POSITION

public static final int GHT_POSITION
See Also:
Constant Field Values

GHT_ROTATION

public static final int GHT_ROTATION
See Also:
Constant Field Values

GHT_SCALE

public static final int GHT_SCALE
See Also:
Constant Field Values

INTER_AREA

public static final int INTER_AREA
See Also:
Constant Field Values

INTER_BITS

public static final int INTER_BITS
See Also:
Constant Field Values

INTER_BITS2

public static final int INTER_BITS2
See Also:
Constant Field Values

INTER_CUBIC

public static final int INTER_CUBIC
See Also:
Constant Field Values

INTER_LANCZOS4

public static final int INTER_LANCZOS4
See Also:
Constant Field Values

INTER_LINEAR

public static final int INTER_LINEAR
See Also:
Constant Field Values

INTER_MAX

public static final int INTER_MAX
See Also:
Constant Field Values

INTER_NEAREST

public static final int INTER_NEAREST
See Also:
Constant Field Values

INTER_TAB_SIZE

public static final int INTER_TAB_SIZE
See Also:
Constant Field Values

INTER_TAB_SIZE2

public static final int INTER_TAB_SIZE2
See Also:
Constant Field Values

KERNEL_ASYMMETRICAL

public static final int KERNEL_ASYMMETRICAL
See Also:
Constant Field Values

KERNEL_GENERAL

public static final int KERNEL_GENERAL
See Also:
Constant Field Values

KERNEL_INTEGER

public static final int KERNEL_INTEGER
See Also:
Constant Field Values

KERNEL_SMOOTH

public static final int KERNEL_SMOOTH
See Also:
Constant Field Values

KERNEL_SYMMETRICAL

public static final int KERNEL_SYMMETRICAL
See Also:
Constant Field Values

MORPH_BLACKHAT

public static final int MORPH_BLACKHAT
See Also:
Constant Field Values

MORPH_CLOSE

public static final int MORPH_CLOSE
See Also:
Constant Field Values

MORPH_CROSS

public static final int MORPH_CROSS
See Also:
Constant Field Values

MORPH_DILATE

public static final int MORPH_DILATE
See Also:
Constant Field Values

MORPH_ELLIPSE

public static final int MORPH_ELLIPSE
See Also:
Constant Field Values

MORPH_ERODE

public static final int MORPH_ERODE
See Also:
Constant Field Values

MORPH_GRADIENT

public static final int MORPH_GRADIENT
See Also:
Constant Field Values

MORPH_OPEN

public static final int MORPH_OPEN
See Also:
Constant Field Values

MORPH_RECT

public static final int MORPH_RECT
See Also:
Constant Field Values

MORPH_TOPHAT

public static final int MORPH_TOPHAT
See Also:
Constant Field Values

PROJ_SPHERICAL_EQRECT

public static final int PROJ_SPHERICAL_EQRECT
See Also:
Constant Field Values

PROJ_SPHERICAL_ORTHO

public static final int PROJ_SPHERICAL_ORTHO
See Also:
Constant Field Values

RETR_CCOMP

public static final int RETR_CCOMP
See Also:
Constant Field Values

RETR_EXTERNAL

public static final int RETR_EXTERNAL
See Also:
Constant Field Values

RETR_FLOODFILL

public static final int RETR_FLOODFILL
See Also:
Constant Field Values

RETR_LIST

public static final int RETR_LIST
See Also:
Constant Field Values

RETR_TREE

public static final int RETR_TREE
See Also:
Constant Field Values

THRESH_BINARY

public static final int THRESH_BINARY
See Also:
Constant Field Values

THRESH_BINARY_INV

public static final int THRESH_BINARY_INV
See Also:
Constant Field Values

THRESH_MASK

public static final int THRESH_MASK
See Also:
Constant Field Values

THRESH_OTSU

public static final int THRESH_OTSU
See Also:
Constant Field Values

THRESH_TOZERO

public static final int THRESH_TOZERO
See Also:
Constant Field Values

THRESH_TOZERO_INV

public static final int THRESH_TOZERO_INV
See Also:
Constant Field Values

THRESH_TRUNC

public static final int THRESH_TRUNC
See Also:
Constant Field Values

TM_CCOEFF

public static final int TM_CCOEFF
See Also:
Constant Field Values

TM_CCOEFF_NORMED

public static final int TM_CCOEFF_NORMED
See Also:
Constant Field Values

TM_CCORR

public static final int TM_CCORR
See Also:
Constant Field Values

TM_CCORR_NORMED

public static final int TM_CCORR_NORMED
See Also:
Constant Field Values

TM_SQDIFF

public static final int TM_SQDIFF
See Also:
Constant Field Values

TM_SQDIFF_NORMED

public static final int TM_SQDIFF_NORMED
See Also:
Constant Field Values

WARP_INVERSE_MAP

public static final int WARP_INVERSE_MAP
See Also:
Constant Field Values
Constructor Detail

Imgproc

public Imgproc()
Method Detail

accumulate

public static void accumulate(Mat src,
                              Mat dst)

Adds an image to the accumulator.

The function adds src or some of its elements to dst :

dst(x,y) <- dst(x,y) + src(x,y) if mask(x,y) != 0

The function supports multi-channel images. Each channel is processed independently.

The functions accumulate* can be used, for example, to collect statistics of a scene background viewed by a still camera and for the further foreground-background segmentation.

Parameters:
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
dst - Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
See Also:
org.opencv.imgproc.Imgproc.accumulate, accumulateWeighted(org.opencv.core.Mat, org.opencv.core.Mat, double, org.opencv.core.Mat), accumulateProduct(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulate

public static void accumulate(Mat src,
                              Mat dst,
                              Mat mask)

Adds an image to the accumulator.

The function adds src or some of its elements to dst :

dst(x,y) <- dst(x,y) + src(x,y) if mask(x,y) != 0

The function supports multi-channel images. Each channel is processed independently.

The functions accumulate* can be used, for example, to collect statistics of a scene background viewed by a still camera and for the further foreground-background segmentation.

Parameters:
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
dst - Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
mask - Optional operation mask.
See Also:
org.opencv.imgproc.Imgproc.accumulate, accumulateWeighted(org.opencv.core.Mat, org.opencv.core.Mat, double, org.opencv.core.Mat), accumulateProduct(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulateProduct

public static void accumulateProduct(Mat src1,
                                     Mat src2,
                                     Mat dst)

Adds the per-element product of two input images to the accumulator.

The function adds the product of two images or their selected regions to the accumulator dst :

dst(x,y) <- dst(x,y) + src1(x,y) * src2(x,y) if mask(x,y) != 0

The function supports multi-channel images. Each channel is processed independently.

Parameters:
src1 - First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
src2 - Second input image of the same type and the same size as src1.
dst - Accumulator with the same number of channels as input images, 32-bit or 64-bit floating-point.
See Also:
org.opencv.imgproc.Imgproc.accumulateProduct, accumulate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateWeighted(org.opencv.core.Mat, org.opencv.core.Mat, double, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulateProduct

public static void accumulateProduct(Mat src1,
                                     Mat src2,
                                     Mat dst,
                                     Mat mask)

Adds the per-element product of two input images to the accumulator.

The function adds the product of two images or their selected regions to the accumulator dst :

dst(x,y) <- dst(x,y) + src1(x,y) * src2(x,y) if mask(x,y) != 0

The function supports multi-channel images. Each channel is processed independently.

Parameters:
src1 - First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
src2 - Second input image of the same type and the same size as src1.
dst - Accumulator with the same number of channels as input images, 32-bit or 64-bit floating-point.
mask - Optional operation mask.
See Also:
org.opencv.imgproc.Imgproc.accumulateProduct, accumulate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateWeighted(org.opencv.core.Mat, org.opencv.core.Mat, double, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulateSquare

public static void accumulateSquare(Mat src,
                                    Mat dst)

Adds the square of a source image to the accumulator.

The function adds the input image src or its selected region, raised to a power of 2, to the accumulator dst :

dst(x,y) <- dst(x,y) + src(x,y)^2 if mask(x,y) != 0

The function supports multi-channel images. Each channel is processed independently.

Parameters:
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
dst - Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
See Also:
org.opencv.imgproc.Imgproc.accumulateSquare, accumulateWeighted(org.opencv.core.Mat, org.opencv.core.Mat, double, org.opencv.core.Mat), accumulateProduct(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulateSquare

public static void accumulateSquare(Mat src,
                                    Mat dst,
                                    Mat mask)

Adds the square of a source image to the accumulator.

The function adds the input image src or its selected region, raised to a power of 2, to the accumulator dst :

dst(x,y) <- dst(x,y) + src(x,y)^2 if mask(x,y) != 0

The function supports multi-channel images. Each channel is processed independently.

Parameters:
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
dst - Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
mask - Optional operation mask.
See Also:
org.opencv.imgproc.Imgproc.accumulateSquare, accumulateWeighted(org.opencv.core.Mat, org.opencv.core.Mat, double, org.opencv.core.Mat), accumulateProduct(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulateWeighted

public static void accumulateWeighted(Mat src,
                                      Mat dst,
                                      double alpha)

Updates a running average.

The function calculates the weighted sum of the input image src and the accumulator dst so that dst becomes a running average of a frame sequence:

dst(x,y) <- (1- alpha) * dst(x,y) + alpha * src(x,y) if mask(x,y) != 0

That is, alpha regulates the update speed (how fast the accumulator "forgets" about earlier images). The function supports multi-channel images. Each channel is processed independently.

Parameters:
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
dst - Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
alpha - Weight of the input image.
See Also:
org.opencv.imgproc.Imgproc.accumulateWeighted, accumulate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateProduct(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

accumulateWeighted

public static void accumulateWeighted(Mat src,
                                      Mat dst,
                                      double alpha,
                                      Mat mask)

Updates a running average.

The function calculates the weighted sum of the input image src and the accumulator dst so that dst becomes a running average of a frame sequence:

dst(x,y) <- (1- alpha) * dst(x,y) + alpha * src(x,y) if mask(x,y) != 0

That is, alpha regulates the update speed (how fast the accumulator "forgets" about earlier images). The function supports multi-channel images. Each channel is processed independently.

Parameters:
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
dst - Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
alpha - Weight of the input image.
mask - Optional operation mask.
See Also:
org.opencv.imgproc.Imgproc.accumulateWeighted, accumulate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateProduct(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), accumulateSquare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

adaptiveThreshold

public static void adaptiveThreshold(Mat src,
                                     Mat dst,
                                     double maxValue,
                                     int adaptiveMethod,
                                     int thresholdType,
                                     int blockSize,
                                     double C)

Applies an adaptive threshold to an array.

The function transforms a grayscale image to a binary image according to the formulae:

dst(x,y) = maxValue if src(x,y) > T(x,y); 0 otherwise

dst(x,y) = 0 if src(x,y) > T(x,y); maxValue otherwise

where T(x,y) is a threshold calculated individually for each pixel.

The function can process the image in-place.

Parameters:
src - Source 8-bit single-channel image.
dst - Destination image of the same size and the same type as src.
maxValue - Non-zero value assigned to the pixels for which the condition is satisfied. See the details below.
adaptiveMethod - Adaptive thresholding algorithm to use, ADAPTIVE_THRESH_MEAN_C or ADAPTIVE_THRESH_GAUSSIAN_C. See the details below.
thresholdType - Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV.
blockSize - Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
C - Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.
See Also:
org.opencv.imgproc.Imgproc.adaptiveThreshold, threshold(org.opencv.core.Mat, org.opencv.core.Mat, double, double, int), GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int)

approxPolyDP

public static void approxPolyDP(MatOfPoint2f curve,
                                MatOfPoint2f approxCurve,
                                double epsilon,
                                boolean closed)

Approximates a polygonal curve(s) with the specified precision.

The functions approxPolyDP approximate a curve or a polygon with another curve/polygon with less vertices so that the distance between them is less or equal to the specified precision. It uses the Douglas-Peucker algorithm http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm

See http://code.opencv.org/projects/opencv/repository/revisions/master/entry/samples/cpp/contours.cpp for the function usage model.

Parameters:
curve - Input vector of a 2D point stored in:
  • std.vector or Mat (C++ interface)
  • Nx2 numpy array (Python interface)
  • CvSeq or CvMat" (C interface)
approxCurve - Result of the approximation. The type should match the type of the input curve. In case of C interface the approximated curve is stored in the memory storage and pointer to it is returned.
epsilon - Parameter specifying the approximation accuracy. This is the maximum distance between the original curve and its approximation.
closed - If true, the approximated curve is closed (its first and last vertices are connected). Otherwise, it is not closed.
See Also:
org.opencv.imgproc.Imgproc.approxPolyDP

arcLength

public static double arcLength(MatOfPoint2f curve,
                               boolean closed)

Calculates a contour perimeter or a curve length.

The function computes a curve length or a closed contour perimeter.

Parameters:
curve - Input vector of 2D points, stored in std.vector or Mat.
closed - Flag indicating whether the curve is closed or not.
See Also:
org.opencv.imgproc.Imgproc.arcLength

bilateralFilter

public static void bilateralFilter(Mat src,
                                   Mat dst,
                                   int d,
                                   double sigmaColor,
                                   double sigmaSpace)

Applies the bilateral filter to an image.

The function applies bilateral filtering to the input image, as described in http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is very slow compared to most filters.

This filter does not work inplace.

Parameters:
src - Source 8-bit or floating-point, 1-channel or 3-channel image.
dst - Destination image of the same size and type as src.
d - Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.
sigmaColor - Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.
sigmaSpace - Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.
See Also:
org.opencv.imgproc.Imgproc.bilateralFilter

bilateralFilter

public static void bilateralFilter(Mat src,
                                   Mat dst,
                                   int d,
                                   double sigmaColor,
                                   double sigmaSpace,
                                   int borderType)

Applies the bilateral filter to an image.

The function applies bilateral filtering to the input image, as described in http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is very slow compared to most filters.

This filter does not work inplace.

Parameters:
src - Source 8-bit or floating-point, 1-channel or 3-channel image.
dst - Destination image of the same size and type as src.
d - Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.
sigmaColor - Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.
sigmaSpace - Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.
borderType - a borderType
See Also:
org.opencv.imgproc.Imgproc.bilateralFilter

blur

public static void blur(Mat src,
                        Mat dst,
                        Size ksize)

Blurs an image using the normalized box filter.

The function smoothes an image using the kernel:

K = 1/(ksize.width*ksize.height) 1 1 1 *s 1 1 1 1 1 *s 1 1.................. 1 1 1 *s 1 1

The call blur(src, dst, ksize, anchor, borderType) is equivalent to boxFilter(src, dst, src.type(), anchor, true, borderType).

Parameters:
src - input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst - output image of the same size and type as src.
ksize - blurring kernel size.
See Also:
org.opencv.imgproc.Imgproc.blur, boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int)

blur

public static void blur(Mat src,
                        Mat dst,
                        Size ksize,
                        Point anchor)

Blurs an image using the normalized box filter.

The function smoothes an image using the kernel:

K = 1/(ksize.width*ksize.height) 1 1 1 *s 1 1 1 1 1 *s 1 1.................. 1 1 1 *s 1 1

The call blur(src, dst, ksize, anchor, borderType) is equivalent to boxFilter(src, dst, src.type(), anchor, true, borderType).

Parameters:
src - input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst - output image of the same size and type as src.
ksize - blurring kernel size.
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
See Also:
org.opencv.imgproc.Imgproc.blur, boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int)

blur

public static void blur(Mat src,
                        Mat dst,
                        Size ksize,
                        Point anchor,
                        int borderType)

Blurs an image using the normalized box filter.

The function smoothes an image using the kernel:

K = 1/(ksize.width*ksize.height) 1 1 1 *s 1 1 1 1 1 *s 1 1.................. 1 1 1 *s 1 1

The call blur(src, dst, ksize, anchor, borderType) is equivalent to boxFilter(src, dst, src.type(), anchor, true, borderType).

Parameters:
src - input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst - output image of the same size and type as src.
ksize - blurring kernel size.
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
borderType - border mode used to extrapolate pixels outside of the image.
See Also:
org.opencv.imgproc.Imgproc.blur, boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int)

borderInterpolate

public static int borderInterpolate(int p,
                                    int len,
                                    int borderType)

Computes the source location of an extrapolated pixel.

The function computes and returns the coordinate of a donor pixel corresponding to the specified extrapolated pixel when using the specified extrapolation border mode. For example, if you use BORDER_WRAP mode in the horizontal direction, BORDER_REFLECT_101 in the vertical direction and want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img, it looks like:

// C++ code:

float val = img.at(borderInterpolate(100, img.rows, BORDER_REFLECT_101),

borderInterpolate(-5, img.cols, BORDER_WRAP));

Normally, the function is not called directly. It is used inside

"FilterEngine" and "copyMakeBorder" to compute tables for quick extrapolation.

Parameters:
p - 0-based coordinate of the extrapolated pixel along one of the axes, likely <0 or >= len.
len - Length of the array along the corresponding axis.
borderType - Border type, one of the BORDER_*, except for BORDER_TRANSPARENT and BORDER_ISOLATED. When borderType==BORDER_CONSTANT, the function always returns -1, regardless of p and len.
See Also:
org.opencv.imgproc.Imgproc.borderInterpolate, copyMakeBorder(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, int, org.opencv.core.Scalar)

boundingRect

public static Rect boundingRect(MatOfPoint points)

Calculates the up-right bounding rectangle of a point set.

The function calculates and returns the minimal up-right bounding rectangle for the specified point set.

Parameters:
points - Input 2D point set, stored in std.vector or Mat.
See Also:
org.opencv.imgproc.Imgproc.boundingRect

boxFilter

public static void boxFilter(Mat src,
                             Mat dst,
                             int ddepth,
                             Size ksize)

Blurs an image using the box filter.

The function smoothes an image using the kernel:

K = alpha 1 1 1 *s 1 1 1 1 1 *s 1 1.................. 1 1 1 *s 1 1

where

alpha = 1/(ksize.width*ksize.height) when normalize=true; 1 otherwise

Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use "integral".

Parameters:
src - input image.
dst - output image of the same size and type as src.
ddepth - the output image depth (-1 to use src.depth()).
ksize - blurring kernel size.
See Also:
org.opencv.imgproc.Imgproc.boxFilter, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int), integral(org.opencv.core.Mat, org.opencv.core.Mat, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int)

boxFilter

public static void boxFilter(Mat src,
                             Mat dst,
                             int ddepth,
                             Size ksize,
                             Point anchor,
                             boolean normalize)

Blurs an image using the box filter.

The function smoothes an image using the kernel:

K = alpha 1 1 1 *s 1 1 1 1 1 *s 1 1.................. 1 1 1 *s 1 1

where

alpha = 1/(ksize.width*ksize.height) when normalize=true; 1 otherwise

Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use "integral".

Parameters:
src - input image.
dst - output image of the same size and type as src.
ddepth - the output image depth (-1 to use src.depth()).
ksize - blurring kernel size.
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
normalize - flag, specifying whether the kernel is normalized by its area or not.
See Also:
org.opencv.imgproc.Imgproc.boxFilter, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int), integral(org.opencv.core.Mat, org.opencv.core.Mat, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int)

boxFilter

public static void boxFilter(Mat src,
                             Mat dst,
                             int ddepth,
                             Size ksize,
                             Point anchor,
                             boolean normalize,
                             int borderType)

Blurs an image using the box filter.

The function smoothes an image using the kernel:

K = alpha 1 1 1 *s 1 1 1 1 1 *s 1 1.................. 1 1 1 *s 1 1

where

alpha = 1/(ksize.width*ksize.height) when normalize=true; 1 otherwise

Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use "integral".

Parameters:
src - input image.
dst - output image of the same size and type as src.
ddepth - the output image depth (-1 to use src.depth()).
ksize - blurring kernel size.
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
normalize - flag, specifying whether the kernel is normalized by its area or not.
borderType - border mode used to extrapolate pixels outside of the image.
See Also:
org.opencv.imgproc.Imgproc.boxFilter, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int), integral(org.opencv.core.Mat, org.opencv.core.Mat, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int)

calcBackProject

public static void calcBackProject(java.util.List<Mat> images,
                                   MatOfInt channels,
                                   Mat hist,
                                   Mat dst,
                                   MatOfFloat ranges,
                                   double scale)

Calculates the back projection of a histogram.

The functions calcBackProject calculate the back project of the histogram. That is, similarly to calcHist, at each location (x, y) the function collects the values from the selected channels in the input images and finds the corresponding histogram bin. But instead of incrementing it, the function reads the bin value, scales it by scale, and stores in backProject(x,y). In terms of statistics, the function computes probability of each element value in respect with the empirical probability distribution represented by the histogram. See how, for example, you can find and track a bright-colored object in a scene:

This is an approximate algorithm of the "CamShift" color object tracker.

Parameters:
images - Source arrays. They all should have the same depth, CV_8U or CV_32F, and the same size. Each of them can have an arbitrary number of channels.
channels - The list of channels used to compute the back projection. The number of channels must match the histogram dimensionality. The first array channels are numerated from 0 to images[0].channels()-1, the second array channels are counted from images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.
hist - Input histogram that can be dense or sparse.
dst - a dst
ranges - Array of arrays of the histogram bin boundaries in each dimension. See "calcHist".
scale - Optional scale factor for the output back projection.
See Also:
org.opencv.imgproc.Imgproc.calcBackProject, calcHist(java.util.List, org.opencv.core.MatOfInt, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfInt, org.opencv.core.MatOfFloat, boolean)

calcHist

public static void calcHist(java.util.List<Mat> images,
                            MatOfInt channels,
                            Mat mask,
                            Mat hist,
                            MatOfInt histSize,
                            MatOfFloat ranges)

Calculates a histogram of a set of arrays.

The functions calcHist calculate the histogram of one or more arrays. The elements of a tuple used to increment a histogram bin are taken from the correspondinginput arrays at the same location. The sample below shows how to compute a 2D Hue-Saturation histogram for a color image.

// C++ code:

#include

#include

using namespace cv;

int main(int argc, char argv)

Mat src, hsv;

if(argc != 2 || !(src=imread(argv[1], 1)).data)

return -1;

cvtColor(src, hsv, CV_BGR2HSV);

// Quantize the hue to 30 levels

// and the saturation to 32 levels

int hbins = 30, sbins = 32;

int histSize[] = {hbins, sbins};

// hue varies from 0 to 179, see cvtColor

float hranges[] = { 0, 180 };

// saturation varies from 0 (black-gray-white) to

// 255 (pure spectrum color)

float sranges[] = { 0, 256 };

const float* ranges[] = { hranges, sranges };

MatND hist;

// we compute the histogram from the 0-th and 1-st channels

int channels[] = {0, 1};

calcHist(&hsv, 1, channels, Mat(), // do not use mask

hist, 2, histSize, ranges,

true, // the histogram is uniform

false);

double maxVal=0;

minMaxLoc(hist, 0, &maxVal, 0, 0);

int scale = 10;

Mat histImg = Mat.zeros(sbins*scale, hbins*10, CV_8UC3);

for(int h = 0; h < hbins; h++)

for(int s = 0; s < sbins; s++)

float binVal = hist.at(h, s);

int intensity = cvRound(binVal*255/maxVal);

rectangle(histImg, Point(h*scale, s*scale),

Point((h+1)*scale - 1, (s+1)*scale - 1),

Scalar.all(intensity),

CV_FILLED);

namedWindow("Source", 1);

imshow("Source", src);

namedWindow("H-S Histogram", 1);

imshow("H-S Histogram", histImg);

waitKey();

Parameters:
images - Source arrays. They all should have the same depth, CV_8U or CV_32F, and the same size. Each of them can have an arbitrary number of channels.
channels - List of the dims channels used to compute the histogram. The first array channels are numerated from 0 to images[0].channels()-1, the second array channels are counted from images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.
mask - Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as images[i]. The non-zero mask elements mark the array elements counted in the histogram.
hist - Output histogram, which is a dense or sparse dims -dimensional array.
histSize - Array of histogram sizes in each dimension.
ranges - Array of the dims arrays of the histogram bin boundaries in each dimension. When the histogram is uniform (uniform =true), then for each dimension i it is enough to specify the lower (inclusive) boundary L_0 of the 0-th histogram bin and the upper (exclusive) boundary U_(histSize[i]-1) for the last histogram bin histSize[i]-1. That is, in case of a uniform histogram each of ranges[i] is an array of 2 elements. When the histogram is not uniform (uniform=false), then each of ranges[i] contains histSize[i]+1 elements: L_0, U_0=L_1, U_1=L_2,..., U_(histSize[i]-2)=L_(histSize[i]-1), U_(histSize[i]-1). The array elements, that are not between L_0 and U_(histSize[i]-1), are not counted in the histogram.
See Also:
org.opencv.imgproc.Imgproc.calcHist

calcHist

public static void calcHist(java.util.List<Mat> images,
                            MatOfInt channels,
                            Mat mask,
                            Mat hist,
                            MatOfInt histSize,
                            MatOfFloat ranges,
                            boolean accumulate)

Calculates a histogram of a set of arrays.

The functions calcHist calculate the histogram of one or more arrays. The elements of a tuple used to increment a histogram bin are taken from the correspondinginput arrays at the same location. The sample below shows how to compute a 2D Hue-Saturation histogram for a color image.

// C++ code:

#include

#include

using namespace cv;

int main(int argc, char argv)

Mat src, hsv;

if(argc != 2 || !(src=imread(argv[1], 1)).data)

return -1;

cvtColor(src, hsv, CV_BGR2HSV);

// Quantize the hue to 30 levels

// and the saturation to 32 levels

int hbins = 30, sbins = 32;

int histSize[] = {hbins, sbins};

// hue varies from 0 to 179, see cvtColor

float hranges[] = { 0, 180 };

// saturation varies from 0 (black-gray-white) to

// 255 (pure spectrum color)

float sranges[] = { 0, 256 };

const float* ranges[] = { hranges, sranges };

MatND hist;

// we compute the histogram from the 0-th and 1-st channels

int channels[] = {0, 1};

calcHist(&hsv, 1, channels, Mat(), // do not use mask

hist, 2, histSize, ranges,

true, // the histogram is uniform

false);

double maxVal=0;

minMaxLoc(hist, 0, &maxVal, 0, 0);

int scale = 10;

Mat histImg = Mat.zeros(sbins*scale, hbins*10, CV_8UC3);

for(int h = 0; h < hbins; h++)

for(int s = 0; s < sbins; s++)

float binVal = hist.at(h, s);

int intensity = cvRound(binVal*255/maxVal);

rectangle(histImg, Point(h*scale, s*scale),

Point((h+1)*scale - 1, (s+1)*scale - 1),

Scalar.all(intensity),

CV_FILLED);

namedWindow("Source", 1);

imshow("Source", src);

namedWindow("H-S Histogram", 1);

imshow("H-S Histogram", histImg);

waitKey();

Parameters:
images - Source arrays. They all should have the same depth, CV_8U or CV_32F, and the same size. Each of them can have an arbitrary number of channels.
channels - List of the dims channels used to compute the histogram. The first array channels are numerated from 0 to images[0].channels()-1, the second array channels are counted from images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.
mask - Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as images[i]. The non-zero mask elements mark the array elements counted in the histogram.
hist - Output histogram, which is a dense or sparse dims -dimensional array.
histSize - Array of histogram sizes in each dimension.
ranges - Array of the dims arrays of the histogram bin boundaries in each dimension. When the histogram is uniform (uniform =true), then for each dimension i it is enough to specify the lower (inclusive) boundary L_0 of the 0-th histogram bin and the upper (exclusive) boundary U_(histSize[i]-1) for the last histogram bin histSize[i]-1. That is, in case of a uniform histogram each of ranges[i] is an array of 2 elements. When the histogram is not uniform (uniform=false), then each of ranges[i] contains histSize[i]+1 elements: L_0, U_0=L_1, U_1=L_2,..., U_(histSize[i]-2)=L_(histSize[i]-1), U_(histSize[i]-1). The array elements, that are not between L_0 and U_(histSize[i]-1), are not counted in the histogram.
accumulate - Accumulation flag. If it is set, the histogram is not cleared in the beginning when it is allocated. This feature enables you to compute a single histogram from several sets of arrays, or to update the histogram in time.
See Also:
org.opencv.imgproc.Imgproc.calcHist

Canny

public static void Canny(Mat image,
                         Mat edges,
                         double threshold1,
                         double threshold2)

Finds edges in an image using the [Canny86] algorithm.

The function finds edges in the input image image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See http://en.wikipedia.org/wiki/Canny_edge_detector

Parameters:
image - single-channel 8-bit input image.
edges - output edge map; it has the same size and type as image.
threshold1 - first threshold for the hysteresis procedure.
threshold2 - second threshold for the hysteresis procedure.
See Also:
org.opencv.imgproc.Imgproc.Canny

Canny

public static void Canny(Mat image,
                         Mat edges,
                         double threshold1,
                         double threshold2,
                         int apertureSize,
                         boolean L2gradient)

Finds edges in an image using the [Canny86] algorithm.

The function finds edges in the input image image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See http://en.wikipedia.org/wiki/Canny_edge_detector

Parameters:
image - single-channel 8-bit input image.
edges - output edge map; it has the same size and type as image.
threshold1 - first threshold for the hysteresis procedure.
threshold2 - second threshold for the hysteresis procedure.
apertureSize - aperture size for the "Sobel" operator.
L2gradient - a flag, indicating whether a more accurate L_2 norm =sqrt((dI/dx)^2 + (dI/dy)^2) should be used to calculate the image gradient magnitude (L2gradient=true), or whether the default L_1 norm =|dI/dx|+|dI/dy| is enough (L2gradient=false).
See Also:
org.opencv.imgproc.Imgproc.Canny

compareHist

public static double compareHist(Mat H1,
                                 Mat H2,
                                 int method)

Compares two histograms.

The functions compareHist compare two dense or two sparse histograms using the specified method:

  • Correlation (method=CV_COMP_CORREL)

d(H_1,H_2) = (sum_I(H_1(I) - H_1")(H_2(I) - H_2"))/(sqrt(sum_I(H_1(I) - H_1")^2 sum_I(H_2(I) - H_2")^2))

where

H_k" = 1/(N) sum _J H_k(J)

and N is a total number of histogram bins.

  • Chi-Square (method=CV_COMP_CHISQR)

d(H_1,H_2) = sum _I((H_1(I)-H_2(I))^2)/(H_1(I))

  • Intersection (method=CV_COMP_INTERSECT)

d(H_1,H_2) = sum _I min(H_1(I), H_2(I))

  • Bhattacharyya distance (method=CV_COMP_BHATTACHARYYA or method=CV_COMP_HELLINGER). In fact, OpenCV computes Hellinger distance, which is related to Bhattacharyya coefficient.

d(H_1,H_2) = sqrt(1 - frac(1)(sqrt(H_1" H_2" N^2)) sum_I sqrt(H_1(I) * H_2(I)))

The function returns d(H_1, H_2).

While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms or more general sparse configurations of weighted points, consider using the "EMD" function.

Parameters:
H1 - First compared histogram.
H2 - Second compared histogram of the same size as H1.
method - Comparison method that could be one of the following:
  • CV_COMP_CORREL Correlation
  • CV_COMP_CHISQR Chi-Square
  • CV_COMP_INTERSECT Intersection
  • CV_COMP_BHATTACHARYYA Bhattacharyya distance
  • CV_COMP_HELLINGER Synonym for CV_COMP_BHATTACHARYYA
See Also:
org.opencv.imgproc.Imgproc.compareHist

contourArea

public static double contourArea(Mat contour)

Calculates a contour area.

The function computes a contour area. Similarly to "moments", the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using "drawContours" or "fillPoly", can be different. Also, the function will most certainly give a wrong results for contours with self-intersections. Example:

// C++ code:

vector contour;

contour.push_back(Point2f(0, 0));

contour.push_back(Point2f(10, 0));

contour.push_back(Point2f(10, 10));

contour.push_back(Point2f(5, 4));

double area0 = contourArea(contour);

vector approx;

approxPolyDP(contour, approx, 5, true);

double area1 = contourArea(approx);

cout << "area0 =" << area0 << endl <<

"area1 =" << area1 << endl <<

"approx poly vertices" << approx.size() << endl;

Parameters:
contour - Input vector of 2D points (contour vertices), stored in std.vector or Mat.
See Also:
org.opencv.imgproc.Imgproc.contourArea

contourArea

public static double contourArea(Mat contour,
                                 boolean oriented)

Calculates a contour area.

The function computes a contour area. Similarly to "moments", the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using "drawContours" or "fillPoly", can be different. Also, the function will most certainly give a wrong results for contours with self-intersections. Example:

// C++ code:

vector contour;

contour.push_back(Point2f(0, 0));

contour.push_back(Point2f(10, 0));

contour.push_back(Point2f(10, 10));

contour.push_back(Point2f(5, 4));

double area0 = contourArea(contour);

vector approx;

approxPolyDP(contour, approx, 5, true);

double area1 = contourArea(approx);

cout << "area0 =" << area0 << endl <<

"area1 =" << area1 << endl <<

"approx poly vertices" << approx.size() << endl;

Parameters:
contour - Input vector of 2D points (contour vertices), stored in std.vector or Mat.
oriented - Oriented area flag. If it is true, the function returns a signed area value, depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can determine orientation of a contour by taking the sign of an area. By default, the parameter is false, which means that the absolute value is returned.
See Also:
org.opencv.imgproc.Imgproc.contourArea

convertMaps

public static void convertMaps(Mat map1,
                               Mat map2,
                               Mat dstmap1,
                               Mat dstmap2,
                               int dstmap1type)

Converts image transformation maps from one representation to another.

The function converts a pair of maps for "remap" from one representation to another. The following options ((map1.type(), map2.type()) -> (dstmap1.type(), dstmap2.type())) are supported:

  • (CV_32FC1, CV_32FC1) -> (CV_16SC2, CV_16UC1). This is the most frequently used conversion operation, in which the original floating-point maps (see "remap") are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when nninterpolation=false) contains indices in the interpolation tables.
  • (CV_32FC2) -> (CV_16SC2, CV_16UC1). The same as above but the original maps are stored in one 2-channel matrix.
  • Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.

Parameters:
map1 - The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2.
map2 - The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), respectively.
dstmap1 - The first output map that has the type dstmap1type and the same size as src.
dstmap2 - The second output map.
dstmap1type - Type of the first output map that should be CV_16SC2, CV_32FC1, or CV_32FC2.
See Also:
org.opencv.imgproc.Imgproc.convertMaps, remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), initUndistortRectifyMap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, org.opencv.core.Mat, org.opencv.core.Mat), undistort(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

convertMaps

public static void convertMaps(Mat map1,
                               Mat map2,
                               Mat dstmap1,
                               Mat dstmap2,
                               int dstmap1type,
                               boolean nninterpolation)

Converts image transformation maps from one representation to another.

The function converts a pair of maps for "remap" from one representation to another. The following options ((map1.type(), map2.type()) -> (dstmap1.type(), dstmap2.type())) are supported:

  • (CV_32FC1, CV_32FC1) -> (CV_16SC2, CV_16UC1). This is the most frequently used conversion operation, in which the original floating-point maps (see "remap") are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when nninterpolation=false) contains indices in the interpolation tables.
  • (CV_32FC2) -> (CV_16SC2, CV_16UC1). The same as above but the original maps are stored in one 2-channel matrix.
  • Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.

Parameters:
map1 - The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2.
map2 - The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), respectively.
dstmap1 - The first output map that has the type dstmap1type and the same size as src.
dstmap2 - The second output map.
dstmap1type - Type of the first output map that should be CV_16SC2, CV_32FC1, or CV_32FC2.
nninterpolation - Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation.
See Also:
org.opencv.imgproc.Imgproc.convertMaps, remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), initUndistortRectifyMap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, org.opencv.core.Mat, org.opencv.core.Mat), undistort(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

convexHull

public static void convexHull(MatOfPoint points,
                              MatOfInt hull)

Finds the convex hull of a point set.

The functions find the convex hull of a 2D point set using the Sklansky's algorithm [Sklansky82] that has *O(N logN)* complexity in the current implementation. See the OpenCV sample convexhull.cpp that demonstrates the usage of different function variants.

Parameters:
points - Input 2D point set, stored in std.vector or Mat.
hull - Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the hull elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, hull elements are the convex hull points themselves.
See Also:
org.opencv.imgproc.Imgproc.convexHull

convexHull

public static void convexHull(MatOfPoint points,
                              MatOfInt hull,
                              boolean clockwise)

Finds the convex hull of a point set.

The functions find the convex hull of a 2D point set using the Sklansky's algorithm [Sklansky82] that has *O(N logN)* complexity in the current implementation. See the OpenCV sample convexhull.cpp that demonstrates the usage of different function variants.

Parameters:
points - Input 2D point set, stored in std.vector or Mat.
hull - Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the hull elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, hull elements are the convex hull points themselves.
clockwise - Orientation flag. If it is true, the output convex hull is oriented clockwise. Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing to the right, and its Y axis pointing upwards.
See Also:
org.opencv.imgproc.Imgproc.convexHull

convexityDefects

public static void convexityDefects(MatOfPoint contour,
                                    MatOfInt convexhull,
                                    MatOfInt4 convexityDefects)

Finds the convexity defects of a contour.

The function finds all convexity defects of the input contour and returns a sequence of the CvConvexityDefect structures, where CvConvexityDetect is defined as:

// C++ code:

struct CvConvexityDefect

CvPoint* start; // point of the contour where the defect begins

CvPoint* end; // point of the contour where the defect ends

CvPoint* depth_point; // the farthest from the convex hull point within the defect

float depth; // distance between the farthest point and the convex hull

};

The figure below displays convexity defects of a hand contour:

Parameters:
contour - Input contour.
convexhull - Convex hull obtained using "convexHull" that should contain indices of the contour points that make the hull.
convexityDefects - The output vector of convexity defects. In C++ and the new Python/Java interface each convexity defect is represented as 4-element integer vector (a.k.a. cv.Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth), where indices are 0-based indices in the original contour of the convexity defect beginning, end and the farthest point, and fixpt_depth is fixed-point approximation (with 8 fractional bits) of the distance between the farthest contour point and the hull. That is, to get the floating-point value of the depth will be fixpt_depth/256.0. In C interface convexity defect is represented by CvConvexityDefect structure - see below.
See Also:
org.opencv.imgproc.Imgproc.convexityDefects

copyMakeBorder

public static void copyMakeBorder(Mat src,
                                  Mat dst,
                                  int top,
                                  int bottom,
                                  int left,
                                  int right,
                                  int borderType)

Forms a border around an image.

The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what "FilterEngine" or filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling. The function supports the mode when src is already in the middle of dst. In this case, the function does not copy src itself but simply constructs the border, for example:

// C++ code:

// let border be the same in all directions

int border=2;

// constructs a larger image to fit both the image and the border

Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());

// select the middle part of it w/o copying data

Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));

// convert image from RGB to grayscale

cvtColor(rgb, gray, CV_RGB2GRAY);

// form a border in-place

copyMakeBorder(gray, gray_buf, border, border,

border, border, BORDER_REPLICATE);

// now do some custom filtering......

Note:

When the source image is a part (ROI) of a bigger image, the function will try to use the pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as if src was not a ROI, use borderType | BORDER_ISOLATED.

Parameters:
src - Source image.
dst - Destination image of the same type as src and the size Size(src.cols+left+right, src.rows+top+bottom).
top - a top
bottom - a bottom
left - a left
right - Parameter specifying how many pixels in each direction from the source image rectangle to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs to be built.
borderType - Border type. See "borderInterpolate" for details.
See Also:
org.opencv.imgproc.Imgproc.copyMakeBorder, borderInterpolate(int, int, int)

copyMakeBorder

public static void copyMakeBorder(Mat src,
                                  Mat dst,
                                  int top,
                                  int bottom,
                                  int left,
                                  int right,
                                  int borderType,
                                  Scalar value)

Forms a border around an image.

The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what "FilterEngine" or filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling. The function supports the mode when src is already in the middle of dst. In this case, the function does not copy src itself but simply constructs the border, for example:

// C++ code:

// let border be the same in all directions

int border=2;

// constructs a larger image to fit both the image and the border

Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());

// select the middle part of it w/o copying data

Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));

// convert image from RGB to grayscale

cvtColor(rgb, gray, CV_RGB2GRAY);

// form a border in-place

copyMakeBorder(gray, gray_buf, border, border,

border, border, BORDER_REPLICATE);

// now do some custom filtering......

Note:

When the source image is a part (ROI) of a bigger image, the function will try to use the pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as if src was not a ROI, use borderType | BORDER_ISOLATED.

Parameters:
src - Source image.
dst - Destination image of the same type as src and the size Size(src.cols+left+right, src.rows+top+bottom).
top - a top
bottom - a bottom
left - a left
right - Parameter specifying how many pixels in each direction from the source image rectangle to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs to be built.
borderType - Border type. See "borderInterpolate" for details.
value - Border value if borderType==BORDER_CONSTANT.
See Also:
org.opencv.imgproc.Imgproc.copyMakeBorder, borderInterpolate(int, int, int)

cornerEigenValsAndVecs

public static void cornerEigenValsAndVecs(Mat src,
                                          Mat dst,
                                          int blockSize,
                                          int ksize)

Calculates eigenvalues and eigenvectors of image blocks for corner detection.

For every pixel p, the function cornerEigenValsAndVecs considers a blockSize x blockSize neighborhood S(p). It calculates the covariation matrix of derivatives over the neighborhood as:

M = sum(by: S(p))(dI/dx)^2 sum(by: S(p))(dI/dx dI/dy)^2 sum(by: S(p))(dI/dx dI/dy)^2 sum(by: S(p))(dI/dy)^2

where the derivatives are computed using the "Sobel" operator.

After that, it finds eigenvectors and eigenvalues of M and stores them in the destination image as (lambda_1, lambda_2, x_1, y_1, x_2, y_2) where

  • lambda_1, lambda_2 are the non-sorted eigenvalues of M
  • x_1, y_1 are the eigenvectors corresponding to lambda_1
  • x_2, y_2 are the eigenvectors corresponding to lambda_2

The output of the function can be used for robust edge or corner detection.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the results. It has the same size as src and the type CV_32FC(6).
blockSize - Neighborhood size (see details below).
ksize - Aperture parameter for the "Sobel" operator.
See Also:
org.opencv.imgproc.Imgproc.cornerEigenValsAndVecs, cornerHarris(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, int), cornerMinEigenVal(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int), preCornerDetect(org.opencv.core.Mat, org.opencv.core.Mat, int, int)

cornerEigenValsAndVecs

public static void cornerEigenValsAndVecs(Mat src,
                                          Mat dst,
                                          int blockSize,
                                          int ksize,
                                          int borderType)

Calculates eigenvalues and eigenvectors of image blocks for corner detection.

For every pixel p, the function cornerEigenValsAndVecs considers a blockSize x blockSize neighborhood S(p). It calculates the covariation matrix of derivatives over the neighborhood as:

M = sum(by: S(p))(dI/dx)^2 sum(by: S(p))(dI/dx dI/dy)^2 sum(by: S(p))(dI/dx dI/dy)^2 sum(by: S(p))(dI/dy)^2

where the derivatives are computed using the "Sobel" operator.

After that, it finds eigenvectors and eigenvalues of M and stores them in the destination image as (lambda_1, lambda_2, x_1, y_1, x_2, y_2) where

  • lambda_1, lambda_2 are the non-sorted eigenvalues of M
  • x_1, y_1 are the eigenvectors corresponding to lambda_1
  • x_2, y_2 are the eigenvectors corresponding to lambda_2

The output of the function can be used for robust edge or corner detection.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the results. It has the same size as src and the type CV_32FC(6).
blockSize - Neighborhood size (see details below).
ksize - Aperture parameter for the "Sobel" operator.
borderType - Pixel extrapolation method. See "borderInterpolate".
See Also:
org.opencv.imgproc.Imgproc.cornerEigenValsAndVecs, cornerHarris(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, int), cornerMinEigenVal(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int), preCornerDetect(org.opencv.core.Mat, org.opencv.core.Mat, int, int)

cornerHarris

public static void cornerHarris(Mat src,
                                Mat dst,
                                int blockSize,
                                int ksize,
                                double k)

Harris edge detector.

The function runs the Harris edge detector on the image. Similarly to "cornerMinEigenVal" and "cornerEigenValsAndVecs", for each pixel (x, y) it calculates a 2x2 gradient covariance matrix M^((x,y)) over a blockSize x blockSize neighborhood. Then, it computes the following characteristic:

dst(x,y) = det M^((x,y)) - k * (tr M^((x,y)))^2

Corners in the image can be found as the local maxima of this response map.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src.
blockSize - Neighborhood size (see the details on "cornerEigenValsAndVecs").
ksize - Aperture parameter for the "Sobel" operator.
k - Harris detector free parameter. See the formula below.
See Also:
org.opencv.imgproc.Imgproc.cornerHarris

cornerHarris

public static void cornerHarris(Mat src,
                                Mat dst,
                                int blockSize,
                                int ksize,
                                double k,
                                int borderType)

Harris edge detector.

The function runs the Harris edge detector on the image. Similarly to "cornerMinEigenVal" and "cornerEigenValsAndVecs", for each pixel (x, y) it calculates a 2x2 gradient covariance matrix M^((x,y)) over a blockSize x blockSize neighborhood. Then, it computes the following characteristic:

dst(x,y) = det M^((x,y)) - k * (tr M^((x,y)))^2

Corners in the image can be found as the local maxima of this response map.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src.
blockSize - Neighborhood size (see the details on "cornerEigenValsAndVecs").
ksize - Aperture parameter for the "Sobel" operator.
k - Harris detector free parameter. See the formula below.
borderType - Pixel extrapolation method. See "borderInterpolate".
See Also:
org.opencv.imgproc.Imgproc.cornerHarris

cornerMinEigenVal

public static void cornerMinEigenVal(Mat src,
                                     Mat dst,
                                     int blockSize)

Calculates the minimal eigenvalue of gradient matrices for corner detection.

The function is similar to "cornerEigenValsAndVecs" but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, min(lambda_1, lambda_2) in terms of the formulae in the "cornerEigenValsAndVecs" description.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src.
blockSize - Neighborhood size (see the details on "cornerEigenValsAndVecs").
See Also:
org.opencv.imgproc.Imgproc.cornerMinEigenVal

cornerMinEigenVal

public static void cornerMinEigenVal(Mat src,
                                     Mat dst,
                                     int blockSize,
                                     int ksize)

Calculates the minimal eigenvalue of gradient matrices for corner detection.

The function is similar to "cornerEigenValsAndVecs" but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, min(lambda_1, lambda_2) in terms of the formulae in the "cornerEigenValsAndVecs" description.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src.
blockSize - Neighborhood size (see the details on "cornerEigenValsAndVecs").
ksize - Aperture parameter for the "Sobel" operator.
See Also:
org.opencv.imgproc.Imgproc.cornerMinEigenVal

cornerMinEigenVal

public static void cornerMinEigenVal(Mat src,
                                     Mat dst,
                                     int blockSize,
                                     int ksize,
                                     int borderType)

Calculates the minimal eigenvalue of gradient matrices for corner detection.

The function is similar to "cornerEigenValsAndVecs" but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, min(lambda_1, lambda_2) in terms of the formulae in the "cornerEigenValsAndVecs" description.

Parameters:
src - Input single-channel 8-bit or floating-point image.
dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src.
blockSize - Neighborhood size (see the details on "cornerEigenValsAndVecs").
ksize - Aperture parameter for the "Sobel" operator.
borderType - Pixel extrapolation method. See "borderInterpolate".
See Also:
org.opencv.imgproc.Imgproc.cornerMinEigenVal

cornerSubPix

public static void cornerSubPix(Mat image,
                                MatOfPoint2f corners,
                                Size winSize,
                                Size zeroZone,
                                TermCriteria criteria)

Refines the corner locations.

The function iterates to find the sub-pixel accurate location of corners or radial saddle points, as shown on the figure below.

Sub-pixel accurate corner locator is based on the observation that every vector from the center q to a point p located within a neighborhood of q is orthogonal to the image gradient at p subject to image and measurement noise. Consider the expression:

epsilon _i = (DI_(p_i))^T * (q - p_i)

where (DI_(p_i)) is an image gradient at one of the points p_i in a neighborhood of q. The value of q is to be found so that epsilon_i is minimized. A system of equations may be set up with epsilon_i set to zero:

sum _i(DI_(p_i) * (DI_(p_i))^T) - sum _i(DI_(p_i) * (DI_(p_i))^T * p_i)

where the gradients are summed within a neighborhood ("search window") of q. Calling the first gradient term G and the second gradient term b gives:

q = G^(-1) * b

The algorithm sets the center of the neighborhood window at this new center q and then iterates until the center stays within a set threshold.

Parameters:
image - Input image.
corners - Initial coordinates of the input corners and refined coordinates provided for output.
winSize - Half of the side length of the search window. For example, if winSize=Size(5,5), then a 5*2+1 x 5*2+1 = 11 x 11 search window is used.
zeroZone - Half of the size of the dead region in the middle of the search zone over which the summation in the formula below is not done. It is used sometimes to avoid possible singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such a size.
criteria - Criteria for termination of the iterative process of corner refinement. That is, the process of corner position refinement stops either after criteria.maxCount iterations or when the corner position moves by less than criteria.epsilon on some iteration.
See Also:
org.opencv.imgproc.Imgproc.cornerSubPix

createHanningWindow

public static void createHanningWindow(Mat dst,
                                       Size winSize,
                                       int type)

This function computes a Hanning window coefficients in two dimensions. See http://en.wikipedia.org/wiki/Hann_function and http://en.wikipedia.org/wiki/Window_function for more information.

An example is shown below:

// C++ code:

// create hanning window of size 100x100 and type CV_32F

Mat hann;

createHanningWindow(hann, Size(100, 100), CV_32F);

Parameters:
dst - Destination array to place Hann coefficients in
winSize - The window size specifications
type - Created array type
See Also:
org.opencv.imgproc.Imgproc.createHanningWindow, phaseCorrelate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

cvtColor

public static void cvtColor(Mat src,
                            Mat dst,
                            int code)

Converts an image from one color space to another.

The function converts an input image from one color space to another. In case of a transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on.

The conventional ranges for R, G, and B channel values are:

  • 0 to 255 for CV_8U images
  • 0 to 65535 for CV_16U images
  • 0 to 1 for CV_32F images

In case of linear transformations, the range does not matter. But in case of a non-linear transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB-> L*u*v* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range instead of 0..1 assumed by the function. So, before calling cvtColor, you need first to scale the image down:

// C++ code:

img *= 1./255;

cvtColor(img, img, CV_BGR2Luv);

If you use cvtColor with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back.

The function can do the following transformations:

  • RGB <-> GRAY (CV_BGR2GRAY, CV_RGB2GRAY, CV_GRAY2BGR, CV_GRAY2RGB) Transformations within RGB space like adding/removing the alpha channel, reversing the channel order, conversion to/from 16-bit RGB color (R5:G6:B5 or R5:G5:B5), as well as conversion to/from grayscale using:

RGB[A] to Gray: Y <- 0.299 * R + 0.587 * G + 0.114 * B

and

Gray to RGB[A]: R <- Y, G <- Y, B <- Y, A <- 0

The conversion from a RGB image to gray is done with:

// C++ code:

cvtColor(src, bwsrc, CV_RGB2GRAY);

More advanced channel reordering can also be done with "mixChannels".

  • RGB <-> CIE XYZ.Rec 709 with D65 white point (CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB):

X Z ltBR gt <- 0.412453 0.357580 0.180423 0.212671 0.715160 0.072169 0.019334 0.119193 0.950227 ltBR gt * R B ltBR gt

R B ltBR gt <- 3.240479 -1.53715 -0.498535 -0.969256 1.875991 0.041556 0.055648 -0.204043 1.057311 ltBR gt * X Z ltBR gt

X, Y and Z cover the whole value range (in case of floating-point images, Z may exceed 1).

  • RGB <-> YCrCb JPEG (or YCC) (CV_BGR2YCrCb, CV_RGB2YCrCb, CV_YCrCb2BGR, CV_YCrCb2RGB)

Y <- 0.299 * R + 0.587 * G + 0.114 * B

Cr <- (R-Y) * 0.713 + delta

Cb <- (B-Y) * 0.564 + delta

R <- Y + 1.403 * (Cr - delta)

G <- Y - 0.714 * (Cr - delta) - 0.344 * (Cb - delta)

B <- Y + 1.773 * (Cb - delta)

where

delta = <= ft (128 for 8-bit images 32768 for 16-bit images 0.5 for floating-point images right.

Y, Cr, and Cb cover the whole value range.

  • RGB <-> HSV (CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR, CV_HSV2RGB) In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

V <- max(R,G,B)

S <- (V-min(R,G,B))/(V) if V != 0; 0 otherwise

H <- (60(G - B))/((V-min(R,G,B))) if V=R; (120+60(B - R))/((V-min(R,G,B))) if V=G; (240+60(R - G))/((V-min(R,G,B))) if V=B

If H<0 then H <- H+360. On output 0 <= V <= 1, 0 <= S <= 1, 0 <= H <= 360.

The values are then converted to the destination data type:

  • 8-bit images

V <- 255 V, S <- 255 S, H <- H/2(to fit to 0 to 255)

  • 16-bit images (currently not supported)

V <- 65535 V, S <- 65535 S, H <- H

  • 32-bit images H, S, and V are left as is
  • RGB <-> HLS (CV_BGR2HLS, CV_RGB2HLS, CV_HLS2BGR, CV_HLS2RGB).

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

V_(max) <- (max)(R,G,B)

V_(min) <- (min)(R,G,B)

L <- (V_(max) + V_(min))/2

S <- fork ((V_(max) - V_(min))/(V_(max) + V_(min)))(if L < 0.5)<BR>((V_(max) - V_(min))/(2 - (V_(max) + V_(min))))(if L >= 0.5)

H <- forkthree ((60(G - B))/(S))(if V_(max)=R)<BR>((120+60(B - R))/(S))(if V_(max)=G)<BR>((240+60(R - G))/(S))(if V_(max)=B)

If H<0 then H <- H+360. On output 0 <= L <= 1, 0 <= S <= 1, 0 <= H <= 360.

The values are then converted to the destination data type:

  • 8-bit images

V <- 255 * V, S <- 255 * S, H <- H/2(to fit to 0 to 255)

  • 16-bit images (currently not supported)

V <- 65535 * V, S <- 65535 * S, H <- H

  • 32-bit images H, S, V are left as is
  • RGB <-> CIE L*a*b* (CV_BGR2Lab, CV_RGB2Lab, CV_Lab2BGR, CV_Lab2RGB).

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

[X Y Z] <- |0.412453 0.357580 0.180423| |0.212671 0.715160 0.072169| |0.019334 0.119193 0.950227|

  • [R G B]

X <- X/X_n, where X_n = 0.950456

Z <- Z/Z_n, where Z_n = 1.088754

L <- 116*Y^(1/3)-16 for Y>0.008856; 903.3*Y for Y <= 0.008856

a <- 500(f(X)-f(Y)) + delta

b <- 200(f(Y)-f(Z)) + delta

where

f(t)= t^(1/3) for t>0.008856; 7.787 t+16/116 for t <= 0.008856

and

delta = 128 for 8-bit images; 0 for floating-point images

This outputs 0 <= L <= 100, -127 <= a <= 127, -127 <= b <= 127. The values are then converted to the destination data type:

  • 8-bit images

L <- L*255/100, a <- a + 128, b <- b + 128

  • 16-bit images (currently not supported)
  • 32-bit images L, a, and b are left as is
  • RGB <-> CIE L*u*v* (CV_BGR2Luv, CV_RGB2Luv, CV_Luv2BGR, CV_Luv2RGB).

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit 0 to 1 range.

[X Y Z] <- |0.412453 0.357580 0.180423| |0.212671 0.715160 0.072169| |0.019334 0.119193 0.950227|

  • [R G B]

L <- 116 Y^(1/3) for Y>0.008856; 903.3 Y for Y <= 0.008856

u' <- 4*X/(X + 15*Y + 3 Z)

v' <- 9*Y/(X + 15*Y + 3 Z)

u <- 13*L*(u' - u_n) where u_n=0.19793943

v <- 13*L*(v' - v_n) where v_n=0.46831096

This outputs 0 <= L <= 100, -134 <= u <= 220, -140 <= v <= 122.

The values are then converted to the destination data type:

  • 8-bit images

L <- 255/100 L, u <- 255/354(u + 134), v <- 255/256(v + 140)

  • 16-bit images (currently not supported)
  • 32-bit images L, u, and v are left as is

The above formulae for converting RGB to/from various color spaces have been taken from multiple sources on the web, primarily from the Charles Poynton site http://www.poynton.com/ColorFAQ.html

  • Bayer -> RGB (CV_BayerBG2BGR, CV_BayerGB2BGR, CV_BayerRG2BGR, CV_BayerGR2BGR, CV_BayerBG2RGB, CV_BayerGB2RGB, CV_BayerRG2RGB, CV_BayerGR2RGB). The Bayer pattern is widely used in CCD and CMOS cameras. It enables you to get color pictures from a single plane where R,G, and B pixels (sensors of a particular component) are interleaved as follows: The output RGB components of a pixel are interpolated from 1, 2, or

// C++ code:

4 neighbors of the pixel having the same color. There are several

modifications of the above pattern that can be achieved by shifting

the pattern one pixel left and/or one pixel up. The two letters

C_1 and

C_2 in the conversion constants CV_Bayer C_1 C_2 2BGR and CV_Bayer C_1 C_2 2RGB indicate the particular pattern

type. These are components from the second row, second and third

columns, respectively. For example, the above pattern has a very

popular "BG" type.

Parameters:
src - input image: 8-bit unsigned, 16-bit unsigned (CV_16UC...), or single-precision floating-point.
dst - output image of the same size and depth as src.
code - color space conversion code (see the description below).
See Also:
org.opencv.imgproc.Imgproc.cvtColor

cvtColor

public static void cvtColor(Mat src,
                            Mat dst,
                            int code,
                            int dstCn)

Converts an image from one color space to another.

The function converts an input image from one color space to another. In case of a transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on.

The conventional ranges for R, G, and B channel values are:

  • 0 to 255 for CV_8U images
  • 0 to 65535 for CV_16U images
  • 0 to 1 for CV_32F images

In case of linear transformations, the range does not matter. But in case of a non-linear transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB-> L*u*v* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range instead of 0..1 assumed by the function. So, before calling cvtColor, you need first to scale the image down:

// C++ code:

img *= 1./255;

cvtColor(img, img, CV_BGR2Luv);

If you use cvtColor with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back.

The function can do the following transformations:

  • RGB <-> GRAY (CV_BGR2GRAY, CV_RGB2GRAY, CV_GRAY2BGR, CV_GRAY2RGB) Transformations within RGB space like adding/removing the alpha channel, reversing the channel order, conversion to/from 16-bit RGB color (R5:G6:B5 or R5:G5:B5), as well as conversion to/from grayscale using:

RGB[A] to Gray: Y <- 0.299 * R + 0.587 * G + 0.114 * B

and

Gray to RGB[A]: R <- Y, G <- Y, B <- Y, A <- 0

The conversion from a RGB image to gray is done with:

// C++ code:

cvtColor(src, bwsrc, CV_RGB2GRAY);

More advanced channel reordering can also be done with "mixChannels".

  • RGB <-> CIE XYZ.Rec 709 with D65 white point (CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB):

X Z ltBR gt <- 0.412453 0.357580 0.180423 0.212671 0.715160 0.072169 0.019334 0.119193 0.950227 ltBR gt * R B ltBR gt

R B ltBR gt <- 3.240479 -1.53715 -0.498535 -0.969256 1.875991 0.041556 0.055648 -0.204043 1.057311 ltBR gt * X Z ltBR gt

X, Y and Z cover the whole value range (in case of floating-point images, Z may exceed 1).

  • RGB <-> YCrCb JPEG (or YCC) (CV_BGR2YCrCb, CV_RGB2YCrCb, CV_YCrCb2BGR, CV_YCrCb2RGB)

Y <- 0.299 * R + 0.587 * G + 0.114 * B

Cr <- (R-Y) * 0.713 + delta

Cb <- (B-Y) * 0.564 + delta

R <- Y + 1.403 * (Cr - delta)

G <- Y - 0.714 * (Cr - delta) - 0.344 * (Cb - delta)

B <- Y + 1.773 * (Cb - delta)

where

delta = <= ft (128 for 8-bit images 32768 for 16-bit images 0.5 for floating-point images right.

Y, Cr, and Cb cover the whole value range.

  • RGB <-> HSV (CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR, CV_HSV2RGB) In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

V <- max(R,G,B)

S <- (V-min(R,G,B))/(V) if V != 0; 0 otherwise

H <- (60(G - B))/((V-min(R,G,B))) if V=R; (120+60(B - R))/((V-min(R,G,B))) if V=G; (240+60(R - G))/((V-min(R,G,B))) if V=B

If H<0 then H <- H+360. On output 0 <= V <= 1, 0 <= S <= 1, 0 <= H <= 360.

The values are then converted to the destination data type:

  • 8-bit images

V <- 255 V, S <- 255 S, H <- H/2(to fit to 0 to 255)

  • 16-bit images (currently not supported)

V <- 65535 V, S <- 65535 S, H <- H

  • 32-bit images H, S, and V are left as is
  • RGB <-> HLS (CV_BGR2HLS, CV_RGB2HLS, CV_HLS2BGR, CV_HLS2RGB).

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

V_(max) <- (max)(R,G,B)

V_(min) <- (min)(R,G,B)

L <- (V_(max) + V_(min))/2

S <- fork ((V_(max) - V_(min))/(V_(max) + V_(min)))(if L < 0.5)<BR>((V_(max) - V_(min))/(2 - (V_(max) + V_(min))))(if L >= 0.5)

H <- forkthree ((60(G - B))/(S))(if V_(max)=R)<BR>((120+60(B - R))/(S))(if V_(max)=G)<BR>((240+60(R - G))/(S))(if V_(max)=B)

If H<0 then H <- H+360. On output 0 <= L <= 1, 0 <= S <= 1, 0 <= H <= 360.

The values are then converted to the destination data type:

  • 8-bit images

V <- 255 * V, S <- 255 * S, H <- H/2(to fit to 0 to 255)

  • 16-bit images (currently not supported)

V <- 65535 * V, S <- 65535 * S, H <- H

  • 32-bit images H, S, V are left as is
  • RGB <-> CIE L*a*b* (CV_BGR2Lab, CV_RGB2Lab, CV_Lab2BGR, CV_Lab2RGB).

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.

[X Y Z] <- |0.412453 0.357580 0.180423| |0.212671 0.715160 0.072169| |0.019334 0.119193 0.950227|

  • [R G B]

X <- X/X_n, where X_n = 0.950456

Z <- Z/Z_n, where Z_n = 1.088754

L <- 116*Y^(1/3)-16 for Y>0.008856; 903.3*Y for Y <= 0.008856

a <- 500(f(X)-f(Y)) + delta

b <- 200(f(Y)-f(Z)) + delta

where

f(t)= t^(1/3) for t>0.008856; 7.787 t+16/116 for t <= 0.008856

and

delta = 128 for 8-bit images; 0 for floating-point images

This outputs 0 <= L <= 100, -127 <= a <= 127, -127 <= b <= 127. The values are then converted to the destination data type:

  • 8-bit images

L <- L*255/100, a <- a + 128, b <- b + 128

  • 16-bit images (currently not supported)
  • 32-bit images L, a, and b are left as is
  • RGB <-> CIE L*u*v* (CV_BGR2Luv, CV_RGB2Luv, CV_Luv2BGR, CV_Luv2RGB).

In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit 0 to 1 range.

[X Y Z] <- |0.412453 0.357580 0.180423| |0.212671 0.715160 0.072169| |0.019334 0.119193 0.950227|

  • [R G B]

L <- 116 Y^(1/3) for Y>0.008856; 903.3 Y for Y <= 0.008856

u' <- 4*X/(X + 15*Y + 3 Z)

v' <- 9*Y/(X + 15*Y + 3 Z)

u <- 13*L*(u' - u_n) where u_n=0.19793943

v <- 13*L*(v' - v_n) where v_n=0.46831096

This outputs 0 <= L <= 100, -134 <= u <= 220, -140 <= v <= 122.

The values are then converted to the destination data type:

  • 8-bit images

L <- 255/100 L, u <- 255/354(u + 134), v <- 255/256(v + 140)

  • 16-bit images (currently not supported)
  • 32-bit images L, u, and v are left as is

The above formulae for converting RGB to/from various color spaces have been taken from multiple sources on the web, primarily from the Charles Poynton site http://www.poynton.com/ColorFAQ.html

  • Bayer -> RGB (CV_BayerBG2BGR, CV_BayerGB2BGR, CV_BayerRG2BGR, CV_BayerGR2BGR, CV_BayerBG2RGB, CV_BayerGB2RGB, CV_BayerRG2RGB, CV_BayerGR2RGB). The Bayer pattern is widely used in CCD and CMOS cameras. It enables you to get color pictures from a single plane where R,G, and B pixels (sensors of a particular component) are interleaved as follows: The output RGB components of a pixel are interpolated from 1, 2, or

// C++ code:

4 neighbors of the pixel having the same color. There are several

modifications of the above pattern that can be achieved by shifting

the pattern one pixel left and/or one pixel up. The two letters

C_1 and

C_2 in the conversion constants CV_Bayer C_1 C_2 2BGR and CV_Bayer C_1 C_2 2RGB indicate the particular pattern

type. These are components from the second row, second and third

columns, respectively. For example, the above pattern has a very

popular "BG" type.

Parameters:
src - input image: 8-bit unsigned, 16-bit unsigned (CV_16UC...), or single-precision floating-point.
dst - output image of the same size and depth as src.
code - color space conversion code (see the description below).
dstCn - number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code.
See Also:
org.opencv.imgproc.Imgproc.cvtColor

dilate

public static void dilate(Mat src,
                          Mat dst,
                          Mat kernel)

Dilates an image by using a specific structuring element.

The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:

dst(x,y) = max _((x',y'): element(x',y') != 0) src(x+x',y+y')

The function supports the in-place mode. Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.

Parameters:
src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - output image of the same size and type as src.
kernel - a kernel
See Also:
org.opencv.imgproc.Imgproc.dilate, erode(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), morphologyEx(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

dilate

public static void dilate(Mat src,
                          Mat dst,
                          Mat kernel,
                          Point anchor,
                          int iterations)

Dilates an image by using a specific structuring element.

The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:

dst(x,y) = max _((x',y'): element(x',y') != 0) src(x+x',y+y')

The function supports the in-place mode. Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.

Parameters:
src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - output image of the same size and type as src.
kernel - a kernel
anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
iterations - number of times dilation is applied.
See Also:
org.opencv.imgproc.Imgproc.dilate, erode(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), morphologyEx(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

dilate

public static void dilate(Mat src,
                          Mat dst,
                          Mat kernel,
                          Point anchor,
                          int iterations,
                          int borderType,
                          Scalar borderValue)

Dilates an image by using a specific structuring element.

The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:

dst(x,y) = max _((x',y'): element(x',y') != 0) src(x+x',y+y')

The function supports the in-place mode. Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.

Parameters:
src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - output image of the same size and type as src.
kernel - a kernel
anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
iterations - number of times dilation is applied.
borderType - pixel extrapolation method (see "borderInterpolate" for details).
borderValue - border value in case of a constant border (see "createMorphologyFilter" for details).
See Also:
org.opencv.imgproc.Imgproc.dilate, erode(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), morphologyEx(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

distanceTransform

public static void distanceTransform(Mat src,
                                     Mat dst,
                                     int distanceType,
                                     int maskSize)

Calculates the distance to the closest zero pixel for each pixel of the source image.

The functions distanceTransform calculate the approximate or precise distance from every binary image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero.

When maskSize == CV_DIST_MASK_PRECISE and distanceType == CV_DIST_L2, the function runs the algorithm described in [Felzenszwalb04]. This algorithm is parallelized with the TBB library.

In other cases, the algorithm [Borgefors86] is used. This means that for a pixel the function finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, diagonal, or knight's move (the latest is available for a 5x 5 mask). The overall distance is calculated as a sum of these basic distances. Since the distance function should be symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a), all the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the same cost (denoted as c). For the CV_DIST_C and CV_DIST_L1 types, the distance is calculated precisely, whereas for CV_DIST_L2 (Euclidean distance) the distance can be calculated only with a relative error (a 5x 5 mask gives more accurate results). For a,b, and c, OpenCV uses the values suggested in the original paper:

============== =================== ====================== CV_DIST_C (3x 3) a = 1, b = 1 \ ============== =================== ====================== CV_DIST_L1 (3x 3) a = 1, b = 2 \ CV_DIST_L2 (3x 3) a=0.955, b=1.3693 \ CV_DIST_L2 (5x 5) a=1, b=1.4, c=2.1969 \ ============== =================== ======================

Typically, for a fast, coarse distance estimation CV_DIST_L2, a 3x 3 mask is used. For a more accurate distance estimation CV_DIST_L2, a 5x 5 mask or the precise algorithm is used. Note that both the precise and the approximate algorithms are linear on the number of pixels.

The second variant of the function does not only compute the minimum distance for each pixel (x, y) but also identifies the nearest connected component consisting of zero pixels (labelType==DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==DIST_LABEL_PIXEL). Index of the component/pixel is stored in labels(x, y). When labelType==DIST_LABEL_CCOMP, the function automatically finds connected components of zero pixels in the input image and marks them with distinct labels. When labelType==DIST_LABEL_CCOMP, the function scans through the input image and marks all the zero pixels with distinct labels.

In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the approximate distance transform algorithm, i.e. maskSize=CV_DIST_MASK_PRECISE is not supported yet.

Parameters:
src - 8-bit, single-channel (binary) source image.
dst - Output image with calculated distances. It is a 32-bit floating-point, single-channel image of the same size as src.
distanceType - Type of distance. It can be CV_DIST_L1, CV_DIST_L2, or CV_DIST_C.
maskSize - Size of the distance transform mask. It can be 3, 5, or CV_DIST_MASK_PRECISE (the latter option is only supported by the first function). In case of the CV_DIST_L1 or CV_DIST_C distance type, the parameter is forced to 3 because a 3x 3 mask gives the same result as 5x 5 or any larger aperture.
See Also:
org.opencv.imgproc.Imgproc.distanceTransform

distanceTransformWithLabels

public static void distanceTransformWithLabels(Mat src,
                                               Mat dst,
                                               Mat labels,
                                               int distanceType,
                                               int maskSize)

Calculates the distance to the closest zero pixel for each pixel of the source image.

The functions distanceTransform calculate the approximate or precise distance from every binary image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero.

When maskSize == CV_DIST_MASK_PRECISE and distanceType == CV_DIST_L2, the function runs the algorithm described in [Felzenszwalb04]. This algorithm is parallelized with the TBB library.

In other cases, the algorithm [Borgefors86] is used. This means that for a pixel the function finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, diagonal, or knight's move (the latest is available for a 5x 5 mask). The overall distance is calculated as a sum of these basic distances. Since the distance function should be symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a), all the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the same cost (denoted as c). For the CV_DIST_C and CV_DIST_L1 types, the distance is calculated precisely, whereas for CV_DIST_L2 (Euclidean distance) the distance can be calculated only with a relative error (a 5x 5 mask gives more accurate results). For a,b, and c, OpenCV uses the values suggested in the original paper:

============== =================== ====================== CV_DIST_C (3x 3) a = 1, b = 1 \ ============== =================== ====================== CV_DIST_L1 (3x 3) a = 1, b = 2 \ CV_DIST_L2 (3x 3) a=0.955, b=1.3693 \ CV_DIST_L2 (5x 5) a=1, b=1.4, c=2.1969 \ ============== =================== ======================

Typically, for a fast, coarse distance estimation CV_DIST_L2, a 3x 3 mask is used. For a more accurate distance estimation CV_DIST_L2, a 5x 5 mask or the precise algorithm is used. Note that both the precise and the approximate algorithms are linear on the number of pixels.

The second variant of the function does not only compute the minimum distance for each pixel (x, y) but also identifies the nearest connected component consisting of zero pixels (labelType==DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==DIST_LABEL_PIXEL). Index of the component/pixel is stored in labels(x, y). When labelType==DIST_LABEL_CCOMP, the function automatically finds connected components of zero pixels in the input image and marks them with distinct labels. When labelType==DIST_LABEL_CCOMP, the function scans through the input image and marks all the zero pixels with distinct labels.

In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the approximate distance transform algorithm, i.e. maskSize=CV_DIST_MASK_PRECISE is not supported yet.

Parameters:
src - 8-bit, single-channel (binary) source image.
dst - Output image with calculated distances. It is a 32-bit floating-point, single-channel image of the same size as src.
labels - Optional output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src. See the details below.
distanceType - Type of distance. It can be CV_DIST_L1, CV_DIST_L2, or CV_DIST_C.
maskSize - Size of the distance transform mask. It can be 3, 5, or CV_DIST_MASK_PRECISE (the latter option is only supported by the first function). In case of the CV_DIST_L1 or CV_DIST_C distance type, the parameter is forced to 3 because a 3x 3 mask gives the same result as 5x 5 or any larger aperture.
See Also:
org.opencv.imgproc.Imgproc.distanceTransform

distanceTransformWithLabels

public static void distanceTransformWithLabels(Mat src,
                                               Mat dst,
                                               Mat labels,
                                               int distanceType,
                                               int maskSize,
                                               int labelType)

Calculates the distance to the closest zero pixel for each pixel of the source image.

The functions distanceTransform calculate the approximate or precise distance from every binary image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero.

When maskSize == CV_DIST_MASK_PRECISE and distanceType == CV_DIST_L2, the function runs the algorithm described in [Felzenszwalb04]. This algorithm is parallelized with the TBB library.

In other cases, the algorithm [Borgefors86] is used. This means that for a pixel the function finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, diagonal, or knight's move (the latest is available for a 5x 5 mask). The overall distance is calculated as a sum of these basic distances. Since the distance function should be symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a), all the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the same cost (denoted as c). For the CV_DIST_C and CV_DIST_L1 types, the distance is calculated precisely, whereas for CV_DIST_L2 (Euclidean distance) the distance can be calculated only with a relative error (a 5x 5 mask gives more accurate results). For a,b, and c, OpenCV uses the values suggested in the original paper:

============== =================== ====================== CV_DIST_C (3x 3) a = 1, b = 1 \ ============== =================== ====================== CV_DIST_L1 (3x 3) a = 1, b = 2 \ CV_DIST_L2 (3x 3) a=0.955, b=1.3693 \ CV_DIST_L2 (5x 5) a=1, b=1.4, c=2.1969 \ ============== =================== ======================

Typically, for a fast, coarse distance estimation CV_DIST_L2, a 3x 3 mask is used. For a more accurate distance estimation CV_DIST_L2, a 5x 5 mask or the precise algorithm is used. Note that both the precise and the approximate algorithms are linear on the number of pixels.

The second variant of the function does not only compute the minimum distance for each pixel (x, y) but also identifies the nearest connected component consisting of zero pixels (labelType==DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==DIST_LABEL_PIXEL). Index of the component/pixel is stored in labels(x, y). When labelType==DIST_LABEL_CCOMP, the function automatically finds connected components of zero pixels in the input image and marks them with distinct labels. When labelType==DIST_LABEL_CCOMP, the function scans through the input image and marks all the zero pixels with distinct labels.

In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the approximate distance transform algorithm, i.e. maskSize=CV_DIST_MASK_PRECISE is not supported yet.

Parameters:
src - 8-bit, single-channel (binary) source image.
dst - Output image with calculated distances. It is a 32-bit floating-point, single-channel image of the same size as src.
labels - Optional output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src. See the details below.
distanceType - Type of distance. It can be CV_DIST_L1, CV_DIST_L2, or CV_DIST_C.
maskSize - Size of the distance transform mask. It can be 3, 5, or CV_DIST_MASK_PRECISE (the latter option is only supported by the first function). In case of the CV_DIST_L1 or CV_DIST_C distance type, the parameter is forced to 3 because a 3x 3 mask gives the same result as 5x 5 or any larger aperture.
labelType - Type of the label array to build. If labelType==DIST_LABEL_CCOMP then each connected component of zeros in src (as well as all the non-zero pixels closest to the connected component) will be assigned the same label. If labelType==DIST_LABEL_PIXEL then each zero pixel (and all the non-zero pixels closest to it) gets its own label.
See Also:
org.opencv.imgproc.Imgproc.distanceTransform

drawContours

public static void drawContours(Mat image,
                                java.util.List<MatOfPoint> contours,
                                int contourIdx,
                                Scalar color)

Draws contours outlines or filled contours.

The function draws contour outlines in the image if thickness >= 0 or fills the area bounded by the contours ifthickness<0. The example below shows how to retrieve connected components from the binary image and label them:

// C++ code:

#include "cv.h"

#include "highgui.h"

using namespace cv;

int main(int argc, char argv)

Mat src;

// the first command-line parameter must be a filename of the binary

// (black-n-white) image

if(argc != 2 || !(src=imread(argv[1], 0)).data)

return -1;

Mat dst = Mat.zeros(src.rows, src.cols, CV_8UC3);

src = src > 1;

namedWindow("Source", 1);

imshow("Source", src);

vector > contours;

vector hierarchy;

findContours(src, contours, hierarchy,

CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

// iterate through all the top-level contours,

// draw each connected component with its own random color

int idx = 0;

for(; idx >= 0; idx = hierarchy[idx][0])

Scalar color(rand()&255, rand()&255, rand()&255);

drawContours(dst, contours, idx, color, CV_FILLED, 8, hierarchy);

namedWindow("Components", 1);

imshow("Components", dst);

waitKey(0);

Parameters:
image - Destination image.
contours - All the input contours. Each contour is stored as a point vector.
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
color - Color of the contours.
See Also:
org.opencv.imgproc.Imgproc.drawContours

drawContours

public static void drawContours(Mat image,
                                java.util.List<MatOfPoint> contours,
                                int contourIdx,
                                Scalar color,
                                int thickness)

Draws contours outlines or filled contours.

The function draws contour outlines in the image if thickness >= 0 or fills the area bounded by the contours ifthickness<0. The example below shows how to retrieve connected components from the binary image and label them:

// C++ code:

#include "cv.h"

#include "highgui.h"

using namespace cv;

int main(int argc, char argv)

Mat src;

// the first command-line parameter must be a filename of the binary

// (black-n-white) image

if(argc != 2 || !(src=imread(argv[1], 0)).data)

return -1;

Mat dst = Mat.zeros(src.rows, src.cols, CV_8UC3);

src = src > 1;

namedWindow("Source", 1);

imshow("Source", src);

vector > contours;

vector hierarchy;

findContours(src, contours, hierarchy,

CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

// iterate through all the top-level contours,

// draw each connected component with its own random color

int idx = 0;

for(; idx >= 0; idx = hierarchy[idx][0])

Scalar color(rand()&255, rand()&255, rand()&255);

drawContours(dst, contours, idx, color, CV_FILLED, 8, hierarchy);

namedWindow("Components", 1);

imshow("Components", dst);

waitKey(0);

Parameters:
image - Destination image.
contours - All the input contours. Each contour is stored as a point vector.
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
color - Color of the contours.
thickness - Thickness of lines the contours are drawn with. If it is negative (for example, thickness=CV_FILLED), the contour interiors are drawn.
See Also:
org.opencv.imgproc.Imgproc.drawContours

drawContours

public static void drawContours(Mat image,
                                java.util.List<MatOfPoint> contours,
                                int contourIdx,
                                Scalar color,
                                int thickness,
                                int lineType,
                                Mat hierarchy,
                                int maxLevel,
                                Point offset)

Draws contours outlines or filled contours.

The function draws contour outlines in the image if thickness >= 0 or fills the area bounded by the contours ifthickness<0. The example below shows how to retrieve connected components from the binary image and label them:

// C++ code:

#include "cv.h"

#include "highgui.h"

using namespace cv;

int main(int argc, char argv)

Mat src;

// the first command-line parameter must be a filename of the binary

// (black-n-white) image

if(argc != 2 || !(src=imread(argv[1], 0)).data)

return -1;

Mat dst = Mat.zeros(src.rows, src.cols, CV_8UC3);

src = src > 1;

namedWindow("Source", 1);

imshow("Source", src);

vector > contours;

vector hierarchy;

findContours(src, contours, hierarchy,

CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

// iterate through all the top-level contours,

// draw each connected component with its own random color

int idx = 0;

for(; idx >= 0; idx = hierarchy[idx][0])

Scalar color(rand()&255, rand()&255, rand()&255);

drawContours(dst, contours, idx, color, CV_FILLED, 8, hierarchy);

namedWindow("Components", 1);

imshow("Components", dst);

waitKey(0);

Parameters:
image - Destination image.
contours - All the input contours. Each contour is stored as a point vector.
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
color - Color of the contours.
thickness - Thickness of lines the contours are drawn with. If it is negative (for example, thickness=CV_FILLED), the contour interiors are drawn.
lineType - Line connectivity. See "line" for details.
hierarchy - Optional information about hierarchy. It is only needed if you want to draw only some of the contours (see maxLevel).
maxLevel - Maximal level for drawn contours. If it is 0, only the specified contour is drawn. If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This parameter is only taken into account when there is hierarchy available.
offset - Optional contour shift parameter. Shift all the drawn contours by the specified offset=(dx,dy).
See Also:
org.opencv.imgproc.Imgproc.drawContours

equalizeHist

public static void equalizeHist(Mat src,
                                Mat dst)

Equalizes the histogram of a grayscale image.

The function equalizes the histogram of the input image using the following algorithm:

  • Calculate the histogram H for src.
  • Normalize the histogram so that the sum of histogram bins is 255.
  • Compute the integral of the histogram:

H'_i = sum(by: 0 <= j < i) H(j)

Transform the image using H' as a look-up table: dst(x,y) = H'(src(x,y))

The algorithm normalizes the brightness and increases the contrast of the image.

Parameters:
src - Source 8-bit single channel image.
dst - Destination image of the same size and type as src.
See Also:
org.opencv.imgproc.Imgproc.equalizeHist

erode

public static void erode(Mat src,
                         Mat dst,
                         Mat kernel)

Erodes an image by using a specific structuring element.

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:

dst(x,y) = min _((x',y'): element(x',y') != 0) src(x+x',y+y')

The function supports the in-place mode. Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.

Parameters:
src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - output image of the same size and type as src.
kernel - a kernel
See Also:
org.opencv.imgproc.Imgproc.erode, morphologyEx(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), dilate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

erode

public static void erode(Mat src,
                         Mat dst,
                         Mat kernel,
                         Point anchor,
                         int iterations)

Erodes an image by using a specific structuring element.

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:

dst(x,y) = min _((x',y'): element(x',y') != 0) src(x+x',y+y')

The function supports the in-place mode. Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.

Parameters:
src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - output image of the same size and type as src.
kernel - a kernel
anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
iterations - number of times erosion is applied.
See Also:
org.opencv.imgproc.Imgproc.erode, morphologyEx(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), dilate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

erode

public static void erode(Mat src,
                         Mat dst,
                         Mat kernel,
                         Point anchor,
                         int iterations,
                         int borderType,
                         Scalar borderValue)

Erodes an image by using a specific structuring element.

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:

dst(x,y) = min _((x',y'): element(x',y') != 0) src(x+x',y+y')

The function supports the in-place mode. Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.

Parameters:
src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - output image of the same size and type as src.
kernel - a kernel
anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
iterations - number of times erosion is applied.
borderType - pixel extrapolation method (see "borderInterpolate" for details).
borderValue - border value in case of a constant border (see "createMorphologyFilter" for details).
See Also:
org.opencv.imgproc.Imgproc.erode, morphologyEx(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), dilate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

filter2D

public static void filter2D(Mat src,
                            Mat dst,
                            int ddepth,
                            Mat kernel)

Convolves an image with the kernel.

The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.

The function does actually compute correlation, not the convolution:

dst(x,y) = sum(by: 0 <= x' < kernel.cols, 0 <= y' < kernel.rows) kernel(x',y')* src(x+x'- anchor.x,y+y'- anchor.y)

That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using "flip" and set the new anchor to (kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1).

The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm (that uses the engine retrieved by "createLinearFilter") for small kernels.

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - desired depth of the destination image; if it is negative, it will be the same as src.depth(); the following combinations of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the output image will have the same depth as the source.

kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using "split" and process them individually.
See Also:
org.opencv.imgproc.Imgproc.filter2D, matchTemplate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int), Core.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int)

filter2D

public static void filter2D(Mat src,
                            Mat dst,
                            int ddepth,
                            Mat kernel,
                            Point anchor,
                            double delta)

Convolves an image with the kernel.

The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.

The function does actually compute correlation, not the convolution:

dst(x,y) = sum(by: 0 <= x' < kernel.cols, 0 <= y' < kernel.rows) kernel(x',y')* src(x+x'- anchor.x,y+y'- anchor.y)

That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using "flip" and set the new anchor to (kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1).

The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm (that uses the engine retrieved by "createLinearFilter") for small kernels.

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - desired depth of the destination image; if it is negative, it will be the same as src.depth(); the following combinations of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the output image will have the same depth as the source.

kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using "split" and process them individually.
anchor - anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
delta - optional value added to the filtered pixels before storing them in dst.
See Also:
org.opencv.imgproc.Imgproc.filter2D, matchTemplate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int), Core.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int)

filter2D

public static void filter2D(Mat src,
                            Mat dst,
                            int ddepth,
                            Mat kernel,
                            Point anchor,
                            double delta,
                            int borderType)

Convolves an image with the kernel.

The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.

The function does actually compute correlation, not the convolution:

dst(x,y) = sum(by: 0 <= x' < kernel.cols, 0 <= y' < kernel.rows) kernel(x',y')* src(x+x'- anchor.x,y+y'- anchor.y)

That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using "flip" and set the new anchor to (kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1).

The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm (that uses the engine retrieved by "createLinearFilter") for small kernels.

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - desired depth of the destination image; if it is negative, it will be the same as src.depth(); the following combinations of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the output image will have the same depth as the source.

kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using "split" and process them individually.
anchor - anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
delta - optional value added to the filtered pixels before storing them in dst.
borderType - pixel extrapolation method (see "borderInterpolate" for details).
See Also:
org.opencv.imgproc.Imgproc.filter2D, matchTemplate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int), Core.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int)

findContours

public static void findContours(Mat image,
                                java.util.List<MatOfPoint> contours,
                                Mat hierarchy,
                                int mode,
                                int method)

Finds contours in a binary image.

The function retrieves contours from the binary image using the algorithm [Suzuki85]. The contours are a useful tool for shape analysis and object detection and recognition. See squares.c in the OpenCV sample directory.

Note: Source image is modified by this function. Also, the function does not take into account 1-pixel border of the image (it's filled with 0's and used for neighbor analysis in the algorithm), therefore the contours touching the image border will be clipped.

Note: If you use the new Python interface then the CV_ prefix has to be omitted in contour retrieval mode and contour approximation method parameters (for example, use cv2.RETR_LIST and cv2.CHAIN_APPROX_NONE parameters). If you use the old Python interface then these parameters have the CV_ prefix (for example, use cv.CV_RETR_LIST and cv.CV_CHAIN_APPROX_NONE).

Parameters:
image - Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as binary. You can use "compare", "inRange", "threshold", "adaptiveThreshold", "Canny", and others to create a binary image out of a grayscale or color one. The function modifies the image while extracting the contours.
contours - Detected contours. Each contour is stored as a vector of points.
hierarchy - Optional output vector, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour contours[i], the elements hierarchy[i][0], hiearchy[i][1], hiearchy[i][2], and hiearchy[i][3] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
mode - Contour retrieval mode (if you use Python see also a note below).
  • CV_RETR_EXTERNAL retrieves only the extreme outer contours. It sets hierarchy[i][2]=hierarchy[i][3]=-1 for all the contours.
  • CV_RETR_LIST retrieves all of the contours without establishing any hierarchical relationships.
  • CV_RETR_CCOMP retrieves all of the contours and organizes them into a two-level hierarchy. At the top level, there are external boundaries of the components. At the second level, there are boundaries of the holes. If there is another contour inside a hole of a connected component, it is still put at the top level.
  • CV_RETR_TREE retrieves all of the contours and reconstructs a full hierarchy of nested contours. This full hierarchy is built and shown in the OpenCV contours.c demo.
method - Contour approximation method (if you use Python see also a note below).
  • CV_CHAIN_APPROX_NONE stores absolutely all the contour points. That is, any 2 subsequent points (x1,y1) and (x2,y2) of the contour will be either horizontal, vertical or diagonal neighbors, that is, max(abs(x1-x2),abs(y2-y1))==1.
  • CV_CHAIN_APPROX_SIMPLE compresses horizontal, vertical, and diagonal segments and leaves only their end points. For example, an up-right rectangular contour is encoded with 4 points.
  • CV_CHAIN_APPROX_TC89_L1,CV_CHAIN_APPROX_TC89_KCOS applies one of the flavors of the Teh-Chin chain approximation algorithm. See [TehChin89] for details.
See Also:
org.opencv.imgproc.Imgproc.findContours

findContours

public static void findContours(Mat image,
                                java.util.List<MatOfPoint> contours,
                                Mat hierarchy,
                                int mode,
                                int method,
                                Point offset)

Finds contours in a binary image.

The function retrieves contours from the binary image using the algorithm [Suzuki85]. The contours are a useful tool for shape analysis and object detection and recognition. See squares.c in the OpenCV sample directory.

Note: Source image is modified by this function. Also, the function does not take into account 1-pixel border of the image (it's filled with 0's and used for neighbor analysis in the algorithm), therefore the contours touching the image border will be clipped.

Note: If you use the new Python interface then the CV_ prefix has to be omitted in contour retrieval mode and contour approximation method parameters (for example, use cv2.RETR_LIST and cv2.CHAIN_APPROX_NONE parameters). If you use the old Python interface then these parameters have the CV_ prefix (for example, use cv.CV_RETR_LIST and cv.CV_CHAIN_APPROX_NONE).

Parameters:
image - Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as binary. You can use "compare", "inRange", "threshold", "adaptiveThreshold", "Canny", and others to create a binary image out of a grayscale or color one. The function modifies the image while extracting the contours.
contours - Detected contours. Each contour is stored as a vector of points.
hierarchy - Optional output vector, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour contours[i], the elements hierarchy[i][0], hiearchy[i][1], hiearchy[i][2], and hiearchy[i][3] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
mode - Contour retrieval mode (if you use Python see also a note below).
  • CV_RETR_EXTERNAL retrieves only the extreme outer contours. It sets hierarchy[i][2]=hierarchy[i][3]=-1 for all the contours.
  • CV_RETR_LIST retrieves all of the contours without establishing any hierarchical relationships.
  • CV_RETR_CCOMP retrieves all of the contours and organizes them into a two-level hierarchy. At the top level, there are external boundaries of the components. At the second level, there are boundaries of the holes. If there is another contour inside a hole of a connected component, it is still put at the top level.
  • CV_RETR_TREE retrieves all of the contours and reconstructs a full hierarchy of nested contours. This full hierarchy is built and shown in the OpenCV contours.c demo.
method - Contour approximation method (if you use Python see also a note below).
  • CV_CHAIN_APPROX_NONE stores absolutely all the contour points. That is, any 2 subsequent points (x1,y1) and (x2,y2) of the contour will be either horizontal, vertical or diagonal neighbors, that is, max(abs(x1-x2),abs(y2-y1))==1.
  • CV_CHAIN_APPROX_SIMPLE compresses horizontal, vertical, and diagonal segments and leaves only their end points. For example, an up-right rectangular contour is encoded with 4 points.
  • CV_CHAIN_APPROX_TC89_L1,CV_CHAIN_APPROX_TC89_KCOS applies one of the flavors of the Teh-Chin chain approximation algorithm. See [TehChin89] for details.
offset - Optional offset by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.
See Also:
org.opencv.imgproc.Imgproc.findContours

fitEllipse

public static RotatedRect fitEllipse(MatOfPoint2f points)

Fits an ellipse around a set of 2D points.

The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed. The algorithm [Fitzgibbon95] is used.

Parameters:
points - Input 2D point set, stored in:
  • std.vector<> or Mat (C++ interface)
  • CvSeq* or CvMat* (C interface)
  • Nx2 numpy array (Python interface)
See Also:
org.opencv.imgproc.Imgproc.fitEllipse

fitLine

public static void fitLine(Mat points,
                           Mat line,
                           int distType,
                           double param,
                           double reps,
                           double aeps)

Fits a line to a 2D or 3D point set.

The function fitLine fits a line to a 2D or 3D point set by minimizing sum_i rho(r_i) where r_i is a distance between the i^(th) point, the line and rho(r) is a distance function, one of the following:

  • distType=CV_DIST_L2

rho(r) = r^2/2(the simplest and the fastest least-squares method)

  • distType=CV_DIST_L1

rho(r) = r

  • distType=CV_DIST_L12

rho(r) = 2 * (sqrt(1 + frac(r^2)2) - 1)

  • distType=CV_DIST_FAIR

rho(r) = C^2 * ((r)/(C) - log((1 + (r)/(C)))) where C=1.3998

  • distType=CV_DIST_WELSCH

rho(r) = (C^2)/2 * (1 - exp((-((r)/(C))^2))) where C=2.9846

  • distType=CV_DIST_HUBER

rho(r) = r^2/2 if r < C; C * (r-C/2) otherwise where C=1.345

The algorithm is based on the M-estimator (http://en.wikipedia.org/wiki/M-estimator) technique that iteratively fits the line using the weighted least-squares algorithm. After each iteration the weights w_i are adjusted to be inversely proportional to rho(r_i).

Parameters:
points - Input vector of 2D or 3D points, stored in std.vector<> or Mat.
line - Output line parameters. In case of 2D fitting, it should be a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on the line.
distType - Distance used by the M-estimator (see the discussion below).
param - Numerical parameter (C) for some types of distances. If it is 0, an optimal value is chosen.
reps - Sufficient accuracy for the radius (distance between the coordinate origin and the line).
aeps - Sufficient accuracy for the angle. 0.01 would be a good default value for reps and aeps.
See Also:
org.opencv.imgproc.Imgproc.fitLine

floodFill

public static int floodFill(Mat image,
                            Mat mask,
                            Point seedPoint,
                            Scalar newVal)

Fills a connected component with the given color.

The functions floodFill fill a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at (x,y) is considered to belong to the repainted domain if:

  • src(x',y')- loDiff <= src(x,y) <= src(x',y')+ upDiff

in case of a grayscale image and floating range

  • src(seedPoint.x, seedPoint.y)- loDiff <= src(x,y) <= src(seedPoint.x, seedPoint.y)+ upDiff

in case of a grayscale image and fixed range

  • src(x',y')_r- loDiff _r <= src(x,y)_r <= src(x',y')_r+ upDiff _r,

src(x',y')_g- loDiff _g <= src(x,y)_g <= src(x',y')_g+ upDiff _g

and

src(x',y')_b- loDiff _b <= src(x,y)_b <= src(x',y')_b+ upDiff _b

in case of a color image and floating range

  • src(seedPoint.x, seedPoint.y)_r- loDiff _r <= src(x,y)_r <= src(seedPoint.x, seedPoint.y)_r+ upDiff _r,

src(seedPoint.x, seedPoint.y)_g- loDiff _g <= src(x,y)_g <= src(seedPoint.x, seedPoint.y)_g+ upDiff _g

and

src(seedPoint.x, seedPoint.y)_b- loDiff _b <= src(x,y)_b <= src(seedPoint.x, seedPoint.y)_b+ upDiff _b

in case of a color image and fixed range

where src(x',y') is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:

  • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
  • Color/brightness of the seed point in case of a fixed range.

Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. Various modes of the function are demonstrated in the floodfill.cpp sample.

Parameters:
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
mask - (For the second function only) Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of initializing the mask content. Flood-filling cannot go across non-zero pixels in the mask. For example, an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask in multiple calls to the function to make sure the filled area does not overlap.

Note: Since the mask is larger than the filled image, a pixel (x, y) in image corresponds to the pixel (x+1, y+1) in the mask.

seedPoint - Starting point.
newVal - New value of the repainted domain pixels.
See Also:
org.opencv.imgproc.Imgproc.floodFill, findContours(org.opencv.core.Mat, java.util.List, org.opencv.core.Mat, int, int, org.opencv.core.Point)

floodFill

public static int floodFill(Mat image,
                            Mat mask,
                            Point seedPoint,
                            Scalar newVal,
                            Rect rect,
                            Scalar loDiff,
                            Scalar upDiff,
                            int flags)

Fills a connected component with the given color.

The functions floodFill fill a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at (x,y) is considered to belong to the repainted domain if:

  • src(x',y')- loDiff <= src(x,y) <= src(x',y')+ upDiff

in case of a grayscale image and floating range

  • src(seedPoint.x, seedPoint.y)- loDiff <= src(x,y) <= src(seedPoint.x, seedPoint.y)+ upDiff

in case of a grayscale image and fixed range

  • src(x',y')_r- loDiff _r <= src(x,y)_r <= src(x',y')_r+ upDiff _r,

src(x',y')_g- loDiff _g <= src(x,y)_g <= src(x',y')_g+ upDiff _g

and

src(x',y')_b- loDiff _b <= src(x,y)_b <= src(x',y')_b+ upDiff _b

in case of a color image and floating range

  • src(seedPoint.x, seedPoint.y)_r- loDiff _r <= src(x,y)_r <= src(seedPoint.x, seedPoint.y)_r+ upDiff _r,

src(seedPoint.x, seedPoint.y)_g- loDiff _g <= src(x,y)_g <= src(seedPoint.x, seedPoint.y)_g+ upDiff _g

and

src(seedPoint.x, seedPoint.y)_b- loDiff _b <= src(x,y)_b <= src(seedPoint.x, seedPoint.y)_b+ upDiff _b

in case of a color image and fixed range

where src(x',y') is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:

  • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
  • Color/brightness of the seed point in case of a fixed range.

Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. Various modes of the function are demonstrated in the floodfill.cpp sample.

Parameters:
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
mask - (For the second function only) Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of initializing the mask content. Flood-filling cannot go across non-zero pixels in the mask. For example, an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask in multiple calls to the function to make sure the filled area does not overlap.

Note: Since the mask is larger than the filled image, a pixel (x, y) in image corresponds to the pixel (x+1, y+1) in the mask.

seedPoint - Starting point.
newVal - New value of the repainted domain pixels.
rect - Optional output parameter set by the function to the minimum bounding rectangle of the repainted domain.
loDiff - Maximal lower brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.
upDiff - Maximal upper brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.
flags - Operation flags. Lower bits contain a connectivity value, 4 (default) or 8, used within the function. Connectivity determines which neighbors of a pixel are considered. Upper bits can be 0 or a combination of the following flags:
  • FLOODFILL_FIXED_RANGE If set, the difference between the current pixel and seed pixel is considered. Otherwise, the difference between neighbor pixels is considered (that is, the range is floating).
  • FLOODFILL_MASK_ONLY If set, the function does not change the image (newVal is ignored), but fills the mask. The flag can be used for the second variant only.
See Also:
org.opencv.imgproc.Imgproc.floodFill, findContours(org.opencv.core.Mat, java.util.List, org.opencv.core.Mat, int, int, org.opencv.core.Point)

GaussianBlur

public static void GaussianBlur(Mat src,
                                Mat dst,
                                Size ksize,
                                double sigmaX)

Blurs an image using a Gaussian filter.

The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.

Parameters:
src - input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst - output image of the same size and type as src.
ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma*.
sigmaX - Gaussian kernel standard deviation in X direction.
See Also:
org.opencv.imgproc.Imgproc.GaussianBlur, sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int), boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int)

GaussianBlur

public static void GaussianBlur(Mat src,
                                Mat dst,
                                Size ksize,
                                double sigmaX,
                                double sigmaY)

Blurs an image using a Gaussian filter.

The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.

Parameters:
src - input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst - output image of the same size and type as src.
ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma*.
sigmaX - Gaussian kernel standard deviation in X direction.
sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see "getGaussianKernel" for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.
See Also:
org.opencv.imgproc.Imgproc.GaussianBlur, sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int), boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int)

GaussianBlur

public static void GaussianBlur(Mat src,
                                Mat dst,
                                Size ksize,
                                double sigmaX,
                                double sigmaY,
                                int borderType)

Blurs an image using a Gaussian filter.

The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.

Parameters:
src - input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst - output image of the same size and type as src.
ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma*.
sigmaX - Gaussian kernel standard deviation in X direction.
sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see "getGaussianKernel" for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.
borderType - pixel extrapolation method (see "borderInterpolate" for details).
See Also:
org.opencv.imgproc.Imgproc.GaussianBlur, sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), medianBlur(org.opencv.core.Mat, org.opencv.core.Mat, int), boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int)

getAffineTransform

public static Mat getAffineTransform(MatOfPoint2f src,
                                     MatOfPoint2f dst)

Calculates an affine transform from three pairs of the corresponding points.

The function calculates the 2 x 3 matrix of an affine transform so that:

x'_i y'_i = map_matrix * x_i y_i 1

where

dst(i)=(x'_i,y'_i),<BR>src(i)=(x_i, y_i),<BR>i=0,1,2

Parameters:
src - Coordinates of triangle vertices in the source image.
dst - Coordinates of the corresponding triangle vertices in the destination image.
See Also:
org.opencv.imgproc.Imgproc.getAffineTransform, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), Core.transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

getDefaultNewCameraMatrix

public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix)

Returns the default new camera matrix.

The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when centerPrinicipalPoint=false), or the modified one (when centerPrincipalPoint=true).

In the latter case, the new camera matrix will be:

f_x 0(imgSize.width -1)*0.5 0 f_y(imgSize.height -1)*0.5 0 0 1,

where f_x and f_y are (0,0) and (1,1) elements of cameraMatrix, respectively.

By default, the undistortion functions in OpenCV (see "initUndistortRectifyMap", "undistort") do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.

Parameters:
cameraMatrix - Input camera matrix.
See Also:
org.opencv.imgproc.Imgproc.getDefaultNewCameraMatrix

getDefaultNewCameraMatrix

public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix,
                                            Size imgsize,
                                            boolean centerPrincipalPoint)

Returns the default new camera matrix.

The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when centerPrinicipalPoint=false), or the modified one (when centerPrincipalPoint=true).

In the latter case, the new camera matrix will be:

f_x 0(imgSize.width -1)*0.5 0 f_y(imgSize.height -1)*0.5 0 0 1,

where f_x and f_y are (0,0) and (1,1) elements of cameraMatrix, respectively.

By default, the undistortion functions in OpenCV (see "initUndistortRectifyMap", "undistort") do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.

Parameters:
cameraMatrix - Input camera matrix.
imgsize - Camera view image size in pixels.
centerPrincipalPoint - Location of the principal point in the new camera matrix. The parameter indicates whether this location should be at the image center or not.
See Also:
org.opencv.imgproc.Imgproc.getDefaultNewCameraMatrix

getDerivKernels

public static void getDerivKernels(Mat kx,
                                   Mat ky,
                                   int dx,
                                   int dy,
                                   int ksize)

Returns filter coefficients for computing spatial image derivatives.

The function computes and returns the filter coefficients for spatial image derivatives. When ksize=CV_SCHARR, the Scharr 3 x 3 kernels are generated (see "Scharr"). Otherwise, Sobel kernels are generated (see "Sobel"). The filters are normally passed to "sepFilter2D" or to "createSeparableLinearFilter".

Parameters:
kx - Output matrix of row filter coefficients. It has the type ktype.
ky - Output matrix of column filter coefficients. It has the type ktype.
dx - Derivative order in respect of x.
dy - Derivative order in respect of y.
ksize - Aperture size. It can be CV_SCHARR, 1, 3, 5, or 7.
See Also:
org.opencv.imgproc.Imgproc.getDerivKernels

getDerivKernels

public static void getDerivKernels(Mat kx,
                                   Mat ky,
                                   int dx,
                                   int dy,
                                   int ksize,
                                   boolean normalize,
                                   int ktype)

Returns filter coefficients for computing spatial image derivatives.

The function computes and returns the filter coefficients for spatial image derivatives. When ksize=CV_SCHARR, the Scharr 3 x 3 kernels are generated (see "Scharr"). Otherwise, Sobel kernels are generated (see "Sobel"). The filters are normally passed to "sepFilter2D" or to "createSeparableLinearFilter".

Parameters:
kx - Output matrix of row filter coefficients. It has the type ktype.
ky - Output matrix of column filter coefficients. It has the type ktype.
dx - Derivative order in respect of x.
dy - Derivative order in respect of y.
ksize - Aperture size. It can be CV_SCHARR, 1, 3, 5, or 7.
normalize - Flag indicating whether to normalize (scale down) the filter coefficients or not. Theoretically, the coefficients should have the denominator =2^(ksize*2-dx-dy-2). If you are going to filter floating-point images, you are likely to use the normalized kernels. But if you compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve all the fractional bits, you may want to set normalize=false.
ktype - Type of filter coefficients. It can be CV_32f or CV_64F.
See Also:
org.opencv.imgproc.Imgproc.getDerivKernels

getGaborKernel

public static Mat getGaborKernel(Size ksize,
                                 double sigma,
                                 double theta,
                                 double lambd,
                                 double gamma)

getGaborKernel

public static Mat getGaborKernel(Size ksize,
                                 double sigma,
                                 double theta,
                                 double lambd,
                                 double gamma,
                                 double psi,
                                 int ktype)

getGaussianKernel

public static Mat getGaussianKernel(int ksize,
                                    double sigma)

Returns Gaussian filter coefficients.

The function computes and returns the ksize x 1 matrix of Gaussian filter coefficients:

G_i= alpha *e^(-(i-(ksize -1)/2)^2/(2* sigma)^2),

where i=0..ksize-1 and alpha is the scale factor chosen so that sum_i G_i=1.

Two of such generated kernels can be passed to "sepFilter2D" or to "createSeparableLinearFilter". Those functions automatically recognize smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly. You may also use the higher-level "GaussianBlur".

Parameters:
ksize - Aperture size. It should be odd (ksize mod 2 = 1) and positive.
sigma - Gaussian standard deviation. If it is non-positive, it is computed from ksize as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8.
See Also:
org.opencv.imgproc.Imgproc.getGaussianKernel, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), getStructuringElement(int, org.opencv.core.Size, org.opencv.core.Point), getDerivKernels(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, boolean, int)

getGaussianKernel

public static Mat getGaussianKernel(int ksize,
                                    double sigma,
                                    int ktype)

Returns Gaussian filter coefficients.

The function computes and returns the ksize x 1 matrix of Gaussian filter coefficients:

G_i= alpha *e^(-(i-(ksize -1)/2)^2/(2* sigma)^2),

where i=0..ksize-1 and alpha is the scale factor chosen so that sum_i G_i=1.

Two of such generated kernels can be passed to "sepFilter2D" or to "createSeparableLinearFilter". Those functions automatically recognize smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly. You may also use the higher-level "GaussianBlur".

Parameters:
ksize - Aperture size. It should be odd (ksize mod 2 = 1) and positive.
sigma - Gaussian standard deviation. If it is non-positive, it is computed from ksize as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8.
ktype - Type of filter coefficients. It can be CV_32f or CV_64F.
See Also:
org.opencv.imgproc.Imgproc.getGaussianKernel, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), getStructuringElement(int, org.opencv.core.Size, org.opencv.core.Point), getDerivKernels(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, boolean, int)

getPerspectiveTransform

public static Mat getPerspectiveTransform(Mat src,
                                          Mat dst)

Calculates a perspective transform from four pairs of the corresponding points.

The function calculates the 3 x 3 matrix of a perspective transform so that:

t_i x'_i t_i y'_i t_i = map_matrix * x_i y_i 1

where

dst(i)=(x'_i,y'_i),<BR>src(i)=(x_i, y_i),<BR>i=0,1,2,3

Parameters:
src - Coordinates of quadrangle vertices in the source image.
dst - Coordinates of the corresponding quadrangle vertices in the destination image.
See Also:
org.opencv.imgproc.Imgproc.getPerspectiveTransform, Calib3d.findHomography(org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f, int, double, org.opencv.core.Mat), Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)

getRectSubPix

public static void getRectSubPix(Mat image,
                                 Size patchSize,
                                 Point center,
                                 Mat patch)

Retrieves a pixel rectangle from an image with sub-pixel accuracy.

The function getRectSubPix extracts pixels from src

dst(x, y) = src(x + center.x - (dst.cols -1)*0.5, y + center.y - (dst.rows -1)*0.5)

where the values of the pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multi-channel images is processed independently. While the center of the rectangle must be inside the image, parts of the rectangle may be outside. In this case, the replication border mode (see "borderInterpolate") is used to extrapolate the pixel values outside of the image.

Parameters:
image - a image
patchSize - Size of the extracted patch.
center - Floating point coordinates of the center of the extracted rectangle within the source image. The center must be inside the image.
patch - a patch
See Also:
org.opencv.imgproc.Imgproc.getRectSubPix, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)

getRectSubPix

public static void getRectSubPix(Mat image,
                                 Size patchSize,
                                 Point center,
                                 Mat patch,
                                 int patchType)

Retrieves a pixel rectangle from an image with sub-pixel accuracy.

The function getRectSubPix extracts pixels from src

dst(x, y) = src(x + center.x - (dst.cols -1)*0.5, y + center.y - (dst.rows -1)*0.5)

where the values of the pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multi-channel images is processed independently. While the center of the rectangle must be inside the image, parts of the rectangle may be outside. In this case, the replication border mode (see "borderInterpolate") is used to extrapolate the pixel values outside of the image.

Parameters:
image - a image
patchSize - Size of the extracted patch.
center - Floating point coordinates of the center of the extracted rectangle within the source image. The center must be inside the image.
patch - a patch
patchType - Depth of the extracted pixels. By default, they have the same depth as src.
See Also:
org.opencv.imgproc.Imgproc.getRectSubPix, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)

getRotationMatrix2D

public static Mat getRotationMatrix2D(Point center,
                                      double angle,
                                      double scale)

Calculates an affine matrix of 2D rotation.

The function calculates the following matrix:

alpha beta(1- alpha) * center.x - beta * center.y - beta alpha beta * center.x + (1- alpha) * center.y

where

alpha = scale * cos angle, beta = scale * sin angle

The transformation maps the rotation center to itself. If this is not the target, adjust the shift.

Parameters:
center - Center of the rotation in the source image.
angle - Rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).
scale - Isotropic scale factor.
See Also:
org.opencv.imgproc.Imgproc.getRotationMatrix2D, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), getAffineTransform(org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f), Core.transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

getStructuringElement

public static Mat getStructuringElement(int shape,
                                        Size ksize)

Returns a structuring element of the specified size and shape for morphological operations.

The function constructs and returns the structuring element that can be further passed to "createMorphologyFilter", "erode", "dilate" or "morphologyEx". But you can also construct an arbitrary binary mask yourself and use it as the structuring element.

Note: When using OpenCV 1.x C API, the created structuring element IplConvKernel* element must be released in the end using cvReleaseStructuringElement(&element).

Parameters:
shape - Element shape that could be one of the following:
  • MORPH_RECT - a rectangular structuring element:

E_(ij)=1

  • MORPH_ELLIPSE - an elliptic structuring element, that is, a filled ellipse inscribed into the rectangle Rect(0, 0, esize.width, 0.esize.height)
  • MORPH_CROSS - a cross-shaped structuring element:

E_(ij) = 1 if i=anchor.y or j=anchor.x; 0 otherwise

  • CV_SHAPE_CUSTOM - custom structuring element (OpenCV 1.x API)
ksize - Size of the structuring element.
See Also:
org.opencv.imgproc.Imgproc.getStructuringElement

getStructuringElement

public static Mat getStructuringElement(int shape,
                                        Size ksize,
                                        Point anchor)

Returns a structuring element of the specified size and shape for morphological operations.

The function constructs and returns the structuring element that can be further passed to "createMorphologyFilter", "erode", "dilate" or "morphologyEx". But you can also construct an arbitrary binary mask yourself and use it as the structuring element.

Note: When using OpenCV 1.x C API, the created structuring element IplConvKernel* element must be released in the end using cvReleaseStructuringElement(&element).

Parameters:
shape - Element shape that could be one of the following:
  • MORPH_RECT - a rectangular structuring element:

E_(ij)=1

  • MORPH_ELLIPSE - an elliptic structuring element, that is, a filled ellipse inscribed into the rectangle Rect(0, 0, esize.width, 0.esize.height)
  • MORPH_CROSS - a cross-shaped structuring element:

E_(ij) = 1 if i=anchor.y or j=anchor.x; 0 otherwise

  • CV_SHAPE_CUSTOM - custom structuring element (OpenCV 1.x API)
ksize - Size of the structuring element.
anchor - Anchor position within the element. The default value (-1, -1) means that the anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor position. In other cases the anchor just regulates how much the result of the morphological operation is shifted.
See Also:
org.opencv.imgproc.Imgproc.getStructuringElement

goodFeaturesToTrack

public static void goodFeaturesToTrack(Mat image,
                                       MatOfPoint corners,
                                       int maxCorners,
                                       double qualityLevel,
                                       double minDistance)

Determines strong corners on an image.

The function finds the most prominent corners in the image or in the specified image region, as described in [Shi94]:

  • Function calculates the corner quality measure at every source image pixel using the "cornerMinEigenVal" or "cornerHarris".
  • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
  • The corners with the minimal eigenvalue less than qualityLevel * max_(x,y) qualityMeasureMap(x,y) are rejected.
  • The remaining corners are sorted by the quality measure in the descending order.
  • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.

The function can be used to initialize a point-based tracker of an object.

Note: If the function is called with different values A and B of the parameter qualityLevel, and A > {B}, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B.

Parameters:
image - Input 8-bit or floating-point 32-bit, single-channel image.
corners - Output vector of detected corners.
maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned.
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see "cornerMinEigenVal") or the Harris function response (see "cornerHarris"). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01, then all the corners with the quality measure less than 15 are rejected.
minDistance - Minimum possible Euclidean distance between the returned corners.
See Also:
org.opencv.imgproc.Imgproc.goodFeaturesToTrack, cornerHarris(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, int), Video.estimateRigidTransform(org.opencv.core.Mat, org.opencv.core.Mat, boolean), cornerMinEigenVal(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int), Video.calcOpticalFlowPyrLK(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfByte, org.opencv.core.MatOfFloat, org.opencv.core.Size, int, org.opencv.core.TermCriteria, int, double)

goodFeaturesToTrack

public static void goodFeaturesToTrack(Mat image,
                                       MatOfPoint corners,
                                       int maxCorners,
                                       double qualityLevel,
                                       double minDistance,
                                       Mat mask,
                                       int blockSize,
                                       boolean useHarrisDetector,
                                       double k)

Determines strong corners on an image.

The function finds the most prominent corners in the image or in the specified image region, as described in [Shi94]:

  • Function calculates the corner quality measure at every source image pixel using the "cornerMinEigenVal" or "cornerHarris".
  • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
  • The corners with the minimal eigenvalue less than qualityLevel * max_(x,y) qualityMeasureMap(x,y) are rejected.
  • The remaining corners are sorted by the quality measure in the descending order.
  • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.

The function can be used to initialize a point-based tracker of an object.

Note: If the function is called with different values A and B of the parameter qualityLevel, and A > {B}, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B.

Parameters:
image - Input 8-bit or floating-point 32-bit, single-channel image.
corners - Output vector of detected corners.
maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned.
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see "cornerMinEigenVal") or the Harris function response (see "cornerHarris"). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01, then all the corners with the quality measure less than 15 are rejected.
minDistance - Minimum possible Euclidean distance between the returned corners.
mask - Optional region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image), it specifies the region in which the corners are detected.
blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See "cornerEigenValsAndVecs".
useHarrisDetector - Parameter indicating whether to use a Harris detector (see "cornerHarris") or "cornerMinEigenVal".
k - Free parameter of the Harris detector.
See Also:
org.opencv.imgproc.Imgproc.goodFeaturesToTrack, cornerHarris(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, int), Video.estimateRigidTransform(org.opencv.core.Mat, org.opencv.core.Mat, boolean), cornerMinEigenVal(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int), Video.calcOpticalFlowPyrLK(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfByte, org.opencv.core.MatOfFloat, org.opencv.core.Size, int, org.opencv.core.TermCriteria, int, double)

grabCut

public static void grabCut(Mat img,
                           Mat mask,
                           Rect rect,
                           Mat bgdModel,
                           Mat fgdModel,
                           int iterCount)

Runs the GrabCut algorithm.

The function implements the GrabCut image segmentation algorithm (http://en.wikipedia.org/wiki/GrabCut). See the sample grabcut.cpp to learn how to use the function.

Parameters:
img - Input 8-bit 3-channel image.
mask - Input/output 8-bit single-channel mask. The mask is initialized by the function when mode is set to GC_INIT_WITH_RECT. Its elements may have one of following values:
  • GC_BGD defines an obvious background pixels.
  • GC_FGD defines an obvious foreground (object) pixel.
  • GC_PR_BGD defines a possible background pixel.
  • GC_PR_FGD defines a possible foreground pixel.
rect - ROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when mode==GC_INIT_WITH_RECT.
bgdModel - Temporary array for the background model. Do not modify it while you are processing the same image.
fgdModel - Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
iterCount - Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with mode==GC_INIT_WITH_MASK or mode==GC_EVAL.
See Also:
org.opencv.imgproc.Imgproc.grabCut

grabCut

public static void grabCut(Mat img,
                           Mat mask,
                           Rect rect,
                           Mat bgdModel,
                           Mat fgdModel,
                           int iterCount,
                           int mode)

Runs the GrabCut algorithm.

The function implements the GrabCut image segmentation algorithm (http://en.wikipedia.org/wiki/GrabCut). See the sample grabcut.cpp to learn how to use the function.

Parameters:
img - Input 8-bit 3-channel image.
mask - Input/output 8-bit single-channel mask. The mask is initialized by the function when mode is set to GC_INIT_WITH_RECT. Its elements may have one of following values:
  • GC_BGD defines an obvious background pixels.
  • GC_FGD defines an obvious foreground (object) pixel.
  • GC_PR_BGD defines a possible background pixel.
  • GC_PR_FGD defines a possible foreground pixel.
rect - ROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when mode==GC_INIT_WITH_RECT.
bgdModel - Temporary array for the background model. Do not modify it while you are processing the same image.
fgdModel - Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
iterCount - Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with mode==GC_INIT_WITH_MASK or mode==GC_EVAL.
mode - Operation mode that could be one of the following:
  • GC_INIT_WITH_RECT The function initializes the state and the mask using the provided rectangle. After that it runs iterCount iterations of the algorithm.
  • GC_INIT_WITH_MASK The function initializes the state using the provided mask. Note that GC_INIT_WITH_RECT and GC_INIT_WITH_MASK can be combined. Then, all the pixels outside of the ROI are automatically initialized with GC_BGD.
  • GC_EVAL The value means that the algorithm should just resume.
See Also:
org.opencv.imgproc.Imgproc.grabCut

HoughCircles

public static void HoughCircles(Mat image,
                                Mat circles,
                                int method,
                                double dp,
                                double minDist)

Finds circles in a grayscale image using the Hough transform.

The function finds circles in a grayscale image using a modification of the Hough transform. Example:

// C++ code:

#include

#include

#include

using namespace cv;

int main(int argc, char argv)

Mat img, gray;

if(argc != 2 && !(img=imread(argv[1], 1)).data)

return -1;

cvtColor(img, gray, CV_BGR2GRAY);

// smooth it, otherwise a lot of false circles may be detected

GaussianBlur(gray, gray, Size(9, 9), 2, 2);

vector circles;

HoughCircles(gray, circles, CV_HOUGH_GRADIENT,

2, gray->rows/4, 200, 100);

for(size_t i = 0; i < circles.size(); i++)

Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));

int radius = cvRound(circles[i][2]);

// draw the circle center

circle(img, center, 3, Scalar(0,255,0), -1, 8, 0);

// draw the circle outline

circle(img, center, radius, Scalar(0,0,255), 3, 8, 0);

namedWindow("circles", 1);

imshow("circles", img);

return 0;

Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range (minRadius and maxRadius) if you know it. Or, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure.

Parameters:
image - 8-bit, single-channel, grayscale input image.
circles - Output vector of found circles. Each vector is encoded as a 3-element floating-point vector (x, y, radius).
method - Detection method to use. Currently, the only implemented method is CV_HOUGH_GRADIENT, which is basically *21HT*, described in [Yuen90].
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1, the accumulator has the same resolution as the input image. If dp=2, the accumulator has half as big width and height.
minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
See Also:
org.opencv.imgproc.Imgproc.HoughCircles, minEnclosingCircle(org.opencv.core.MatOfPoint2f, org.opencv.core.Point, float[]), fitEllipse(org.opencv.core.MatOfPoint2f)

HoughCircles

public static void HoughCircles(Mat image,
                                Mat circles,
                                int method,
                                double dp,
                                double minDist,
                                double param1,
                                double param2,
                                int minRadius,
                                int maxRadius)

Finds circles in a grayscale image using the Hough transform.

The function finds circles in a grayscale image using a modification of the Hough transform. Example:

// C++ code:

#include

#include

#include

using namespace cv;

int main(int argc, char argv)

Mat img, gray;

if(argc != 2 && !(img=imread(argv[1], 1)).data)

return -1;

cvtColor(img, gray, CV_BGR2GRAY);

// smooth it, otherwise a lot of false circles may be detected

GaussianBlur(gray, gray, Size(9, 9), 2, 2);

vector circles;

HoughCircles(gray, circles, CV_HOUGH_GRADIENT,

2, gray->rows/4, 200, 100);

for(size_t i = 0; i < circles.size(); i++)

Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));

int radius = cvRound(circles[i][2]);

// draw the circle center

circle(img, center, 3, Scalar(0,255,0), -1, 8, 0);

// draw the circle outline

circle(img, center, radius, Scalar(0,0,255), 3, 8, 0);

namedWindow("circles", 1);

imshow("circles", img);

return 0;

Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range (minRadius and maxRadius) if you know it. Or, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure.

Parameters:
image - 8-bit, single-channel, grayscale input image.
circles - Output vector of found circles. Each vector is encoded as a 3-element floating-point vector (x, y, radius).
method - Detection method to use. Currently, the only implemented method is CV_HOUGH_GRADIENT, which is basically *21HT*, described in [Yuen90].
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1, the accumulator has the same resolution as the input image. If dp=2, the accumulator has half as big width and height.
minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
param1 - First method-specific parameter. In case of CV_HOUGH_GRADIENT, it is the higher threshold of the two passed to the "Canny" edge detector (the lower one is twice smaller).
param2 - Second method-specific parameter. In case of CV_HOUGH_GRADIENT, it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first.
minRadius - Minimum circle radius.
maxRadius - Maximum circle radius.
See Also:
org.opencv.imgproc.Imgproc.HoughCircles, minEnclosingCircle(org.opencv.core.MatOfPoint2f, org.opencv.core.Point, float[]), fitEllipse(org.opencv.core.MatOfPoint2f)

HoughLines

public static void HoughLines(Mat image,
                              Mat lines,
                              double rho,
                              double theta,
                              int threshold)

Finds lines in a binary image using the standard Hough transform.

The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform. See also the example in "HoughLinesP" description.

Parameters:
image - 8-bit, single-channel binary source image. The image may be modified by the function.
lines - Output vector of lines. Each line is represented by a two-element vector (rho, theta). rho is the distance from the coordinate origin (0,0) (top-left corner of the image). theta is the line rotation angle in radians (0 ~ vertical line, pi/2 ~ horizontal line).
rho - Distance resolution of the accumulator in pixels.
theta - Angle resolution of the accumulator in radians.
threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes (>threshold).
See Also:
org.opencv.imgproc.Imgproc.HoughLines

HoughLines

public static void HoughLines(Mat image,
                              Mat lines,
                              double rho,
                              double theta,
                              int threshold,
                              double srn,
                              double stn)

Finds lines in a binary image using the standard Hough transform.

The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform. See also the example in "HoughLinesP" description.

Parameters:
image - 8-bit, single-channel binary source image. The image may be modified by the function.
lines - Output vector of lines. Each line is represented by a two-element vector (rho, theta). rho is the distance from the coordinate origin (0,0) (top-left corner of the image). theta is the line rotation angle in radians (0 ~ vertical line, pi/2 ~ horizontal line).
rho - Distance resolution of the accumulator in pixels.
theta - Angle resolution of the accumulator in radians.
threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes (>threshold).
srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho. The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these parameters should be positive.
stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
See Also:
org.opencv.imgproc.Imgproc.HoughLines

HoughLinesP

public static void HoughLinesP(Mat image,
                               Mat lines,
                               double rho,
                               double theta,
                               int threshold)

Finds line segments in a binary image using the probabilistic Hough transform.

The function implements the probabilistic Hough transform algorithm for line detection, described in[Matas00]. See the line detection example below:

// C++ code:

/ * This is a standalone program. Pass an image name as the first parameter

of the program. Switch between standard and probabilistic Hough transform

by changing "#if 1" to "#if 0" and back * /

#include

#include

#include

using namespace cv;

int main(int argc, char argv)

Mat src, dst, color_dst;

if(argc != 2 || !(src=imread(argv[1], 0)).data)

return -1;

Canny(src, dst, 50, 200, 3);

cvtColor(dst, color_dst, CV_GRAY2BGR);

#if 0

vector lines;

HoughLines(dst, lines, 1, CV_PI/180, 100);

for(size_t i = 0; i < lines.size(); i++)

float rho = lines[i][0];

float theta = lines[i][1];

double a = cos(theta), b = sin(theta);

double x0 = a*rho, y0 = b*rho;

Point pt1(cvRound(x0 + 1000*(-b)),

cvRound(y0 + 1000*(a)));

Point pt2(cvRound(x0 - 1000*(-b)),

cvRound(y0 - 1000*(a)));

line(color_dst, pt1, pt2, Scalar(0,0,255), 3, 8);

#else

vector lines;

HoughLinesP(dst, lines, 1, CV_PI/180, 80, 30, 10);

for(size_t i = 0; i < lines.size(); i++)

line(color_dst, Point(lines[i][0], lines[i][1]),

Point(lines[i][2], lines[i][3]), Scalar(0,0,255), 3, 8);

#endif

namedWindow("Source", 1);

imshow("Source", src);

namedWindow("Detected Lines", 1);

imshow("Detected Lines", color_dst);

waitKey(0);

return 0;

This is a sample picture the function parameters have been tuned for:

And this is the output of the above program in case of the probabilistic Hough transform:

Parameters:
image - 8-bit, single-channel binary source image. The image may be modified by the function.
lines - Output vector of lines. Each line is represented by a 4-element vector (x_1, y_1, x_2, y_2), where (x_1,y_1) and (x_2, y_2) are the ending points of each detected line segment.
rho - Distance resolution of the accumulator in pixels.
theta - Angle resolution of the accumulator in radians.
threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes (>threshold).
See Also:
org.opencv.imgproc.Imgproc.HoughLinesP

HoughLinesP

public static void HoughLinesP(Mat image,
                               Mat lines,
                               double rho,
                               double theta,
                               int threshold,
                               double minLineLength,
                               double maxLineGap)

Finds line segments in a binary image using the probabilistic Hough transform.

The function implements the probabilistic Hough transform algorithm for line detection, described in[Matas00]. See the line detection example below:

// C++ code:

/ * This is a standalone program. Pass an image name as the first parameter

of the program. Switch between standard and probabilistic Hough transform

by changing "#if 1" to "#if 0" and back * /

#include

#include

#include

using namespace cv;

int main(int argc, char argv)

Mat src, dst, color_dst;

if(argc != 2 || !(src=imread(argv[1], 0)).data)

return -1;

Canny(src, dst, 50, 200, 3);

cvtColor(dst, color_dst, CV_GRAY2BGR);

#if 0

vector lines;

HoughLines(dst, lines, 1, CV_PI/180, 100);

for(size_t i = 0; i < lines.size(); i++)

float rho = lines[i][0];

float theta = lines[i][1];

double a = cos(theta), b = sin(theta);

double x0 = a*rho, y0 = b*rho;

Point pt1(cvRound(x0 + 1000*(-b)),

cvRound(y0 + 1000*(a)));

Point pt2(cvRound(x0 - 1000*(-b)),

cvRound(y0 - 1000*(a)));

line(color_dst, pt1, pt2, Scalar(0,0,255), 3, 8);

#else

vector lines;

HoughLinesP(dst, lines, 1, CV_PI/180, 80, 30, 10);

for(size_t i = 0; i < lines.size(); i++)

line(color_dst, Point(lines[i][0], lines[i][1]),

Point(lines[i][2], lines[i][3]), Scalar(0,0,255), 3, 8);

#endif

namedWindow("Source", 1);

imshow("Source", src);

namedWindow("Detected Lines", 1);

imshow("Detected Lines", color_dst);

waitKey(0);

return 0;

This is a sample picture the function parameters have been tuned for:

And this is the output of the above program in case of the probabilistic Hough transform:

Parameters:
image - 8-bit, single-channel binary source image. The image may be modified by the function.
lines - Output vector of lines. Each line is represented by a 4-element vector (x_1, y_1, x_2, y_2), where (x_1,y_1) and (x_2, y_2) are the ending points of each detected line segment.
rho - Distance resolution of the accumulator in pixels.
theta - Angle resolution of the accumulator in radians.
threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes (>threshold).
minLineLength - Minimum line length. Line segments shorter than that are rejected.
maxLineGap - Maximum allowed gap between points on the same line to link them.
See Also:
org.opencv.imgproc.Imgproc.HoughLinesP

HuMoments

public static void HuMoments(Moments m,
                             Mat hu)

Calculates seven Hu invariants.

The function calculates seven Hu invariants (introduced in [Hu62]; see also http://en.wikipedia.org/wiki/Image_moment) defined as:

hu[0]= eta _20+ eta _02 hu[1]=(eta _20- eta _02)^2+4 eta _11^2 hu[2]=(eta _30-3 eta _12)^2+ (3 eta _21- eta _03)^2 hu[3]=(eta _30+ eta _12)^2+ (eta _21+ eta _03)^2 hu[4]=(eta _30-3 eta _12)(eta _30+ eta _12)[(eta _30+ eta _12)^2-3(eta _21+ eta _03)^2]+(3 eta _21- eta _03)(eta _21+ eta _03)[3(eta _30+ eta _12)^2-(eta _21+ eta _03)^2] hu[5]=(eta _20- eta _02)[(eta _30+ eta _12)^2- (eta _21+ eta _03)^2]+4 eta _11(eta _30+ eta _12)(eta _21+ eta _03) hu[6]=(3 eta _21- eta _03)(eta _21+ eta _03)[3(eta _30+ eta _12)^2-(eta _21+ eta _03)^2]-(eta _30-3 eta _12)(eta _21+ eta _03)[3(eta _30+ eta _12)^2-(eta _21+ eta _03)^2]

where eta_(ji) stands for Moments.nu_(ji).

These values are proved to be invariants to the image scale, rotation, and reflection except the seventh one, whose sign is changed by reflection. This invariance is proved with the assumption of infinite image resolution. In case of raster images, the computed Hu invariants for the original and transformed images are a bit different.

Parameters:
m - a m
hu - Output Hu invariants.
See Also:
org.opencv.imgproc.Imgproc.HuMoments, matchShapes(org.opencv.core.Mat, org.opencv.core.Mat, int, double)

initUndistortRectifyMap

public static void initUndistortRectifyMap(Mat cameraMatrix,
                                           Mat distCoeffs,
                                           Mat R,
                                           Mat newCameraMatrix,
                                           Size size,
                                           int m1type,
                                           Mat map1,
                                           Mat map2)

Computes the undistortion and rectification transformation map.

The function computes the joint undistortion and rectification transformation and represents the result in the form of maps for "remap". The undistorted image looks like original, as if it is captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by "getOptimalNewCameraMatrix" for a better control over scaling. In case of a stereo camera, newCameraMatrix is normally set to P1 or P2 computed by "stereoRectify".

Also, this new camera is oriented differently in the coordinate space, according to R. That, for example, helps to align two heads of a stereo camera so that the epipolar lines on both images become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).

The function actually builds the maps for the inverse mapping algorithm that is used by "remap". That is, for each pixel (u, v) in the destination (corrected and rectified) image, the function computes the corresponding coordinates in the source image (that is, in the original image from camera). The following process is applied:

x <- (u - (c')_x)/(f')_x y <- (v - (c')_y)/(f')_y ([X Y W]) ^T <- R^(-1)*[x y 1]^T x' <- X/W y' <- Y/W x" <- x' (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + 2p_1 x' y' + p_2(r^2 + 2 x'^2) y" <- y' (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + p_1(r^2 + 2 y'^2) + 2 p_2 x' y' map_x(u,v) <- x" f_x + c_x map_y(u,v) <- y" f_y + c_y

where (k_1, k_2, p_1, p_2[, k_3]) are the distortion coefficients.

In case of a stereo camera, this function is called twice: once for each camera head, after "stereoRectify", which in its turn is called after "stereoCalibrate". But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using "stereoRectifyUncalibrated". For each camera, the function computes homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D space. R can be computed from H as

R = cameraMatrix ^(-1) * H * cameraMatrix

where cameraMatrix can be chosen arbitrarily.

Parameters:
cameraMatrix - Input camera matrix A=

|f_x 0 c_x| |0 f_y c_y| |0 0 1| .

distCoeffs - Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
R - Optional rectification transformation in the object space (3x3 matrix). R1 or R2, computed by "stereoRectify" can be passed here. If the matrix is empty, the identity transformation is assumed. In cvInitUndistortMap R assumed to be an identity matrix.
newCameraMatrix - New camera matrix A'=

|f_x' 0 c_x'| |0 f_y' c_y'| |0 0 1| .

size - Undistorted image size.
m1type - Type of the first output map that can be CV_32FC1 or CV_16SC2. See "convertMaps" for details.
map1 - The first output map.
map2 - The second output map.
See Also:
org.opencv.imgproc.Imgproc.initUndistortRectifyMap

initWideAngleProjMap

public static float initWideAngleProjMap(Mat cameraMatrix,
                                         Mat distCoeffs,
                                         Size imageSize,
                                         int destImageWidth,
                                         int m1type,
                                         Mat map1,
                                         Mat map2)

initWideAngleProjMap

public static float initWideAngleProjMap(Mat cameraMatrix,
                                         Mat distCoeffs,
                                         Size imageSize,
                                         int destImageWidth,
                                         int m1type,
                                         Mat map1,
                                         Mat map2,
                                         int projType,
                                         double alpha)

integral

public static void integral(Mat src,
                            Mat sum)

Calculates the integral of an image.

The functions calculate one or more integral images for the source image as follows:

sum(X,Y) = sum(by: x<X,y<Y) image(x,y)

sqsum(X,Y) = sum(by: x<X,y<Y) image(x,y)^2

tilted(X,Y) = sum(by: y<Y,abs(x-X+1) <= Y-y-1) image(x,y)

Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:

sum(by: x_1 <= x < x_2, y_1 <= y < y_2) image(x,y) = sum(x_2,y_2)- sum(x_1,y_2)- sum(x_2,y_1)+ sum(x_1,y_1)

It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.

As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3). The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted.

Parameters:
src - a src
sum - integral image as (W+1)x(H+1), 32-bit integer or floating-point (32f or 64f).
See Also:
org.opencv.imgproc.Imgproc.integral

integral

public static void integral(Mat src,
                            Mat sum,
                            int sdepth)

Calculates the integral of an image.

The functions calculate one or more integral images for the source image as follows:

sum(X,Y) = sum(by: x<X,y<Y) image(x,y)

sqsum(X,Y) = sum(by: x<X,y<Y) image(x,y)^2

tilted(X,Y) = sum(by: y<Y,abs(x-X+1) <= Y-y-1) image(x,y)

Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:

sum(by: x_1 <= x < x_2, y_1 <= y < y_2) image(x,y) = sum(x_2,y_2)- sum(x_1,y_2)- sum(x_2,y_1)+ sum(x_1,y_1)

It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.

As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3). The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted.

Parameters:
src - a src
sum - integral image as (W+1)x(H+1), 32-bit integer or floating-point (32f or 64f).
sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.
See Also:
org.opencv.imgproc.Imgproc.integral

integral2

public static void integral2(Mat src,
                             Mat sum,
                             Mat sqsum)

Calculates the integral of an image.

The functions calculate one or more integral images for the source image as follows:

sum(X,Y) = sum(by: x<X,y<Y) image(x,y)

sqsum(X,Y) = sum(by: x<X,y<Y) image(x,y)^2

tilted(X,Y) = sum(by: y<Y,abs(x-X+1) <= Y-y-1) image(x,y)

Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:

sum(by: x_1 <= x < x_2, y_1 <= y < y_2) image(x,y) = sum(x_2,y_2)- sum(x_1,y_2)- sum(x_2,y_1)+ sum(x_1,y_1)

It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.

As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3). The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted.

Parameters:
src - a src
sum - integral image as (W+1)x(H+1), 32-bit integer or floating-point (32f or 64f).
sqsum - integral image for squared pixel values; it is (W+1)x(H+1), double-precision floating-point (64f) array.
See Also:
org.opencv.imgproc.Imgproc.integral

integral2

public static void integral2(Mat src,
                             Mat sum,
                             Mat sqsum,
                             int sdepth)

Calculates the integral of an image.

The functions calculate one or more integral images for the source image as follows:

sum(X,Y) = sum(by: x<X,y<Y) image(x,y)

sqsum(X,Y) = sum(by: x<X,y<Y) image(x,y)^2

tilted(X,Y) = sum(by: y<Y,abs(x-X+1) <= Y-y-1) image(x,y)

Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:

sum(by: x_1 <= x < x_2, y_1 <= y < y_2) image(x,y) = sum(x_2,y_2)- sum(x_1,y_2)- sum(x_2,y_1)+ sum(x_1,y_1)

It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.

As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3). The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted.

Parameters:
src - a src
sum - integral image as (W+1)x(H+1), 32-bit integer or floating-point (32f or 64f).
sqsum - integral image for squared pixel values; it is (W+1)x(H+1), double-precision floating-point (64f) array.
sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.
See Also:
org.opencv.imgproc.Imgproc.integral

integral3

public static void integral3(Mat src,
                             Mat sum,
                             Mat sqsum,
                             Mat tilted)

Calculates the integral of an image.

The functions calculate one or more integral images for the source image as follows:

sum(X,Y) = sum(by: x<X,y<Y) image(x,y)

sqsum(X,Y) = sum(by: x<X,y<Y) image(x,y)^2

tilted(X,Y) = sum(by: y<Y,abs(x-X+1) <= Y-y-1) image(x,y)

Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:

sum(by: x_1 <= x < x_2, y_1 <= y < y_2) image(x,y) = sum(x_2,y_2)- sum(x_1,y_2)- sum(x_2,y_1)+ sum(x_1,y_1)

It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.

As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3). The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted.

Parameters:
src - a src
sum - integral image as (W+1)x(H+1), 32-bit integer or floating-point (32f or 64f).
sqsum - integral image for squared pixel values; it is (W+1)x(H+1), double-precision floating-point (64f) array.
tilted - integral for the image rotated by 45 degrees; it is (W+1)x(H+1) array with the same data type as sum.
See Also:
org.opencv.imgproc.Imgproc.integral

integral3

public static void integral3(Mat src,
                             Mat sum,
                             Mat sqsum,
                             Mat tilted,
                             int sdepth)

Calculates the integral of an image.

The functions calculate one or more integral images for the source image as follows:

sum(X,Y) = sum(by: x<X,y<Y) image(x,y)

sqsum(X,Y) = sum(by: x<X,y<Y) image(x,y)^2

tilted(X,Y) = sum(by: y<Y,abs(x-X+1) <= Y-y-1) image(x,y)

Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:

sum(by: x_1 <= x < x_2, y_1 <= y < y_2) image(x,y) = sum(x_2,y_2)- sum(x_1,y_2)- sum(x_2,y_1)+ sum(x_1,y_1)

It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.

As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3). The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted.

Parameters:
src - a src
sum - integral image as (W+1)x(H+1), 32-bit integer or floating-point (32f or 64f).
sqsum - integral image for squared pixel values; it is (W+1)x(H+1), double-precision floating-point (64f) array.
tilted - integral for the image rotated by 45 degrees; it is (W+1)x(H+1) array with the same data type as sum.
sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.
See Also:
org.opencv.imgproc.Imgproc.integral

intersectConvexConvex

public static float intersectConvexConvex(Mat _p1,
                                          Mat _p2,
                                          Mat _p12)

intersectConvexConvex

public static float intersectConvexConvex(Mat _p1,
                                          Mat _p2,
                                          Mat _p12,
                                          boolean handleNested)

invertAffineTransform

public static void invertAffineTransform(Mat M,
                                         Mat iM)

Inverts an affine transformation.

The function computes an inverse affine transformation represented by 2 x 3 matrix M :

a_11 a_12 b_1 a_21 a_22 b_2

The result is also a 2 x 3 matrix of the same type as M.

Parameters:
M - Original affine transformation.
iM - Output reverse affine transformation.
See Also:
org.opencv.imgproc.Imgproc.invertAffineTransform

isContourConvex

public static boolean isContourConvex(MatOfPoint contour)

Tests a contour convexity.

The function tests whether the input contour is convex or not. The contour must be simple, that is, without self-intersections. Otherwise, the function output is undefined.

Parameters:
contour - Input vector of 2D points, stored in:
  • std.vector<> or Mat (C++ interface)
  • CvSeq* or CvMat* (C interface)
  • Nx2 numpy array (Python interface)
See Also:
org.opencv.imgproc.Imgproc.isContourConvex

Laplacian

public static void Laplacian(Mat src,
                             Mat dst,
                             int ddepth)

Calculates the Laplacian of an image.

The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator:

dst = Delta src = (d^2 src)/(dx^2) + (d^2 src)/(dy^2)

This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image with the following 3 x 3 aperture:

vecthreethree 0101(-4)1010

Parameters:
src - Source image.
dst - Destination image of the same size and the same number of channels as src.
ddepth - Desired depth of the destination image.
See Also:
org.opencv.imgproc.Imgproc.Laplacian, Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int), Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int)

Laplacian

public static void Laplacian(Mat src,
                             Mat dst,
                             int ddepth,
                             int ksize,
                             double scale,
                             double delta)

Calculates the Laplacian of an image.

The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator:

dst = Delta src = (d^2 src)/(dx^2) + (d^2 src)/(dy^2)

This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image with the following 3 x 3 aperture:

vecthreethree 0101(-4)1010

Parameters:
src - Source image.
dst - Destination image of the same size and the same number of channels as src.
ddepth - Desired depth of the destination image.
ksize - Aperture size used to compute the second-derivative filters. See "getDerivKernels" for details. The size must be positive and odd.
scale - Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See "getDerivKernels" for details.
delta - Optional delta value that is added to the results prior to storing them in dst.
See Also:
org.opencv.imgproc.Imgproc.Laplacian, Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int), Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int)

Laplacian

public static void Laplacian(Mat src,
                             Mat dst,
                             int ddepth,
                             int ksize,
                             double scale,
                             double delta,
                             int borderType)

Calculates the Laplacian of an image.

The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator:

dst = Delta src = (d^2 src)/(dx^2) + (d^2 src)/(dy^2)

This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image with the following 3 x 3 aperture:

vecthreethree 0101(-4)1010

Parameters:
src - Source image.
dst - Destination image of the same size and the same number of channels as src.
ddepth - Desired depth of the destination image.
ksize - Aperture size used to compute the second-derivative filters. See "getDerivKernels" for details. The size must be positive and odd.
scale - Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See "getDerivKernels" for details.
delta - Optional delta value that is added to the results prior to storing them in dst.
borderType - Pixel extrapolation method. See "borderInterpolate" for details.
See Also:
org.opencv.imgproc.Imgproc.Laplacian, Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int), Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int)

matchShapes

public static double matchShapes(Mat contour1,
                                 Mat contour2,
                                 int method,
                                 double parameter)

Compares two shapes.

The function compares two shapes. All three implemented methods use the Hu invariants (see "HuMoments") as follows (A denotes object1,B denotes object2):

  • method=CV_CONTOURS_MATCH_I1

I_1(A,B) = sum(by: i=1...7) <= ft|1/(m^A_i) - 1/(m^B_i) right|

  • method=CV_CONTOURS_MATCH_I2

I_2(A,B) = sum(by: i=1...7) <= ft|m^A_i - m^B_i right|

  • method=CV_CONTOURS_MATCH_I3

I_3(A,B) = max _(i=1...7)(<= ft| m^A_i - m^B_i right|)/(<= ft| m^A_i right|)

where

m^A_i = sign(h^A_i) * log(h^A_i) m^B_i = sign(h^B_i) * log(h^B_i)

and h^A_i, h^B_i are the Hu moments of A and B, respectively.

Parameters:
contour1 - a contour1
contour2 - a contour2
method - Comparison method: CV_CONTOURS_MATCH_I1, CV_CONTOURS_MATCH_I2 \

or CV_CONTOURS_MATCH_I3 (see the details below).

parameter - Method-specific parameter (not supported now).
See Also:
org.opencv.imgproc.Imgproc.matchShapes

matchTemplate

public static void matchTemplate(Mat image,
                                 Mat templ,
                                 Mat result,
                                 int method)

Compares a template against overlapped image regions.

The function slides through image, compares the overlapped patches of size w x h against templ using the specified method and stores the comparison results in result. Here are the formulae for the available comparison methods (I denotes image, T template, R result). The summation is done over template and/or the image patch: x' = 0...w-1, y' = 0...h-1

  • method=CV_TM_SQDIFF

R(x,y)= sum(by: x',y')(T(x',y')-I(x+x',y+y'))^2

  • method=CV_TM_SQDIFF_NORMED

R(x,y)= (sum_(x',y')(T(x',y')-I(x+x',y+y'))^2)/(sqrt(sum_(x',y')T(x',y')^2 * sum_(x',y') I(x+x',y+y')^2))

  • method=CV_TM_CCORR

R(x,y)= sum(by: x',y')(T(x',y') * I(x+x',y+y'))

  • method=CV_TM_CCORR_NORMED

R(x,y)= (sum_(x',y')(T(x',y') * I(x+x',y+y')))/(sqrt(sum_(x',y')T(x',y')^2 * sum_(x',y') I(x+x',y+y')^2))

  • method=CV_TM_CCOEFF

R(x,y)= sum(by: x',y')(T'(x',y') * I'(x+x',y+y'))

where

T'(x',y')=T(x',y') - 1/(w * h) * sum(by: x'',y'') T(x'',y'') I'(x+x',y+y')=I(x+x',y+y') - 1/(w * h) * sum(by: x'',y'') I(x+x'',y+y'')

  • method=CV_TM_CCOEFF_NORMED

R(x,y)= (sum_(x',y')(T'(x',y') * I'(x+x',y+y')))/(sqrt(sum_(x',y')T'(x',y')^2 * sum_(x',y') I'(x+x',y+y')^2))

After the function finishes the comparison, the best matches can be found as global minimums (when CV_TM_SQDIFF was used) or maximums (when CV_TM_CCORR or CV_TM_CCOEFF was used) using the "minMaxLoc" function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze.

Parameters:
image - Image where the search is running. It must be 8-bit or 32-bit floating-point.
templ - Searched template. It must be not greater than the source image and have the same data type.
result - Map of comparison results. It must be single-channel 32-bit floating-point. If image is W x H and templ is w x h, then result is (W-w+1) x(H-h+1).
method - Parameter specifying the comparison method (see below).
See Also:
org.opencv.imgproc.Imgproc.matchTemplate

medianBlur

public static void medianBlur(Mat src,
                              Mat dst,
                              int ksize)

Blurs an image using the median filter.

The function smoothes an image using the median filter with the ksize x ksize aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.

Parameters:
src - input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U.
dst - destination array of the same size and type as src.
ksize - aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7...
See Also:
org.opencv.imgproc.Imgproc.medianBlur, boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), bilateralFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, double, double, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int)

minAreaRect

public static RotatedRect minAreaRect(MatOfPoint2f points)

Finds a rotated rectangle of the minimum area enclosing the input 2D point set.

The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a specified point set. See the OpenCV sample minarea.cpp.

Parameters:
points - Input vector of 2D points, stored in:
  • std.vector<> or Mat (C++ interface)
  • CvSeq* or CvMat* (C interface)
  • Nx2 numpy array (Python interface)
See Also:
org.opencv.imgproc.Imgproc.minAreaRect

minEnclosingCircle

public static void minEnclosingCircle(MatOfPoint2f points,
                                      Point center,
                                      float[] radius)

Finds a circle of the minimum area enclosing a 2D point set.

The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm. See the OpenCV sample minarea.cpp.

Parameters:
points - Input vector of 2D points, stored in:
  • std.vector<> or Mat (C++ interface)
  • CvSeq* or CvMat* (C interface)
  • Nx2 numpy array (Python interface)
center - Output center of the circle.
radius - Output radius of the circle.
See Also:
org.opencv.imgproc.Imgproc.minEnclosingCircle

moments

public static Moments moments(Mat array)

Calculates all of the moments up to the third order of a polygon or rasterized shape.

The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in the structure Moments defined as:

// C++ code:

class Moments

public:

Moments();

Moments(double m00, double m10, double m01, double m20, double m11,

double m02, double m30, double m21, double m12, double m03);

Moments(const CvMoments& moments);

operator CvMoments() const;

// spatial moments

double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;

// central moments

double mu20, mu11, mu02, mu30, mu21, mu12, mu03;

// central normalized moments

double nu20, nu11, nu02, nu30, nu21, nu12, nu03;

In case of a raster image, the spatial moments Moments.m_(ji) are computed as:

m _(ji)= sum(by: x,y)(array(x,y) * x^j * y^i)

The central moments Moments.mu_(ji) are computed as:

mu _(ji)= sum(by: x,y)(array(x,y) * (x - x")^j * (y - y")^i)

where (x", y") is the mass center:

x" = (m_10)/(m_(00)), y" = (m_01)/(m_(00))

The normalized central moments Moments.nu_(ij) are computed as:

nu _(ji)= (mu_(ji))/(m_(00)^((i+j)/2+1)).

Note:

mu_00=m_00, nu_00=1 nu_10=mu_10=mu_01=mu_10=0, hence the values are not stored.

The moments of a contour are defined in the same way but computed using the Green's formula (see http://en.wikipedia.org/wiki/Green_theorem). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.

Note:

Since the contour moments are computed using Green formula, you may get seemingly odd results for contours with self-intersections, e.g. a zero area (m00) for butterfly-shaped contours.

Parameters:
array - Raster image (single-channel, 8-bit or floating-point 2D array) or an array (1 x N or N x 1) of 2D points (Point or Point2f).
See Also:
org.opencv.imgproc.Imgproc.moments, contourArea(org.opencv.core.Mat, boolean), arcLength(org.opencv.core.MatOfPoint2f, boolean)

moments

public static Moments moments(Mat array,
                              boolean binaryImage)

Calculates all of the moments up to the third order of a polygon or rasterized shape.

The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in the structure Moments defined as:

// C++ code:

class Moments

public:

Moments();

Moments(double m00, double m10, double m01, double m20, double m11,

double m02, double m30, double m21, double m12, double m03);

Moments(const CvMoments& moments);

operator CvMoments() const;

// spatial moments

double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;

// central moments

double mu20, mu11, mu02, mu30, mu21, mu12, mu03;

// central normalized moments

double nu20, nu11, nu02, nu30, nu21, nu12, nu03;

In case of a raster image, the spatial moments Moments.m_(ji) are computed as:

m _(ji)= sum(by: x,y)(array(x,y) * x^j * y^i)

The central moments Moments.mu_(ji) are computed as:

mu _(ji)= sum(by: x,y)(array(x,y) * (x - x")^j * (y - y")^i)

where (x", y") is the mass center:

x" = (m_10)/(m_(00)), y" = (m_01)/(m_(00))

The normalized central moments Moments.nu_(ij) are computed as:

nu _(ji)= (mu_(ji))/(m_(00)^((i+j)/2+1)).

Note:

mu_00=m_00, nu_00=1 nu_10=mu_10=mu_01=mu_10=0, hence the values are not stored.

The moments of a contour are defined in the same way but computed using the Green's formula (see http://en.wikipedia.org/wiki/Green_theorem). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.

Note:

Since the contour moments are computed using Green formula, you may get seemingly odd results for contours with self-intersections, e.g. a zero area (m00) for butterfly-shaped contours.

Parameters:
array - Raster image (single-channel, 8-bit or floating-point 2D array) or an array (1 x N or N x 1) of 2D points (Point or Point2f).
binaryImage - If it is true, all non-zero image pixels are treated as 1's. The parameter is used for images only.
See Also:
org.opencv.imgproc.Imgproc.moments, contourArea(org.opencv.core.Mat, boolean), arcLength(org.opencv.core.MatOfPoint2f, boolean)

morphologyEx

public static void morphologyEx(Mat src,
                                Mat dst,
                                int op,
                                Mat kernel)

Performs advanced morphological transformations.

The function can perform advanced morphological transformations using an erosion and dilation as basic operations.

Opening operation:

dst = open(src, element)= dilate(erode(src, element))

Closing operation:

dst = close(src, element)= erode(dilate(src, element))

Morphological gradient:

dst = morph_grad(src, element)= dilate(src, element)- erode(src, element)

"Top hat":

dst = tophat(src, element)= src - open(src, element)

"Black hat":

dst = blackhat(src, element)= close(src, element)- src

Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.

Parameters:
src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - Destination image of the same size and type as src.
op - Type of a morphological operation that can be one of the following:
  • MORPH_OPEN - an opening operation
  • MORPH_CLOSE - a closing operation
  • MORPH_GRADIENT - a morphological gradient
  • MORPH_TOPHAT - "top hat"
  • MORPH_BLACKHAT - "black hat"
kernel - a kernel
See Also:
org.opencv.imgproc.Imgproc.morphologyEx, erode(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), dilate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

morphologyEx

public static void morphologyEx(Mat src,
                                Mat dst,
                                int op,
                                Mat kernel,
                                Point anchor,
                                int iterations)

Performs advanced morphological transformations.

The function can perform advanced morphological transformations using an erosion and dilation as basic operations.

Opening operation:

dst = open(src, element)= dilate(erode(src, element))

Closing operation:

dst = close(src, element)= erode(dilate(src, element))

Morphological gradient:

dst = morph_grad(src, element)= dilate(src, element)- erode(src, element)

"Top hat":

dst = tophat(src, element)= src - open(src, element)

"Black hat":

dst = blackhat(src, element)= close(src, element)- src

Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.

Parameters:
src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - Destination image of the same size and type as src.
op - Type of a morphological operation that can be one of the following:
  • MORPH_OPEN - an opening operation
  • MORPH_CLOSE - a closing operation
  • MORPH_GRADIENT - a morphological gradient
  • MORPH_TOPHAT - "top hat"
  • MORPH_BLACKHAT - "black hat"
kernel - a kernel
anchor - a anchor
iterations - Number of times erosion and dilation are applied.
See Also:
org.opencv.imgproc.Imgproc.morphologyEx, erode(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), dilate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

morphologyEx

public static void morphologyEx(Mat src,
                                Mat dst,
                                int op,
                                Mat kernel,
                                Point anchor,
                                int iterations,
                                int borderType,
                                Scalar borderValue)

Performs advanced morphological transformations.

The function can perform advanced morphological transformations using an erosion and dilation as basic operations.

Opening operation:

dst = open(src, element)= dilate(erode(src, element))

Closing operation:

dst = close(src, element)= erode(dilate(src, element))

Morphological gradient:

dst = morph_grad(src, element)= dilate(src, element)- erode(src, element)

"Top hat":

dst = tophat(src, element)= src - open(src, element)

"Black hat":

dst = blackhat(src, element)= close(src, element)- src

Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.

Parameters:
src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F" or CV_64F".
dst - Destination image of the same size and type as src.
op - Type of a morphological operation that can be one of the following:
  • MORPH_OPEN - an opening operation
  • MORPH_CLOSE - a closing operation
  • MORPH_GRADIENT - a morphological gradient
  • MORPH_TOPHAT - "top hat"
  • MORPH_BLACKHAT - "black hat"
kernel - a kernel
anchor - a anchor
iterations - Number of times erosion and dilation are applied.
borderType - Pixel extrapolation method. See "borderInterpolate" for details.
borderValue - Border value in case of a constant border. The default value has a special meaning. See "createMorphologyFilter" for details.
See Also:
org.opencv.imgproc.Imgproc.morphologyEx, erode(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar), dilate(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, int, int, org.opencv.core.Scalar)

phaseCorrelate

public static Point phaseCorrelate(Mat src1,
                                   Mat src2)

The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see http://en.wikipedia.org/wiki/Phase_correlation.

Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with "getOptimalDFTSize".

Return value: detected phase shift (sub-pixel) between the two arrays.

The function performs the following equations

  • First it applies a Hanning window (see http://en.wikipedia.org/wiki/Hann_function) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
  • Next it computes the forward DFTs of each source array:

mathbf(G)_a = mathcal(F)(src_1), mathbf(G)_b = mathcal(F)(src_2)

where mathcal(F) is the forward DFT.

  • It then computes the cross-power spectrum of each frequency domain array:

R = (mathbf(G)_a mathbf(G)_b^*)/(|mathbf(G)_a mathbf(G)_b^*|)

  • Next the cross-correlation is converted back into the time domain via the inverse DFT:

r = mathcal(F)^(-1)(R)

  • Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy.

(Delta x, Delta y) = weightedCentroid (arg max_((x, y))(r))

  • If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.

Parameters:
src1 - Source floating point array (CV_32FC1 or CV_64FC1)
src2 - Source floating point array (CV_32FC1 or CV_64FC1)
See Also:
org.opencv.imgproc.Imgproc.phaseCorrelate, createHanningWindow(org.opencv.core.Mat, org.opencv.core.Size, int), Core.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int), Core.mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean), Core.getOptimalDFTSize(int), Core.idft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)

phaseCorrelate

public static Point phaseCorrelate(Mat src1,
                                   Mat src2,
                                   Mat window)

The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see http://en.wikipedia.org/wiki/Phase_correlation.

Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with "getOptimalDFTSize".

Return value: detected phase shift (sub-pixel) between the two arrays.

The function performs the following equations

  • First it applies a Hanning window (see http://en.wikipedia.org/wiki/Hann_function) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
  • Next it computes the forward DFTs of each source array:

mathbf(G)_a = mathcal(F)(src_1), mathbf(G)_b = mathcal(F)(src_2)

where mathcal(F) is the forward DFT.

  • It then computes the cross-power spectrum of each frequency domain array:

R = (mathbf(G)_a mathbf(G)_b^*)/(|mathbf(G)_a mathbf(G)_b^*|)

  • Next the cross-correlation is converted back into the time domain via the inverse DFT:

r = mathcal(F)^(-1)(R)

  • Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy.

(Delta x, Delta y) = weightedCentroid (arg max_((x, y))(r))

  • If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.

Parameters:
src1 - Source floating point array (CV_32FC1 or CV_64FC1)
src2 - Source floating point array (CV_32FC1 or CV_64FC1)
window - Floating point array with windowing coefficients to reduce edge effects (optional).
See Also:
org.opencv.imgproc.Imgproc.phaseCorrelate, createHanningWindow(org.opencv.core.Mat, org.opencv.core.Size, int), Core.dft(org.opencv.core.Mat, org.opencv.core.Mat, int, int), Core.mulSpectrums(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, boolean), Core.getOptimalDFTSize(int), Core.idft(org.opencv.core.Mat, org.opencv.core.Mat, int, int)

phaseCorrelateRes

public static Point phaseCorrelateRes(Mat src1,
                                      Mat src2,
                                      Mat window)

phaseCorrelateRes

public static Point phaseCorrelateRes(Mat src1,
                                      Mat src2,
                                      Mat window,
                                      double[] response)

pointPolygonTest

public static double pointPolygonTest(MatOfPoint2f contour,
                                      Point pt,
                                      boolean measureDist)

Performs a point-in-contour test.

The function determines whether the point is inside a contour, outside, or lies on an edge (or coincides with a vertex). It returns positive (inside), negative (outside), or zero (on an edge) value, correspondingly. When measureDist=false, the return value is +1, -1, and 0, respectively. Otherwise, the return value is a signed distance between the point and the nearest contour edge.

See below a sample output of the function where each image pixel is tested against the contour.

Parameters:
contour - Input contour.
pt - Point tested against the contour.
measureDist - If true, the function estimates the signed distance from the point to the nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not.
See Also:
org.opencv.imgproc.Imgproc.pointPolygonTest

preCornerDetect

public static void preCornerDetect(Mat src,
                                   Mat dst,
                                   int ksize)

Calculates a feature map for corner detection.

The function calculates the complex spatial derivative-based function of the source image

dst = (D_x src)^2 * D_(yy) src + (D_y src)^2 * D_(xx) src - 2 D_x src * D_y src * D_(xy) src

where D_x,D_y are the first image derivatives, D_(xx),D_(yy) are the second image derivatives, and D_(xy) is the mixed derivative. The corners can be found as local maximums of the functions, as shown below:

// C++ code:

Mat corners, dilated_corners;

preCornerDetect(image, corners, 3);

// dilation with 3x3 rectangular structuring element

dilate(corners, dilated_corners, Mat(), 1);

Mat corner_mask = corners == dilated_corners;

Parameters:
src - Source single-channel 8-bit of floating-point image.
dst - Output image that has the type CV_32F and the same size as src.
ksize - Aperture size of the "Sobel".
See Also:
org.opencv.imgproc.Imgproc.preCornerDetect

preCornerDetect

public static void preCornerDetect(Mat src,
                                   Mat dst,
                                   int ksize,
                                   int borderType)

Calculates a feature map for corner detection.

The function calculates the complex spatial derivative-based function of the source image

dst = (D_x src)^2 * D_(yy) src + (D_y src)^2 * D_(xx) src - 2 D_x src * D_y src * D_(xy) src

where D_x,D_y are the first image derivatives, D_(xx),D_(yy) are the second image derivatives, and D_(xy) is the mixed derivative. The corners can be found as local maximums of the functions, as shown below:

// C++ code:

Mat corners, dilated_corners;

preCornerDetect(image, corners, 3);

// dilation with 3x3 rectangular structuring element

dilate(corners, dilated_corners, Mat(), 1);

Mat corner_mask = corners == dilated_corners;

Parameters:
src - Source single-channel 8-bit of floating-point image.
dst - Output image that has the type CV_32F and the same size as src.
ksize - Aperture size of the "Sobel".
borderType - Pixel extrapolation method. See "borderInterpolate".
See Also:
org.opencv.imgproc.Imgproc.preCornerDetect

PSNR

public static double PSNR(Mat src1,
                          Mat src2)

pyrDown

public static void pyrDown(Mat src,
                           Mat dst)

Blurs an image and downsamples it.

The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel:

1/256 1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 4 16 24 16 4 1 4 6 4 1

Then, it downsamples the image by rejecting even rows and columns.

Parameters:
src - input image.
dst - output image; it has the specified size and the same type as src.
See Also:
org.opencv.imgproc.Imgproc.pyrDown

pyrDown

public static void pyrDown(Mat src,
                           Mat dst,
                           Size dstsize)

Blurs an image and downsamples it.

The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel:

1/256 1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 4 16 24 16 4 1 4 6 4 1

Then, it downsamples the image by rejecting even rows and columns.

Parameters:
src - input image.
dst - output image; it has the specified size and the same type as src.
dstsize - size of the output image; by default, it is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in any case, the following conditions should be satisfied:

ltBR gt| dstsize.width *2-src.cols| <= 2 |dstsize.height *2-src.rows| <= 2

See Also:
org.opencv.imgproc.Imgproc.pyrDown

pyrDown

public static void pyrDown(Mat src,
                           Mat dst,
                           Size dstsize,
                           int borderType)

Blurs an image and downsamples it.

The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel:

1/256 1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 4 16 24 16 4 1 4 6 4 1

Then, it downsamples the image by rejecting even rows and columns.

Parameters:
src - input image.
dst - output image; it has the specified size and the same type as src.
dstsize - size of the output image; by default, it is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in any case, the following conditions should be satisfied:

ltBR gt| dstsize.width *2-src.cols| <= 2 |dstsize.height *2-src.rows| <= 2

borderType - a borderType
See Also:
org.opencv.imgproc.Imgproc.pyrDown

pyrMeanShiftFiltering

public static void pyrMeanShiftFiltering(Mat src,
                                         Mat dst,
                                         double sp,
                                         double sr)

Performs initial step of meanshift segmentation of an image.

The function implements the filtering stage of meanshift segmentation, that is, the output of the function is the filtered "posterized" image with color gradients and fine-grain texture flattened. At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is considered:

(x,y): X- sp <= x <= X+ sp, Y- sp <= y <= Y+ sp, ||(R,G,B)-(r,g,b)|| <= sr

where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively (though, the algorithm does not depend on the color space used, so any 3-component color space can be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector (R',G',B') are found and they act as the neighborhood center on the next iteration:

(X,Y)~(X',Y'), (R,G,B)~(R',G',B').

After the iterations over, the color components of the initial pixel (that is, the pixel from where the iterations started) are set to the final value (average color at the last iteration):

I(X,Y) <- (R*,G*,B*)

When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is run on the smallest layer first. After that, the results are propagated to the larger layer and the iterations are run again only on those pixels where the layer colors differ by more than sr from the lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the results will be actually different from the ones obtained by running the meanshift procedure on the whole original image (i.e. when maxLevel==0).

Parameters:
src - The source 8-bit, 3-channel image.
dst - The destination image of the same format and the same size as the source.
sp - The spatial window radius.
sr - The color window radius.
See Also:
org.opencv.imgproc.Imgproc.pyrMeanShiftFiltering

pyrMeanShiftFiltering

public static void pyrMeanShiftFiltering(Mat src,
                                         Mat dst,
                                         double sp,
                                         double sr,
                                         int maxLevel,
                                         TermCriteria termcrit)

Performs initial step of meanshift segmentation of an image.

The function implements the filtering stage of meanshift segmentation, that is, the output of the function is the filtered "posterized" image with color gradients and fine-grain texture flattened. At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is considered:

(x,y): X- sp <= x <= X+ sp, Y- sp <= y <= Y+ sp, ||(R,G,B)-(r,g,b)|| <= sr

where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively (though, the algorithm does not depend on the color space used, so any 3-component color space can be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector (R',G',B') are found and they act as the neighborhood center on the next iteration:

(X,Y)~(X',Y'), (R,G,B)~(R',G',B').

After the iterations over, the color components of the initial pixel (that is, the pixel from where the iterations started) are set to the final value (average color at the last iteration):

I(X,Y) <- (R*,G*,B*)

When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is run on the smallest layer first. After that, the results are propagated to the larger layer and the iterations are run again only on those pixels where the layer colors differ by more than sr from the lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the results will be actually different from the ones obtained by running the meanshift procedure on the whole original image (i.e. when maxLevel==0).

Parameters:
src - The source 8-bit, 3-channel image.
dst - The destination image of the same format and the same size as the source.
sp - The spatial window radius.
sr - The color window radius.
maxLevel - Maximum level of the pyramid for the segmentation.
termcrit - Termination criteria: when to stop meanshift iterations.
See Also:
org.opencv.imgproc.Imgproc.pyrMeanShiftFiltering

pyrUp

public static void pyrUp(Mat src,
                         Mat dst)

Upsamples an image and then blurs it.

The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in "pyrDown" multiplied by 4.

Parameters:
src - input image.
dst - output image. It has the specified size and the same type as src.
See Also:
org.opencv.imgproc.Imgproc.pyrUp

pyrUp

public static void pyrUp(Mat src,
                         Mat dst,
                         Size dstsize)

Upsamples an image and then blurs it.

The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in "pyrDown" multiplied by 4.

Parameters:
src - input image.
dst - output image. It has the specified size and the same type as src.
dstsize - size of the output image; by default, it is computed as Size(src.cols*2, (src.rows*2), but in any case, the following conditions should be satisfied:

ltBR gt| dstsize.width -src.cols*2| <= (dstsize.width mod 2) |dstsize.height -src.rows*2| <= (dstsize.height mod 2)

See Also:
org.opencv.imgproc.Imgproc.pyrUp

pyrUp

public static void pyrUp(Mat src,
                         Mat dst,
                         Size dstsize,
                         int borderType)

Upsamples an image and then blurs it.

The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in "pyrDown" multiplied by 4.

Parameters:
src - input image.
dst - output image. It has the specified size and the same type as src.
dstsize - size of the output image; by default, it is computed as Size(src.cols*2, (src.rows*2), but in any case, the following conditions should be satisfied:

ltBR gt| dstsize.width -src.cols*2| <= (dstsize.width mod 2) |dstsize.height -src.rows*2| <= (dstsize.height mod 2)

borderType - a borderType
See Also:
org.opencv.imgproc.Imgproc.pyrUp

remap

public static void remap(Mat src,
                         Mat dst,
                         Mat map1,
                         Mat map2,
                         int interpolation)

Applies a generic geometrical transformation to an image.

The function remap transforms the source image using the specified map:

dst(x,y) = src(map_x(x,y),map_y(x,y))

where values of pixels with non-integer coordinates are computed using one of available interpolation methods. map_x and map_y can be encoded as separate floating-point maps in map_1 and map_2 respectively, or interleaved floating-point maps of (x,y) in map_1, or fixed-point maps created by using "convertMaps". The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (~2x) remapping operations. In the converted case, map_1 contains pairs (cvFloor(x), cvFloor(y)) and map_2 contains indices in a table of interpolation coefficients.

This function cannot operate in-place.

Parameters:
src - Source image.
dst - Destination image. It has the same size as map1 and the same type as src.
map1 - The first map of either (x,y) points or just x values having the type CV_16SC2, CV_32FC1, or CV_32FC2. See "convertMaps" for details on converting a floating point representation to fixed-point for speed.
map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
interpolation - Interpolation method (see "resize"). The method INTER_AREA is not supported by this function.
See Also:
org.opencv.imgproc.Imgproc.remap

remap

public static void remap(Mat src,
                         Mat dst,
                         Mat map1,
                         Mat map2,
                         int interpolation,
                         int borderMode,
                         Scalar borderValue)

Applies a generic geometrical transformation to an image.

The function remap transforms the source image using the specified map:

dst(x,y) = src(map_x(x,y),map_y(x,y))

where values of pixels with non-integer coordinates are computed using one of available interpolation methods. map_x and map_y can be encoded as separate floating-point maps in map_1 and map_2 respectively, or interleaved floating-point maps of (x,y) in map_1, or fixed-point maps created by using "convertMaps". The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (~2x) remapping operations. In the converted case, map_1 contains pairs (cvFloor(x), cvFloor(y)) and map_2 contains indices in a table of interpolation coefficients.

This function cannot operate in-place.

Parameters:
src - Source image.
dst - Destination image. It has the same size as map1 and the same type as src.
map1 - The first map of either (x,y) points or just x values having the type CV_16SC2, CV_32FC1, or CV_32FC2. See "convertMaps" for details on converting a floating point representation to fixed-point for speed.
map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
interpolation - Interpolation method (see "resize"). The method INTER_AREA is not supported by this function.
borderMode - Pixel extrapolation method (see "borderInterpolate"). When borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
borderValue - Value used in case of a constant border. By default, it is 0.
See Also:
org.opencv.imgproc.Imgproc.remap

resize

public static void resize(Mat src,
                          Mat dst,
                          Size dsize)

Resizes an image.

The function resize resizes the image src down to or up to the specified size.Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst, you may call the function as follows:

// C++ code:

// explicitly specify dsize=dst.size(); fx and fy will be computed from that.

resize(src, dst, dst.size(), 0, 0, interpolation);

If you want to decimate the image by factor of 2 in each direction, you can call the function this way:

// specify fx and fy and let the function compute the destination image size.

resize(src, dst, Size(), 0.5, 0.5, interpolation);

To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).

Parameters:
src - input image.
dst - output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
dsize - output image size; if it equals zero, it is computed as:

dsize = Size(round(fx*src.cols), round(fy*src.rows))

Either dsize or both fx and fy must be non-zero.

See Also:
org.opencv.imgproc.Imgproc.resize, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)

resize

public static void resize(Mat src,
                          Mat dst,
                          Size dsize,
                          double fx,
                          double fy,
                          int interpolation)

Resizes an image.

The function resize resizes the image src down to or up to the specified size.Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst, you may call the function as follows:

// C++ code:

// explicitly specify dsize=dst.size(); fx and fy will be computed from that.

resize(src, dst, dst.size(), 0, 0, interpolation);

If you want to decimate the image by factor of 2 in each direction, you can call the function this way:

// specify fx and fy and let the function compute the destination image size.

resize(src, dst, Size(), 0.5, 0.5, interpolation);

To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).

Parameters:
src - input image.
dst - output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
dsize - output image size; if it equals zero, it is computed as:

dsize = Size(round(fx*src.cols), round(fy*src.rows))

Either dsize or both fx and fy must be non-zero.

fx - scale factor along the horizontal axis; when it equals 0, it is computed as

(double)dsize.width/src.cols

fy - scale factor along the vertical axis; when it equals 0, it is computed as

(double)dsize.height/src.rows

interpolation - interpolation method:
  • INTER_NEAREST - a nearest-neighbor interpolation
  • INTER_LINEAR - a bilinear interpolation (used by default)
  • INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire'-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
  • INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
  • INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
See Also:
org.opencv.imgproc.Imgproc.resize, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)

Scharr

public static void Scharr(Mat src,
                          Mat dst,
                          int ddepth,
                          int dx,
                          int dy)

Calculates the first x- or y- image derivative using Scharr operator.

The function computes the first x- or y- spatial image derivative using the Scharr operator. The call

Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)

is equivalent to

Sobel(src, dst, ddepth, dx, dy, CV_SCHARR, scale, delta, borderType).

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - output image depth (see "Sobel" for the list of supported combination of src.depth() and ddepth).
dx - order of the derivative x.
dy - order of the derivative y.
See Also:
org.opencv.imgproc.Imgproc.Scharr, Core.cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)

Scharr

public static void Scharr(Mat src,
                          Mat dst,
                          int ddepth,
                          int dx,
                          int dy,
                          double scale,
                          double delta)

Calculates the first x- or y- image derivative using Scharr operator.

The function computes the first x- or y- spatial image derivative using the Scharr operator. The call

Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)

is equivalent to

Sobel(src, dst, ddepth, dx, dy, CV_SCHARR, scale, delta, borderType).

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - output image depth (see "Sobel" for the list of supported combination of src.depth() and ddepth).
dx - order of the derivative x.
dy - order of the derivative y.
scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see "getDerivKernels" for details).
delta - optional delta value that is added to the results prior to storing them in dst.
See Also:
org.opencv.imgproc.Imgproc.Scharr, Core.cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)

Scharr

public static void Scharr(Mat src,
                          Mat dst,
                          int ddepth,
                          int dx,
                          int dy,
                          double scale,
                          double delta,
                          int borderType)

Calculates the first x- or y- image derivative using Scharr operator.

The function computes the first x- or y- spatial image derivative using the Scharr operator. The call

Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)

is equivalent to

Sobel(src, dst, ddepth, dx, dy, CV_SCHARR, scale, delta, borderType).

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - output image depth (see "Sobel" for the list of supported combination of src.depth() and ddepth).
dx - order of the derivative x.
dy - order of the derivative y.
scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see "getDerivKernels" for details).
delta - optional delta value that is added to the results prior to storing them in dst.
borderType - pixel extrapolation method (see "borderInterpolate" for details).
See Also:
org.opencv.imgproc.Imgproc.Scharr, Core.cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean)

sepFilter2D

public static void sepFilter2D(Mat src,
                               Mat dst,
                               int ddepth,
                               Mat kernelX,
                               Mat kernelY)

Applies a separable linear filter to an image.

The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst.

Parameters:
src - Source image.
dst - Destination image of the same size and the same number of channels as src.
ddepth - Destination image depth. The following combination of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the destination image will have the same depth as the source.

kernelX - Coefficients for filtering each row.
kernelY - Coefficients for filtering each column.
See Also:
org.opencv.imgproc.Imgproc.sepFilter2D, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int), boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)

sepFilter2D

public static void sepFilter2D(Mat src,
                               Mat dst,
                               int ddepth,
                               Mat kernelX,
                               Mat kernelY,
                               Point anchor,
                               double delta)

Applies a separable linear filter to an image.

The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst.

Parameters:
src - Source image.
dst - Destination image of the same size and the same number of channels as src.
ddepth - Destination image depth. The following combination of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the destination image will have the same depth as the source.

kernelX - Coefficients for filtering each row.
kernelY - Coefficients for filtering each column.
anchor - Anchor position within the kernel. The default value (-1, 1) means that the anchor is at the kernel center.
delta - Value added to the filtered results before storing them.
See Also:
org.opencv.imgproc.Imgproc.sepFilter2D, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int), boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)

sepFilter2D

public static void sepFilter2D(Mat src,
                               Mat dst,
                               int ddepth,
                               Mat kernelX,
                               Mat kernelY,
                               Point anchor,
                               double delta,
                               int borderType)

Applies a separable linear filter to an image.

The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst.

Parameters:
src - Source image.
dst - Destination image of the same size and the same number of channels as src.
ddepth - Destination image depth. The following combination of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the destination image will have the same depth as the source.

kernelX - Coefficients for filtering each row.
kernelY - Coefficients for filtering each column.
anchor - Anchor position within the kernel. The default value (-1, 1) means that the anchor is at the kernel center.
delta - Value added to the filtered results before storing them.
borderType - Pixel extrapolation method. See "borderInterpolate" for details.
See Also:
org.opencv.imgproc.Imgproc.sepFilter2D, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Sobel(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, int, double, double, int), boxFilter(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Size, org.opencv.core.Point, boolean, int), blur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)

Sobel

public static void Sobel(Mat src,
                         Mat dst,
                         int ddepth,
                         int dx,
                         int dy)

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

In all cases except one, the ksize x<BR>ksize separable kernel is used to calculate the derivative. When ksize = 1, the 3 x 1 or 1 x 3 kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives.

There is also the special value ksize = CV_SCHARR (-1) that corresponds to the 3x3 Scharr filter that may give more accurate results than the 3x3 Sobel. The Scharr aperture is

|-3 0 3| |-10 0 10| |-3 0 3|

for the x-derivative, or transposed for the y-derivative.

The function calculates an image derivative by convolving the image with the appropriate kernel:

dst = (d^(xorder+yorder) src)/(dx^(xorder) dy^(yorder))

The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with (xorder = 1, yorder = 0, ksize = 3) or (xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of:

|-1 0 1| |-2 0 2| |-1 0 1|

The second case corresponds to a kernel of:

|-1 -2 -1| |0 0 0| |1 2 1|

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - output image depth; the following combinations of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the destination image will have the same depth as the source; in the case of 8-bit input images it will result in truncated derivatives.

dx - a dx
dy - a dy
See Also:
org.opencv.imgproc.Imgproc.Sobel, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Core.cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), Laplacian(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, double, int), Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)

Sobel

public static void Sobel(Mat src,
                         Mat dst,
                         int ddepth,
                         int dx,
                         int dy,
                         int ksize,
                         double scale,
                         double delta)

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

In all cases except one, the ksize x<BR>ksize separable kernel is used to calculate the derivative. When ksize = 1, the 3 x 1 or 1 x 3 kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives.

There is also the special value ksize = CV_SCHARR (-1) that corresponds to the 3x3 Scharr filter that may give more accurate results than the 3x3 Sobel. The Scharr aperture is

|-3 0 3| |-10 0 10| |-3 0 3|

for the x-derivative, or transposed for the y-derivative.

The function calculates an image derivative by convolving the image with the appropriate kernel:

dst = (d^(xorder+yorder) src)/(dx^(xorder) dy^(yorder))

The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with (xorder = 1, yorder = 0, ksize = 3) or (xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of:

|-1 0 1| |-2 0 2| |-1 0 1|

The second case corresponds to a kernel of:

|-1 -2 -1| |0 0 0| |1 2 1|

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - output image depth; the following combinations of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the destination image will have the same depth as the source; in the case of 8-bit input images it will result in truncated derivatives.

dx - a dx
dy - a dy
ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see "getDerivKernels" for details).
delta - optional delta value that is added to the results prior to storing them in dst.
See Also:
org.opencv.imgproc.Imgproc.Sobel, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Core.cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), Laplacian(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, double, int), Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)

Sobel

public static void Sobel(Mat src,
                         Mat dst,
                         int ddepth,
                         int dx,
                         int dy,
                         int ksize,
                         double scale,
                         double delta,
                         int borderType)

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

In all cases except one, the ksize x<BR>ksize separable kernel is used to calculate the derivative. When ksize = 1, the 3 x 1 or 1 x 3 kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives.

There is also the special value ksize = CV_SCHARR (-1) that corresponds to the 3x3 Scharr filter that may give more accurate results than the 3x3 Sobel. The Scharr aperture is

|-3 0 3| |-10 0 10| |-3 0 3|

for the x-derivative, or transposed for the y-derivative.

The function calculates an image derivative by convolving the image with the appropriate kernel:

dst = (d^(xorder+yorder) src)/(dx^(xorder) dy^(yorder))

The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with (xorder = 1, yorder = 0, ksize = 3) or (xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of:

|-1 0 1| |-2 0 2| |-1 0 1|

The second case corresponds to a kernel of:

|-1 -2 -1| |0 0 0| |1 2 1|

Parameters:
src - input image.
dst - output image of the same size and the same number of channels as src.
ddepth - output image depth; the following combinations of src.depth() and ddepth are supported:
  • src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
  • src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
  • src.depth() = CV_64F, ddepth = -1/CV_64F

when ddepth=-1, the destination image will have the same depth as the source; in the case of 8-bit input images it will result in truncated derivatives.

dx - a dx
dy - a dy
ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see "getDerivKernels" for details).
delta - optional delta value that is added to the results prior to storing them in dst.
borderType - pixel extrapolation method (see "borderInterpolate" for details).
See Also:
org.opencv.imgproc.Imgproc.Sobel, GaussianBlur(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Core.cartToPolar(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean), sepFilter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Point, double, int), Laplacian(org.opencv.core.Mat, org.opencv.core.Mat, int, int, double, double, int), Scharr(org.opencv.core.Mat, org.opencv.core.Mat, int, int, int, double, double, int), filter2D(org.opencv.core.Mat, org.opencv.core.Mat, int, org.opencv.core.Mat, org.opencv.core.Point, double, int)

threshold

public static double threshold(Mat src,
                               Mat dst,
                               double thresh,
                               double maxval,
                               int type)

Applies a fixed-level threshold to each array element.

The function applies fixed-level thresholding to a single-channel array. The function is typically used to get a bi-level (binary) image out of a grayscale image ("compare" could be also used for this purpose) or for removing a noise, that is, filtering out pixels with too small or too large values. There are several types of thresholding supported by the function. They are determined by type :

  • THRESH_BINARY

dst(x,y) = maxval if src(x,y) > thresh; 0 otherwise

  • THRESH_BINARY_INV

dst(x,y) = 0 if src(x,y) > thresh; maxval otherwise

  • THRESH_TRUNC

dst(x,y) = threshold if src(x,y) > thresh; src(x,y) otherwise

  • THRESH_TOZERO

dst(x,y) = src(x,y) if src(x,y) > thresh; 0 otherwise

  • THRESH_TOZERO_INV

dst(x,y) = 0 if src(x,y) > thresh; src(x,y) otherwise

Also, the special value THRESH_OTSU may be combined with one of the above values. In this case, the function determines the optimal threshold value using the Otsu's algorithm and uses it instead of the specified thresh. The function returns the computed threshold value. Currently, the Otsu's method is implemented only for 8-bit images.

Parameters:
src - input array (single-channel, 8-bit or 32-bit floating point).
dst - output array of the same size and type as src.
thresh - threshold value.
maxval - maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.
type - thresholding type (see the details below).
See Also:
org.opencv.imgproc.Imgproc.threshold, findContours(org.opencv.core.Mat, java.util.List, org.opencv.core.Mat, int, int, org.opencv.core.Point), Core.max(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), adaptiveThreshold(org.opencv.core.Mat, org.opencv.core.Mat, double, int, int, int, double), Core.compare(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int), Core.min(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

undistort

public static void undistort(Mat src,
                             Mat dst,
                             Mat cameraMatrix,
                             Mat distCoeffs)

Transforms an image to compensate for lens distortion.

The function transforms an image to compensate radial and tangential lens distortion.

The function is simply a combination of "initUndistortRectifyMap" (with unity R) and "remap" (with bilinear interpolation). See the former function for details of the transformation being performed.

Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).

A particular subset of the source image that will be visible in the corrected image can be regulated by newCameraMatrix. You can use "getOptimalNewCameraMatrix" to compute the appropriate newCameraMatrix depending on your requirements.

The camera matrix and the distortion parameters can be determined using "calibrateCamera". If the resolution of images is different from the resolution used at the calibration stage, f_x, f_y, c_x and c_y need to be scaled accordingly, while the distortion coefficients remain the same.

Parameters:
src - Input (distorted) image.
dst - Output (corrected) image that has the same size and type as src.
cameraMatrix - Input camera matrix A =

|f_x 0 c_x| |0 f_y c_y| |0 0 1| .

distCoeffs - Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
See Also:
org.opencv.imgproc.Imgproc.undistort

undistort

public static void undistort(Mat src,
                             Mat dst,
                             Mat cameraMatrix,
                             Mat distCoeffs,
                             Mat newCameraMatrix)

Transforms an image to compensate for lens distortion.

The function transforms an image to compensate radial and tangential lens distortion.

The function is simply a combination of "initUndistortRectifyMap" (with unity R) and "remap" (with bilinear interpolation). See the former function for details of the transformation being performed.

Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).

A particular subset of the source image that will be visible in the corrected image can be regulated by newCameraMatrix. You can use "getOptimalNewCameraMatrix" to compute the appropriate newCameraMatrix depending on your requirements.

The camera matrix and the distortion parameters can be determined using "calibrateCamera". If the resolution of images is different from the resolution used at the calibration stage, f_x, f_y, c_x and c_y need to be scaled accordingly, while the distortion coefficients remain the same.

Parameters:
src - Input (distorted) image.
dst - Output (corrected) image that has the same size and type as src.
cameraMatrix - Input camera matrix A =

|f_x 0 c_x| |0 f_y c_y| |0 0 1| .

distCoeffs - Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
newCameraMatrix - Camera matrix of the distorted image. By default, it is the same as cameraMatrix but you may additionally scale and shift the result by using a different matrix.
See Also:
org.opencv.imgproc.Imgproc.undistort

undistortPoints

public static void undistortPoints(MatOfPoint2f src,
                                   MatOfPoint2f dst,
                                   Mat cameraMatrix,
                                   Mat distCoeffs)

Computes the ideal point coordinates from the observed point coordinates.

The function is similar to "undistort" and "initUndistortRectifyMap" but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to"projectPoints". In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper R is specified.

// C++ code:

// (u,v) is the input point, (u', v') is the output point

// camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]

// P=[fx' 0 cx' tx; 0 fy' cy' ty; 0 0 1 tz]

x" = (u - cx)/fx

y" = (v - cy)/fy

(x',y') = undistort(x",y",dist_coeffs)

[X,Y,W]T = R*[x' y' 1]T

x = X/W, y = Y/W

// only performed if P=[fx' 0 cx' [tx]; 0 fy' cy' [ty]; 0 0 1 [tz]] is specified

u' = x*fx' + cx'

v' = y*fy' + cy',

where undistort() is an approximate iterative algorithm that estimates the normalized original point coordinates out of the normalized distorted point coordinates ("normalized" means that the coordinates do not depend on the camera matrix).

The function can be used for both a stereo camera head or a monocular camera (when R is empty).

Parameters:
src - Observed point coordinates, 1xN or Nx1 2-channel (CV_32FC2 or CV_64FC2).
dst - Output ideal point coordinates after undistortion and reverse perspective transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
cameraMatrix - Camera matrix

|f_x 0 c_x| |0 f_y c_y| |0 0 1| .

distCoeffs - Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
See Also:
org.opencv.imgproc.Imgproc.undistortPoints

undistortPoints

public static void undistortPoints(MatOfPoint2f src,
                                   MatOfPoint2f dst,
                                   Mat cameraMatrix,
                                   Mat distCoeffs,
                                   Mat R,
                                   Mat P)

Computes the ideal point coordinates from the observed point coordinates.

The function is similar to "undistort" and "initUndistortRectifyMap" but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to"projectPoints". In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper R is specified.

// C++ code:

// (u,v) is the input point, (u', v') is the output point

// camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]

// P=[fx' 0 cx' tx; 0 fy' cy' ty; 0 0 1 tz]

x" = (u - cx)/fx

y" = (v - cy)/fy

(x',y') = undistort(x",y",dist_coeffs)

[X,Y,W]T = R*[x' y' 1]T

x = X/W, y = Y/W

// only performed if P=[fx' 0 cx' [tx]; 0 fy' cy' [ty]; 0 0 1 [tz]] is specified

u' = x*fx' + cx'

v' = y*fy' + cy',

where undistort() is an approximate iterative algorithm that estimates the normalized original point coordinates out of the normalized distorted point coordinates ("normalized" means that the coordinates do not depend on the camera matrix).

The function can be used for both a stereo camera head or a monocular camera (when R is empty).

Parameters:
src - Observed point coordinates, 1xN or Nx1 2-channel (CV_32FC2 or CV_64FC2).
dst - Output ideal point coordinates after undistortion and reverse perspective transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
cameraMatrix - Camera matrix

|f_x 0 c_x| |0 f_y c_y| |0 0 1| .

distCoeffs - Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
R - Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by "stereoRectify" can be passed here. If the matrix is empty, the identity transformation is used.
P - New camera matrix (3x3) or new projection matrix (3x4). P1 or P2 computed by "stereoRectify" can be passed here. If the matrix is empty, the identity new camera matrix is used.
See Also:
org.opencv.imgproc.Imgproc.undistortPoints

warpAffine

public static void warpAffine(Mat src,
                              Mat dst,
                              Mat M,
                              Size dsize)

Applies an affine transformation to an image.

The function warpAffine transforms the source image using the specified matrix:

dst(x,y) = src(M _11 x + M _12 y + M _13, M _21 x + M _22 y + M _23)

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with "invertAffineTransform" and then put in the formula above instead of M. The function cannot operate in-place.

Note: cvGetQuadrangleSubPix is similar to cvWarpAffine, but the outliers are extrapolated using replication border mode.

Parameters:
src - input image.
dst - output image that has the size dsize and the same type as src.
M - 2x 3 transformation matrix.
dsize - size of the output image.
See Also:
org.opencv.imgproc.Imgproc.warpAffine, remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), getRectSubPix(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, org.opencv.core.Mat, int), resize(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Core.transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

warpAffine

public static void warpAffine(Mat src,
                              Mat dst,
                              Mat M,
                              Size dsize,
                              int flags)

Applies an affine transformation to an image.

The function warpAffine transforms the source image using the specified matrix:

dst(x,y) = src(M _11 x + M _12 y + M _13, M _21 x + M _22 y + M _23)

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with "invertAffineTransform" and then put in the formula above instead of M. The function cannot operate in-place.

Note: cvGetQuadrangleSubPix is similar to cvWarpAffine, but the outliers are extrapolated using replication border mode.

Parameters:
src - input image.
dst - output image that has the size dsize and the same type as src.
M - 2x 3 transformation matrix.
dsize - size of the output image.
flags - combination of interpolation methods (see "resize") and the optional flag WARP_INVERSE_MAP that means that M is the inverse transformation (dst->src).
See Also:
org.opencv.imgproc.Imgproc.warpAffine, remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), getRectSubPix(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, org.opencv.core.Mat, int), resize(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Core.transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

warpAffine

public static void warpAffine(Mat src,
                              Mat dst,
                              Mat M,
                              Size dsize,
                              int flags,
                              int borderMode,
                              Scalar borderValue)

Applies an affine transformation to an image.

The function warpAffine transforms the source image using the specified matrix:

dst(x,y) = src(M _11 x + M _12 y + M _13, M _21 x + M _22 y + M _23)

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with "invertAffineTransform" and then put in the formula above instead of M. The function cannot operate in-place.

Note: cvGetQuadrangleSubPix is similar to cvWarpAffine, but the outliers are extrapolated using replication border mode.

Parameters:
src - input image.
dst - output image that has the size dsize and the same type as src.
M - 2x 3 transformation matrix.
dsize - size of the output image.
flags - combination of interpolation methods (see "resize") and the optional flag WARP_INVERSE_MAP that means that M is the inverse transformation (dst->src).
borderMode - pixel extrapolation method (see "borderInterpolate"); when borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function.
borderValue - value used in case of a constant border; by default, it is 0.
See Also:
org.opencv.imgproc.Imgproc.warpAffine, remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), getRectSubPix(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, org.opencv.core.Mat, int), resize(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int), Core.transform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)

warpPerspective

public static void warpPerspective(Mat src,
                                   Mat dst,
                                   Mat M,
                                   Size dsize)

Applies a perspective transformation to an image.

The function warpPerspective transforms the source image using the specified matrix:

dst(x,y) = src((M_11 x + M_12 y + M_13)/(M_(31) x + M_32 y + M_33),<BR>(M_21 x + M_22 y + M_23)/(M_(31) x + M_32 y + M_33))

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with "invert" and then put in the formula above instead of M. The function cannot operate in-place.

Parameters:
src - input image.
dst - output image that has the size dsize and the same type as src.
M - 3x 3 transformation matrix.
dsize - size of the output image.
See Also:
org.opencv.imgproc.Imgproc.warpPerspective, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), getRectSubPix(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, org.opencv.core.Mat, int), resize(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int)

warpPerspective

public static void warpPerspective(Mat src,
                                   Mat dst,
                                   Mat M,
                                   Size dsize,
                                   int flags)

Applies a perspective transformation to an image.

The function warpPerspective transforms the source image using the specified matrix:

dst(x,y) = src((M_11 x + M_12 y + M_13)/(M_(31) x + M_32 y + M_33),<BR>(M_21 x + M_22 y + M_23)/(M_(31) x + M_32 y + M_33))

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with "invert" and then put in the formula above instead of M. The function cannot operate in-place.

Parameters:
src - input image.
dst - output image that has the size dsize and the same type as src.
M - 3x 3 transformation matrix.
dsize - size of the output image.
flags - combination of interpolation methods (INTER_LINEAR or INTER_NEAREST) and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst->src).
See Also:
org.opencv.imgproc.Imgproc.warpPerspective, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), getRectSubPix(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, org.opencv.core.Mat, int), resize(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int)

warpPerspective

public static void warpPerspective(Mat src,
                                   Mat dst,
                                   Mat M,
                                   Size dsize,
                                   int flags,
                                   int borderMode,
                                   Scalar borderValue)

Applies a perspective transformation to an image.

The function warpPerspective transforms the source image using the specified matrix:

dst(x,y) = src((M_11 x + M_12 y + M_13)/(M_(31) x + M_32 y + M_33),<BR>(M_21 x + M_22 y + M_23)/(M_(31) x + M_32 y + M_33))

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with "invert" and then put in the formula above instead of M. The function cannot operate in-place.

Parameters:
src - input image.
dst - output image that has the size dsize and the same type as src.
M - 3x 3 transformation matrix.
dsize - size of the output image.
flags - combination of interpolation methods (INTER_LINEAR or INTER_NEAREST) and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst->src).
borderMode - pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).
borderValue - value used in case of a constant border; by default, it equals 0.
See Also:
org.opencv.imgproc.Imgproc.warpPerspective, warpAffine(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar), remap(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, int, int, org.opencv.core.Scalar), Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat), getRectSubPix(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Point, org.opencv.core.Mat, int), resize(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, double, double, int)

watershed

public static void watershed(Mat image,
                             Mat markers)

Performs a marker-based image segmentation using the watershed algorithm.

The function implements one of the variants of watershed, non-parametric marker-based segmentation algorithm, described in [Meyer92].

Before passing the image to the function, you have to roughly outline the desired regions in the image markers with positive (>0) indices. So, every region is represented as one or more connected components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary mask using "findContours" and "drawContours" (see the watershed.cpp demo). The markers are "seeds" of the future image regions. All the other pixels in markers, whose relation to the outlined regions is not known and should be defined by the algorithm, should be set to 0's. In the function output, each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the regions.

Visual demonstration and usage example of the function can be found in the OpenCV samples directory (see the watershed.cpp demo).

Note: Any two neighbor connected components are not necessarily separated by a watershed boundary (-1's pixels); for example, they can touch each other in the initial marker image passed to the function.

Parameters:
image - Input 8-bit 3-channel image.
markers - Input/output 32-bit single-channel image (map) of markers. It should have the same size as image.
See Also:
org.opencv.imgproc.Imgproc.watershed, findContours(org.opencv.core.Mat, java.util.List, org.opencv.core.Mat, int, int, org.opencv.core.Point)

OpenCV 2.4.6 Documentation