Opencv-linear filter filer2d

Source: Internet
Author: User
# Include "opencv2/imgproc. HPP "# include" opencv2/highgui. HPP "# include <stdlib. h> # include <stdio. h> using namespace CV; int main (INT argc, char ** argv) {// variable declaration mat SRC, DST; MAT kernel; point Anchor; Double Delta; int ddepth; int kernel_size; char * window_name = "filter2d Demo"; int C; // load image src = imread (argv [1]); If (! SRC. data) {return-1;} // create a window named window (window_name, cv_window_autosize); // initialize anchor = point (-1,-1) for the filter ); // The default anchor point is Delta = 0 in the Processing Kernel Window center. // the value added to each pixel of the image during convolution. The default value is 0 ddepth =-1; // negative number indicates that the processing result image is the same as the original image depth // loop-will filter the image with Different kernel sizes each 0.5 seconds int ind = 0; while (true) {c = waitkey (500); // press 'esc 'to exit the program if (char) C = 27) {break ;} // update kernel size for a normalized Box Filter kernel_size = 3 + 2 * (IND % 5); // ensure that the processing kernel size is an odd number of kernel = mat :: ones (kernel_size, kernel_size, cv_32f)/(float) (kernel_size * kernel_size); // use a filter to process filter2d (SRC, DST, ddepth, kernel, anchor, Delta, border_default ); imshow (window_name, DST); ind ++;} return 0 ;}

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.