In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of the dynamic change of threshold binarization in OpenCV. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
In OpenCV4Android, we often use binarization. The simple binarization process is to change the picture into a grayscale image through Imgproc.cvtColor, and then binarize it through Imgproc.threshold.
Imgproc.threshold
/ / binary image thresh. If the specified number here is the specified threshold, if it is set to 0 here, the parameter is followed by Imgproc.THRESH_OTSU.
/ / in most cases, we add Imgproc.THRESH_OTSU and let it calculate on its own.
Imgproc.threshold (src, dst, val, 255, Imgproc.THRESH_BINARY)
Parameter src is the source of Mat, and dst is the target of Mat. The third parameter we set is the threshold we want to enter. The threshold ranges from 0 to 225,0 is white, 255is black, and then 255is the maximum number of thresholds. The last parameter, Imgproc.THRESH_BINARY, is binarization. When we manually modify the parameter threshold, we can simply fill in one of these. If the default threshold is 0, it is recommended to add Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU, OTSU so that API will automatically calculate the most reasonable value for you to deal with.
Layout layout
We first add a seekbar and a TextView to the layout diagram to adjust our values and display the current values
All in one LinearLayout, let it be laid out horizontally, and the proportion of seekbar in length is 8, and the proportion of TextView is 2.
Layout effect
MainActivity
Then add in MainActivity to load two controls and write the corresponding events
SeekBar
Load the SeekBar control, and add the Change event, that is, when the value changes, we call our binarization method to update the picture. In order to have a change effect, we write an image that returns Bitbmp in the ImgDealUtil.thresholdbmpforval method, and then update the display on the original picture.
TexView
Load textView control
ImgDealUtil.thresholdbmpforval method
We added a new thresholdbmpforval method to the ImgDealUtil class
Two parameters, int is the current threshold, bitbmp is the current picture information.
The effect after entering the program
We choose the binarization threshold.
Then drag left and right on the seekbar control, and the picture will change the effect.
This is the end of this article on "example analysis of the dynamic change of threshold binarization in OpenCV". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.