Threshold of Valve value

Source: Internet
Author: User

  • Threshold value (threshold) function in OpenCV: the use of threshold.
  • C++:double threshold (inputarray src, outputarray DST, double thresh, double maxval, int threshold-
    Type)
    Python:cv2.threshold (SRC, thresh, maxval, type[, DST])! retval, DST
    C:double cvthreshold (const cvarr* SRC, cvarr* DST, double threshold, double maxValue, int threshold-
    Type)
    PYTHON:CV. Threshold (SRC, DST, Threshold, MaxValue, Thresholdtype)! None
    Parameters
    src–source Array (Single-channel, 8-bit of 32-bit floating point).
    DST–destination 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.
    Thresholdtype–thresholding type (see the details below).

    • The simplest method of image segmentation.

    • Examples of applications: using thresholds from an image to separate the parts of the object we need (of course, the objects here can be part or whole). The image segmentation method is based on the gray difference between the object and the background in the image, and this segmentation belongs to the pixel-level segmentation.

    • In order to extract the parts we need from an image, we should compare the gray value of each pixel in the image with the chosen threshold, and make the corresponding judgment. (Note: The selection of thresholds depends on the specific issue.) That is, objects may have different grayscale values in different images.

    • Once we have found the pixel points of the objects that need to be segmented, we can set some specific values for these pixels to represent. (For example: You can set the gray value of the object's pixel point to: ' 0 ' (black), the other pixel gray value is: ' 255 ' (white), of course, the gray value of the pixel can be arbitrary, but the best set of two color contrast is strong, convenient observation results).

Threshold Type 1: Binary thresholding (thresh_binary)
    • The threshold type is shown in the following format:

    • Explanation: In the use of this threshold type, the first to select a specific threshold amount, such as: 125, so that the new threshold generation rule can be interpreted as greater than 125 of the gray value of the pixel is set to the maximum value (such as 8-bit grayscale value of up to 255), gray value less than 125 of the pixel's grayscale value is set to 0

Threshold Type 2: Inverse binary thresholding (THRESH_BINARY_INV)
    • The threshold type is shown in the following formula:

    • Explanation: This threshold is similar to binary thresholding, where a specific grayscale value is selected as the threshold value, but the last set value is reversed. (in 8-bit grayscale, for example, a setting greater than a threshold is 0, and a setting of less than this threshold is 255).

Threshold Type 3: Truncation threshold (THRESH_TRUNC)
    • The threshold type is shown in the following format:

    • Explanation: It is also necessary to first select a threshold where pixels greater than the threshold in the image are set to that threshold, which is less than the threshold value remains unchanged. (For example: Threshold selection is 125, that threshold of less than 125 does not change, and a grayscale value greater than 125 (230) is set to that threshold).

Threshold Type 4: Threshold value 0 (Thresh_tozero)
    • The threshold type is shown in the following formula:

    • Explanation: First select a threshold and then do the following: The gray value of the 1 pixel point is greater than the threshold value, and the gray value of the 2 pixel point is less than the threshold value, and its grayscale values all change to 0.

Threshold Type 5: Anti-threshold value 0 (THRESH_TOZERO_INV)
    • The threshold type is shown in the following formula:

    • Explanation: The principle is similar to the 0 threshold, but in the process of processing the image, the opposite is: the gray value of the pixel is less than the threshold value of no change, and greater than the threshold value of the portion, its gray value all become 0.

Threshold of Valve value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.