In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "OpenCV how to use color segmentation to obtain quantity", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "OpenCV how to use color segmentation to obtain quantity" bar!
Realization idea
Segmentation using HSV color
Morphological operation (usually with open operation)
Find the outline and calculate the number
Take a look at the above implementation ideas, compared with the previous one, it feels like a lot of simplification, let's demonstrate the code below.
Code demonstration
Let's create a new project named opencv--inrange, follow the configuration properties (VS2017 configure OpenCV common properties), and then write the # include and main methods in the source file.
1. Load Ima
two。 Gaussian blur, define color and segment color
3. Morphological operation, do two open operations
4. Find the outline and draw the outline
5. Print out the number of contours and display images
Next, let's take a look at the effect after running.
In the red box in the lower left corner, we can see that the 12 numbers we got are completely correct. In the upper left corner of our original image, the upper right corner is the shape drawn by random color after the outline is finally found. The lower right corner is the temporary picture displayed through HSV color segmentation and morphological operation in our processing process. As can be seen from the lower right picture, the two leftmost dates are completely separated by color segmentation. Unlike in our previous article, the two are glued together and need to be processed by distance transformation and connected region calculation.
As we learn more and more, we need to use the best strategy in image processing. To write this article alone, one is to review some practices at that time and do a solid review. The other is to look at what we have learned to see if we can use the best way to extract what we have done before. As a result, we are quite satisfied and achieve the ultimate goal.
Thank you for your reading, the above is the content of "how OpenCV uses color segmentation to obtain quantity". After the study of this article, I believe you have a deeper understanding of how OpenCV uses color segmentation to obtain quantity, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.