My opencv study notes (8): Mean Filtering for airspace Filtering

Source: Internet
Author: User

According to the pixel operation method, the spatial filter can be divided into two types: linear filtering (low-pass, high-pass, and band-pass) and non-linear filtering (maximum value, minimum value, and median)

Based on the effects of image processing, smooth filtering and sharpening filtering can be performed.

The concept of linear filtering is actually borrowed from Signals and Systems. When an input signal passes through a linear system, the output result is convolution of the input signal and the system's time-domain impact response. In image processing, linear weighting is performed on pixels (and surrounding pixels) using a template. The weight is determined by the template's pixel value. The calculation method is similar to Convolution, so it is called filtering. Non-linear filtering is not a linear operation.

Because there is no formula, you may not understand the text. Here we mainly want to explain the features of these filters and how the program is implemented:

 

Start with the simplest mean filter today:

// Source image mat scr = imread ("D:/picture/IMG. TIF "); // result image mat RST; rst. create (SCR. rows, SCR. cols, SCR. type (); imshow ("Original Image", Scr); // mean filter function: Replace the average values of all pixels in the template with the blue R (SCR, RST, size (5, 5); imshow ("smooth filtering result", RST );

 

Result

When the template is changed to 10*10

Obviously, the larger the template, the blurrier the image. So if you use a filter to remove noise, the image details will also be smoothed.

You can also use the filter2d function to perform the same operation:

// Call the filter function to sharpen the image // The kernel mat kernel of the filter = mat: ones (5, 5, cv_32f)/(float) (5*5 ); // call the filter function filter2d (SCR, RST, SCR. depth (), kernel );

 

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.