c++ - OpenCV filter2D: Filtering only part of the matrix/image -


i encountered following problem. need filter matrix/image linear filter, want filter pixels have sufficient number of neighbors around (according kernel size). concretely result of filtering 32x32 image 5x5 kernel should of 28x28 size.
possible such processing in relatively simple way opencv built-in functions?

int kernel_size = 3; cv::mat in_img, out_img; cv::mat kernel = mat::ones( kernel_size, kernel_size, cv_32f )/ (float)(kernel_size*kernel_size);        cv::filter2d(in_img, out_img, -1 , kernel); //filtering  cv::size size = in_img.size(); cv::rect roi(kernel_size, kernel_size,size.width - 2*kernel_size, size.height - 2*kernel_size); cv::mat cropped = in_img(roi).clone(); //cropping 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -