In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about how to customize the filter in OpenCV. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The function of ImgProc.filter2D was used in the bilateral ambiguity we learned in the last article, and there is a setting of Mat convolution kernel before the call.
Today we will explain the parameters of this in detail.
Same as usual, first add these parameters to Clistitem, this time we add three parameters
SelitemActivity's listview plus item
Add the corresponding event to the button event of MainActivity
And then add our method to ImgDealUtil.
Public static void CustomFilter (String command, Bitmap bmp) {
Mat src = new Mat ()
Mat dst = new Mat ()
Utils.bitmapToMat (bmp, src)
Mat kernel = getCustomOperator (command)
Imgproc.filter2D (src, dst,-1, kernel, new Point (- 1,-1), 0.0, Imgproc.BORDER_DEFAULT)
Utils.matToBitmap (dst, bmp)
Src.release ()
Dst.release ()
Kernel.release ()
}
Private static Mat getCustomOperator (String command) {
/ / changing Cvtype to 32fc1 is to blur the mean and change each to 1 / 9 of them.
/ / both row type and cols type are 3, which is exactly 9 squares.
/ / in the parameters of put, the first two parameters are 0. 0 means to start processing from the first one in the top left corner, and the following data exactly sets 1 / 9 of the nine.
Mat kernel = new Mat (3,3, CvType.CV_32FC1)
If (Clistitem.IMAGE_CUSTOMBLURCOMMAND.equals (command)) {
/ / in the parameters of put, the first two parameters are 0. 0 means to start processing from the first one in the top left corner, and the following data exactly sets 1 / 9 of the nine.
Kernel.put (0,0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0,1.0 / 9.0
} else if (Clistitem.IMAGE_CUSTOMEDGECOMMAND.equals (command)) {
/ / the middle 8 of the nine palace grids on the edge of Laplace, and the rest are-1, so press the following settings
Kernel.put (0,0,-1,-1,-1,-1,-8-1,-1,-1,-1)
} else if (Clistitem.IMAGE_CUSTOMBRARPENCOMMAND.equals (command)) {
/ / Laplace sharpens the middle 9 of the nine grids, and the rest is-1, so press the following settings
Kernel.put (0,0,-1,-1,-1,-1,-9-1,-1,-1,-1)
}
Return kernel
}
After reading the above, have you mastered the method of how to customize the filter in OpenCV? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.