Thresholding
After removing the background, we only have to binarize the image for future segmentation. We are going to do this with threshold. Threshold is a simple function that sets each pixel's values to a maximum value (255, for example). If the pixel's value is greater than the threshold value or if the pixel's value is lower than the threshold value, it will be set to a minimum (0):

Now, we are going to apply the threshold function using two different threshold values: we will use a 30 threshold value when we remove the light/background because all non-interesting regions are black. This is because we apply background removal. We will also a medium value threshold (140) when we do not use a light removal method, because we have a white background. This last option is used to allow us to check the results with and without background removal:
// Binarize image for segment Mat img_thr; if(method_light!=2){ threshold(img_no_light, img_thr, 30, 255, THRESH_BINARY); }else{ threshold(img_no_light, img_thr, 140, 255, THRESH_BINARY_INV); }
Now, we are going to continue with the most important part of our application: the segmentation. We are going to use two different approaches or algorithms here: connected components and find contours.
- 漫話大數(shù)據(jù)
- Python絕技:運(yùn)用Python成為頂級(jí)數(shù)據(jù)工程師
- Spark大數(shù)據(jù)分析實(shí)戰(zhàn)
- 大數(shù)據(jù)可視化
- 文本挖掘:基于R語言的整潔工具
- 數(shù)據(jù)化網(wǎng)站運(yùn)營(yíng)深度剖析
- 達(dá)夢(mèng)數(shù)據(jù)庫性能優(yōu)化
- 基于OPAC日志的高校圖書館用戶信息需求與檢索行為研究
- 金融商業(yè)算法建模:基于Python和SAS
- 企業(yè)級(jí)容器云架構(gòu)開發(fā)指南
- Instant Autodesk AutoCAD 2014 Customization with .NET
- 智慧的云計(jì)算
- 爬蟲實(shí)戰(zhàn):從數(shù)據(jù)到產(chǎn)品
- 區(qū)域云計(jì)算和大數(shù)據(jù)產(chǎn)業(yè)發(fā)展:浙江樣板
- 改變未來的九大算法