Chapter 5-image morphology-cvthreshold, channel summation

Source: Internet
Author: User

Threshold:

We hope to make a final decision on the pixels in the image, or directly remove some pixels smaller than or higher than a certain value. In opencv, cvthreshold () can complete this task, the basic idea is to give an array and a threshold, and then process it based on whether the value of each element in the array is lower than or higher than the threshold.

The data structure and method involved in this routine chapter_ch5_example_2:

Cvsplit

Splits the number of channels to form several single-channel arrays or extracts a channel from the array.

Void cvsplit (const cvarr * SRC, cvarr * dst0, cvarr * dst1, cvarr * dst2, cvarr * dst3 );

# Define cvcvtpixtoplane cvsplit

SRC original array.

Dst0... dst3 target channel

The cvsplit function separates multiple channels to form a separate single-channel Array D. Two operation modes are available. if the original array has n channels and the first N output arrays are not null, all channels will be extracted from the original array, if the first n channels have only one non-null channel function to extract only the specified channel, otherwise an error will occur. The remaining channel (more than the first n channels) must be set to null. cvcopy can also be used for iplimage with COI settings to extract a single channel from the image.

Cvaddweighted

Void cvaddweighted (
Constcvarr * src1, double alpha,
Const cvarr * src2,
Double beta,
Double gamma,
Cvarr * DST
);
In cvaddweighted (), there are two source images: src1 and src2. The two images can be any pixel type, as long as they are of the same type. They can be single-channel or three-channel, as long as they match. The destination image of the calculation result, DST, must be of the same pixel type as src1 and src2. These images can be of different sizes, but their ROI must have the same size. Otherwise, opencv reports an error. The Alpha parameter indicates the mixture strength of src1 and beta indicates the mixture strength of src2. The formula for calculating the Alpha mixture is as follows: You can set the value to 0 to 1 and the value of Gama to 0. The formula above is converted to the standard Alpha hybrid formula:

Cvthreshold

Cvthreshold is a function in the opencv library.
Function: applies fixed threshold operations to single-channel arrays. A typical application of this function is to perform threshold operations on grayscale images to obtain binary images. (Cvcmps can also achieve this goal) or remove noise, such as filtering small or very elephant prime value image points. The method supported by this function for obtaining the image threshold is determined by threshold_type.
Format: void cvthreshold (const cvarr * SRC, cvarr * DST, double threshold, double max_value, int threshold_type );
SRC: original array (single channel, 8-bit of 32-bit floating point number ). DST: Output array, which must be of the same type as SRC or 8-bit.
Threshold: Threshold
Max_value: Use the maximum values of cv_thresh_binary and cv_thresh_binary_inv.
Threshold_type: Threshold type threshold_type = cv_thresh_binary:
If SRC (x, y)> threshold, DST (x, y) = max_value; otherwise, des (x, y) = 0;
Threshold_type = cv_thresh_binary_inv:
If SRC (x, y)> threshold, DST (x, y) = 0; otherwise, DST (x, y) = max_value.
Threshold_typ

/* Program */

#include <stdio.h>#include 

/* Result */

Source image

The threshold is 50.

The threshold is 100.

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.