:param maxValue:Maximum value that is used with ``CV_THRESH_BINARY`` and ``CV_THRESH_BINARY_INV``
:type maxValue:float
:param adaptive_method:Adaptive thresholding algorithm to use: ``CV_ADAPTIVE_THRESH_MEAN_C`` or ``CV_ADAPTIVE_THRESH_GAUSSIAN_C`` (see the discussion)
:type adaptive_method:int
:param thresholdType:Thresholding type; must be one of
***CV_THRESH_BINARY** xxx
***CV_THRESH_BINARY_INV** xxx
:type thresholdType:int
:param blockSize:The size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on
:type blockSize:int
:param param1:The method-dependent parameter. For the methods ``CV_ADAPTIVE_THRESH_MEAN_C`` and ``CV_ADAPTIVE_THRESH_GAUSSIAN_C`` it is a constant subtracted from the mean or weighted mean (see the discussion), though it may be negative
:type param1:float
The function transforms a grayscale image to a binary image according to the formulas:
:param dst:The destination image of the same data type as the source. The number of channels may be different
:type dst::class:`CvArr`
:param code:Color conversion operation that can be specifed using ``CV_ *src_color_space* 2 *dst_color_space*`` constants (see below)
:type code:int
The function converts the input image from one color
space to another. The function ignores the
``colorModel``
and
``channelSeq``
fields of the
``IplImage``
header, so the
source image color space should be specified correctly (including
order of the channels in the case of RGB space. For example, BGR means 24-bit
format with
:math:`B_0, G_0, R_0, B_1, G_1, R_1, ...`
layout
whereas RGB means 24-format with
:math:`R_0, G_0, B_0, R_1, G_1, B_1, ...`
layout).
The conventional range for R,G,B channel values is:
*
0 to 255 for 8-bit images
*
0 to 65535 for 16-bit images and
*
0 to 1 for floating-point images.
Of course, in the case of linear transformations the range can be
specific, but in order to get correct results in the case of non-linear
transformations, the input image should be scaled.
The function can do the following transformations:
*
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:
..math::
\text{RGB[A] to Gray:} Y \leftarrow 0.299 \cdot R + 0.587 \cdot G + 0.114 \cdot B
and
..math::
\text{Gray to RGB[A]:} R \leftarrow Y, G \leftarrow Y, B \leftarrow Y, A \leftarrow 0
The conversion from a RGB image to gray is done with:
) The Bayer pattern is widely used in CCD and CMOS cameras. It allows one to get color pictures from a single plane where R,G and B pixels (sensors of a particular component) are interleaved like this:
:param dst:Output image with calculated distances (32-bit floating-point, single-channel)
:type dst::class:`CvArr`
:param distance_type:Type of distance; can be ``CV_DIST_L1, CV_DIST_L2, CV_DIST_C`` or ``CV_DIST_USER``
:type distance_type:int
:param mask_size:Size of the distance transform mask; can be 3 or 5. in the case of ``CV_DIST_L1`` or ``CV_DIST_C`` the parameter is forced to 3, because a :math:`3\times 3` mask gives the same result as a :math:`5\times 5` yet it is faster
:type mask_size:int
:param mask:User-defined mask in the case of a user-defined distance, it consists of 2 numbers (horizontal/vertical shift cost, diagonal shift cost) in the case ofa :math:`3\times 3` mask and 3 numbers (horizontal/vertical shift cost, diagonal shift cost, knight's move cost) in the case of a :math:`5\times 5` mask
:type mask:sequence of float
:param labels:The optional output 2d array of integer type labels, the same size as ``src`` and ``dst``
:type labels::class:`CvArr`
The function calculates the approximated
distance from every binary image pixel to the nearest zero pixel.
For zero pixels the function sets the zero distance, for others it
finds the shortest path consisting of basic shifts: horizontal,
vertical, diagonal or knight's move (the latest is available for a
:math:`5\times 5`
mask). The overall distance is calculated as a sum of these
basic distances. Because the distance function should be symmetric,
all of the horizontal and vertical shifts must have the same cost (that
is denoted as
``a``
), all the diagonal shifts must have the
same cost (denoted
``b``
), and all knight's moves must have
the same cost (denoted
``c``
). For
``CV_DIST_C``
and
``CV_DIST_L1``
types the distance is calculated precisely,
whereas for
``CV_DIST_L2``
(Euclidian distance) the distance
can be calculated only with some relative error (a
:math:`5\times 5`
mask
gives more accurate results), OpenCV uses the values suggested in
:param image:Input 1- or 3-channel, 8-bit or floating-point image. It is modified by the function unless the ``CV_FLOODFILL_MASK_ONLY`` flag is set (see below)
:type image::class:`CvArr`
:param seed_point:The starting point
:type seed_point::class:`CvPoint`
:param new_val:New value of the repainted domain pixels
:type new_val::class:`CvScalar`
:param lo_diff: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. In the case of 8-bit color images it is a packed value
:type lo_diff::class:`CvScalar`
:param up_diff: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. In the case of 8-bit color images it is a packed value
:type up_diff::class:`CvScalar`
:param comp:Returned connected component for the repainted domain. Note that the function does not fill ``comp->contour`` field. The boundary of the filled component can be retrieved from the output mask image using :ref:`FindContours`
:type comp::class:`CvConnectedComp`
:param flags:The operation flags. Lower bits contain connectivity value, 4 (by 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:
***CV_FLOODFILL_FIXED_RANGE** if set, the difference between the current pixel and seed pixel is considered, otherwise the difference between neighbor pixels is considered (the range is floating)
***CV_FLOODFILL_MASK_ONLY** if set, the function does not fill the image ( ``new_val`` is ignored), but fills the mask (that must be non-NULL in this case)
:type flags:int
:param mask:Operation mask, should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than ``image`` . If not NULL, the function uses and updates the mask, so the user takes responsibility of initializing the ``mask`` content. Floodfilling can't 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 do not overlap. **Note** : because the mask is larger than the filled image, a pixel in ``mask`` that corresponds to :math:`(x,y)` pixel in ``image`` will have coordinates :math:`(x+1,y+1)`
:type mask::class:`CvArr`
The function fills a connected component starting from the seed point with the specified color. The connectivity is determined by the closeness of pixel values. The pixel at
:math:`(x,y)`
is considered to belong to the repainted domain if:
:param src:The input 8-bit 1-channel or 3-channel image.
:type src::class:`CvArr`
:param mask:The inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that needs to be inpainted.
:type mask::class:`CvArr`
:param dst:The output image of the same format and the same size as input.
:type dst::class:`CvArr`
:param inpaintRadius:The radius of circlular neighborhood of each point inpainted that is considered by the algorithm.
:type inpaintRadius:float
:param flags:The inpainting method, one of the following:
***CV_INPAINT_NS** Navier-Stokes based method.
***CV_INPAINT_TELEA** The method by Alexandru Telea Telea04
:type flags:int
The function reconstructs the selected image area from the pixel near the area boundary. The function may be used to remove dust and scratches from a scanned photo, or to remove undesirable objects from still images or video.
Using these integral images, one may calculate sum, mean and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:
It makes possible to do a fast blurring or fast block correlation with variable window size, for example. In the case of multi-channel images, sums for each channel are accumulated independently.
:param dst:The destination image of the same format and the same size as the source.
:type dst::class:`CvArr`
:param sp:The spatial window radius.
:type sp:float
:param sr:The color window radius.
:type sr:float
:param max_level:Maximum level of the pyramid for the segmentation.
:type max_level:int
:param termcrit:Termination criteria: when to stop meanshift iterations.
:type termcrit::class:`CvTermCriteria`
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
:math:`(X,Y)`
of the input image (or
down-sized input image, see below) the function executes meanshift
iterations, that is, the pixel
:math:`(X,Y)`
neighborhood in the joint
space-color hyperspace is considered:
..math::
(x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{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:
:math:`(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):
:math:`I(X,Y) <- (R*,G*,B*)`
Then
:math:`\texttt{max\_level}>0`
, the gaussian pyramid of
:math:`\texttt{max\_level}+1`
levels is built, and the above procedure is run
on the smallest layer. 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 much (
:math:`>\texttt{sr}`
) from the lower-resolution
layer, that is, the boundaries of the color regions are clarified. 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