JavaScript image processing: Threshold values

Source: Internet
Author: User

Objective

In the previous article, we explained the changes in brightness and contrast in image processing, and this article we'll do a threshold function.

The simplest method of image segmentation

The threshold is the simplest method of image segmentation.

For example, in order to separate the apples from the image below, we use the gray difference between the foreground and the background, by setting a threshold value, which is black when the pixel is greater than this threshold, and is less than gray.

Five types of threshold values

As with OPENCV, we will provide five types of thresholds for ease of use.

The following is the waveform representation of the original image, the ordinate indicates the pixel gray value size, the Blue line is the threshold size.

Binary threshold value

The formula representation is:

TEXTTT{DST} (x,y) = Fork{texttt{maxval}}{if $texttt {src} (x,y) > Texttt{thresh}$}{0}{otherwise}

The image representation is:

Threshold Binary

The maximum value (that is, 255) that exceeds this threshold is visible, otherwise the minimum value (that is, 0) is changed. We need a function to implement this function:

var cv_thresh_binary = function (__value, __thresh, __maxval) {return
    __value > __thresh? __maxval:0;
};

Related Article

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.